lftp-4.6.3a/0000755000015000007670000000000012540300657007635 500000000000000lftp-4.6.3a/aclocal.m40000644000015000007670000015547312540277160011436 00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # PKG_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable pkgconfigdir as the location where a module # should install pkg-config .pc files. By default the directory is # $libdir/pkgconfig, but the default can be changed by passing # DIRECTORY. The user can override through the --with-pkgconfigdir # parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_INSTALLDIR # PKG_NOARCH_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable noarch_pkgconfigdir as the location where a # module should install arch-independent pkg-config .pc files. By # default the directory is $datadir/pkgconfig, but the default can be # changed by passing DIRECTORY. The user can override through the # --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_NOARCH_INSTALLDIR # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # ------------------------------------------- # Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])# PKG_CHECK_VAR # Copyright (C) 2002-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. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-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. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-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. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-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. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-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. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-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. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-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. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-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. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-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. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-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. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # -*- Autoconf -*- # Obsolete and "removed" macros, that must however still report explicit # error messages when used, to smooth transition. # # Copyright (C) 1996-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([AM_CONFIG_HEADER], [AC_DIAGNOSE([obsolete], ['$0': this macro is obsolete. You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl AC_CONFIG_HEADERS($@)]) AC_DEFUN([AM_PROG_CC_STDC], [AC_PROG_CC am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc AC_DIAGNOSE([obsolete], ['$0': this macro is obsolete. You should simply use the 'AC][_PROG_CC' macro instead. Also, your code should no longer depend upon 'am_cv_prog_cc_stdc', but upon 'ac_cv_prog_cc_stdc'.])]) AC_DEFUN([AM_C_PROTOTYPES], [AC_FATAL([automatic de-ANSI-fication support has been removed])]) AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-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. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-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. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-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. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-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. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 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. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-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. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-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. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-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. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/00gnulib.m4]) m4_include([m4/absolute-header.m4]) m4_include([m4/alloca.m4]) m4_include([m4/arpa_inet_h.m4]) m4_include([m4/bison.m4]) m4_include([m4/btowc.m4]) m4_include([m4/chown.m4]) m4_include([m4/clock_time.m4]) m4_include([m4/close.m4]) m4_include([m4/closedir.m4]) m4_include([m4/codeset.m4]) m4_include([m4/configmake.m4]) m4_include([m4/cxx-dynamic-initializers.m4]) m4_include([m4/d-type.m4]) m4_include([m4/dirent_h.m4]) m4_include([m4/dirfd.m4]) m4_include([m4/dup2.m4]) m4_include([m4/eealloc.m4]) m4_include([m4/environ.m4]) m4_include([m4/errno_h.m4]) m4_include([m4/error.m4]) m4_include([m4/exponentd.m4]) m4_include([m4/exponentf.m4]) m4_include([m4/exponentl.m4]) m4_include([m4/extensions.m4]) m4_include([m4/extern-inline.m4]) m4_include([m4/fcntl-o.m4]) m4_include([m4/fcntl.m4]) m4_include([m4/fcntl_h.m4]) m4_include([m4/filemode.m4]) m4_include([m4/float_h.m4]) m4_include([m4/fnmatch.m4]) m4_include([m4/fpieee.m4]) m4_include([m4/frexp.m4]) m4_include([m4/frexpl.m4]) m4_include([m4/fstat.m4]) m4_include([m4/getdtablesize.m4]) m4_include([m4/getlogin_r.m4]) m4_include([m4/getopt.m4]) m4_include([m4/gettext.m4]) m4_include([m4/gettime.m4]) m4_include([m4/gettimeofday.m4]) m4_include([m4/gl-openssl.m4]) m4_include([m4/glibc21.m4]) m4_include([m4/glob.m4]) m4_include([m4/gnulib-common.m4]) m4_include([m4/gnulib-comp.m4]) m4_include([m4/human.m4]) m4_include([m4/iconv.m4]) m4_include([m4/iconv_h.m4]) m4_include([m4/iconv_open.m4]) m4_include([m4/include_next.m4]) m4_include([m4/inet_pton.m4]) m4_include([m4/inline.m4]) m4_include([m4/intlmacosx.m4]) m4_include([m4/intmax_t.m4]) m4_include([m4/inttypes.m4]) m4_include([m4/inttypes_h.m4]) m4_include([m4/isnand.m4]) m4_include([m4/isnanf.m4]) m4_include([m4/isnanl.m4]) m4_include([m4/langinfo_h.m4]) m4_include([m4/largefile.m4]) m4_include([m4/lchown.m4]) m4_include([m4/ldexpl.m4]) m4_include([m4/lftp.m4]) m4_include([m4/lib-ld.m4]) m4_include([m4/lib-link.m4]) m4_include([m4/lib-prefix.m4]) m4_include([m4/libtool.m4]) m4_include([m4/libunistring-base.m4]) m4_include([m4/localcharset.m4]) m4_include([m4/locale-fr.m4]) m4_include([m4/locale-ja.m4]) m4_include([m4/locale-zh.m4]) m4_include([m4/locale_h.m4]) m4_include([m4/localeconv.m4]) m4_include([m4/lock.m4]) m4_include([m4/longlong.m4]) m4_include([m4/lstat.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) m4_include([m4/malloc.m4]) m4_include([m4/malloca.m4]) m4_include([m4/math_h.m4]) m4_include([m4/mbrtowc.m4]) m4_include([m4/mbsinit.m4]) m4_include([m4/mbsrtowcs.m4]) m4_include([m4/mbstate_t.m4]) m4_include([m4/mbswidth.m4]) m4_include([m4/mbtowc.m4]) m4_include([m4/md5.m4]) m4_include([m4/memchr.m4]) m4_include([m4/memmem.m4]) m4_include([m4/mempcpy.m4]) m4_include([m4/mktime.m4]) m4_include([m4/mmap-anon.m4]) m4_include([m4/mode_t.m4]) m4_include([m4/modechange.m4]) m4_include([m4/msvc-inval.m4]) m4_include([m4/msvc-nothrow.m4]) m4_include([m4/multiarch.m4]) m4_include([m4/needtrio.m4]) m4_include([m4/netinet_in_h.m4]) m4_include([m4/nl_langinfo.m4]) m4_include([m4/nls.m4]) m4_include([m4/nocrash.m4]) m4_include([m4/off_t.m4]) m4_include([m4/open.m4]) m4_include([m4/opendir.m4]) m4_include([m4/parse-datetime.m4]) m4_include([m4/passfd.m4]) m4_include([m4/pathmax.m4]) m4_include([m4/po.m4]) m4_include([m4/poll.m4]) m4_include([m4/poll_h.m4]) m4_include([m4/printf-frexp.m4]) m4_include([m4/printf-frexpl.m4]) m4_include([m4/printf.m4]) m4_include([m4/progtest.m4]) m4_include([m4/pty.m4]) m4_include([m4/quote.m4]) m4_include([m4/quotearg.m4]) m4_include([m4/readdir.m4]) m4_include([m4/readline.m4]) m4_include([m4/readlink.m4]) m4_include([m4/regex.m4]) m4_include([m4/select.m4]) m4_include([m4/setenv.m4]) m4_include([m4/sha1.m4]) m4_include([m4/signal_h.m4]) m4_include([m4/signbit.m4]) m4_include([m4/size_max.m4]) m4_include([m4/socketlib.m4]) m4_include([m4/sockets.m4]) m4_include([m4/socklen.m4]) m4_include([m4/sockpfaf.m4]) m4_include([m4/ssize_t.m4]) m4_include([m4/ssl.m4]) m4_include([m4/st_dm_mode.m4]) m4_include([m4/stat.m4]) m4_include([m4/stdalign.m4]) m4_include([m4/stdbool.m4]) m4_include([m4/stddef_h.m4]) m4_include([m4/stdint.m4]) m4_include([m4/stdint_h.m4]) m4_include([m4/stdio_h.m4]) m4_include([m4/stdlib_h.m4]) m4_include([m4/strcase.m4]) m4_include([m4/strdup.m4]) m4_include([m4/strerror.m4]) m4_include([m4/strftime.m4]) m4_include([m4/string_h.m4]) m4_include([m4/strings_h.m4]) m4_include([m4/strptime.m4]) m4_include([m4/strstr.m4]) m4_include([m4/strtok_r.m4]) m4_include([m4/strtoull.m4]) m4_include([m4/strtoumax.m4]) m4_include([m4/sys_select_h.m4]) m4_include([m4/sys_socket_h.m4]) m4_include([m4/sys_stat_h.m4]) m4_include([m4/sys_time_h.m4]) m4_include([m4/sys_types_h.m4]) m4_include([m4/sys_uio_h.m4]) m4_include([m4/terminfo.m4]) m4_include([m4/threadlib.m4]) m4_include([m4/time_h.m4]) m4_include([m4/time_r.m4]) m4_include([m4/timespec.m4]) m4_include([m4/tm_gmtoff.m4]) m4_include([m4/unistd_h.m4]) m4_include([m4/va_copy.m4]) m4_include([m4/vasnprintf.m4]) m4_include([m4/vsnprintf-posix.m4]) m4_include([m4/vsnprintf.m4]) m4_include([m4/wchar_h.m4]) m4_include([m4/wchar_t.m4]) m4_include([m4/wcrtomb.m4]) m4_include([m4/wctype_h.m4]) m4_include([m4/wcwidth.m4]) m4_include([m4/wint_t.m4]) m4_include([m4/xalloc.m4]) m4_include([m4/xsize.m4]) m4_include([m4/xstrtol.m4]) lftp-4.6.3a/FEATURES0000644000015000007670000000535312355455722010734 00000000000000LFTP includes the following features (some may be missed in this list): * FTP and HTTP protocols support. * FTP (e.g. TIS FWTK) proxy support. * HTTP proxy support. * FTP over HTTP proxy support (hftp and CONNECT method). * HTTPS and FTPS protocols support using GNU TLS or OpenSSL library. * Automatic OPIE/SKEY support in FTP protocol. * FXP transfers support (between two FTP servers, bypassing client machine). * FTP listings support: unix-style, NT, EPLF, OS/2, AS400, MacWebStar, MLSD. * Automatic reconnect and retry of an operation on retriable errors or timeout. * IPv6 support in both FTP and HTTP. * FISH protocol support. It uses ssh with no special program on server side. * SFTP protocol v3-v6 support. * HTTP/1.1 keep-alive support. * Partial WebDAV support. * BitTorrent protocol support (including IPv6). * BitTorrent extensions: Fast, DHT, PEX, Multi-tracker, Metadata, magnet. * Experimental support for SRV DNS records. * SOCKS support (configure option). * Modification time preservation (if server can report it). * `reget' and `reput' support. * Built-in mirror and reverse mirror (mirror -R). * Transfer rate throttling for each connection and for all connections in sum. * Limit for number of connections to the same site. Interruption of background transfer to do a foreground operation when the limit is reached. * Socket options tuning: buffer size and maximum segment size. * Job queueing. * Job execution at specified time. * Comprehensive scripting support. * URL recognition in most operations. * Readline library is used for input. * Context sensitive completion. * Bash-like prompt extensions. * Launching of local shell commands. * Suspend support. * Bookmarks. * Aliases. * Saving of last directory on each site. `cd -' to go there. * Copying of files (including mirror) between two servers over the client, automatic usage of FXP when possible to bypass the client. * Numerous settings which can be associated with a specific server or a group. * Paging of remote files using external program. * `zcat' and `zmore' support. * Help for commands. * Command history saved in a file. * Transfer status includes rate and ETA. * File listing cache. * Background jobs (bash-like). * Job output redirection to a file or to a program via pipe. * Conditional commands depending on exit status of previous one. * Loading of binary modules at run time (configure option). * `pget' to download a file using several connections. `pget' download can be continued as it saves a status file periodically. * `mirror' can download several files in parallel (--parallel option) and a single file with `pget' (--use-pget-n option). * Slots. Each slot is a separate session, switch using Meta-{1-9} or `slot' command. Refer to a slot site using pseudo URL slot:name. lftp-4.6.3a/lftp.conf0000644000015000007670000000627012506512474011402 00000000000000## some useful aliases alias dir ls alias less more alias zless zmore alias bzless bzmore alias reconnect "close; cache flush; cd ." ## make prompt look better set prompt "lftp \S\? \u\@\h:\w> " ## some may prefer colors (contributed by Matthew ) #set prompt "\[\e[1;30m\][\[\e[0;34m\]f\[\e[1m\]t\[\e[37m\]p\[\e[30m\]] \[\e[34m\]\u\[\e[0;34m\]\@\[\e[1m\]\h\[\e[1;30m\]:\[\e[1;34m\]\w\[\e[1;30m\]>\[\e[0m\] " ## Uncomment the following two lines to make switch cls and ls, making ## cls the default. #alias ls command cls #alias hostls command ls ## default protocol selection #set default-protocol/ftp.* ftp #set default-protocol/www.* http #set default-protocol/localhost file ## this makes lftp faster but doesn't work with some sites/routers #set ftp:sync-mode off ## synchronous mode for broken servers and/or routers set sync-mode/ftp.idsoftware.com on set sync-mode/ftp.microsoft.com on set sync-mode/sunsolve.sun.com on ## extended regex to match first server message for automatic sync-mode. set auto-sync-mode "icrosoft FTP Service|MadGoat|MikroTik" ## if default ftp passive mode does not work, try this: # set ftp:passive-mode off ## Set this to follow http redirections set xfer:max-redirections 10 ## Proxy can help to pass a firewall ## Environment variables ftp_proxy, http_proxy and no_proxy are used to ## initialize the below variables automatically. You can set them here too. ## ## ftp:proxy must communicate with client over ftp protocol, squid won't do. ## This can be e.g. TIS-FWTK or rftpd. User and password are optional. # set ftp:proxy ftp://[user:pass@]your_ftp_proxy:port ## ...but squid still can be used to access ftp servers, using hftp protocol: # set ftp:proxy http://your.squid.address:port ## ...if squid allows CONNECT to arbitrary ports, then you can use CONNECT ## instead of hftp: # set ftp:use-hftp no ## ## no proxy for host # set ftp:proxy/local_host "" ## or domain # set ftp:proxy/*.domain.com ... ## ## http:proxy must communicate with client over http protocol, e.g. squid. ## Default port is 3128. # set http:proxy your_http_proxy[:port] ## hftp:proxy must also be an http proxy. It is used for FTP over HTTP access. # set hftp:proxy your_http_proxy[:port] ## ## net:no-proxy disables proxy usage for list of domains. # set net:no-proxy .domain.com,.otherdom.net ## If you don't have direct ftp access, this setting can be useful to select ## hftp instead of ftp automatically. # set ftp:proxy http://your.http.proxy:port ## This can be used for automatic saving of configuration # set at-exit "set > ~/.lftp/settings" # source ~/.lftp/settings ## and this is for remembring last site ## (combine with previous rule if you want) # set at-exit "bo a last" # open last ## Terminal strings to set titlebars for terminals that don't ## properly specify tsl and fsl capabilities. ## Use cmd:set-term-status to enable this. set cmd:term-status/*screen* "\e_\T\e\\" set cmd:term-status/*xterm* "\e[11;0]\e]2;\T\007\e[11]" set cmd:term-status/*rxvt* "\e[11;0]\e]2;\T\007\e[11]" # set cmd:set-term-status on ## If you don't like advertising lftp or servers hate it, set this: # set ftp:anon-pass "mozilla@" # set ftp:client "" # set http:user-agent "Mozilla/4.7 [en] (WinNT; I)" lftp-4.6.3a/Makefile.am0000644000015000007670000000465312417400627011622 00000000000000EXTRA_DIST = lftp.conf lftp.lsm FAQ MIRRORS BUGS FEATURES\ README README.debug-levels README.modules README.dnssec\ lib/hstrerror.c if NEED_TRIO TRIO = trio endif SUBDIRS = m4 doc lib $(TRIO) src po ACLOCAL_AMFLAGS = -I m4 install-data-local: if [ ! -f $(DESTDIR)$(sysconfdir)/lftp.conf ]; then \ $(mkinstalldirs) $(DESTDIR)$(sysconfdir); \ $(INSTALL_DATA) $(srcdir)/lftp.conf $(DESTDIR)$(sysconfdir)/lftp.conf; \ fi uninstall-local: if cmp -s $(DESTDIR)$(sysconfdir)/lftp.conf $(srcdir)/lftp.conf; then \ echo "$(DESTDIR)$(sysconfdir)/lftp.conf is not changed and will be removed."; \ rm -f $(DESTDIR)$(sysconfdir)/lftp.conf; \ fi dist-hook: @echo $(PACKAGE).spec updating... @rm -f $(distdir)/$(PACKAGE).spec @-sed "s/%define version .*/%define version $(VERSION)/" \ $(srcdir)/$(PACKAGE).spec > $(distdir)/$(PACKAGE).spec && \ cp $(distdir)/$(PACKAGE).spec $(srcdir)/$(PACKAGE).spec @echo $(PACKAGE).lsm updating... @rm -f $(distdir)/$(PACKAGE).lsm @-SIZE=`$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c | wc -c`; SIZE=`expr \( $$SIZE + 512 \) / 1024`; echo Size: $$SIZE kB; \ DATE=`date +%Y-%m-%d`; echo Date: $$DATE; \ sed -e "s/Version: .*/Version: $(VERSION)/" \ -e "s/[0-9]* kB $(PACKAGE)-.*\.tar\.gz/$$SIZE kB $(PACKAGE)-$(VERSION).tar.gz/" \ -e "s/Entered-date: .*/Entered-date: $$DATE/" \ $(srcdir)/$(PACKAGE).lsm > $(distdir)/$(PACKAGE).lsm && \ cp $(distdir)/$(PACKAGE).lsm $(srcdir)/$(PACKAGE).lsm REL_DIR=/home/lav/www-lftp/ftp release-check: for opt in "" "--with-modules" "--without-gnutls" "--without-openssl" \ "--without-gnutls --without-openssl" \ "--with-modules --without-gnutls --without-openssl"; \ do \ make DISTCHECK_CONFIGURE_FLAGS="$$opt" distcheck || exit 1; \ done release: # cvs commit -m $(VERSION) # make dist # cvs commit -m $(VERSION) make release-check make release-ftp release-ftp: mv $(PACKAGE)-$(VERSION).tar.gz $(REL_DIR)/$(PACKAGE)-$(VERSION).tar.gz cp -p $(PACKAGE).lsm $(REL_DIR)/$(PACKAGE)-$(VERSION).lsm cd $(REL_DIR) && \ (addbz $(PACKAGE)-$(VERSION).tar.gz; \ gpg -ba $(PACKAGE)-$(VERSION).tar.gz; \ gpg -ba $(PACKAGE)-$(VERSION).tar.bz2; \ gpg -ba $(PACKAGE)-$(VERSION).tar.xz; \ md5sum $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION).tar.bz2 $(PACKAGE)-$(VERSION).tar.xz > $(PACKAGE)-$(VERSION).md5sum) mutt -s add lsm@execpc.com < $(PACKAGE).lsm # cvs tag $(PACKAGE)-`echo $(VERSION) | sed 's/\./-/g'` . lftp-4.6.3a/lib/0000755000015000007670000000000012540300656010402 500000000000000lftp-4.6.3a/lib/fd-hook.h0000644000015000007670000001135112466374011012026 00000000000000/* Hook for making making file descriptor functions close(), ioctl() extensible. Copyright (C) 2009-2015 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 . */ #ifndef FD_HOOK_H #define FD_HOOK_H #ifdef __cplusplus extern "C" { #endif /* Currently, this entire code is only needed for the handling of sockets on native Windows platforms. */ #if WINDOWS_SOCKETS /* Type of function that closes FD. */ typedef int (*gl_close_fn) (int fd); /* Type of function that applies a control request to FD. */ typedef int (*gl_ioctl_fn) (int fd, int request, void *arg); /* An element of the list of file descriptor hooks. In CLOS (Common Lisp Object System) speak, it consists of an "around" method for the close() function and an "around" method for the ioctl() function. The fields of this structure are considered private. */ struct fd_hook { /* Doubly linked list. */ struct fd_hook *private_next; struct fd_hook *private_prev; /* Function that treats the types of FD that it knows about and calls execute_close_hooks (REMAINING_LIST, PRIMARY, FD) as a fallback. */ int (*private_close_fn) (const struct fd_hook *remaining_list, gl_close_fn primary, int fd); /* Function that treats the types of FD that it knows about and calls execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) as a fallback. */ int (*private_ioctl_fn) (const struct fd_hook *remaining_list, gl_ioctl_fn primary, int fd, int request, void *arg); }; /* This type of function closes FD, applying special knowledge for the FD types it knows about, and calls execute_close_hooks (REMAINING_LIST, PRIMARY, FD) for the other FD types. In CLOS speak, REMAINING_LIST is the remaining list of "around" methods, and PRIMARY is the "primary" method for close(). */ typedef int (*close_hook_fn) (const struct fd_hook *remaining_list, gl_close_fn primary, int fd); /* Execute the close hooks in REMAINING_LIST, with PRIMARY as "primary" method. Return 0 or -1, like close() would do. */ extern int execute_close_hooks (const struct fd_hook *remaining_list, gl_close_fn primary, int fd); /* Execute all close hooks, with PRIMARY as "primary" method. Return 0 or -1, like close() would do. */ extern int execute_all_close_hooks (gl_close_fn primary, int fd); /* This type of function applies a control request to FD, applying special knowledge for the FD types it knows about, and calls execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) for the other FD types. In CLOS speak, REMAINING_LIST is the remaining list of "around" methods, and PRIMARY is the "primary" method for ioctl(). */ typedef int (*ioctl_hook_fn) (const struct fd_hook *remaining_list, gl_ioctl_fn primary, int fd, int request, void *arg); /* Execute the ioctl hooks in REMAINING_LIST, with PRIMARY as "primary" method. Return 0 or -1, like ioctl() would do. */ extern int execute_ioctl_hooks (const struct fd_hook *remaining_list, gl_ioctl_fn primary, int fd, int request, void *arg); /* Execute all ioctl hooks, with PRIMARY as "primary" method. Return 0 or -1, like ioctl() would do. */ extern int execute_all_ioctl_hooks (gl_ioctl_fn primary, int fd, int request, void *arg); /* Add a function pair to the list of file descriptor hooks. CLOSE_HOOK and IOCTL_HOOK may be NULL, indicating no change. The LINK variable points to a piece of memory which is guaranteed to be accessible until the corresponding call to unregister_fd_hook. */ extern void register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook, struct fd_hook *link); /* Removes a hook from the list of file descriptor hooks. */ extern void unregister_fd_hook (struct fd_hook *link); #endif #ifdef __cplusplus } #endif #endif /* FD_HOOK_H */ lftp-4.6.3a/lib/math.c0000644000015000007670000000012012122621312011377 00000000000000#include #define _GL_MATH_INLINE _GL_EXTERN_INLINE #include "math.h" lftp-4.6.3a/lib/msvc-inval.c0000644000015000007670000000751112466374011012554 00000000000000/* Invalid parameter handler for MSVC runtime libraries. Copyright (C) 2011-2015 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 . */ #include /* Specification. */ #include "msvc-inval.h" #if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING) /* Get _invalid_parameter_handler type and _set_invalid_parameter_handler declaration. */ # include # if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING static void __cdecl gl_msvc_invalid_parameter_handler (const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t dummy) { } # else /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include # if defined _MSC_VER static void __cdecl gl_msvc_invalid_parameter_handler (const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t dummy) { RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); } # else /* An index to thread-local storage. */ static DWORD tls_index; static int tls_initialized /* = 0 */; /* Used as a fallback only. */ static struct gl_msvc_inval_per_thread not_per_thread; struct gl_msvc_inval_per_thread * gl_msvc_inval_current (void) { if (!tls_initialized) { tls_index = TlsAlloc (); tls_initialized = 1; } if (tls_index == TLS_OUT_OF_INDEXES) /* TlsAlloc had failed. */ return ¬_per_thread; else { struct gl_msvc_inval_per_thread *pointer = (struct gl_msvc_inval_per_thread *) TlsGetValue (tls_index); if (pointer == NULL) { /* First call. Allocate a new 'struct gl_msvc_inval_per_thread'. */ pointer = (struct gl_msvc_inval_per_thread *) malloc (sizeof (struct gl_msvc_inval_per_thread)); if (pointer == NULL) /* Could not allocate memory. Use the global storage. */ pointer = ¬_per_thread; TlsSetValue (tls_index, pointer); } return pointer; } } static void __cdecl gl_msvc_invalid_parameter_handler (const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t dummy) { struct gl_msvc_inval_per_thread *current = gl_msvc_inval_current (); if (current->restart_valid) longjmp (current->restart, 1); else /* An invalid parameter notification from outside the gnulib code. Give the caller a chance to intervene. */ RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); } # endif # endif static int gl_msvc_inval_initialized /* = 0 */; void gl_msvc_inval_ensure_handler (void) { if (gl_msvc_inval_initialized == 0) { _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler); gl_msvc_inval_initialized = 1; } } #endif lftp-4.6.3a/lib/xstrtol-error.c0000644000015000007670000000537012466374012013345 00000000000000/* A more useful interface to strtol. Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2015 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 . */ #include #include "xstrtol.h" #include #include "error.h" #include "exitfail.h" #include "gettext.h" #define N_(msgid) msgid /* Report an error for an invalid integer in an option argument. ERR is the error code returned by one of the xstrto* functions. Use OPT_IDX to decide whether to print the short option string "C" or "-C" or a long option string derived from LONG_OPTION. OPT_IDX is -2 if the short option "C" was used, without any leading "-"; it is -1 if the short option "-C" was used; otherwise it is an index into LONG_OPTIONS, which should have a name preceded by two '-' characters. ARG is the option-argument containing the integer. After reporting an error, exit with status EXIT_STATUS if it is nonzero. */ static void xstrtol_error (enum strtol_error err, int opt_idx, char c, struct option const *long_options, char const *arg, int exit_status) { char const *hyphens = "--"; char const *msgid; char const *option; char option_buffer[2]; switch (err) { default: abort (); case LONGINT_INVALID: msgid = N_("invalid %s%s argument '%s'"); break; case LONGINT_INVALID_SUFFIX_CHAR: case LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW: msgid = N_("invalid suffix in %s%s argument '%s'"); break; case LONGINT_OVERFLOW: msgid = N_("%s%s argument '%s' too large"); break; } if (opt_idx < 0) { hyphens -= opt_idx; option_buffer[0] = c; option_buffer[1] = '\0'; option = option_buffer; } else option = long_options[opt_idx].name; error (exit_status, 0, gettext (msgid), hyphens, option, arg); } /* Like xstrtol_error, except exit with a failure status. */ void xstrtol_fatal (enum strtol_error err, int opt_idx, char c, struct option const *long_options, char const *arg) { xstrtol_error (err, opt_idx, c, long_options, arg, exit_failure); abort (); } lftp-4.6.3a/lib/getopt.in.h0000644000015000007670000002162112466374011012407 00000000000000/* Declarations for getopt. Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2015 Free Software Foundation, Inc. This file is part of 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 . */ #ifndef _@GUARD_PREFIX@_GETOPT_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. We must also inform the replacement unistd.h to not recursively use ; our definitions will be present soon enough. */ #if @HAVE_GETOPT_H@ # define _GL_SYSTEM_GETOPT # @INCLUDE_NEXT@ @NEXT_GETOPT_H@ # undef _GL_SYSTEM_GETOPT #endif #ifndef _@GUARD_PREFIX@_GETOPT_H #ifndef __need_getopt # define _@GUARD_PREFIX@_GETOPT_H 1 #endif /* Standalone applications should #define __GETOPT_PREFIX to an identifier that prefixes the external functions and variables defined in this header. When this happens, include the headers that might declare getopt so that they will not cause confusion if included after this file (if the system had , we have already included it). Then systematically rename identifiers so that they do not collide with the system functions and variables. Renaming avoids problems with some compilers and linkers. */ #if defined __GETOPT_PREFIX && !defined __need_getopt # if !@HAVE_GETOPT_H@ # define __need_system_stdlib_h # include # undef __need_system_stdlib_h # include # include # endif # undef __need_getopt # undef getopt # undef getopt_long # undef getopt_long_only # undef optarg # undef opterr # undef optind # undef optopt # undef option # define __GETOPT_CONCAT(x, y) x ## y # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) # define getopt __GETOPT_ID (getopt) # define getopt_long __GETOPT_ID (getopt_long) # define getopt_long_only __GETOPT_ID (getopt_long_only) # define optarg __GETOPT_ID (optarg) # define opterr __GETOPT_ID (opterr) # define optind __GETOPT_ID (optind) # define optopt __GETOPT_ID (optopt) # define option __GETOPT_ID (option) # define _getopt_internal __GETOPT_ID (getopt_internal) #endif /* Standalone applications get correct prototypes for getopt_long and getopt_long_only; they declare "char **argv". libc uses prototypes with "char *const *argv" that are incorrect because getopt_long and getopt_long_only can permute argv; this is required for backward compatibility (e.g., for LSB 2.0.1). This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt', but it caused redefinition warnings if both unistd.h and getopt.h were included, since unistd.h includes getopt.h having previously defined __need_getopt. The only place where __getopt_argv_const is used is in definitions of getopt_long and getopt_long_only below, but these are visible only if __need_getopt is not defined, so it is quite safe to rewrite the conditional as follows: */ #if !defined __need_getopt # if defined __GETOPT_PREFIX # define __getopt_argv_const /* empty */ # else # define __getopt_argv_const const # endif #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used standalone, or this is the first header included in the source file. If we are being used with glibc, we need to include , but that does not exist if we are standalone. So: if __GNU_LIBRARY__ is not defined, include , which will pull in for us if it's from glibc. (Why ctype.h? It's guaranteed to exist and it doesn't flood the namespace with stuff the way some other headers do.) */ #if !defined __GNU_LIBRARY__ # include #endif #ifndef __THROW # ifndef __GNUC_PREREQ # define __GNUC_PREREQ(maj, min) (0) # endif # if defined __cplusplus && __GNUC_PREREQ (2,8) # define __THROW throw () # else # define __THROW # endif #endif /* The definition of _GL_ARG_NONNULL is copied here. */ #ifdef __cplusplus extern "C" { #endif /* For communication from 'getopt' to the caller. When 'getopt' finds an option that takes an argument, the argument value is returned here. Also, when 'ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to 'getopt'. On entry to 'getopt', zero means this is the first call; initialize. When 'getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, 'optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message 'getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of 'struct option' terminated by an element containing a name which is zero. The field 'has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field 'flag' is not NULL, it points to a variable that is set to the value given in the field 'val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an 'int' to a compiled-in constant, such as set a value from 'optarg', set the option's 'flag' field to zero and its 'val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero 'flag' field, 'getopt' returns the contents of the 'val' field. */ # if !GNULIB_defined_struct_option struct option { const char *name; /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; # define GNULIB_defined_struct_option 1 # endif /* Names for the values of the 'has_arg' field of 'struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, 'optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in 'optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU 'getopt'. The argument '--' causes premature termination of argument scanning, explicitly telling 'getopt' that there are no more options. If OPTS begins with '-', then non-option arguments are treated as arguments to the option '\1'. This behavior is specific to the GNU 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in the environment, then do not permute arguments. */ extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) __THROW _GL_ARG_NONNULL ((2, 3)); #ifndef __need_getopt extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind) __THROW _GL_ARG_NONNULL ((2, 3)); extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind) __THROW _GL_ARG_NONNULL ((2, 3)); #endif #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* _@GUARD_PREFIX@_GETOPT_H */ #endif /* _@GUARD_PREFIX@_GETOPT_H */ lftp-4.6.3a/lib/close.c0000644000015000007670000000270712466374011011604 00000000000000/* close replacement. Copyright (C) 2008-2015 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 . */ #include /* Specification. */ #include #include #include "fd-hook.h" #include "msvc-inval.h" #undef close #if HAVE_MSVC_INVALID_PARAMETER_HANDLER static int close_nothrow (int fd) { int result; TRY_MSVC_INVAL { result = close (fd); } CATCH_MSVC_INVAL { result = -1; errno = EBADF; } DONE_MSVC_INVAL; return result; } #else # define close_nothrow close #endif /* Override close() to call into other gnulib modules. */ int rpl_close (int fd) { #if WINDOWS_SOCKETS int retval = execute_all_close_hooks (close_nothrow, fd); #else int retval = close_nothrow (fd); #endif #if REPLACE_FCHDIR if (retval >= 0) _gl_unregister_fd (fd); #endif return retval; } lftp-4.6.3a/lib/iconv.c0000644000015000007670000002627512466374011011623 00000000000000/* Character set conversion. Copyright (C) 1999-2001, 2007, 2009-2015 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 . */ #include /* Specification. */ #include #include #if REPLACE_ICONV_UTF # include # include # include # include "unistr.h" # ifndef uintptr_t # define uintptr_t unsigned long # endif #endif #if REPLACE_ICONV_UTF /* UTF-{16,32}{BE,LE} converters taken from GNU libiconv 1.11. */ /* Return code if invalid. (xxx_mbtowc) */ # define RET_ILSEQ -1 /* Return code if no bytes were read. (xxx_mbtowc) */ # define RET_TOOFEW -2 /* Return code if invalid. (xxx_wctomb) */ # define RET_ILUNI -1 /* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */ # define RET_TOOSMALL -2 /* * UTF-16BE */ /* Specification: RFC 2781 */ static int utf16be_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n) { if (n >= 2) { ucs4_t wc = (s[0] << 8) + s[1]; if (wc >= 0xd800 && wc < 0xdc00) { if (n >= 4) { ucs4_t wc2 = (s[2] << 8) + s[3]; if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) return RET_ILSEQ; *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); return 4; } } else if (wc >= 0xdc00 && wc < 0xe000) { return RET_ILSEQ; } else { *pwc = wc; return 2; } } return RET_TOOFEW; } static int utf16be_wctomb (unsigned char *r, ucs4_t wc, size_t n) { if (!(wc >= 0xd800 && wc < 0xe000)) { if (wc < 0x10000) { if (n >= 2) { r[0] = (unsigned char) (wc >> 8); r[1] = (unsigned char) wc; return 2; } else return RET_TOOSMALL; } else if (wc < 0x110000) { if (n >= 4) { ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); r[0] = (unsigned char) (wc1 >> 8); r[1] = (unsigned char) wc1; r[2] = (unsigned char) (wc2 >> 8); r[3] = (unsigned char) wc2; return 4; } else return RET_TOOSMALL; } } return RET_ILUNI; } /* * UTF-16LE */ /* Specification: RFC 2781 */ static int utf16le_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n) { if (n >= 2) { ucs4_t wc = s[0] + (s[1] << 8); if (wc >= 0xd800 && wc < 0xdc00) { if (n >= 4) { ucs4_t wc2 = s[2] + (s[3] << 8); if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) return RET_ILSEQ; *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); return 4; } } else if (wc >= 0xdc00 && wc < 0xe000) { return RET_ILSEQ; } else { *pwc = wc; return 2; } } return RET_TOOFEW; } static int utf16le_wctomb (unsigned char *r, ucs4_t wc, size_t n) { if (!(wc >= 0xd800 && wc < 0xe000)) { if (wc < 0x10000) { if (n >= 2) { r[0] = (unsigned char) wc; r[1] = (unsigned char) (wc >> 8); return 2; } else return RET_TOOSMALL; } else if (wc < 0x110000) { if (n >= 4) { ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); r[0] = (unsigned char) wc1; r[1] = (unsigned char) (wc1 >> 8); r[2] = (unsigned char) wc2; r[3] = (unsigned char) (wc2 >> 8); return 4; } else return RET_TOOSMALL; } } return RET_ILUNI; } /* * UTF-32BE */ /* Specification: Unicode 3.1 Standard Annex #19 */ static int utf32be_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n) { if (n >= 4) { ucs4_t wc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]; if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { *pwc = wc; return 4; } else return RET_ILSEQ; } return RET_TOOFEW; } static int utf32be_wctomb (unsigned char *r, ucs4_t wc, size_t n) { if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { if (n >= 4) { r[0] = 0; r[1] = (unsigned char) (wc >> 16); r[2] = (unsigned char) (wc >> 8); r[3] = (unsigned char) wc; return 4; } else return RET_TOOSMALL; } return RET_ILUNI; } /* * UTF-32LE */ /* Specification: Unicode 3.1 Standard Annex #19 */ static int utf32le_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n) { if (n >= 4) { ucs4_t wc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24); if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { *pwc = wc; return 4; } else return RET_ILSEQ; } return RET_TOOFEW; } static int utf32le_wctomb (unsigned char *r, ucs4_t wc, size_t n) { if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { if (n >= 4) { r[0] = (unsigned char) wc; r[1] = (unsigned char) (wc >> 8); r[2] = (unsigned char) (wc >> 16); r[3] = 0; return 4; } else return RET_TOOSMALL; } return RET_ILUNI; } #endif size_t rpl_iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) #undef iconv { #if REPLACE_ICONV_UTF switch ((uintptr_t) cd) { { int (*xxx_wctomb) (unsigned char *, ucs4_t, size_t); case (uintptr_t) _ICONV_UTF8_UTF16BE: xxx_wctomb = utf16be_wctomb; goto loop_from_utf8; case (uintptr_t) _ICONV_UTF8_UTF16LE: xxx_wctomb = utf16le_wctomb; goto loop_from_utf8; case (uintptr_t) _ICONV_UTF8_UTF32BE: xxx_wctomb = utf32be_wctomb; goto loop_from_utf8; case (uintptr_t) _ICONV_UTF8_UTF32LE: xxx_wctomb = utf32le_wctomb; goto loop_from_utf8; loop_from_utf8: if (inbuf == NULL || *inbuf == NULL) return 0; { ICONV_CONST char *inptr = *inbuf; size_t inleft = *inbytesleft; char *outptr = *outbuf; size_t outleft = *outbytesleft; size_t res = 0; while (inleft > 0) { ucs4_t uc; int m = u8_mbtoucr (&uc, (const uint8_t *) inptr, inleft); if (m <= 0) { if (m == -1) { errno = EILSEQ; res = (size_t)(-1); break; } if (m == -2) { errno = EINVAL; res = (size_t)(-1); break; } abort (); } else { int n = xxx_wctomb ((uint8_t *) outptr, uc, outleft); if (n < 0) { if (n == RET_ILUNI) { errno = EILSEQ; res = (size_t)(-1); break; } if (n == RET_TOOSMALL) { errno = E2BIG; res = (size_t)(-1); break; } abort (); } else { inptr += m; inleft -= m; outptr += n; outleft -= n; } } } *inbuf = inptr; *inbytesleft = inleft; *outbuf = outptr; *outbytesleft = outleft; return res; } } { int (*xxx_mbtowc) (ucs4_t *, const unsigned char *, size_t); case (uintptr_t) _ICONV_UTF16BE_UTF8: xxx_mbtowc = utf16be_mbtowc; goto loop_to_utf8; case (uintptr_t) _ICONV_UTF16LE_UTF8: xxx_mbtowc = utf16le_mbtowc; goto loop_to_utf8; case (uintptr_t) _ICONV_UTF32BE_UTF8: xxx_mbtowc = utf32be_mbtowc; goto loop_to_utf8; case (uintptr_t) _ICONV_UTF32LE_UTF8: xxx_mbtowc = utf32le_mbtowc; goto loop_to_utf8; loop_to_utf8: if (inbuf == NULL || *inbuf == NULL) return 0; { ICONV_CONST char *inptr = *inbuf; size_t inleft = *inbytesleft; char *outptr = *outbuf; size_t outleft = *outbytesleft; size_t res = 0; while (inleft > 0) { ucs4_t uc; int m = xxx_mbtowc (&uc, (const uint8_t *) inptr, inleft); if (m <= 0) { if (m == RET_ILSEQ) { errno = EILSEQ; res = (size_t)(-1); break; } if (m == RET_TOOFEW) { errno = EINVAL; res = (size_t)(-1); break; } abort (); } else { int n = u8_uctomb ((uint8_t *) outptr, uc, outleft); if (n < 0) { if (n == -1) { errno = EILSEQ; res = (size_t)(-1); break; } if (n == -2) { errno = E2BIG; res = (size_t)(-1); break; } abort (); } else { inptr += m; inleft -= m; outptr += n; outleft -= n; } } } *inbuf = inptr; *inbytesleft = inleft; *outbuf = outptr; *outbytesleft = outleft; return res; } } } #endif return iconv (cd, inbuf, inbytesleft, outbuf, outbytesleft); } lftp-4.6.3a/lib/getlogin_r.c0000644000015000007670000000466512466374011012635 00000000000000/* Provide a working getlogin_r for systems which lack it. Copyright (C) 2005-2007, 2010-2015 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 . */ /* Written by Paul Eggert, Derek Price, and Bruno Haible. */ #include /* Specification. */ #include #include #include #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include #else # if !HAVE_DECL_GETLOGIN extern char *getlogin (void); # endif #endif /* See unistd.in.h for documentation. */ int getlogin_r (char *name, size_t size) { #undef getlogin_r #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Native Windows platform. */ DWORD sz; /* When size > 0x7fff, the doc says that GetUserName will fail. Actually, on Windows XP SP3, it succeeds. But let's be safe, for the sake of older Windows versions. */ if (size > 0x7fff) size = 0x7fff; sz = size; if (!GetUserName (name, &sz)) { if (GetLastError () == ERROR_INSUFFICIENT_BUFFER) /* In this case, the doc says that sz contains the required size, but actually, on Windows XP SP3, it contains 2 * the required size. */ return ERANGE; else return ENOENT; } return 0; #elif HAVE_GETLOGIN_R /* Platform with a getlogin_r() function. */ int ret = getlogin_r (name, size); if (ret == 0 && memchr (name, '\0', size) == NULL) /* name contains a truncated result. */ return ERANGE; return ret; #else /* Platform with a getlogin() function. */ char *n; size_t nlen; errno = 0; n = getlogin (); if (!n) /* ENOENT is a reasonable errno value if getlogin returns NULL. */ return (errno != 0 ? errno : ENOENT); nlen = strlen (n); if (size <= nlen) return ERANGE; memcpy (name, n, nlen + 1); return 0; #endif } lftp-4.6.3a/lib/xstrtol.h0000644000015000007670000000473512466374012012227 00000000000000/* A more useful interface to strtol. Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2015 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 . */ #ifndef XSTRTOL_H_ # define XSTRTOL_H_ 1 # include # include # ifndef _STRTOL_ERROR enum strtol_error { LONGINT_OK = 0, /* These two values can be ORed together, to indicate that both errors occurred. */ LONGINT_OVERFLOW = 1, LONGINT_INVALID_SUFFIX_CHAR = 2, LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR | LONGINT_OVERFLOW), LONGINT_INVALID = 4 }; typedef enum strtol_error strtol_error; # endif # define _DECLARE_XSTRTOL(name, type) \ strtol_error name (const char *, char **, int, type *, const char *); _DECLARE_XSTRTOL (xstrtol, long int) _DECLARE_XSTRTOL (xstrtoul, unsigned long int) _DECLARE_XSTRTOL (xstrtoimax, intmax_t) _DECLARE_XSTRTOL (xstrtoumax, uintmax_t) #if HAVE_LONG_LONG_INT _DECLARE_XSTRTOL (xstrtoll, long long int) _DECLARE_XSTRTOL (xstrtoull, unsigned long long int) #endif /* Report an error for an invalid integer in an option argument. ERR is the error code returned by one of the xstrto* functions. Use OPT_IDX to decide whether to print the short option string "C" or "-C" or a long option string derived from LONG_OPTION. OPT_IDX is -2 if the short option "C" was used, without any leading "-"; it is -1 if the short option "-C" was used; otherwise it is an index into LONG_OPTIONS, which should have a name preceded by two '-' characters. ARG is the option-argument containing the integer. After reporting an error, exit with a failure status. */ _Noreturn void xstrtol_fatal (enum strtol_error, int, char, struct option const *, char const *); #endif /* not XSTRTOL_H_ */ lftp-4.6.3a/lib/iconv_open-irix.gperf0000644000015000007670000000136412122621312014452 00000000000000struct mapping { int standard_name; const char vendor_name[10 + 1]; }; %struct-type %language=ANSI-C %define slot-name standard_name %define hash-function-name mapping_hash %define lookup-function-name mapping_lookup %readonly-tables %global-table %define word-array-name mappings %pic %% # On IRIX 6.5, look in /usr/lib/iconv and /usr/lib/international/encodings. ISO-8859-1, "ISO8859-1" ISO-8859-2, "ISO8859-2" ISO-8859-3, "ISO8859-3" ISO-8859-4, "ISO8859-4" ISO-8859-5, "ISO8859-5" ISO-8859-6, "ISO8859-6" ISO-8859-7, "ISO8859-7" ISO-8859-8, "ISO8859-8" ISO-8859-9, "ISO8859-9" ISO-8859-15, "ISO8859-15" KOI8-R, "KOI8" CP855, "DOS855" CP1251, "WIN1251" GB2312, "eucCN" EUC-JP, "eucJP" EUC-KR, "eucKR" EUC-TW, "eucTW" SHIFT_JIS, "sjis" TIS-620, "TIS620" lftp-4.6.3a/lib/iconv_open-irix.h0000644000015000007670000001734212122621410013600 00000000000000/* ANSI-C code produced by gperf version 3.0.4 */ /* Command-line: gperf -m 10 ./iconv_open-irix.gperf */ /* Computed positions: -k'1,$' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "./iconv_open-irix.gperf" struct mapping { int standard_name; const char vendor_name[10 + 1]; }; #define TOTAL_KEYWORDS 19 #define MIN_WORD_LENGTH 5 #define MAX_WORD_LENGTH 11 #define MIN_HASH_VALUE 5 #define MAX_HASH_VALUE 23 /* maximum key range = 19, duplicates = 0 */ #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static unsigned int mapping_hash (register const char *str, register unsigned int len) { static const unsigned char asso_values[] = { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 8, 2, 5, 12, 11, 0, 10, 9, 8, 7, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 24, 0, 24, 5, 24, 0, 24, 7, 24, 24, 24, 24, 7, 24, 1, 0, 8, 24, 24, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 }; return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]]; } struct stringpool_t { char stringpool_str5[sizeof("CP855")]; char stringpool_str6[sizeof("EUC-TW")]; char stringpool_str7[sizeof("EUC-KR")]; char stringpool_str8[sizeof("CP1251")]; char stringpool_str9[sizeof("SHIFT_JIS")]; char stringpool_str10[sizeof("ISO-8859-5")]; char stringpool_str11[sizeof("ISO-8859-15")]; char stringpool_str12[sizeof("ISO-8859-1")]; char stringpool_str13[sizeof("EUC-JP")]; char stringpool_str14[sizeof("KOI8-R")]; char stringpool_str15[sizeof("ISO-8859-2")]; char stringpool_str16[sizeof("GB2312")]; char stringpool_str17[sizeof("ISO-8859-9")]; char stringpool_str18[sizeof("ISO-8859-8")]; char stringpool_str19[sizeof("ISO-8859-7")]; char stringpool_str20[sizeof("ISO-8859-6")]; char stringpool_str21[sizeof("ISO-8859-4")]; char stringpool_str22[sizeof("ISO-8859-3")]; char stringpool_str23[sizeof("TIS-620")]; }; static const struct stringpool_t stringpool_contents = { "CP855", "EUC-TW", "EUC-KR", "CP1251", "SHIFT_JIS", "ISO-8859-5", "ISO-8859-15", "ISO-8859-1", "EUC-JP", "KOI8-R", "ISO-8859-2", "GB2312", "ISO-8859-9", "ISO-8859-8", "ISO-8859-7", "ISO-8859-6", "ISO-8859-4", "ISO-8859-3", "TIS-620" }; #define stringpool ((const char *) &stringpool_contents) static const struct mapping mappings[] = { {-1}, {-1}, {-1}, {-1}, {-1}, #line 24 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str5, "DOS855"}, #line 29 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str6, "eucTW"}, #line 28 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str7, "eucKR"}, #line 25 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str8, "WIN1251"}, #line 30 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str9, "sjis"}, #line 17 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str10, "ISO8859-5"}, #line 22 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str11, "ISO8859-15"}, #line 13 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str12, "ISO8859-1"}, #line 27 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str13, "eucJP"}, #line 23 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str14, "KOI8"}, #line 14 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, "ISO8859-2"}, #line 26 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str16, "eucCN"}, #line 21 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str17, "ISO8859-9"}, #line 20 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, "ISO8859-8"}, #line 19 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str19, "ISO8859-7"}, #line 18 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str20, "ISO8859-6"}, #line 16 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str21, "ISO8859-4"}, #line 15 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str22, "ISO8859-3"}, #line 31 "./iconv_open-irix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str23, "TIS620"} }; #ifdef __GNUC__ __inline #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ __attribute__ ((__gnu_inline__)) #endif #endif const struct mapping * mapping_lookup (register const char *str, register unsigned int len) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { register int key = mapping_hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) { register int o = mappings[key].standard_name; if (o >= 0) { register const char *s = o + stringpool; if (*str == *s && !strcmp (str + 1, s + 1)) return &mappings[key]; } } } return 0; } lftp-4.6.3a/lib/passfd.h0000644000015000007670000000167512466374011011767 00000000000000/* passfd.h -- definitions and prototypes for passfd.c Copyright (C) 2011-2015 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 . */ #ifndef PASSFD_H_ #define PASSFD_H_ 1 #ifdef __cplusplus extern "C" { #endif extern int sendfd (int sock, int fd); extern int recvfd (int sock, int flags); #ifdef __cplusplus } #endif #endif lftp-4.6.3a/lib/signbitf.c0000644000015000007670000000407712466374012012307 00000000000000/* signbit() macro: Determine the sign bit of a floating-point number. Copyright (C) 2007, 2009-2015 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 . */ #include /* Specification. */ #include #include #include "isnanf-nolibm.h" #include "float+.h" #ifdef gl_signbitf_OPTIMIZED_MACRO # undef gl_signbitf #endif int gl_signbitf (float arg) { #if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT /* The use of a union to extract the bits of the representation of a 'long double' is safe in practice, despite of the "aliasing rules" of C99, because the GCC docs say "Even with '-fstrict-aliasing', type-punning is allowed, provided the memory is accessed through the union type." and similarly for other compilers. */ # define NWORDS \ ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) union { float value; unsigned int word[NWORDS]; } m; m.value = arg; return (m.word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; #elif HAVE_COPYSIGNF_IN_LIBC return copysignf (1.0f, arg) < 0; #else /* This does not do the right thing for NaN, but this is irrelevant for most use cases. */ if (isnanf (arg)) return 0; if (arg < 0.0f) return 1; else if (arg == 0.0f) { /* Distinguish 0.0f and -0.0f. */ static float plus_zero = 0.0f; float arg_mem = arg; return (memcmp (&plus_zero, &arg_mem, SIZEOF_FLT) != 0); } else return 0; #endif } lftp-4.6.3a/lib/float+.h0000644000015000007670000001274512466374011011667 00000000000000/* Supplemental information about the floating-point formats. Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2007. 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 . */ #ifndef _FLOATPLUS_H #define _FLOATPLUS_H #include #include /* Number of bits in the mantissa of a floating-point number, including the "hidden bit". */ #if FLT_RADIX == 2 # define FLT_MANT_BIT FLT_MANT_DIG # define DBL_MANT_BIT DBL_MANT_DIG # define LDBL_MANT_BIT LDBL_MANT_DIG #elif FLT_RADIX == 4 # define FLT_MANT_BIT (FLT_MANT_DIG * 2) # define DBL_MANT_BIT (DBL_MANT_DIG * 2) # define LDBL_MANT_BIT (LDBL_MANT_DIG * 2) #elif FLT_RADIX == 16 # define FLT_MANT_BIT (FLT_MANT_DIG * 4) # define DBL_MANT_BIT (DBL_MANT_DIG * 4) # define LDBL_MANT_BIT (LDBL_MANT_DIG * 4) #endif /* Bit mask that can be used to mask the exponent, as an unsigned number. */ #define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7) #define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) #define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7) /* Number of bits used for the exponent of a floating-point number, including the exponent's sign. */ #define FLT_EXP_BIT \ (FLT_EXP_MASK < 0x100 ? 8 : \ FLT_EXP_MASK < 0x200 ? 9 : \ FLT_EXP_MASK < 0x400 ? 10 : \ FLT_EXP_MASK < 0x800 ? 11 : \ FLT_EXP_MASK < 0x1000 ? 12 : \ FLT_EXP_MASK < 0x2000 ? 13 : \ FLT_EXP_MASK < 0x4000 ? 14 : \ FLT_EXP_MASK < 0x8000 ? 15 : \ FLT_EXP_MASK < 0x10000 ? 16 : \ FLT_EXP_MASK < 0x20000 ? 17 : \ FLT_EXP_MASK < 0x40000 ? 18 : \ FLT_EXP_MASK < 0x80000 ? 19 : \ FLT_EXP_MASK < 0x100000 ? 20 : \ FLT_EXP_MASK < 0x200000 ? 21 : \ FLT_EXP_MASK < 0x400000 ? 22 : \ FLT_EXP_MASK < 0x800000 ? 23 : \ FLT_EXP_MASK < 0x1000000 ? 24 : \ FLT_EXP_MASK < 0x2000000 ? 25 : \ FLT_EXP_MASK < 0x4000000 ? 26 : \ FLT_EXP_MASK < 0x8000000 ? 27 : \ FLT_EXP_MASK < 0x10000000 ? 28 : \ FLT_EXP_MASK < 0x20000000 ? 29 : \ FLT_EXP_MASK < 0x40000000 ? 30 : \ FLT_EXP_MASK <= 0x7fffffff ? 31 : \ 32) #define DBL_EXP_BIT \ (DBL_EXP_MASK < 0x100 ? 8 : \ DBL_EXP_MASK < 0x200 ? 9 : \ DBL_EXP_MASK < 0x400 ? 10 : \ DBL_EXP_MASK < 0x800 ? 11 : \ DBL_EXP_MASK < 0x1000 ? 12 : \ DBL_EXP_MASK < 0x2000 ? 13 : \ DBL_EXP_MASK < 0x4000 ? 14 : \ DBL_EXP_MASK < 0x8000 ? 15 : \ DBL_EXP_MASK < 0x10000 ? 16 : \ DBL_EXP_MASK < 0x20000 ? 17 : \ DBL_EXP_MASK < 0x40000 ? 18 : \ DBL_EXP_MASK < 0x80000 ? 19 : \ DBL_EXP_MASK < 0x100000 ? 20 : \ DBL_EXP_MASK < 0x200000 ? 21 : \ DBL_EXP_MASK < 0x400000 ? 22 : \ DBL_EXP_MASK < 0x800000 ? 23 : \ DBL_EXP_MASK < 0x1000000 ? 24 : \ DBL_EXP_MASK < 0x2000000 ? 25 : \ DBL_EXP_MASK < 0x4000000 ? 26 : \ DBL_EXP_MASK < 0x8000000 ? 27 : \ DBL_EXP_MASK < 0x10000000 ? 28 : \ DBL_EXP_MASK < 0x20000000 ? 29 : \ DBL_EXP_MASK < 0x40000000 ? 30 : \ DBL_EXP_MASK <= 0x7fffffff ? 31 : \ 32) #define LDBL_EXP_BIT \ (LDBL_EXP_MASK < 0x100 ? 8 : \ LDBL_EXP_MASK < 0x200 ? 9 : \ LDBL_EXP_MASK < 0x400 ? 10 : \ LDBL_EXP_MASK < 0x800 ? 11 : \ LDBL_EXP_MASK < 0x1000 ? 12 : \ LDBL_EXP_MASK < 0x2000 ? 13 : \ LDBL_EXP_MASK < 0x4000 ? 14 : \ LDBL_EXP_MASK < 0x8000 ? 15 : \ LDBL_EXP_MASK < 0x10000 ? 16 : \ LDBL_EXP_MASK < 0x20000 ? 17 : \ LDBL_EXP_MASK < 0x40000 ? 18 : \ LDBL_EXP_MASK < 0x80000 ? 19 : \ LDBL_EXP_MASK < 0x100000 ? 20 : \ LDBL_EXP_MASK < 0x200000 ? 21 : \ LDBL_EXP_MASK < 0x400000 ? 22 : \ LDBL_EXP_MASK < 0x800000 ? 23 : \ LDBL_EXP_MASK < 0x1000000 ? 24 : \ LDBL_EXP_MASK < 0x2000000 ? 25 : \ LDBL_EXP_MASK < 0x4000000 ? 26 : \ LDBL_EXP_MASK < 0x8000000 ? 27 : \ LDBL_EXP_MASK < 0x10000000 ? 28 : \ LDBL_EXP_MASK < 0x20000000 ? 29 : \ LDBL_EXP_MASK < 0x40000000 ? 30 : \ LDBL_EXP_MASK <= 0x7fffffff ? 31 : \ 32) /* Number of bits used for a floating-point number: the mantissa (not counting the "hidden bit", since it may or may not be explicit), the exponent, and the sign. */ #define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1) #define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1) #define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1) /* Number of bytes used for a floating-point number. This can be smaller than the 'sizeof'. For example, on i386 systems, 'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but sizeof (long double) = 12 or = 16. */ #define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) #define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) #define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) /* Verify that SIZEOF_FLT <= sizeof (float) etc. */ typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1]; typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1]; typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1]; #endif /* _FLOATPLUS_H */ lftp-4.6.3a/lib/human.c0000644000015000007670000003235412466374011011610 00000000000000/* human.c -- print human readable file size Copyright (C) 1996-2007, 2009-2015 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 . */ /* Written by Paul Eggert and Larry McVoy. */ #include #include "human.h" #include #include #include #include #include #include #include /* The maximum length of a suffix like "KiB". */ #define HUMAN_READABLE_SUFFIX_LENGTH_MAX 3 static const char power_letter[] = { 0, /* not used */ 'K', /* kibi ('k' for kilo is a special case) */ 'M', /* mega or mebi */ 'G', /* giga or gibi */ 'T', /* tera or tebi */ 'P', /* peta or pebi */ 'E', /* exa or exbi */ 'Z', /* zetta or 2**70 */ 'Y' /* yotta or 2**80 */ }; /* If INEXACT_STYLE is not human_round_to_nearest, and if easily possible, adjust VALUE according to the style. */ static long double adjust_value (int inexact_style, long double value) { /* Do not use the floorl or ceill functions, as that would mean checking for their presence and possibly linking with the standard math library, which is a porting pain. So leave the value alone if it is too large to easily round. */ if (inexact_style != human_round_to_nearest && value < UINTMAX_MAX) { uintmax_t u = value; value = u + (inexact_style == human_ceiling && u != value); } return value; } /* Group the digits of NUMBER according to the grouping rules of the current locale. NUMBER contains NUMBERLEN digits. Modify the bytes pointed to by NUMBER in place, subtracting 1 from NUMBER for each byte inserted. Return the starting address of the modified number. To group the digits, use GROUPING and THOUSANDS_SEP as in 'struct lconv' from . */ static char * group_number (char *number, size_t numberlen, char const *grouping, char const *thousands_sep) { register char *d; size_t grouplen = SIZE_MAX; size_t thousands_seplen = strlen (thousands_sep); size_t i = numberlen; /* The maximum possible value for NUMBERLEN is the number of digits in the square of the largest uintmax_t, so double the size needed. */ char buf[2 * INT_STRLEN_BOUND (uintmax_t) + 1]; memcpy (buf, number, numberlen); d = number + numberlen; for (;;) { unsigned char g = *grouping; if (g) { grouplen = g < CHAR_MAX ? g : i; grouping++; } if (i < grouplen) grouplen = i; d -= grouplen; i -= grouplen; memcpy (d, buf + i, grouplen); if (i == 0) return d; d -= thousands_seplen; memcpy (d, thousands_sep, thousands_seplen); } } /* Convert N to a human readable format in BUF, using the options OPTS. N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must be nonnegative. Use units of TO_BLOCK_SIZE in the output number. TO_BLOCK_SIZE must be positive. Use (OPTS & (human_round_to_nearest | human_floor | human_ceiling)) to determine whether to take the ceiling or floor of any result that cannot be expressed exactly. If (OPTS & human_group_digits), group the thousands digits according to the locale, e.g., "1,000,000" in an American English locale. If (OPTS & human_autoscale), deduce the output block size automatically; TO_BLOCK_SIZE must be 1 but it has no effect on the output. Use powers of 1024 if (OPTS & human_base_1024), and powers of 1000 otherwise. For example, assuming powers of 1024, 8500 would be converted to 8.3, 133456345 to 127, 56990456345 to 53, and so on. Numbers smaller than the power aren't modified. human_autoscale is normally used together with human_SI. If (OPTS & human_space_before_unit), use a space to separate the number from any suffix that is appended as described below. If (OPTS & human_SI), append an SI prefix indicating which power is being used. If in addition (OPTS & human_B), append "B" (if base 1000) or "iB" (if base 1024) to the SI prefix. When ((OPTS & human_SI) && ! (OPTS & human_autoscale)), TO_BLOCK_SIZE must be a power of 1024 or of 1000, depending on (OPTS & human_base_1024). */ char * human_readable (uintmax_t n, char *buf, int opts, uintmax_t from_block_size, uintmax_t to_block_size) { int inexact_style = opts & (human_round_to_nearest | human_floor | human_ceiling); unsigned int base = opts & human_base_1024 ? 1024 : 1000; uintmax_t amt; int tenths; int exponent = -1; int exponent_max = sizeof power_letter - 1; char *p; char *psuffix; char const *integerlim; /* 0 means adjusted N == AMT.TENTHS; 1 means AMT.TENTHS < adjusted N < AMT.TENTHS + 0.05; 2 means adjusted N == AMT.TENTHS + 0.05; 3 means AMT.TENTHS + 0.05 < adjusted N < AMT.TENTHS + 0.1. */ int rounding; char const *decimal_point = "."; size_t decimal_pointlen = 1; char const *grouping = ""; char const *thousands_sep = ""; struct lconv const *l = localeconv (); size_t pointlen = strlen (l->decimal_point); if (0 < pointlen && pointlen <= MB_LEN_MAX) { decimal_point = l->decimal_point; decimal_pointlen = pointlen; } grouping = l->grouping; if (strlen (l->thousands_sep) <= MB_LEN_MAX) thousands_sep = l->thousands_sep; psuffix = buf + LONGEST_HUMAN_READABLE - HUMAN_READABLE_SUFFIX_LENGTH_MAX; p = psuffix; /* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE units. If this can be done exactly with integer arithmetic, do not use floating point operations. */ if (to_block_size <= from_block_size) { if (from_block_size % to_block_size == 0) { uintmax_t multiplier = from_block_size / to_block_size; amt = n * multiplier; if (amt / multiplier == n) { tenths = 0; rounding = 0; goto use_integer_arithmetic; } } } else if (from_block_size != 0 && to_block_size % from_block_size == 0) { uintmax_t divisor = to_block_size / from_block_size; uintmax_t r10 = (n % divisor) * 10; uintmax_t r2 = (r10 % divisor) * 2; amt = n / divisor; tenths = r10 / divisor; rounding = r2 < divisor ? 0 < r2 : 2 + (divisor < r2); goto use_integer_arithmetic; } { /* Either the result cannot be computed easily using uintmax_t, or from_block_size is zero. Fall back on floating point. FIXME: This can yield answers that are slightly off. */ long double dto_block_size = to_block_size; long double damt = n * (from_block_size / dto_block_size); size_t buflen; size_t nonintegerlen; if (! (opts & human_autoscale)) { sprintf (buf, "%.0Lf", adjust_value (inexact_style, damt)); buflen = strlen (buf); nonintegerlen = 0; } else { long double e = 1; exponent = 0; do { e *= base; exponent++; } while (e * base <= damt && exponent < exponent_max); damt /= e; sprintf (buf, "%.1Lf", adjust_value (inexact_style, damt)); buflen = strlen (buf); nonintegerlen = decimal_pointlen + 1; if (1 + nonintegerlen + ! (opts & human_base_1024) < buflen || ((opts & human_suppress_point_zero) && buf[buflen - 1] == '0')) { sprintf (buf, "%.0Lf", adjust_value (inexact_style, damt * 10) / 10); buflen = strlen (buf); nonintegerlen = 0; } } p = psuffix - buflen; memmove (p, buf, buflen); integerlim = p + buflen - nonintegerlen; } goto do_grouping; use_integer_arithmetic: { /* The computation can be done exactly, with integer arithmetic. Use power of BASE notation if requested and if adjusted AMT is large enough. */ if (opts & human_autoscale) { exponent = 0; if (base <= amt) { do { unsigned int r10 = (amt % base) * 10 + tenths; unsigned int r2 = (r10 % base) * 2 + (rounding >> 1); amt /= base; tenths = r10 / base; rounding = (r2 < base ? (r2 + rounding) != 0 : 2 + (base < r2 + rounding)); exponent++; } while (base <= amt && exponent < exponent_max); if (amt < 10) { if (inexact_style == human_round_to_nearest ? 2 < rounding + (tenths & 1) : inexact_style == human_ceiling && 0 < rounding) { tenths++; rounding = 0; if (tenths == 10) { amt++; tenths = 0; } } if (amt < 10 && (tenths || ! (opts & human_suppress_point_zero))) { *--p = '0' + tenths; p -= decimal_pointlen; memcpy (p, decimal_point, decimal_pointlen); tenths = rounding = 0; } } } } if (inexact_style == human_round_to_nearest ? 5 < tenths + (0 < rounding + (amt & 1)) : inexact_style == human_ceiling && 0 < tenths + rounding) { amt++; if ((opts & human_autoscale) && amt == base && exponent < exponent_max) { exponent++; if (! (opts & human_suppress_point_zero)) { *--p = '0'; p -= decimal_pointlen; memcpy (p, decimal_point, decimal_pointlen); } amt = 1; } } integerlim = p; do { int digit = amt % 10; *--p = digit + '0'; } while ((amt /= 10) != 0); } do_grouping: if (opts & human_group_digits) p = group_number (p, integerlim - p, grouping, thousands_sep); if (opts & human_SI) { if (exponent < 0) { uintmax_t power; exponent = 0; for (power = 1; power < to_block_size; power *= base) if (++exponent == exponent_max) break; } if ((exponent | (opts & human_B)) && (opts & human_space_before_unit)) *psuffix++ = ' '; if (exponent) *psuffix++ = (! (opts & human_base_1024) && exponent == 1 ? 'k' : power_letter[exponent]); if (opts & human_B) { if ((opts & human_base_1024) && exponent) *psuffix++ = 'i'; *psuffix++ = 'B'; } } *psuffix = '\0'; return p; } /* The default block size used for output. This number may change in the future as disks get larger. */ #ifndef DEFAULT_BLOCK_SIZE # define DEFAULT_BLOCK_SIZE 1024 #endif static char const *const block_size_args[] = { "human-readable", "si", 0 }; static int const block_size_opts[] = { human_autoscale + human_SI + human_base_1024, human_autoscale + human_SI }; static uintmax_t default_block_size (void) { return getenv ("POSIXLY_CORRECT") ? 512 : DEFAULT_BLOCK_SIZE; } static strtol_error humblock (char const *spec, uintmax_t *block_size, int *options) { int i; int opts = 0; if (! spec && ! (spec = getenv ("BLOCK_SIZE")) && ! (spec = getenv ("BLOCKSIZE"))) *block_size = default_block_size (); else { if (*spec == '\'') { opts |= human_group_digits; spec++; } if (0 <= (i = ARGMATCH (spec, block_size_args, block_size_opts))) { opts |= block_size_opts[i]; *block_size = 1; } else { char *ptr; strtol_error e = xstrtoumax (spec, &ptr, 0, block_size, "eEgGkKmMpPtTyYzZ0"); if (e != LONGINT_OK) { *options = 0; return e; } for (; ! ('0' <= *spec && *spec <= '9'); spec++) if (spec == ptr) { opts |= human_SI; if (ptr[-1] == 'B') opts |= human_B; if (ptr[-1] != 'B' || ptr[-2] == 'i') opts |= human_base_1024; break; } } } *options = opts; return LONGINT_OK; } enum strtol_error human_options (char const *spec, int *opts, uintmax_t *block_size) { strtol_error e = humblock (spec, block_size, opts); if (*block_size == 0) { *block_size = default_block_size (); e = LONGINT_INVALID; } return e; } lftp-4.6.3a/lib/printf-frexp.c0000644000015000007670000001231612466374011013120 00000000000000/* Split a double into fraction and mantissa, for hexadecimal printf. Copyright (C) 2007, 2009-2015 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 . */ #if ! defined USE_LONG_DOUBLE # include #endif /* Specification. */ #ifdef USE_LONG_DOUBLE # include "printf-frexpl.h" #else # include "printf-frexp.h" #endif #include #include #ifdef USE_LONG_DOUBLE # include "fpucw.h" #endif /* This file assumes FLT_RADIX = 2. If FLT_RADIX is a power of 2 greater than 2, or not even a power of 2, some rounding errors can occur, so that then the returned mantissa is only guaranteed to be <= 2.0, not < 2.0. */ #ifdef USE_LONG_DOUBLE # define FUNC printf_frexpl # define DOUBLE long double # define MIN_EXP LDBL_MIN_EXP # if HAVE_FREXPL_IN_LIBC && HAVE_LDEXPL_IN_LIBC # define USE_FREXP_LDEXP # define FREXP frexpl # define LDEXP ldexpl # endif # define DECL_ROUNDING DECL_LONG_DOUBLE_ROUNDING # define BEGIN_ROUNDING() BEGIN_LONG_DOUBLE_ROUNDING () # define END_ROUNDING() END_LONG_DOUBLE_ROUNDING () # define L_(literal) literal##L #else # define FUNC printf_frexp # define DOUBLE double # define MIN_EXP DBL_MIN_EXP # if HAVE_FREXP_IN_LIBC && HAVE_LDEXP_IN_LIBC # define USE_FREXP_LDEXP # define FREXP frexp # define LDEXP ldexp # endif # define DECL_ROUNDING # define BEGIN_ROUNDING() # define END_ROUNDING() # define L_(literal) literal #endif DOUBLE FUNC (DOUBLE x, int *expptr) { int exponent; DECL_ROUNDING BEGIN_ROUNDING (); #ifdef USE_FREXP_LDEXP /* frexp and ldexp are usually faster than the loop below. */ x = FREXP (x, &exponent); x = x + x; exponent -= 1; if (exponent < MIN_EXP - 1) { x = LDEXP (x, exponent - (MIN_EXP - 1)); exponent = MIN_EXP - 1; } #else { /* Since the exponent is an 'int', it fits in 64 bits. Therefore the loops are executed no more than 64 times. */ DOUBLE pow2[64]; /* pow2[i] = 2^2^i */ DOUBLE powh[64]; /* powh[i] = 2^-2^i */ int i; exponent = 0; if (x >= L_(1.0)) { /* A nonnegative exponent. */ { DOUBLE pow2_i; /* = pow2[i] */ DOUBLE powh_i; /* = powh[i] */ /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, x * 2^exponent = argument, x >= 1.0. */ for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); ; i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) { if (x >= pow2_i) { exponent += (1 << i); x *= powh_i; } else break; pow2[i] = pow2_i; powh[i] = powh_i; } } /* Here 1.0 <= x < 2^2^i. */ } else { /* A negative exponent. */ { DOUBLE pow2_i; /* = pow2[i] */ DOUBLE powh_i; /* = powh[i] */ /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, x * 2^exponent = argument, x < 1.0, exponent >= MIN_EXP - 1. */ for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); ; i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) { if (exponent - (1 << i) < MIN_EXP - 1) break; exponent -= (1 << i); x *= pow2_i; if (x >= L_(1.0)) break; pow2[i] = pow2_i; powh[i] = powh_i; } } /* Here either x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent, or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ if (x < L_(1.0)) /* Invariants: x * 2^exponent = argument, x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent. */ while (i > 0) { i--; if (exponent - (1 << i) >= MIN_EXP - 1) { exponent -= (1 << i); x *= pow2[i]; if (x >= L_(1.0)) break; } } /* Here either x < 1.0 and exponent = MIN_EXP - 1, or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ } /* Invariants: x * 2^exponent = argument, and either x < 1.0 and exponent = MIN_EXP - 1, or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ while (i > 0) { i--; if (x >= pow2[i]) { exponent += (1 << i); x *= powh[i]; } } /* Here either x < 1.0 and exponent = MIN_EXP - 1, or 1.0 <= x < 2.0 and exponent >= MIN_EXP - 1. */ } #endif END_ROUNDING (); *expptr = exponent; return x; } lftp-4.6.3a/lib/strerror-override.c0000644000015000007670000002146512466374012014201 00000000000000/* strerror-override.c --- POSIX compatible system error routine Copyright (C) 2010-2015 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 . */ /* Written by Bruno Haible , 2010. */ #include #include "strerror-override.h" #include #if GNULIB_defined_EWINSOCK /* native Windows platforms */ # if HAVE_WINSOCK2_H # include # endif #endif /* If ERRNUM maps to an errno value defined by gnulib, return a string describing the error. Otherwise return NULL. */ const char * strerror_override (int errnum) { /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ switch (errnum) { #if REPLACE_STRERROR_0 case 0: return "Success"; #endif #if GNULIB_defined_ESOCK /* native Windows platforms with older */ case EINPROGRESS: return "Operation now in progress"; case EALREADY: return "Operation already in progress"; case ENOTSOCK: return "Socket operation on non-socket"; case EDESTADDRREQ: return "Destination address required"; case EMSGSIZE: return "Message too long"; case EPROTOTYPE: return "Protocol wrong type for socket"; case ENOPROTOOPT: return "Protocol not available"; case EPROTONOSUPPORT: return "Protocol not supported"; case EOPNOTSUPP: return "Operation not supported"; case EAFNOSUPPORT: return "Address family not supported by protocol"; case EADDRINUSE: return "Address already in use"; case EADDRNOTAVAIL: return "Cannot assign requested address"; case ENETDOWN: return "Network is down"; case ENETUNREACH: return "Network is unreachable"; case ECONNRESET: return "Connection reset by peer"; case ENOBUFS: return "No buffer space available"; case EISCONN: return "Transport endpoint is already connected"; case ENOTCONN: return "Transport endpoint is not connected"; case ETIMEDOUT: return "Connection timed out"; case ECONNREFUSED: return "Connection refused"; case ELOOP: return "Too many levels of symbolic links"; case EHOSTUNREACH: return "No route to host"; case EWOULDBLOCK: return "Operation would block"; #endif #if GNULIB_defined_ESTREAMS /* native Windows platforms with older */ case ETXTBSY: return "Text file busy"; case ENODATA: return "No data available"; case ENOSR: return "Out of streams resources"; case ENOSTR: return "Device not a stream"; case ETIME: return "Timer expired"; case EOTHER: return "Other error"; #endif #if GNULIB_defined_EWINSOCK /* native Windows platforms */ case ESOCKTNOSUPPORT: return "Socket type not supported"; case EPFNOSUPPORT: return "Protocol family not supported"; case ESHUTDOWN: return "Cannot send after transport endpoint shutdown"; case ETOOMANYREFS: return "Too many references: cannot splice"; case EHOSTDOWN: return "Host is down"; case EPROCLIM: return "Too many processes"; case EUSERS: return "Too many users"; case EDQUOT: return "Disk quota exceeded"; case ESTALE: return "Stale NFS file handle"; case EREMOTE: return "Object is remote"; # if HAVE_WINSOCK2_H /* WSA_INVALID_HANDLE maps to EBADF */ /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ /* WSA_INVALID_PARAMETER maps to EINVAL */ case WSA_OPERATION_ABORTED: return "Overlapped operation aborted"; case WSA_IO_INCOMPLETE: return "Overlapped I/O event object not in signaled state"; case WSA_IO_PENDING: return "Overlapped operations will complete later"; /* WSAEINTR maps to EINTR */ /* WSAEBADF maps to EBADF */ /* WSAEACCES maps to EACCES */ /* WSAEFAULT maps to EFAULT */ /* WSAEINVAL maps to EINVAL */ /* WSAEMFILE maps to EMFILE */ /* WSAEWOULDBLOCK maps to EWOULDBLOCK */ /* WSAEINPROGRESS maps to EINPROGRESS */ /* WSAEALREADY maps to EALREADY */ /* WSAENOTSOCK maps to ENOTSOCK */ /* WSAEDESTADDRREQ maps to EDESTADDRREQ */ /* WSAEMSGSIZE maps to EMSGSIZE */ /* WSAEPROTOTYPE maps to EPROTOTYPE */ /* WSAENOPROTOOPT maps to ENOPROTOOPT */ /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */ /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */ /* WSAEOPNOTSUPP maps to EOPNOTSUPP */ /* WSAEPFNOSUPPORT is EPFNOSUPPORT */ /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */ /* WSAEADDRINUSE maps to EADDRINUSE */ /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */ /* WSAENETDOWN maps to ENETDOWN */ /* WSAENETUNREACH maps to ENETUNREACH */ /* WSAENETRESET maps to ENETRESET */ /* WSAECONNABORTED maps to ECONNABORTED */ /* WSAECONNRESET maps to ECONNRESET */ /* WSAENOBUFS maps to ENOBUFS */ /* WSAEISCONN maps to EISCONN */ /* WSAENOTCONN maps to ENOTCONN */ /* WSAESHUTDOWN is ESHUTDOWN */ /* WSAETOOMANYREFS is ETOOMANYREFS */ /* WSAETIMEDOUT maps to ETIMEDOUT */ /* WSAECONNREFUSED maps to ECONNREFUSED */ /* WSAELOOP maps to ELOOP */ /* WSAENAMETOOLONG maps to ENAMETOOLONG */ /* WSAEHOSTDOWN is EHOSTDOWN */ /* WSAEHOSTUNREACH maps to EHOSTUNREACH */ /* WSAENOTEMPTY maps to ENOTEMPTY */ /* WSAEPROCLIM is EPROCLIM */ /* WSAEUSERS is EUSERS */ /* WSAEDQUOT is EDQUOT */ /* WSAESTALE is ESTALE */ /* WSAEREMOTE is EREMOTE */ case WSASYSNOTREADY: return "Network subsystem is unavailable"; case WSAVERNOTSUPPORTED: return "Winsock.dll version out of range"; case WSANOTINITIALISED: return "Successful WSAStartup not yet performed"; case WSAEDISCON: return "Graceful shutdown in progress"; case WSAENOMORE: case WSA_E_NO_MORE: return "No more results"; case WSAECANCELLED: case WSA_E_CANCELLED: return "Call was canceled"; case WSAEINVALIDPROCTABLE: return "Procedure call table is invalid"; case WSAEINVALIDPROVIDER: return "Service provider is invalid"; case WSAEPROVIDERFAILEDINIT: return "Service provider failed to initialize"; case WSASYSCALLFAILURE: return "System call failure"; case WSASERVICE_NOT_FOUND: return "Service not found"; case WSATYPE_NOT_FOUND: return "Class type not found"; case WSAEREFUSED: return "Database query was refused"; case WSAHOST_NOT_FOUND: return "Host not found"; case WSATRY_AGAIN: return "Nonauthoritative host not found"; case WSANO_RECOVERY: return "Nonrecoverable error"; case WSANO_DATA: return "Valid name, no data record of requested type"; /* WSA_QOS_* omitted */ # endif #endif #if GNULIB_defined_ENOMSG case ENOMSG: return "No message of desired type"; #endif #if GNULIB_defined_EIDRM case EIDRM: return "Identifier removed"; #endif #if GNULIB_defined_ENOLINK case ENOLINK: return "Link has been severed"; #endif #if GNULIB_defined_EPROTO case EPROTO: return "Protocol error"; #endif #if GNULIB_defined_EMULTIHOP case EMULTIHOP: return "Multihop attempted"; #endif #if GNULIB_defined_EBADMSG case EBADMSG: return "Bad message"; #endif #if GNULIB_defined_EOVERFLOW case EOVERFLOW: return "Value too large for defined data type"; #endif #if GNULIB_defined_ENOTSUP case ENOTSUP: return "Not supported"; #endif #if GNULIB_defined_ENETRESET case ENETRESET: return "Network dropped connection on reset"; #endif #if GNULIB_defined_ECONNABORTED case ECONNABORTED: return "Software caused connection abort"; #endif #if GNULIB_defined_ESTALE case ESTALE: return "Stale NFS file handle"; #endif #if GNULIB_defined_EDQUOT case EDQUOT: return "Disk quota exceeded"; #endif #if GNULIB_defined_ECANCELED case ECANCELED: return "Operation canceled"; #endif #if GNULIB_defined_EOWNERDEAD case EOWNERDEAD: return "Owner died"; #endif #if GNULIB_defined_ENOTRECOVERABLE case ENOTRECOVERABLE: return "State not recoverable"; #endif #if GNULIB_defined_EILSEQ case EILSEQ: return "Invalid or incomplete multibyte or wide character"; #endif default: return NULL; } } lftp-4.6.3a/lib/readdir.c0000644000015000007670000000567612466374011012121 00000000000000/* Read the next entry of a directory. Copyright (C) 2011-2015 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 . */ #include /* Specification. */ #include #include #include #include "dirent-private.h" struct dirent * readdir (DIR *dirp) { char type; struct dirent *result; /* There is no need to add code to produce entries for "." and "..". According to the POSIX:2008 section "4.12 Pathname Resolution" "." and ".." are syntactic entities. POSIX also says: "If entries for dot or dot-dot exist, one entry shall be returned for dot and one entry shall be returned for dot-dot; otherwise, they shall not be returned." */ switch (dirp->status) { case -2: /* End of directory already reached. */ return NULL; case -1: break; case 0: if (!FindNextFile (dirp->current, &dirp->entry)) { switch (GetLastError ()) { case ERROR_NO_MORE_FILES: dirp->status = -2; return NULL; default: errno = EIO; return NULL; } } break; default: errno = dirp->status; return NULL; } dirp->status = 0; if (dirp->entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) type = DT_DIR; else if (dirp->entry.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) type = DT_LNK; else if ((dirp->entry.dwFileAttributes & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_SPARSE_FILE | FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED | FILE_ATTRIBUTE_ENCRYPTED)) == 0) /* Devices like COM1, LPT1, NUL would also have the attributes 0x20 but they cannot occur here. */ type = DT_REG; else type = DT_UNKNOWN; /* Reuse the memory of dirp->entry for the result. */ result = (struct dirent *) ((char *) dirp->entry.cFileName - offsetof (struct dirent, d_name[0])); result->d_type = type; return result; } lftp-4.6.3a/lib/malloca.h0000644000015000007670000001107312466374011012110 00000000000000/* Safe automatic memory allocation. Copyright (C) 2003-2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2003. 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 . */ #ifndef _MALLOCA_H #define _MALLOCA_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* safe_alloca(N) is equivalent to alloca(N) when it is safe to call alloca(N); otherwise it returns NULL. It either returns N bytes of memory allocated on the stack, that lasts until the function returns, or NULL. Use of safe_alloca should be avoided: - inside arguments of function calls - undefined behaviour, - in inline functions - the allocation may actually last until the calling function returns. */ #if HAVE_ALLOCA /* The OS usually guarantees only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely allocate anything larger than 4096 bytes. Also care for the possibility of a few compiler-allocated temporary stack slots. This must be a macro, not a function. */ # define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL) #else # define safe_alloca(N) ((void) (N), NULL) #endif /* malloca(N) is a safe variant of alloca(N). It allocates N bytes of memory allocated on the stack, that must be freed using freea() before the function returns. Upon failure, it returns NULL. */ #if HAVE_ALLOCA # define malloca(N) \ ((N) < 4032 - sa_increment \ ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \ : mmalloca (N)) #else # define malloca(N) \ mmalloca (N) #endif extern void * mmalloca (size_t n); /* Free a block of memory allocated through malloca(). */ #if HAVE_ALLOCA extern void freea (void *p); #else # define freea free #endif /* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). It allocates an array of N objects, each with S bytes of memory, on the stack. S must be positive and N must be nonnegative. The array must be freed using freea() before the function returns. */ #if 1 /* Cf. the definition of xalloc_oversized. */ # define nmalloca(n, s) \ ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \ ? NULL \ : malloca ((n) * (s))) #else extern void * nmalloca (size_t n, size_t s); #endif #ifdef __cplusplus } #endif /* ------------------- Auxiliary, non-public definitions ------------------- */ /* Determine the alignment of a type at compile time. */ #if defined __GNUC__ || defined __IBM__ALIGNOF__ # define sa_alignof __alignof__ #elif defined __cplusplus template struct sa_alignof_helper { char __slot1; type __slot2; }; # define sa_alignof(type) offsetof (sa_alignof_helper, __slot2) #elif defined __hpux /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof values. */ # define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) #elif defined _AIX /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof values. */ # define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) #else # define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) #endif enum { /* The desired alignment of memory allocations is the maximum alignment among all elementary types. */ sa_alignment_long = sa_alignof (long), sa_alignment_double = sa_alignof (double), #if HAVE_LONG_LONG_INT sa_alignment_longlong = sa_alignof (long long), #endif sa_alignment_longdouble = sa_alignof (long double), sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) #if HAVE_LONG_LONG_INT | (sa_alignment_longlong - 1) #endif | (sa_alignment_longdouble - 1) ) + 1, /* The increment that guarantees room for a magic word must be >= sizeof (int) and a multiple of sa_alignment_max. */ sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max }; #endif /* _MALLOCA_H */ lftp-4.6.3a/lib/langinfo.in.h0000644000015000007670000001321212466374011012677 00000000000000/* Substitute for and wrapper around . Copyright (C) 2009-2015 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 . */ /* * POSIX for platforms that lack it or have an incomplete one. * */ #ifndef _@GUARD_PREFIX@_LANGINFO_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_LANGINFO_H@ # @INCLUDE_NEXT@ @NEXT_LANGINFO_H@ #endif #ifndef _@GUARD_PREFIX@_LANGINFO_H #define _@GUARD_PREFIX@_LANGINFO_H #if !@HAVE_LANGINFO_H@ /* A platform that lacks . */ /* Assume that it also lacks and the nl_item type. */ # if !GNULIB_defined_nl_item typedef int nl_item; # define GNULIB_defined_nl_item 1 # endif /* nl_langinfo items of the LC_CTYPE category */ # define CODESET 10000 /* nl_langinfo items of the LC_NUMERIC category */ # define RADIXCHAR 10001 # define DECIMAL_POINT RADIXCHAR # define THOUSEP 10002 # define THOUSANDS_SEP THOUSEP # define GROUPING 10114 /* nl_langinfo items of the LC_TIME category */ # define D_T_FMT 10003 # define D_FMT 10004 # define T_FMT 10005 # define T_FMT_AMPM 10006 # define AM_STR 10007 # define PM_STR 10008 # define DAY_1 10009 # define DAY_2 (DAY_1 + 1) # define DAY_3 (DAY_1 + 2) # define DAY_4 (DAY_1 + 3) # define DAY_5 (DAY_1 + 4) # define DAY_6 (DAY_1 + 5) # define DAY_7 (DAY_1 + 6) # define ABDAY_1 10016 # define ABDAY_2 (ABDAY_1 + 1) # define ABDAY_3 (ABDAY_1 + 2) # define ABDAY_4 (ABDAY_1 + 3) # define ABDAY_5 (ABDAY_1 + 4) # define ABDAY_6 (ABDAY_1 + 5) # define ABDAY_7 (ABDAY_1 + 6) # define MON_1 10023 # define MON_2 (MON_1 + 1) # define MON_3 (MON_1 + 2) # define MON_4 (MON_1 + 3) # define MON_5 (MON_1 + 4) # define MON_6 (MON_1 + 5) # define MON_7 (MON_1 + 6) # define MON_8 (MON_1 + 7) # define MON_9 (MON_1 + 8) # define MON_10 (MON_1 + 9) # define MON_11 (MON_1 + 10) # define MON_12 (MON_1 + 11) # define ABMON_1 10035 # define ABMON_2 (ABMON_1 + 1) # define ABMON_3 (ABMON_1 + 2) # define ABMON_4 (ABMON_1 + 3) # define ABMON_5 (ABMON_1 + 4) # define ABMON_6 (ABMON_1 + 5) # define ABMON_7 (ABMON_1 + 6) # define ABMON_8 (ABMON_1 + 7) # define ABMON_9 (ABMON_1 + 8) # define ABMON_10 (ABMON_1 + 9) # define ABMON_11 (ABMON_1 + 10) # define ABMON_12 (ABMON_1 + 11) # define ERA 10047 # define ERA_D_FMT 10048 # define ERA_D_T_FMT 10049 # define ERA_T_FMT 10050 # define ALT_DIGITS 10051 /* nl_langinfo items of the LC_MONETARY category */ # define CRNCYSTR 10052 # define CURRENCY_SYMBOL CRNCYSTR # define INT_CURR_SYMBOL 10100 # define MON_DECIMAL_POINT 10101 # define MON_THOUSANDS_SEP 10102 # define MON_GROUPING 10103 # define POSITIVE_SIGN 10104 # define NEGATIVE_SIGN 10105 # define FRAC_DIGITS 10106 # define INT_FRAC_DIGITS 10107 # define P_CS_PRECEDES 10108 # define N_CS_PRECEDES 10109 # define P_SEP_BY_SPACE 10110 # define N_SEP_BY_SPACE 10111 # define P_SIGN_POSN 10112 # define N_SIGN_POSN 10113 /* nl_langinfo items of the LC_MESSAGES category */ # define YESEXPR 10053 # define NOEXPR 10054 #else /* A platform that has . */ # if !@HAVE_LANGINFO_CODESET@ # define CODESET 10000 # define GNULIB_defined_CODESET 1 # endif # if !@HAVE_LANGINFO_T_FMT_AMPM@ # define T_FMT_AMPM 10006 # define GNULIB_defined_T_FMT_AMPM 1 # endif # if !@HAVE_LANGINFO_ERA@ # define ERA 10047 # define ERA_D_FMT 10048 # define ERA_D_T_FMT 10049 # define ERA_T_FMT 10050 # define ALT_DIGITS 10051 # define GNULIB_defined_ERA 1 # endif # if !@HAVE_LANGINFO_YESEXPR@ # define YESEXPR 10053 # define NOEXPR 10054 # define GNULIB_defined_YESEXPR 1 # endif #endif /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_WARN_ON_USE is copied here. */ /* Declare overridden functions. */ /* Return a piece of locale dependent information. Note: The difference between nl_langinfo (CODESET) and locale_charset () is that the latter normalizes the encoding names to GNU conventions. */ #if @GNULIB_NL_LANGINFO@ # if @REPLACE_NL_LANGINFO@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef nl_langinfo # define nl_langinfo rpl_nl_langinfo # endif _GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item)); _GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item)); # else # if !@HAVE_NL_LANGINFO@ _GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item)); # endif _GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item)); # endif _GL_CXXALIASWARN (nl_langinfo); #elif defined GNULIB_POSIXCHECK # undef nl_langinfo # if HAVE_RAW_DECL_NL_LANGINFO _GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - " "use gnulib module nl_langinfo for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_LANGINFO_H */ #endif /* _@GUARD_PREFIX@_LANGINFO_H */ lftp-4.6.3a/lib/float.in.h0000644000015000007670000001673412466374011012223 00000000000000/* A correct . Copyright (C) 2007-2015 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 . */ #ifndef _@GUARD_PREFIX@_FLOAT_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_FLOAT_H@ #ifndef _@GUARD_PREFIX@_FLOAT_H #define _@GUARD_PREFIX@_FLOAT_H /* 'long double' properties. */ #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) /* Number of mantissa units, in base FLT_RADIX. */ # undef LDBL_MANT_DIG # define LDBL_MANT_DIG 64 /* Number of decimal digits that is sufficient for representing a number. */ # undef LDBL_DIG # define LDBL_DIG 18 /* x-1 where x is the smallest representable number > 1. */ # undef LDBL_EPSILON # define LDBL_EPSILON 1.0842021724855044340E-19L /* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP (-16381) /* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */ # undef LDBL_MAX_EXP # define LDBL_MAX_EXP 16384 /* Minimum positive normalized number. */ # undef LDBL_MIN # define LDBL_MIN 3.3621031431120935063E-4932L /* Maximum representable finite number. */ # undef LDBL_MAX # define LDBL_MAX 1.1897314953572317650E+4932L /* Minimum e such that 10^e is in the range of normalized numbers. */ # undef LDBL_MIN_10_EXP # define LDBL_MIN_10_EXP (-4931) /* Maximum e such that 10^e is in the range of representable finite numbers. */ # undef LDBL_MAX_10_EXP # define LDBL_MAX_10_EXP 4932 #endif /* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of precision in the compiler but 64 bits of precision at runtime. See . */ #if defined __i386__ && defined __FreeBSD__ /* Number of mantissa units, in base FLT_RADIX. */ # undef LDBL_MANT_DIG # define LDBL_MANT_DIG 64 /* Number of decimal digits that is sufficient for representing a number. */ # undef LDBL_DIG # define LDBL_DIG 18 /* x-1 where x is the smallest representable number > 1. */ # undef LDBL_EPSILON # define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */ /* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP (-16381) /* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */ # undef LDBL_MAX_EXP # define LDBL_MAX_EXP 16384 /* Minimum positive normalized number. */ # undef LDBL_MIN # define LDBL_MIN 3.3621031431120935E-4932L /* = 0x1p-16382L */ /* Maximum representable finite number. */ # undef LDBL_MAX /* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }. But the largest literal that GCC allows us to write is 0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }. So, define it like this through a reference to an external variable const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }; extern const long double LDBL_MAX; Unfortunately, this is not a constant expression. */ union gl_long_double_union { struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd; long double ld; }; extern const union gl_long_double_union gl_LDBL_MAX; # define LDBL_MAX (gl_LDBL_MAX.ld) /* Minimum e such that 10^e is in the range of normalized numbers. */ # undef LDBL_MIN_10_EXP # define LDBL_MIN_10_EXP (-4931) /* Maximum e such that 10^e is in the range of representable finite numbers. */ # undef LDBL_MAX_10_EXP # define LDBL_MAX_10_EXP 4932 #endif /* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are wrong. On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */ #if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP # undef LDBL_MIN_10_EXP # define LDBL_MIN_10_EXP DBL_MIN_10_EXP # undef LDBL_MIN # define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ #endif #if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ # undef LDBL_MAX /* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }. It is not easy to define: #define LDBL_MAX 1.79769313486231580793728971405302307166e308L is too small, whereas #define LDBL_MAX 1.79769313486231580793728971405302307167e308L is too large. Apparently a bug in GCC decimal-to-binary conversion. Also, I can't get values larger than #define LDBL63 ((long double) (1ULL << 63)) #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63) #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL) which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }. So, define it like this through a reference to an external variable const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }; extern const long double LDBL_MAX; or through a pointer cast #define LDBL_MAX \ (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }) Unfortunately, this is not a constant expression, and the latter expression does not work well when GCC is optimizing.. */ union gl_long_double_union { struct { double hi; double lo; } dd; long double ld; }; extern const union gl_long_double_union gl_LDBL_MAX; # define LDBL_MAX (gl_LDBL_MAX.ld) #endif /* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong. On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON are wrong. */ #if defined __sgi && (LDBL_MANT_DIG >= 106) # undef LDBL_MANT_DIG # define LDBL_MANT_DIG 106 # if defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP # undef LDBL_MIN_10_EXP # define LDBL_MIN_10_EXP DBL_MIN_10_EXP # undef LDBL_MIN # define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ # undef LDBL_EPSILON # define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */ # endif #endif #if @REPLACE_ITOLD@ /* Pull in a function that fixes the 'int' to 'long double' conversion of glibc 2.7. */ extern # ifdef __cplusplus "C" # endif void _Qp_itoq (long double *, int); static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq; #endif #endif /* _@GUARD_PREFIX@_FLOAT_H */ #endif /* _@GUARD_PREFIX@_FLOAT_H */ lftp-4.6.3a/lib/arpa_inet.in.h0000644000015000007670000001143312466374011013047 00000000000000/* A GNU-like . Copyright (C) 2005-2006, 2008-2015 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 . */ #ifndef _@GUARD_PREFIX@_ARPA_INET_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if @HAVE_FEATURES_H@ # include /* for __GLIBC__ */ #endif /* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and for pulling in winsock2.h etc. under MinGW. But avoid namespace pollution on glibc systems. */ #ifndef __GLIBC__ # include #endif /* On NonStop Kernel, inet_ntop and inet_pton are declared in . But avoid namespace pollution on glibc systems. */ #if defined __TANDEM && !defined __GLIBC__ # include #endif #if @HAVE_ARPA_INET_H@ /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@ #endif #ifndef _@GUARD_PREFIX@_ARPA_INET_H #define _@GUARD_PREFIX@_ARPA_INET_H /* 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. */ #if @GNULIB_INET_NTOP@ /* Converts an internet address from internal format to a printable, presentable format. AF is an internet address family, such as AF_INET or AF_INET6. SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr' (for AF_INET6). DST points to a buffer having room for CNT bytes. The printable representation of the address (in numeric form, not surrounded by [...], no reverse DNS is done) is placed in DST, and DST is returned. If an error occurs, the return value is NULL and errno is set. If CNT bytes are not sufficient to hold the result, the return value is NULL and errno is set to ENOSPC. A good value for CNT is 46. For more details, see the POSIX:2001 specification . */ # if @REPLACE_INET_NTOP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef inet_ntop # define inet_ntop rpl_inet_ntop # endif _GL_FUNCDECL_RPL (inet_ntop, const char *, (int af, const void *restrict src, char *restrict dst, socklen_t cnt) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (inet_ntop, const char *, (int af, const void *restrict src, char *restrict dst, socklen_t cnt)); # else # if !@HAVE_DECL_INET_NTOP@ _GL_FUNCDECL_SYS (inet_ntop, const char *, (int af, const void *restrict src, char *restrict dst, socklen_t cnt) _GL_ARG_NONNULL ((2, 3))); # endif /* Need to cast, because on NonStop Kernel, the fourth parameter is size_t cnt. */ _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *, (int af, const void *restrict src, char *restrict dst, socklen_t cnt)); # endif _GL_CXXALIASWARN (inet_ntop); #elif defined GNULIB_POSIXCHECK # undef inet_ntop # if HAVE_RAW_DECL_INET_NTOP _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - " "use gnulib module inet_ntop for portability"); # endif #endif #if @GNULIB_INET_PTON@ # if @REPLACE_INET_PTON@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef inet_pton # define inet_pton rpl_inet_pton # endif _GL_FUNCDECL_RPL (inet_pton, int, (int af, const char *restrict src, void *restrict dst) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (inet_pton, int, (int af, const char *restrict src, void *restrict dst)); # else # if !@HAVE_DECL_INET_PTON@ _GL_FUNCDECL_SYS (inet_pton, int, (int af, const char *restrict src, void *restrict dst) _GL_ARG_NONNULL ((2, 3))); # endif _GL_CXXALIAS_SYS (inet_pton, int, (int af, const char *restrict src, void *restrict dst)); # endif _GL_CXXALIASWARN (inet_pton); #elif defined GNULIB_POSIXCHECK # undef inet_pton # if HAVE_RAW_DECL_INET_PTON _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - " "use gnulib module inet_pton for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_ARPA_INET_H */ #endif /* _@GUARD_PREFIX@_ARPA_INET_H */ lftp-4.6.3a/lib/gl_openssl.h0000644000015000007670000000732012466374011012645 00000000000000/* gl_openssl.h -- wrap openssl crypto hash routines in gnulib interface Copyright (C) 2013-2015 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 . */ /* Written by Pádraig Brady */ #ifndef GL_OPENSSL_NAME # error "Please define GL_OPENSSL_NAME to 1,5,256 etc." #endif #ifndef _GL_INLINE_HEADER_BEGIN # error "Please include config.h first." #endif _GL_INLINE_HEADER_BEGIN #ifndef GL_OPENSSL_INLINE # define GL_OPENSSL_INLINE _GL_INLINE #endif /* Concatenate two preprocessor tokens. */ #define _GLCRYPTO_CONCAT_(prefix, suffix) prefix##suffix #define _GLCRYPTO_CONCAT(prefix, suffix) _GLCRYPTO_CONCAT_ (prefix, suffix) #if GL_OPENSSL_NAME == 5 # define OPENSSL_ALG md5 #else # define OPENSSL_ALG _GLCRYPTO_CONCAT (sha, GL_OPENSSL_NAME) #endif /* Context type mappings. */ #if BASE_OPENSSL_TYPE != GL_OPENSSL_NAME # undef BASE_OPENSSL_TYPE # if GL_OPENSSL_NAME == 224 # define BASE_OPENSSL_TYPE 256 # elif GL_OPENSSL_NAME == 384 # define BASE_OPENSSL_TYPE 512 # endif # define md5_CTX MD5_CTX # define sha1_CTX SHA_CTX # define sha224_CTX SHA256_CTX # define sha224_ctx sha256_ctx # define sha256_CTX SHA256_CTX # define sha384_CTX SHA512_CTX # define sha384_ctx sha512_ctx # define sha512_CTX SHA512_CTX # undef _gl_CTX # undef _gl_ctx # define _gl_CTX _GLCRYPTO_CONCAT (OPENSSL_ALG, _CTX) /* openssl type. */ # define _gl_ctx _GLCRYPTO_CONCAT (OPENSSL_ALG, _ctx) /* gnulib type. */ struct _gl_ctx { _gl_CTX CTX; }; #endif /* Function name mappings. */ #define md5_prefix MD5 #define sha1_prefix SHA1 #define sha224_prefix SHA224 #define sha256_prefix SHA256 #define sha384_prefix SHA384 #define sha512_prefix SHA512 #define _GLCRYPTO_PREFIX _GLCRYPTO_CONCAT (OPENSSL_ALG, _prefix) #define OPENSSL_FN(suffix) _GLCRYPTO_CONCAT (_GLCRYPTO_PREFIX, suffix) #define GL_CRYPTO_FN(suffix) _GLCRYPTO_CONCAT (OPENSSL_ALG, suffix) GL_OPENSSL_INLINE void GL_CRYPTO_FN (_init_ctx) (struct _gl_ctx *ctx) { (void) OPENSSL_FN (_Init) ((_gl_CTX *) ctx); } /* These were never exposed by gnulib. */ #if ! (GL_OPENSSL_NAME == 224 || GL_OPENSSL_NAME == 384) GL_OPENSSL_INLINE void GL_CRYPTO_FN (_process_bytes) (const void *buf, size_t len, struct _gl_ctx *ctx) { OPENSSL_FN (_Update) ((_gl_CTX *) ctx, buf, len); } GL_OPENSSL_INLINE void GL_CRYPTO_FN (_process_block) (const void *buf, size_t len, struct _gl_ctx *ctx) { GL_CRYPTO_FN (_process_bytes) (buf, len, ctx); } #endif GL_OPENSSL_INLINE void * GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *ctx, void *res) { OPENSSL_FN (_Final) ((unsigned char *) res, (_gl_CTX *) ctx); return res; } GL_OPENSSL_INLINE void * GL_CRYPTO_FN (_buffer) (const char *buf, size_t len, void *res) { return OPENSSL_FN () ((const unsigned char *) buf, len, (unsigned char *) res); } GL_OPENSSL_INLINE void * GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *res) { /* Assume any unprocessed bytes in ctx are not to be ignored. */ _gl_CTX tmp_ctx = *(_gl_CTX *) ctx; OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx); return res; } /* Undef so we can include multiple times. */ #undef GL_CRYPTO_FN #undef OPENSSL_FN #undef _GLCRYPTO_PREFIX #undef OPENSSL_ALG #undef GL_OPENSSL_NAME _GL_INLINE_HEADER_END lftp-4.6.3a/lib/xalloc-die.c0000644000015000007670000000243412466374012012516 00000000000000/* Report a memory allocation failure and exit. Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2015 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 . */ #include #include "xalloc.h" #include #include "error.h" #include "exitfail.h" #include "gettext.h" #define _(msgid) gettext (msgid) void xalloc_die (void) { error (exit_failure, 0, "%s", _("memory exhausted")); /* _Noreturn cannot be given to error, since it may return if its first argument is 0. To help compilers understand the xalloc_die does not return, call abort. Also, the abort is a safety feature if exit_failure is 0 (which shouldn't happen). */ abort (); } lftp-4.6.3a/lib/sys_time.in.h0000644000015000007670000001700112466374012012737 00000000000000/* Provide a more complete sys/time.h. Copyright (C) 2007-2015 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 . */ /* Written by Paul Eggert. */ #ifndef _@GUARD_PREFIX@_SYS_TIME_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* On Cygwin and on many BSDish systems, includes itself recursively via . Simply delegate to the system's header in this case; it is a no-op. Without this extra ifdef, the C++ gettimeofday declaration below would be a forward declaration in gnulib's nested . */ #if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_ # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ #else /* The include_next requires a split double-inclusion guard. */ #if @HAVE_SYS_TIME_H@ # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ #endif #ifndef _@GUARD_PREFIX@_SYS_TIME_H #define _@GUARD_PREFIX@_SYS_TIME_H #if ! @HAVE_SYS_TIME_H@ # include #endif /* On native Windows with MSVC, get the 'struct timeval' type. Also, on native Windows with a 64-bit time_t, where we are overriding the 'struct timeval' type, get all declarations of system functions whose signature contains 'struct timeval'. */ #if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H # define _GL_INCLUDING_WINSOCK2_H # include # undef _GL_INCLUDING_WINSOCK2_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 #if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ # if @REPLACE_STRUCT_TIMEVAL@ # define timeval rpl_timeval # endif # if !GNULIB_defined_struct_timeval struct timeval { time_t tv_sec; long int tv_usec; }; # define GNULIB_defined_struct_timeval 1 # endif #endif #ifdef __cplusplus } #endif #if @GNULIB_GETTIMEOFDAY@ # if @REPLACE_GETTIMEOFDAY@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef gettimeofday # define gettimeofday rpl_gettimeofday # endif _GL_FUNCDECL_RPL (gettimeofday, int, (struct timeval *restrict, void *restrict) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (gettimeofday, int, (struct timeval *restrict, void *restrict)); # else # if !@HAVE_GETTIMEOFDAY@ _GL_FUNCDECL_SYS (gettimeofday, int, (struct timeval *restrict, void *restrict) _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on glibc systems, by default, the second argument is struct timezone *. */ _GL_CXXALIAS_SYS_CAST (gettimeofday, int, (struct timeval *restrict, void *restrict)); # endif _GL_CXXALIASWARN (gettimeofday); #elif defined GNULIB_POSIXCHECK # undef gettimeofday # if HAVE_RAW_DECL_GETTIMEOFDAY _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " "use gnulib module gettimeofday for portability"); # endif #endif /* Hide some function declarations from . */ #if defined _MSC_VER && @HAVE_WINSOCK2_H@ # if !defined _@GUARD_PREFIX@_UNISTD_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef close # define close close_used_without_including_unistd_h # else _GL_WARN_ON_USE (close, "close() used without including "); # endif # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef gethostname # define gethostname gethostname_used_without_including_unistd_h # else _GL_WARN_ON_USE (gethostname, "gethostname() used without including "); # endif # endif # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef socket # define socket socket_used_without_including_sys_socket_h # undef connect # define connect connect_used_without_including_sys_socket_h # undef accept # define accept accept_used_without_including_sys_socket_h # undef bind # define bind bind_used_without_including_sys_socket_h # undef getpeername # define getpeername getpeername_used_without_including_sys_socket_h # undef getsockname # define getsockname getsockname_used_without_including_sys_socket_h # undef getsockopt # define getsockopt getsockopt_used_without_including_sys_socket_h # undef listen # define listen listen_used_without_including_sys_socket_h # undef recv # define recv recv_used_without_including_sys_socket_h # undef send # define send send_used_without_including_sys_socket_h # undef recvfrom # define recvfrom recvfrom_used_without_including_sys_socket_h # undef sendto # define sendto sendto_used_without_including_sys_socket_h # undef setsockopt # define setsockopt setsockopt_used_without_including_sys_socket_h # undef shutdown # define shutdown shutdown_used_without_including_sys_socket_h # else _GL_WARN_ON_USE (socket, "socket() used without including "); _GL_WARN_ON_USE (connect, "connect() used without including "); _GL_WARN_ON_USE (accept, "accept() used without including "); _GL_WARN_ON_USE (bind, "bind() used without including "); _GL_WARN_ON_USE (getpeername, "getpeername() used without including "); _GL_WARN_ON_USE (getsockname, "getsockname() used without including "); _GL_WARN_ON_USE (getsockopt, "getsockopt() used without including "); _GL_WARN_ON_USE (listen, "listen() used without including "); _GL_WARN_ON_USE (recv, "recv() used without including "); _GL_WARN_ON_USE (send, "send() used without including "); _GL_WARN_ON_USE (recvfrom, "recvfrom() used without including "); _GL_WARN_ON_USE (sendto, "sendto() used without including "); _GL_WARN_ON_USE (setsockopt, "setsockopt() used without including "); _GL_WARN_ON_USE (shutdown, "shutdown() used without including "); # endif # endif # if !defined _@GUARD_PREFIX@_SYS_SELECT_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef select # define select select_used_without_including_sys_select_h # else _GL_WARN_ON_USE (select, "select() used without including "); # endif # endif #endif #endif /* _@GUARD_PREFIX@_SYS_TIME_H */ #endif /* _CYGWIN_SYS_TIME_H */ #endif /* _@GUARD_PREFIX@_SYS_TIME_H */ lftp-4.6.3a/lib/iconv_open-osf.gperf0000644000015000007670000000200212122621312014254 00000000000000struct mapping { int standard_name; const char vendor_name[10 + 1]; }; %struct-type %language=ANSI-C %define slot-name standard_name %define hash-function-name mapping_hash %define lookup-function-name mapping_lookup %readonly-tables %global-table %define word-array-name mappings %pic %% # On OSF/1 5.1, look in /usr/lib/nls/loc/iconv. ISO-8859-1, "ISO8859-1" ISO-8859-2, "ISO8859-2" ISO-8859-3, "ISO8859-3" ISO-8859-4, "ISO8859-4" ISO-8859-5, "ISO8859-5" ISO-8859-6, "ISO8859-6" ISO-8859-7, "ISO8859-7" ISO-8859-8, "ISO8859-8" ISO-8859-9, "ISO8859-9" ISO-8859-15, "ISO8859-15" CP437, "cp437" CP775, "cp775" CP850, "cp850" CP852, "cp852" CP855, "cp855" CP857, "cp857" CP861, "cp861" CP862, "cp862" CP865, "cp865" CP866, "cp866" CP869, "cp869" CP874, "cp874" CP949, "KSC5601" CP1250, "cp1250" CP1251, "cp1251" CP1252, "cp1252" CP1253, "cp1253" CP1254, "cp1254" CP1255, "cp1255" CP1256, "cp1256" CP1257, "cp1257" CP1258, "cp1258" EUC-JP, "eucJP" EUC-KR, "eucKR" EUC-TW, "eucTW" BIG5, "big5" SHIFT_JIS, "SJIS" TIS-620, "TACTIS" lftp-4.6.3a/lib/COPYING.LIB0000644000015000007670000006130312122054516011762 00000000000000 GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! lftp-4.6.3a/lib/c-ctype.c0000644000015000007670000002534112466374011012042 00000000000000/* Character handling in C locale. Copyright 2000-2003, 2006, 2009-2015 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 . */ #include /* Specification. */ #define NO_C_CTYPE_MACROS #include "c-ctype.h" /* The function isascii is not locale dependent. Its use in EBCDIC is questionable. */ bool c_isascii (int c) { return (c >= 0x00 && c <= 0x7f); } bool c_isalnum (int c) { #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII return ((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')); #else return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); #endif #else switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': return 1; default: return 0; } #endif } bool c_isalpha (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'); #else return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); #endif #else switch (c) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': return 1; default: return 0; } #endif } bool c_isblank (int c) { return (c == ' ' || c == '\t'); } bool c_iscntrl (int c) { #if C_CTYPE_ASCII return ((c & ~0x1f) == 0 || c == 0x7f); #else switch (c) { case ' ': case '!': case '"': case '#': case '$': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case '`': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': case '~': return 0; default: return 1; } #endif } bool c_isdigit (int c) { #if C_CTYPE_CONSECUTIVE_DIGITS return (c >= '0' && c <= '9'); #else switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return 1; default: return 0; } #endif } bool c_islower (int c) { #if C_CTYPE_CONSECUTIVE_LOWERCASE return (c >= 'a' && c <= 'z'); #else switch (c) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': return 1; default: return 0; } #endif } bool c_isgraph (int c) { #if C_CTYPE_ASCII return (c >= '!' && c <= '~'); #else switch (c) { case '!': case '"': case '#': case '$': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case '`': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': case '~': return 1; default: return 0; } #endif } bool c_isprint (int c) { #if C_CTYPE_ASCII return (c >= ' ' && c <= '~'); #else switch (c) { case ' ': case '!': case '"': case '#': case '$': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case '`': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': case '~': return 1; default: return 0; } #endif } bool c_ispunct (int c) { #if C_CTYPE_ASCII return ((c >= '!' && c <= '~') && !((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'))); #else switch (c) { case '!': case '"': case '#': case '$': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case '[': case '\\': case ']': case '^': case '_': case '`': case '{': case '|': case '}': case '~': return 1; default: return 0; } #endif } bool c_isspace (int c) { return (c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'); } bool c_isupper (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE return (c >= 'A' && c <= 'Z'); #else switch (c) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': return 1; default: return 0; } #endif } bool c_isxdigit (int c) { #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII return ((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F')); #else return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); #endif #else switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': return 1; default: return 0; } #endif } int c_tolower (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c); #else switch (c) { case 'A': return 'a'; case 'B': return 'b'; case 'C': return 'c'; case 'D': return 'd'; case 'E': return 'e'; case 'F': return 'f'; case 'G': return 'g'; case 'H': return 'h'; case 'I': return 'i'; case 'J': return 'j'; case 'K': return 'k'; case 'L': return 'l'; case 'M': return 'm'; case 'N': return 'n'; case 'O': return 'o'; case 'P': return 'p'; case 'Q': return 'q'; case 'R': return 'r'; case 'S': return 's'; case 'T': return 't'; case 'U': return 'u'; case 'V': return 'v'; case 'W': return 'w'; case 'X': return 'x'; case 'Y': return 'y'; case 'Z': return 'z'; default: return c; } #endif } int c_toupper (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c); #else switch (c) { case 'a': return 'A'; case 'b': return 'B'; case 'c': return 'C'; case 'd': return 'D'; case 'e': return 'E'; case 'f': return 'F'; case 'g': return 'G'; case 'h': return 'H'; case 'i': return 'I'; case 'j': return 'J'; case 'k': return 'K'; case 'l': return 'L'; case 'm': return 'M'; case 'n': return 'N'; case 'o': return 'O'; case 'p': return 'P'; case 'q': return 'Q'; case 'r': return 'R'; case 's': return 'S'; case 't': return 'T'; case 'u': return 'U'; case 'v': return 'V'; case 'w': return 'W'; case 'x': return 'X'; case 'y': return 'Y'; case 'z': return 'Z'; default: return c; } #endif } lftp-4.6.3a/lib/netinet_in.in.h0000644000015000007670000000247412466374011013246 00000000000000/* Substitute for . Copyright (C) 2007-2015 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 . */ #ifndef _@GUARD_PREFIX@_NETINET_IN_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if @HAVE_NETINET_IN_H@ /* On many platforms, assumes prior inclusion of . */ # include /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_NETINET_IN_H@ #endif #ifndef _@GUARD_PREFIX@_NETINET_IN_H #define _@GUARD_PREFIX@_NETINET_IN_H #if !@HAVE_NETINET_IN_H@ /* A platform that lacks . */ # include #endif #endif /* _@GUARD_PREFIX@_NETINET_IN_H */ #endif /* _@GUARD_PREFIX@_NETINET_IN_H */ lftp-4.6.3a/lib/getopt_int.h0000644000015000007670000001174212466374011012657 00000000000000/* Internal declarations for getopt. Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2015 Free Software Foundation, Inc. This file is part of 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 . */ #ifndef _GETOPT_INT_H #define _GETOPT_INT_H 1 #include extern int _getopt_internal (int ___argc, char **___argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only, int __posixly_correct); /* Reentrant versions which can handle parsing multiple argument vectors at the same time. */ /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using '+' as the first character of the list of option characters, or by calling getopt. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using '-' as the first character of the list of option characters selects this mode of operation. The special argument '--' forces an end of option-scanning regardless of the value of 'ordering'. In the case of RETURN_IN_ORDER, only '--' can cause 'getopt' to return -1 with 'optind' != ARGC. */ enum __ord { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER }; /* Data type for reentrant functions. */ struct _getopt_data { /* These have exactly the same meaning as the corresponding global variables, except that they are used for the reentrant versions of getopt. */ int optind; int opterr; int optopt; char *optarg; /* Internal members. */ /* True if the internal members have been initialized. */ int __initialized; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ char *__nextchar; /* See __ord above. */ enum __ord __ordering; /* If the POSIXLY_CORRECT environment variable is set or getopt was called. */ int __posixly_correct; /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. 'first_nonopt' is the index in ARGV of the first of them; 'last_nonopt' is the index after the last of them. */ int __first_nonopt; int __last_nonopt; #if defined _LIBC && defined USE_NONOPTION_FLAGS int __nonoption_flags_max_len; int __nonoption_flags_len; #endif }; /* The initializer is necessary to set OPTIND and OPTERR to their default values and to clear the initialization flag. */ #define _GETOPT_DATA_INITIALIZER { 1, 1 } extern int _getopt_internal_r (int ___argc, char **___argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only, struct _getopt_data *__data, int __posixly_correct); extern int _getopt_long_r (int ___argc, char **___argv, const char *__shortopts, const struct option *__longopts, int *__longind, struct _getopt_data *__data); extern int _getopt_long_only_r (int ___argc, char **___argv, const char *__shortopts, const struct option *__longopts, int *__longind, struct _getopt_data *__data); #endif /* getopt_int.h */ lftp-4.6.3a/lib/filemode.h0000644000015000007670000000231512466374011012263 00000000000000/* Make a string describing file modes. Copyright (C) 1998-1999, 2003, 2006, 2009-2015 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 . */ #ifndef FILEMODE_H_ # include # include /* Get the declaration of strmode. */ # if HAVE_DECL_STRMODE # include /* Mac OS X, FreeBSD, OpenBSD */ # include /* NetBSD */ # endif # ifdef __cplusplus extern "C" { # endif # if !HAVE_DECL_STRMODE extern void strmode (mode_t mode, char *str); # endif extern void filemodestring (struct stat const *statp, char *str); # ifdef __cplusplus } # endif #endif lftp-4.6.3a/lib/Makefile.am0000644000015000007670000034677712466374017012417 00000000000000## DO NOT EDIT! GENERATED AUTOMATICALLY! ## Process this file with automake to produce Makefile.in. # Copyright (C) 2002-2015 Free Software Foundation, Inc. # # This file 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 file 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 file. If not, see . # # As a special exception to the GNU General Public License, # this file may be distributed as part of a program that # contains a configuration script generated by Autoconf, under # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=gl alloca-opt arpa_inet crypto/md5 crypto/sha1 environ filemode fnmatch fnmatch-gnu getopt-gnu gettext gettimeofday glob human iconv_open inet_pton lchown longlong lstat mbswidth memmem mktime modechange parse-datetime passfd poll readlink regex sockets socklen strdup-posix strftime strptime strstr strtok_r unsetenv vsnprintf vsnprintf-posix wcwidth AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects SUBDIRS = noinst_HEADERS = noinst_LIBRARIES = noinst_LTLIBRARIES = EXTRA_DIST = BUILT_SOURCES = SUFFIXES = MOSTLYCLEANFILES = core *.stackdump MOSTLYCLEANDIRS = CLEANFILES = DISTCLEANFILES = MAINTAINERCLEANFILES = AM_CPPFLAGS = AM_CFLAGS = noinst_LTLIBRARIES += libgnu.la libgnu_la_SOURCES = libgnu_la_LIBADD = $(gl_LTLIBOBJS) libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS) EXTRA_libgnu_la_SOURCES = libgnu_la_LDFLAGS = $(AM_LDFLAGS) libgnu_la_LDFLAGS += -no-undefined libgnu_la_LDFLAGS += $(INET_PTON_LIB) libgnu_la_LDFLAGS += $(LIBSOCKET) libgnu_la_LDFLAGS += $(LIB_CLOCK_GETTIME) libgnu_la_LDFLAGS += $(LIB_CRYPTO) libgnu_la_LDFLAGS += $(LIB_POLL) libgnu_la_LDFLAGS += $(LIB_SELECT) libgnu_la_LDFLAGS += $(LTLIBICONV) libgnu_la_LDFLAGS += $(LTLIBINTL) libgnu_la_LDFLAGS += $(LTLIBTHREAD) ## begin gnulib module absolute-header # Use this preprocessor expression to decide whether #include_next works. # Do not rely on a 'configure'-time test for this, since the expression # might appear in an installed header, which is used by some other compiler. HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER) ## end gnulib module absolute-header ## begin gnulib module alloca libgnu_la_LIBADD += @LTALLOCA@ libgnu_la_DEPENDENCIES += @LTALLOCA@ EXTRA_DIST += alloca.c EXTRA_libgnu_la_SOURCES += alloca.c ## end gnulib module alloca ## begin gnulib module alloca-opt BUILT_SOURCES += $(ALLOCA_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. if GL_GENERATE_ALLOCA_H alloca.h: alloca.in.h $(top_builddir)/config.status $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/alloca.in.h; \ } > $@-t && \ mv -f $@-t $@ else alloca.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += alloca.h alloca.h-t EXTRA_DIST += alloca.in.h ## end gnulib module alloca-opt ## begin gnulib module argmatch libgnu_la_SOURCES += argmatch.c EXTRA_DIST += argmatch.h ## end gnulib module argmatch ## begin gnulib module arpa_inet BUILT_SOURCES += arpa/inet.h # We need the following in order to create when the system # doesn't have one. arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) arpa $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ -e 's/@''GNULIB_INET_NTOP''@/$(GNULIB_INET_NTOP)/g' \ -e 's/@''GNULIB_INET_PTON''@/$(GNULIB_INET_PTON)/g' \ -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \ -e 's|@''REPLACE_INET_PTON''@|$(REPLACE_INET_PTON)|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)/arpa_inet.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t MOSTLYCLEANDIRS += arpa EXTRA_DIST += arpa_inet.in.h ## end gnulib module arpa_inet ## begin gnulib module assure EXTRA_DIST += assure.h ## end gnulib module assure ## begin gnulib module btowc EXTRA_DIST += btowc.c EXTRA_libgnu_la_SOURCES += btowc.c ## end gnulib module btowc ## begin gnulib module c-ctype libgnu_la_SOURCES += c-ctype.h c-ctype.c ## end gnulib module c-ctype ## begin gnulib module c-strcase libgnu_la_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c ## end gnulib module c-strcase ## begin gnulib module c-strcaseeq EXTRA_DIST += c-strcaseeq.h ## end gnulib module c-strcaseeq ## begin gnulib module chown EXTRA_DIST += chown.c fchown-stub.c EXTRA_libgnu_la_SOURCES += chown.c fchown-stub.c ## end gnulib module chown ## begin gnulib module cloexec libgnu_la_SOURCES += cloexec.c EXTRA_DIST += cloexec.h ## end gnulib module cloexec ## begin gnulib module close EXTRA_DIST += close.c EXTRA_libgnu_la_SOURCES += close.c ## end gnulib module close ## begin gnulib module closedir EXTRA_DIST += closedir.c dirent-private.h EXTRA_libgnu_la_SOURCES += closedir.c ## end gnulib module closedir ## begin gnulib module configmake # Listed in the same order as the GNU makefile conventions, and # provided by autoconf 2.59c+ or 2.70. # The Automake-defined pkg* macros are appended, in the order # listed in the Automake 1.10a+ documentation. configmake.h: Makefile $(AM_V_GEN)rm -f $@-t && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ echo '#define PREFIX "$(prefix)"'; \ echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ echo '#define BINDIR "$(bindir)"'; \ echo '#define SBINDIR "$(sbindir)"'; \ echo '#define LIBEXECDIR "$(libexecdir)"'; \ echo '#define DATAROOTDIR "$(datarootdir)"'; \ echo '#define DATADIR "$(datadir)"'; \ echo '#define SYSCONFDIR "$(sysconfdir)"'; \ echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \ echo '#define LOCALSTATEDIR "$(localstatedir)"'; \ echo '#define RUNSTATEDIR "$(runstatedir)"'; \ echo '#define INCLUDEDIR "$(includedir)"'; \ echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \ echo '#define DOCDIR "$(docdir)"'; \ echo '#define INFODIR "$(infodir)"'; \ echo '#define HTMLDIR "$(htmldir)"'; \ echo '#define DVIDIR "$(dvidir)"'; \ echo '#define PDFDIR "$(pdfdir)"'; \ echo '#define PSDIR "$(psdir)"'; \ echo '#define LIBDIR "$(libdir)"'; \ echo '#define LISPDIR "$(lispdir)"'; \ echo '#define LOCALEDIR "$(localedir)"'; \ echo '#define MANDIR "$(mandir)"'; \ echo '#define MANEXT "$(manext)"'; \ echo '#define PKGDATADIR "$(pkgdatadir)"'; \ echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \ echo '#define PKGLIBDIR "$(pkglibdir)"'; \ echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ } | sed '/""/d' > $@-t && \ mv -f $@-t $@ BUILT_SOURCES += configmake.h CLEANFILES += configmake.h configmake.h-t ## end gnulib module configmake ## begin gnulib module crypto/md5 libgnu_la_SOURCES += md5.c EXTRA_DIST += gl_openssl.h md5.h ## end gnulib module crypto/md5 ## begin gnulib module crypto/sha1 libgnu_la_SOURCES += sha1.c EXTRA_DIST += gl_openssl.h sha1.h ## end gnulib module crypto/sha1 ## begin gnulib module dirent BUILT_SOURCES += dirent.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_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_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \ -e 's/@''GNULIB_OPENDIR''@/$(GNULIB_OPENDIR)/g' \ -e 's/@''GNULIB_READDIR''@/$(GNULIB_READDIR)/g' \ -e 's/@''GNULIB_REWINDDIR''@/$(GNULIB_REWINDDIR)/g' \ -e 's/@''GNULIB_CLOSEDIR''@/$(GNULIB_CLOSEDIR)/g' \ -e 's/@''GNULIB_DIRFD''@/$(GNULIB_DIRFD)/g' \ -e 's/@''GNULIB_FDOPENDIR''@/$(GNULIB_FDOPENDIR)/g' \ -e 's/@''GNULIB_SCANDIR''@/$(GNULIB_SCANDIR)/g' \ -e 's/@''GNULIB_ALPHASORT''@/$(GNULIB_ALPHASORT)/g' \ -e 's/@''HAVE_OPENDIR''@/$(HAVE_OPENDIR)/g' \ -e 's/@''HAVE_READDIR''@/$(HAVE_READDIR)/g' \ -e 's/@''HAVE_REWINDDIR''@/$(HAVE_REWINDDIR)/g' \ -e 's/@''HAVE_CLOSEDIR''@/$(HAVE_CLOSEDIR)/g' \ -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \ -e 's|@''HAVE_DECL_FDOPENDIR''@|$(HAVE_DECL_FDOPENDIR)|g' \ -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \ -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \ -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \ -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|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)/dirent.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += dirent.h dirent.h-t EXTRA_DIST += dirent.in.h ## end gnulib module dirent ## begin gnulib module dirfd EXTRA_DIST += dirfd.c EXTRA_libgnu_la_SOURCES += dirfd.c ## end gnulib module dirfd ## begin gnulib module dosname EXTRA_DIST += dosname.h ## end gnulib module dosname ## begin gnulib module dup2 EXTRA_DIST += dup2.c EXTRA_libgnu_la_SOURCES += dup2.c ## end gnulib module dup2 ## begin gnulib module errno BUILT_SOURCES += $(ERRNO_H) # We need the following in order to create when the system # doesn't have one that is POSIX compliant. if GL_GENERATE_ERRNO_H errno.h: errno.in.h $(top_builddir)/config.status $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \ -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \ -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \ -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \ -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \ -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \ -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \ < $(srcdir)/errno.in.h; \ } > $@-t && \ mv $@-t $@ else errno.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += errno.h errno.h-t EXTRA_DIST += errno.in.h ## end gnulib module errno ## begin gnulib module error EXTRA_DIST += error.c error.h EXTRA_libgnu_la_SOURCES += error.c ## end gnulib module error ## begin gnulib module exitfail libgnu_la_SOURCES += exitfail.c EXTRA_DIST += exitfail.h ## end gnulib module exitfail ## begin gnulib module fcntl EXTRA_DIST += fcntl.c EXTRA_libgnu_la_SOURCES += fcntl.c ## end gnulib module fcntl ## begin gnulib module fcntl-h BUILT_SOURCES += fcntl.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ -e 's/@''GNULIB_FCNTL''@/$(GNULIB_FCNTL)/g' \ -e 's/@''GNULIB_NONBLOCKING''@/$(GNULIB_NONBLOCKING)/g' \ -e 's/@''GNULIB_OPEN''@/$(GNULIB_OPEN)/g' \ -e 's/@''GNULIB_OPENAT''@/$(GNULIB_OPENAT)/g' \ -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \ -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \ -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \ -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|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)/fcntl.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += fcntl.h fcntl.h-t EXTRA_DIST += fcntl.in.h ## end gnulib module fcntl-h ## begin gnulib module fd-hook libgnu_la_SOURCES += fd-hook.c EXTRA_DIST += fd-hook.h ## end gnulib module fd-hook ## begin gnulib module filemode libgnu_la_SOURCES += filemode.c EXTRA_DIST += filemode.h ## end gnulib module filemode ## begin gnulib module filename EXTRA_DIST += filename.h ## end gnulib module filename ## begin gnulib module float BUILT_SOURCES += $(FLOAT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. if GL_GENERATE_FLOAT_H float.h: float.in.h $(top_builddir)/config.status $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ < $(srcdir)/float.in.h; \ } > $@-t && \ mv $@-t $@ else float.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += float.h float.h-t EXTRA_DIST += float.c float.in.h itold.c EXTRA_libgnu_la_SOURCES += float.c itold.c ## end gnulib module float ## begin gnulib module fnmatch BUILT_SOURCES += $(FNMATCH_H) # We need the following in order to create when the system # doesn't have one that supports the required API. if GL_GENERATE_FNMATCH_H fnmatch.h: fnmatch.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/fnmatch.in.h; \ } > $@-t && \ mv -f $@-t $@ else fnmatch.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t EXTRA_DIST += fnmatch.c fnmatch.in.h fnmatch_loop.c EXTRA_libgnu_la_SOURCES += fnmatch.c fnmatch_loop.c ## end gnulib module fnmatch ## begin gnulib module fpucw EXTRA_DIST += fpucw.h ## end gnulib module fpucw ## begin gnulib module frexp-nolibm EXTRA_DIST += frexp.c EXTRA_libgnu_la_SOURCES += frexp.c ## end gnulib module frexp-nolibm ## begin gnulib module frexpl-nolibm EXTRA_DIST += frexp.c frexpl.c EXTRA_libgnu_la_SOURCES += frexp.c frexpl.c ## end gnulib module frexpl-nolibm ## begin gnulib module fstat EXTRA_DIST += fstat.c EXTRA_libgnu_la_SOURCES += fstat.c ## end gnulib module fstat ## begin gnulib module getdtablesize EXTRA_DIST += getdtablesize.c EXTRA_libgnu_la_SOURCES += getdtablesize.c ## end gnulib module getdtablesize ## begin gnulib module getlogin_r EXTRA_DIST += getlogin_r.c EXTRA_libgnu_la_SOURCES += getlogin_r.c ## end gnulib module getlogin_r ## begin gnulib module getopt-posix BUILT_SOURCES += $(GETOPT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. getopt.h: getopt.in.h $(top_builddir)/config.status $(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_GETOPT_H''@|$(HAVE_GETOPT_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_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/getopt.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += getopt.h getopt.h-t EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h EXTRA_libgnu_la_SOURCES += getopt.c getopt1.c ## end gnulib module getopt-posix ## begin gnulib module gettext # If your project uses "gettextize --intl" to put a source-code # copy of libintl into the package, every Makefile.am needs # -I$(top_builddir)/intl, so that can be found in this directory. # Here's one way to do this: #AM_CPPFLAGS += -I$(top_builddir)/intl # This option has no effect when the user disables NLS (because then # the intl directory contains no libintl.h file). This option is not # enabled by default because the intl directory might not exist if # your project does not use "gettext --intl", and some compilers # complain about -I options applied to nonexistent directories. EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath ## end gnulib module gettext ## begin gnulib module gettext-h libgnu_la_SOURCES += gettext.h ## end gnulib module gettext-h ## begin gnulib module gettime libgnu_la_SOURCES += gettime.c ## end gnulib module gettime ## begin gnulib module gettimeofday EXTRA_DIST += gettimeofday.c EXTRA_libgnu_la_SOURCES += gettimeofday.c ## end gnulib module gettimeofday ## begin gnulib module glob BUILT_SOURCES += $(GLOB_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. if GL_GENERATE_GLOB_H glob.h: glob.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|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)/glob.in.h; \ } > $@-t && \ mv -f $@-t $@ else glob.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += glob.h glob.h-t EXTRA_DIST += glob-libc.h glob.c glob.in.h EXTRA_libgnu_la_SOURCES += glob.c ## end gnulib module glob ## begin gnulib module gperf GPERF = gperf ## end gnulib module gperf ## begin gnulib module havelib EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath ## end gnulib module havelib ## begin gnulib module human libgnu_la_SOURCES += human.c EXTRA_DIST += human.h ## end gnulib module human ## begin gnulib module iconv-h BUILT_SOURCES += $(ICONV_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. if GL_GENERATE_ICONV_H iconv.h: iconv.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_ICONV_H''@|$(NEXT_ICONV_H)|g' \ -e 's/@''GNULIB_ICONV''@/$(GNULIB_ICONV)/g' \ -e 's|@''ICONV_CONST''@|$(ICONV_CONST)|g' \ -e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \ -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \ -e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|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)/iconv.in.h; \ } > $@-t && \ mv $@-t $@ else iconv.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += iconv.h iconv.h-t EXTRA_DIST += iconv.in.h ## end gnulib module iconv-h ## begin gnulib module iconv_open iconv_open-aix.h: iconv_open-aix.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-aix.gperf > $(srcdir)/iconv_open-aix.h-t mv $(srcdir)/iconv_open-aix.h-t $(srcdir)/iconv_open-aix.h iconv_open-hpux.h: iconv_open-hpux.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-hpux.gperf > $(srcdir)/iconv_open-hpux.h-t mv $(srcdir)/iconv_open-hpux.h-t $(srcdir)/iconv_open-hpux.h iconv_open-irix.h: iconv_open-irix.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-irix.gperf > $(srcdir)/iconv_open-irix.h-t mv $(srcdir)/iconv_open-irix.h-t $(srcdir)/iconv_open-irix.h iconv_open-osf.h: iconv_open-osf.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t mv $(srcdir)/iconv_open-osf.h-t $(srcdir)/iconv_open-osf.h iconv_open-solaris.h: iconv_open-solaris.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t mv $(srcdir)/iconv_open-solaris.h-t $(srcdir)/iconv_open-solaris.h BUILT_SOURCES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h MOSTLYCLEANFILES += iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t iconv_open-solaris.h-t MAINTAINERCLEANFILES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h EXTRA_DIST += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h EXTRA_DIST += iconv.c iconv_close.c iconv_open-aix.gperf iconv_open-hpux.gperf iconv_open-irix.gperf iconv_open-osf.gperf iconv_open-solaris.gperf iconv_open.c EXTRA_libgnu_la_SOURCES += iconv.c iconv_close.c iconv_open.c ## end gnulib module iconv_open ## begin gnulib module inet_pton EXTRA_DIST += inet_pton.c EXTRA_libgnu_la_SOURCES += inet_pton.c ## end gnulib module inet_pton ## begin gnulib module intprops EXTRA_DIST += intprops.h ## end gnulib module intprops ## begin gnulib module inttypes-incomplete BUILT_SOURCES += inttypes.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. inttypes.h: inttypes.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/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_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_INTTYPES_H''@|$(NEXT_INTTYPES_H)|g' \ -e 's/@''PRI_MACROS_BROKEN''@/$(PRI_MACROS_BROKEN)/g' \ -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ -e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \ -e 's/@''GNULIB_IMAXABS''@/$(GNULIB_IMAXABS)/g' \ -e 's/@''GNULIB_IMAXDIV''@/$(GNULIB_IMAXDIV)/g' \ -e 's/@''GNULIB_STRTOIMAX''@/$(GNULIB_STRTOIMAX)/g' \ -e 's/@''GNULIB_STRTOUMAX''@/$(GNULIB_STRTOUMAX)/g' \ -e 's/@''HAVE_DECL_IMAXABS''@/$(HAVE_DECL_IMAXABS)/g' \ -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \ -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \ -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \ -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \ -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \ -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \ -e 's/@''INT64_MAX_EQ_LONG_MAX''@/$(INT64_MAX_EQ_LONG_MAX)/g' \ -e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \ -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/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)/inttypes.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += inttypes.h inttypes.h-t EXTRA_DIST += inttypes.in.h ## end gnulib module inttypes-incomplete ## begin gnulib module isnand-nolibm EXTRA_DIST += float+.h isnan.c isnand-nolibm.h isnand.c EXTRA_libgnu_la_SOURCES += isnan.c isnand.c ## end gnulib module isnand-nolibm ## begin gnulib module isnanf-nolibm EXTRA_DIST += float+.h isnan.c isnanf-nolibm.h isnanf.c EXTRA_libgnu_la_SOURCES += isnan.c isnanf.c ## end gnulib module isnanf-nolibm ## begin gnulib module isnanl-nolibm EXTRA_DIST += float+.h isnan.c isnanl-nolibm.h isnanl.c EXTRA_libgnu_la_SOURCES += isnan.c isnanl.c ## end gnulib module isnanl-nolibm ## begin gnulib module langinfo BUILT_SOURCES += langinfo.h # We need the following in order to create an empty placeholder for # when the system doesn't have one. langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_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_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ -e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \ -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \ -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \ -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/langinfo.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += langinfo.h langinfo.h-t EXTRA_DIST += langinfo.in.h ## end gnulib module langinfo ## begin gnulib module lchown EXTRA_DIST += lchown.c EXTRA_libgnu_la_SOURCES += lchown.c ## end gnulib module lchown ## begin gnulib module localcharset libgnu_la_SOURCES += localcharset.h localcharset.c # We need the following in order to install a simple file in $(libdir) # which is shared with other installed packages. We use a list of referencing # packages so that "make uninstall" will remove the file if and only if it # is not used by another installed package. # On systems with glibc-2.1 or newer, the file is redundant, therefore we # avoid installing it. all-local: charset.alias ref-add.sed ref-del.sed charset_alias = $(DESTDIR)$(libdir)/charset.alias charset_tmp = $(DESTDIR)$(libdir)/charset.tmp install-exec-local: install-exec-localcharset install-exec-localcharset: all-local if test $(GLIBC21) = no; then \ case '$(host_os)' in \ darwin[56]*) \ need_charset_alias=true ;; \ darwin* | cygwin* | mingw* | pw32* | cegcc*) \ need_charset_alias=false ;; \ *) \ need_charset_alias=true ;; \ esac ; \ else \ need_charset_alias=false ; \ fi ; \ if $$need_charset_alias; then \ $(mkinstalldirs) $(DESTDIR)$(libdir) ; \ fi ; \ if test -f $(charset_alias); then \ sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \ $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \ rm -f $(charset_tmp) ; \ else \ if $$need_charset_alias; then \ sed -f ref-add.sed charset.alias > $(charset_tmp) ; \ $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \ rm -f $(charset_tmp) ; \ fi ; \ fi uninstall-local: uninstall-localcharset uninstall-localcharset: all-local if test -f $(charset_alias); then \ sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \ if grep '^# Packages using this file: $$' $(charset_tmp) \ > /dev/null; then \ rm -f $(charset_alias); \ else \ $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \ fi; \ rm -f $(charset_tmp); \ fi charset.alias: config.charset $(AM_V_GEN)rm -f t-$@ $@ && \ $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \ mv t-$@ $@ SUFFIXES += .sed .sin .sin.sed: $(AM_V_GEN)rm -f t-$@ $@ && \ sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \ mv t-$@ $@ CLEANFILES += charset.alias ref-add.sed ref-del.sed EXTRA_DIST += config.charset ref-add.sin ref-del.sin ## end gnulib module localcharset ## begin gnulib module locale BUILT_SOURCES += locale.h # We need the following in order to create when the system # doesn't have one that provides all definitions. locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \ -e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \ -e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \ -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \ -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \ -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|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)/locale.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += locale.h locale.h-t EXTRA_DIST += locale.in.h ## end gnulib module locale ## begin gnulib module localeconv EXTRA_DIST += localeconv.c EXTRA_libgnu_la_SOURCES += localeconv.c ## end gnulib module localeconv ## begin gnulib module lock libgnu_la_SOURCES += glthread/lock.h glthread/lock.c ## end gnulib module lock ## begin gnulib module lstat EXTRA_DIST += lstat.c EXTRA_libgnu_la_SOURCES += lstat.c ## end gnulib module lstat ## begin gnulib module malloc-posix EXTRA_DIST += malloc.c EXTRA_libgnu_la_SOURCES += malloc.c ## end gnulib module malloc-posix ## begin gnulib module malloca libgnu_la_SOURCES += malloca.c EXTRA_DIST += malloca.h malloca.valgrind ## end gnulib module malloca ## begin gnulib module math BUILT_SOURCES += math.h libgnu_la_SOURCES += math.c # We need the following in order to create when the system # doesn't have one that works with the given compiler. math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \ -e 's/@''GNULIB_ACOSF''@/$(GNULIB_ACOSF)/g' \ -e 's/@''GNULIB_ACOSL''@/$(GNULIB_ACOSL)/g' \ -e 's/@''GNULIB_ASINF''@/$(GNULIB_ASINF)/g' \ -e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \ -e 's/@''GNULIB_ATANF''@/$(GNULIB_ATANF)/g' \ -e 's/@''GNULIB_ATANL''@/$(GNULIB_ATANL)/g' \ -e 's/@''GNULIB_ATAN2F''@/$(GNULIB_ATAN2F)/g' \ -e 's/@''GNULIB_CBRT''@/$(GNULIB_CBRT)/g' \ -e 's/@''GNULIB_CBRTF''@/$(GNULIB_CBRTF)/g' \ -e 's/@''GNULIB_CBRTL''@/$(GNULIB_CBRTL)/g' \ -e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \ -e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \ -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \ -e 's/@''GNULIB_COPYSIGN''@/$(GNULIB_COPYSIGN)/g' \ -e 's/@''GNULIB_COPYSIGNF''@/$(GNULIB_COPYSIGNF)/g' \ -e 's/@''GNULIB_COPYSIGNL''@/$(GNULIB_COPYSIGNL)/g' \ -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \ -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \ -e 's/@''GNULIB_COSHF''@/$(GNULIB_COSHF)/g' \ -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \ -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \ -e 's/@''GNULIB_EXP2''@/$(GNULIB_EXP2)/g' \ -e 's/@''GNULIB_EXP2F''@/$(GNULIB_EXP2F)/g' \ -e 's/@''GNULIB_EXP2L''@/$(GNULIB_EXP2L)/g' \ -e 's/@''GNULIB_EXPM1''@/$(GNULIB_EXPM1)/g' \ -e 's/@''GNULIB_EXPM1F''@/$(GNULIB_EXPM1F)/g' \ -e 's/@''GNULIB_EXPM1L''@/$(GNULIB_EXPM1L)/g' \ -e 's/@''GNULIB_FABSF''@/$(GNULIB_FABSF)/g' \ -e 's/@''GNULIB_FABSL''@/$(GNULIB_FABSL)/g' \ -e 's/@''GNULIB_FLOOR''@/$(GNULIB_FLOOR)/g' \ -e 's/@''GNULIB_FLOORF''@/$(GNULIB_FLOORF)/g' \ -e 's/@''GNULIB_FLOORL''@/$(GNULIB_FLOORL)/g' \ -e 's/@''GNULIB_FMA''@/$(GNULIB_FMA)/g' \ -e 's/@''GNULIB_FMAF''@/$(GNULIB_FMAF)/g' \ -e 's/@''GNULIB_FMAL''@/$(GNULIB_FMAL)/g' \ -e 's/@''GNULIB_FMOD''@/$(GNULIB_FMOD)/g' \ -e 's/@''GNULIB_FMODF''@/$(GNULIB_FMODF)/g' \ -e 's/@''GNULIB_FMODL''@/$(GNULIB_FMODL)/g' \ -e 's/@''GNULIB_FREXPF''@/$(GNULIB_FREXPF)/g' \ -e 's/@''GNULIB_FREXP''@/$(GNULIB_FREXP)/g' \ -e 's/@''GNULIB_FREXPL''@/$(GNULIB_FREXPL)/g' \ -e 's/@''GNULIB_HYPOT''@/$(GNULIB_HYPOT)/g' \ -e 's/@''GNULIB_HYPOTF''@/$(GNULIB_HYPOTF)/g' \ -e 's/@''GNULIB_HYPOTL''@/$(GNULIB_HYPOTL)/g' \ < $(srcdir)/math.in.h | \ sed -e 's/@''GNULIB_ILOGB''@/$(GNULIB_ILOGB)/g' \ -e 's/@''GNULIB_ILOGBF''@/$(GNULIB_ILOGBF)/g' \ -e 's/@''GNULIB_ILOGBL''@/$(GNULIB_ILOGBL)/g' \ -e 's/@''GNULIB_ISFINITE''@/$(GNULIB_ISFINITE)/g' \ -e 's/@''GNULIB_ISINF''@/$(GNULIB_ISINF)/g' \ -e 's/@''GNULIB_ISNAN''@/$(GNULIB_ISNAN)/g' \ -e 's/@''GNULIB_ISNANF''@/$(GNULIB_ISNANF)/g' \ -e 's/@''GNULIB_ISNAND''@/$(GNULIB_ISNAND)/g' \ -e 's/@''GNULIB_ISNANL''@/$(GNULIB_ISNANL)/g' \ -e 's/@''GNULIB_LDEXPF''@/$(GNULIB_LDEXPF)/g' \ -e 's/@''GNULIB_LDEXPL''@/$(GNULIB_LDEXPL)/g' \ -e 's/@''GNULIB_LOG''@/$(GNULIB_LOG)/g' \ -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \ -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \ -e 's/@''GNULIB_LOG10''@/$(GNULIB_LOG10)/g' \ -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \ -e 's/@''GNULIB_LOG10L''@/$(GNULIB_LOG10L)/g' \ -e 's/@''GNULIB_LOG1P''@/$(GNULIB_LOG1P)/g' \ -e 's/@''GNULIB_LOG1PF''@/$(GNULIB_LOG1PF)/g' \ -e 's/@''GNULIB_LOG1PL''@/$(GNULIB_LOG1PL)/g' \ -e 's/@''GNULIB_LOG2''@/$(GNULIB_LOG2)/g' \ -e 's/@''GNULIB_LOG2F''@/$(GNULIB_LOG2F)/g' \ -e 's/@''GNULIB_LOG2L''@/$(GNULIB_LOG2L)/g' \ -e 's/@''GNULIB_LOGB''@/$(GNULIB_LOGB)/g' \ -e 's/@''GNULIB_LOGBF''@/$(GNULIB_LOGBF)/g' \ -e 's/@''GNULIB_LOGBL''@/$(GNULIB_LOGBL)/g' \ -e 's/@''GNULIB_MODF''@/$(GNULIB_MODF)/g' \ -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \ -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \ -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \ -e 's/@''GNULIB_REMAINDER''@/$(GNULIB_REMAINDER)/g' \ -e 's/@''GNULIB_REMAINDERF''@/$(GNULIB_REMAINDERF)/g' \ -e 's/@''GNULIB_REMAINDERL''@/$(GNULIB_REMAINDERL)/g' \ -e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \ -e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \ -e 's/@''GNULIB_RINTL''@/$(GNULIB_RINTL)/g' \ -e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \ -e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \ -e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \ -e 's/@''GNULIB_SIGNBIT''@/$(GNULIB_SIGNBIT)/g' \ -e 's/@''GNULIB_SINF''@/$(GNULIB_SINF)/g' \ -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \ -e 's/@''GNULIB_SINHF''@/$(GNULIB_SINHF)/g' \ -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \ -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \ -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \ -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \ -e 's/@''GNULIB_TANHF''@/$(GNULIB_TANHF)/g' \ -e 's/@''GNULIB_TRUNC''@/$(GNULIB_TRUNC)/g' \ -e 's/@''GNULIB_TRUNCF''@/$(GNULIB_TRUNCF)/g' \ -e 's/@''GNULIB_TRUNCL''@/$(GNULIB_TRUNCL)/g' \ | \ sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \ -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \ -e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \ -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \ -e 's|@''HAVE_ATANF''@|$(HAVE_ATANF)|g' \ -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \ -e 's|@''HAVE_ATAN2F''@|$(HAVE_ATAN2F)|g' \ -e 's|@''HAVE_CBRT''@|$(HAVE_CBRT)|g' \ -e 's|@''HAVE_CBRTF''@|$(HAVE_CBRTF)|g' \ -e 's|@''HAVE_CBRTL''@|$(HAVE_CBRTL)|g' \ -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \ -e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \ -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \ -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \ -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \ -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \ -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \ -e 's|@''HAVE_EXPM1''@|$(HAVE_EXPM1)|g' \ -e 's|@''HAVE_EXPM1F''@|$(HAVE_EXPM1F)|g' \ -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \ -e 's|@''HAVE_FABSL''@|$(HAVE_FABSL)|g' \ -e 's|@''HAVE_FMA''@|$(HAVE_FMA)|g' \ -e 's|@''HAVE_FMAF''@|$(HAVE_FMAF)|g' \ -e 's|@''HAVE_FMAL''@|$(HAVE_FMAL)|g' \ -e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \ -e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \ -e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \ -e 's|@''HAVE_HYPOTF''@|$(HAVE_HYPOTF)|g' \ -e 's|@''HAVE_HYPOTL''@|$(HAVE_HYPOTL)|g' \ -e 's|@''HAVE_ILOGB''@|$(HAVE_ILOGB)|g' \ -e 's|@''HAVE_ILOGBF''@|$(HAVE_ILOGBF)|g' \ -e 's|@''HAVE_ILOGBL''@|$(HAVE_ILOGBL)|g' \ -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \ -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \ -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \ -e 's|@''HAVE_LDEXPF''@|$(HAVE_LDEXPF)|g' \ -e 's|@''HAVE_LOGF''@|$(HAVE_LOGF)|g' \ -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \ -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \ -e 's|@''HAVE_LOG10L''@|$(HAVE_LOG10L)|g' \ -e 's|@''HAVE_LOG1P''@|$(HAVE_LOG1P)|g' \ -e 's|@''HAVE_LOG1PF''@|$(HAVE_LOG1PF)|g' \ -e 's|@''HAVE_LOG1PL''@|$(HAVE_LOG1PL)|g' \ -e 's|@''HAVE_LOGBF''@|$(HAVE_LOGBF)|g' \ -e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \ -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \ -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \ -e 's|@''HAVE_REMAINDER''@|$(HAVE_REMAINDER)|g' \ -e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \ -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \ -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \ -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \ -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \ -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \ -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \ -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \ -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \ -e 's|@''HAVE_TANHF''@|$(HAVE_TANHF)|g' \ -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ -e 's|@''HAVE_DECL_CBRTF''@|$(HAVE_DECL_CBRTF)|g' \ -e 's|@''HAVE_DECL_CBRTL''@|$(HAVE_DECL_CBRTL)|g' \ -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \ -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \ -e 's|@''HAVE_DECL_COPYSIGNF''@|$(HAVE_DECL_COPYSIGNF)|g' \ -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ -e 's|@''HAVE_DECL_EXP2''@|$(HAVE_DECL_EXP2)|g' \ -e 's|@''HAVE_DECL_EXP2F''@|$(HAVE_DECL_EXP2F)|g' \ -e 's|@''HAVE_DECL_EXP2L''@|$(HAVE_DECL_EXP2L)|g' \ -e 's|@''HAVE_DECL_EXPM1L''@|$(HAVE_DECL_EXPM1L)|g' \ -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \ -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \ -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ -e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \ -e 's|@''HAVE_DECL_LOG2''@|$(HAVE_DECL_LOG2)|g' \ -e 's|@''HAVE_DECL_LOG2F''@|$(HAVE_DECL_LOG2F)|g' \ -e 's|@''HAVE_DECL_LOG2L''@|$(HAVE_DECL_LOG2L)|g' \ -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \ -e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \ -e 's|@''HAVE_DECL_REMAINDERL''@|$(HAVE_DECL_REMAINDERL)|g' \ -e 's|@''HAVE_DECL_RINTF''@|$(HAVE_DECL_RINTF)|g' \ -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \ -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \ -e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \ -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \ -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \ -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ | \ sed -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \ -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \ -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \ -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \ -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \ -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \ -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \ -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \ -e 's|@''REPLACE_FLOOR''@|$(REPLACE_FLOOR)|g' \ -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \ -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \ -e 's|@''REPLACE_FMA''@|$(REPLACE_FMA)|g' \ -e 's|@''REPLACE_FMAF''@|$(REPLACE_FMAF)|g' \ -e 's|@''REPLACE_FMAL''@|$(REPLACE_FMAL)|g' \ -e 's|@''REPLACE_FMOD''@|$(REPLACE_FMOD)|g' \ -e 's|@''REPLACE_FMODF''@|$(REPLACE_FMODF)|g' \ -e 's|@''REPLACE_FMODL''@|$(REPLACE_FMODL)|g' \ -e 's|@''REPLACE_FREXPF''@|$(REPLACE_FREXPF)|g' \ -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \ -e 's|@''REPLACE_HYPOT''@|$(REPLACE_HYPOT)|g' \ -e 's|@''REPLACE_HYPOTF''@|$(REPLACE_HYPOTF)|g' \ -e 's|@''REPLACE_HYPOTL''@|$(REPLACE_HYPOTL)|g' \ -e 's|@''REPLACE_ILOGB''@|$(REPLACE_ILOGB)|g' \ -e 's|@''REPLACE_ILOGBF''@|$(REPLACE_ILOGBF)|g' \ -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \ -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \ -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \ -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \ -e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \ -e 's|@''REPLACE_LOG10''@|$(REPLACE_LOG10)|g' \ -e 's|@''REPLACE_LOG10F''@|$(REPLACE_LOG10F)|g' \ -e 's|@''REPLACE_LOG10L''@|$(REPLACE_LOG10L)|g' \ -e 's|@''REPLACE_LOG1P''@|$(REPLACE_LOG1P)|g' \ -e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \ -e 's|@''REPLACE_LOG1PL''@|$(REPLACE_LOG1PL)|g' \ -e 's|@''REPLACE_LOG2''@|$(REPLACE_LOG2)|g' \ -e 's|@''REPLACE_LOG2F''@|$(REPLACE_LOG2F)|g' \ -e 's|@''REPLACE_LOG2L''@|$(REPLACE_LOG2L)|g' \ -e 's|@''REPLACE_LOGB''@|$(REPLACE_LOGB)|g' \ -e 's|@''REPLACE_LOGBF''@|$(REPLACE_LOGBF)|g' \ -e 's|@''REPLACE_LOGBL''@|$(REPLACE_LOGBL)|g' \ -e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \ -e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \ -e 's|@''REPLACE_MODFL''@|$(REPLACE_MODFL)|g' \ -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \ -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \ -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \ -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \ -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|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)'; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += math.h math.h-t EXTRA_DIST += math.in.h ## end gnulib module math ## begin gnulib module mbrtowc EXTRA_DIST += mbrtowc.c EXTRA_libgnu_la_SOURCES += mbrtowc.c ## end gnulib module mbrtowc ## begin gnulib module mbsinit EXTRA_DIST += mbsinit.c EXTRA_libgnu_la_SOURCES += mbsinit.c ## end gnulib module mbsinit ## begin gnulib module mbsrtowcs EXTRA_DIST += mbsrtowcs-impl.h mbsrtowcs-state.c mbsrtowcs.c EXTRA_libgnu_la_SOURCES += mbsrtowcs-state.c mbsrtowcs.c ## end gnulib module mbsrtowcs ## begin gnulib module mbswidth libgnu_la_SOURCES += mbswidth.h mbswidth.c ## end gnulib module mbswidth ## begin gnulib module mbtowc EXTRA_DIST += mbtowc-impl.h mbtowc.c EXTRA_libgnu_la_SOURCES += mbtowc.c ## end gnulib module mbtowc ## begin gnulib module memchr EXTRA_DIST += memchr.c memchr.valgrind EXTRA_libgnu_la_SOURCES += memchr.c ## end gnulib module memchr ## begin gnulib module memmem-simple EXTRA_DIST += memmem.c str-two-way.h EXTRA_libgnu_la_SOURCES += memmem.c ## end gnulib module memmem-simple ## begin gnulib module mempcpy EXTRA_DIST += mempcpy.c EXTRA_libgnu_la_SOURCES += mempcpy.c ## end gnulib module mempcpy ## begin gnulib module mktime EXTRA_DIST += mktime-internal.h mktime.c EXTRA_libgnu_la_SOURCES += mktime.c ## end gnulib module mktime ## begin gnulib module modechange libgnu_la_SOURCES += modechange.c EXTRA_DIST += modechange.h ## end gnulib module modechange ## begin gnulib module msvc-inval EXTRA_DIST += msvc-inval.c msvc-inval.h EXTRA_libgnu_la_SOURCES += msvc-inval.c ## end gnulib module msvc-inval ## begin gnulib module msvc-nothrow EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h EXTRA_libgnu_la_SOURCES += msvc-nothrow.c ## end gnulib module msvc-nothrow ## begin gnulib module netinet_in BUILT_SOURCES += $(NETINET_IN_H) # We need the following in order to create when the system # doesn't have one. if GL_GENERATE_NETINET_IN_H netinet/in.h: netinet_in.in.h $(top_builddir)/config.status $(AM_V_at)$(MKDIR_P) netinet $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ < $(srcdir)/netinet_in.in.h; \ } > $@-t && \ mv $@-t $@ else netinet/in.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t MOSTLYCLEANDIRS += netinet EXTRA_DIST += netinet_in.in.h ## end gnulib module netinet_in ## begin gnulib module nl_langinfo EXTRA_DIST += nl_langinfo.c EXTRA_libgnu_la_SOURCES += nl_langinfo.c ## end gnulib module nl_langinfo ## begin gnulib module open EXTRA_DIST += open.c EXTRA_libgnu_la_SOURCES += open.c ## end gnulib module open ## begin gnulib module opendir EXTRA_DIST += dirent-private.h opendir.c EXTRA_libgnu_la_SOURCES += opendir.c ## end gnulib module opendir ## begin gnulib module parse-datetime # This rule overrides the Automake generated .y.c rule, to ensure that the # parse-datetime.c file gets generated in the source directory, not in the # build directory. parse-datetime.c: parse-datetime.y $(AM_V_GEN)$(SHELL) $(YLWRAP) $(srcdir)/parse-datetime.y \ y.tab.c parse-datetime.c \ y.tab.h parse-datetime.h \ y.output parse-datetime.output \ -- $(YACC) $(YFLAGS) $(AM_YFLAGS) && \ mv parse-datetime.c parse-datetime.c-t && \ mv parse-datetime.c-t $(srcdir)/parse-datetime.c libgnu_la_SOURCES += parse-datetime.y BUILT_SOURCES += parse-datetime.c MOSTLYCLEANFILES += parse-datetime.c-t MAINTAINERCLEANFILES += parse-datetime.c EXTRA_DIST += parse-datetime.c EXTRA_DIST += parse-datetime.h ## end gnulib module parse-datetime ## begin gnulib module passfd libgnu_la_SOURCES += passfd.c EXTRA_DIST += passfd.h ## end gnulib module passfd ## begin gnulib module pathmax EXTRA_DIST += pathmax.h ## end gnulib module pathmax ## begin gnulib module poll EXTRA_DIST += poll.c EXTRA_libgnu_la_SOURCES += poll.c ## end gnulib module poll ## begin gnulib module poll-h BUILT_SOURCES += poll.h # We need the following in order to create when the system # doesn't have one. poll.h: poll.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''HAVE_POLL_H''@|$(HAVE_POLL_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_POLL_H''@|$(NEXT_POLL_H)|g' \ -e 's/@''GNULIB_POLL''@/$(GNULIB_POLL)/g' \ -e 's|@''HAVE_POLL''@|$(HAVE_POLL)|g' \ -e 's|@''REPLACE_POLL''@|$(REPLACE_POLL)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/poll.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += poll.h poll.h-t EXTRA_DIST += poll.in.h ## end gnulib module poll-h ## begin gnulib module printf-frexp libgnu_la_SOURCES += printf-frexp.c EXTRA_DIST += printf-frexp.h ## end gnulib module printf-frexp ## begin gnulib module printf-frexpl libgnu_la_SOURCES += printf-frexpl.c EXTRA_DIST += printf-frexp.c printf-frexpl.h EXTRA_libgnu_la_SOURCES += printf-frexp.c ## end gnulib module printf-frexpl ## begin gnulib module quote EXTRA_DIST += quote.h ## end gnulib module quote ## begin gnulib module quotearg libgnu_la_SOURCES += quotearg.c EXTRA_DIST += quote.h quotearg.h ## end gnulib module quotearg ## begin gnulib module readdir EXTRA_DIST += dirent-private.h readdir.c EXTRA_libgnu_la_SOURCES += readdir.c ## end gnulib module readdir ## begin gnulib module readlink EXTRA_DIST += readlink.c EXTRA_libgnu_la_SOURCES += readlink.c ## end gnulib module readlink ## begin gnulib module regex EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c EXTRA_libgnu_la_SOURCES += regcomp.c regex.c regex_internal.c regexec.c ## end gnulib module regex ## begin gnulib module select EXTRA_DIST += select.c EXTRA_libgnu_la_SOURCES += select.c ## end gnulib module select ## begin gnulib module setenv EXTRA_DIST += setenv.c EXTRA_libgnu_la_SOURCES += setenv.c ## end gnulib module setenv ## begin gnulib module signal-h BUILT_SOURCES += signal.h # We need the following in order to create when the system # doesn't have a complete one. signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \ -e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \ -e 's|@''GNULIB_RAISE''@|$(GNULIB_RAISE)|g' \ -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \ -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \ -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \ -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \ -e 's|@''HAVE_RAISE''@|$(HAVE_RAISE)|g' \ -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \ -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \ -e 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g' \ -e 's|@''REPLACE_RAISE''@|$(REPLACE_RAISE)|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)/signal.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += signal.h signal.h-t EXTRA_DIST += signal.in.h ## end gnulib module signal-h ## begin gnulib module signbit EXTRA_DIST += float+.h signbitd.c signbitf.c signbitl.c EXTRA_libgnu_la_SOURCES += signbitd.c signbitf.c signbitl.c ## end gnulib module signbit ## begin gnulib module size_max libgnu_la_SOURCES += size_max.h ## end gnulib module size_max ## begin gnulib module snippet/_Noreturn # Because this Makefile snippet defines a variable used by other # gnulib Makefile snippets, it must be present in all Makefile.am that # need it. This is ensured by the applicability 'all' defined above. _NORETURN_H=$(top_srcdir)/build-aux/snippet/_Noreturn.h EXTRA_DIST += $(top_srcdir)/build-aux/snippet/_Noreturn.h ## end gnulib module snippet/_Noreturn ## begin gnulib module snippet/arg-nonnull # The BUILT_SOURCES created by this Makefile snippet are not used via #include # statements but through direct file reference. Therefore this snippet must be # present in all Makefile.am that need it. This is ensured by the applicability # 'all' defined above. BUILT_SOURCES += arg-nonnull.h # The arg-nonnull.h that gets inserted into generated .h files is the same as # build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut # off. arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h $(AM_V_GEN)rm -f $@-t $@ && \ sed -n -e '/GL_ARG_NONNULL/,$$p' \ < $(top_srcdir)/build-aux/snippet/arg-nonnull.h \ > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t ARG_NONNULL_H=arg-nonnull.h EXTRA_DIST += $(top_srcdir)/build-aux/snippet/arg-nonnull.h ## end gnulib module snippet/arg-nonnull ## begin gnulib module snippet/c++defs # The BUILT_SOURCES created by this Makefile snippet are not used via #include # statements but through direct file reference. Therefore this snippet must be # present in all Makefile.am that need it. This is ensured by the applicability # 'all' defined above. BUILT_SOURCES += c++defs.h # The c++defs.h that gets inserted into generated .h files is the same as # build-aux/snippet/c++defs.h, except that it has the copyright header cut off. c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h $(AM_V_GEN)rm -f $@-t $@ && \ sed -n -e '/_GL_CXXDEFS/,$$p' \ < $(top_srcdir)/build-aux/snippet/c++defs.h \ > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += c++defs.h c++defs.h-t CXXDEFS_H=c++defs.h EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h ## end gnulib module snippet/c++defs ## begin gnulib module snippet/unused-parameter # The BUILT_SOURCES created by this Makefile snippet are not used via #include # statements but through direct file reference. Therefore this snippet must be # present in all Makefile.am that need it. This is ensured by the applicability # 'all' defined above. BUILT_SOURCES += unused-parameter.h # The unused-parameter.h that gets inserted into generated .h files is the same # as build-aux/snippet/unused-parameter.h, except that it has the copyright # header cut off. unused-parameter.h: $(top_srcdir)/build-aux/snippet/unused-parameter.h $(AM_V_GEN)rm -f $@-t $@ && \ sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \ < $(top_srcdir)/build-aux/snippet/unused-parameter.h \ > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t UNUSED_PARAMETER_H=unused-parameter.h EXTRA_DIST += $(top_srcdir)/build-aux/snippet/unused-parameter.h ## end gnulib module snippet/unused-parameter ## begin gnulib module snippet/warn-on-use BUILT_SOURCES += warn-on-use.h # The warn-on-use.h that gets inserted into generated .h files is the same as # build-aux/snippet/warn-on-use.h, except that it has the copyright header cut # off. warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h $(AM_V_GEN)rm -f $@-t $@ && \ sed -n -e '/^.ifndef/,$$p' \ < $(top_srcdir)/build-aux/snippet/warn-on-use.h \ > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t WARN_ON_USE_H=warn-on-use.h EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h ## end gnulib module snippet/warn-on-use ## begin gnulib module sockets libgnu_la_SOURCES += sockets.h sockets.c EXTRA_DIST += w32sock.h ## end gnulib module sockets ## begin gnulib module stat EXTRA_DIST += stat.c EXTRA_libgnu_la_SOURCES += stat.c ## end gnulib module stat ## begin gnulib module stat-macros EXTRA_DIST += stat-macros.h ## end gnulib module stat-macros ## begin gnulib module stdalign BUILT_SOURCES += $(STDALIGN_H) # We need the following in order to create when the system # doesn't have one that works. if GL_GENERATE_STDALIGN_H stdalign.h: stdalign.in.h $(top_builddir)/config.status $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/stdalign.in.h; \ } > $@-t && \ mv $@-t $@ else stdalign.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += stdalign.h stdalign.h-t EXTRA_DIST += stdalign.in.h ## end gnulib module stdalign ## begin gnulib module stdbool BUILT_SOURCES += $(STDBOOL_H) # We need the following in order to create when the system # doesn't have one that works. if GL_GENERATE_STDBOOL_H stdbool.h: stdbool.in.h $(top_builddir)/config.status $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ } > $@-t && \ mv $@-t $@ else stdbool.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += stdbool.h stdbool.h-t EXTRA_DIST += stdbool.in.h ## end gnulib module stdbool ## begin gnulib module stddef BUILT_SOURCES += $(STDDEF_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. if GL_GENERATE_STDDEF_H stddef.h: stddef.in.h $(top_builddir)/config.status $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \ -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ < $(srcdir)/stddef.in.h; \ } > $@-t && \ mv $@-t $@ else stddef.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += stddef.h stddef.h-t EXTRA_DIST += stddef.in.h ## end gnulib module stddef ## begin gnulib module stdint BUILT_SOURCES += $(STDINT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. if GL_GENERATE_STDINT_H stdint.h: stdint.in.h $(top_builddir)/config.status $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_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_STDINT_H''@|$(NEXT_STDINT_H)|g' \ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \ -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \ -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \ -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \ -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \ -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \ -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \ -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \ -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \ -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \ -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \ -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ < $(srcdir)/stdint.in.h; \ } > $@-t && \ mv $@-t $@ else stdint.h: $(top_builddir)/config.status rm -f $@ endif MOSTLYCLEANFILES += stdint.h stdint.h-t EXTRA_DIST += stdint.in.h ## end gnulib module stdint ## begin gnulib module stdio BUILT_SOURCES += stdio.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_STDIO_H''@|$(NEXT_STDIO_H)|g' \ -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \ -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \ -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \ -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \ -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \ -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \ -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \ -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \ -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \ -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \ -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \ -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \ -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \ -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \ -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \ -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \ -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \ -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \ -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \ -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \ -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \ -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \ -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \ -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \ -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \ -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \ -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \ -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \ -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \ -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \ -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \ -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \ -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \ -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \ -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \ -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \ -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \ -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \ -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \ -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \ -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \ -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \ -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \ -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \ -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \ -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \ -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \ -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \ -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \ -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \ -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \ < $(srcdir)/stdio.in.h | \ sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \ -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \ -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \ -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \ -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \ -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \ -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ -e 's|@''REPLACE_STDIO_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|g' \ -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \ -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|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)'; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += stdio.h stdio.h-t EXTRA_DIST += stdio.in.h ## end gnulib module stdio ## begin gnulib module stdlib BUILT_SOURCES += stdlib.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \ -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \ -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \ -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \ -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \ -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \ -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \ -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \ -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/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_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \ -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \ -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \ -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \ -e 's/@''GNULIB_QSORT_R''@/$(GNULIB_QSORT_R)/g' \ -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \ -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \ -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \ -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \ -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \ -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \ -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \ -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \ -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \ -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \ -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \ -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \ -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \ -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \ < $(srcdir)/stdlib.in.h | \ sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|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_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \ -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \ -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \ -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \ -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _Noreturn/r $(_NORETURN_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += stdlib.h stdlib.h-t EXTRA_DIST += stdlib.in.h ## end gnulib module stdlib ## begin gnulib module strcase EXTRA_DIST += strcasecmp.c strncasecmp.c EXTRA_libgnu_la_SOURCES += strcasecmp.c strncasecmp.c ## end gnulib module strcase ## begin gnulib module strdup-posix EXTRA_DIST += strdup.c EXTRA_libgnu_la_SOURCES += strdup.c ## end gnulib module strdup-posix ## begin gnulib module streq EXTRA_DIST += streq.h ## end gnulib module streq ## begin gnulib module strerror EXTRA_DIST += strerror.c EXTRA_libgnu_la_SOURCES += strerror.c ## end gnulib module strerror ## begin gnulib module strerror-override EXTRA_DIST += strerror-override.c strerror-override.h EXTRA_libgnu_la_SOURCES += strerror-override.c ## end gnulib module strerror-override ## begin gnulib module strftime libgnu_la_SOURCES += strftime.c EXTRA_DIST += strftime.h ## end gnulib module strftime ## begin gnulib module string BUILT_SOURCES += string.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_STRING_H''@|$(NEXT_STRING_H)|g' \ -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \ -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \ -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \ -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \ -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \ -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \ -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \ -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \ -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \ -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \ -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \ -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \ -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \ -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \ -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \ -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \ -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \ -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \ -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \ -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \ -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \ -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \ -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \ -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \ -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \ -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \ -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \ -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \ -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \ -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \ -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \ -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \ -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \ -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \ -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \ -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \ -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \ < $(srcdir)/string.in.h | \ sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \ -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|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)/string.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += string.h string.h-t 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 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 strnlen1 libgnu_la_SOURCES += strnlen1.h strnlen1.c ## end gnulib module strnlen1 ## begin gnulib module strptime EXTRA_DIST += strptime.c EXTRA_libgnu_la_SOURCES += strptime.c ## end gnulib module strptime ## begin gnulib module strstr-simple EXTRA_DIST += str-two-way.h strstr.c EXTRA_libgnu_la_SOURCES += strstr.c ## end gnulib module strstr-simple ## begin gnulib module strtok_r EXTRA_DIST += strtok_r.c EXTRA_libgnu_la_SOURCES += strtok_r.c ## end gnulib module strtok_r ## begin gnulib module strtoull EXTRA_DIST += strtol.c strtoul.c strtoull.c EXTRA_libgnu_la_SOURCES += strtol.c strtoul.c strtoull.c ## end gnulib module strtoull ## begin gnulib module strtoumax EXTRA_DIST += strtoimax.c strtoumax.c EXTRA_libgnu_la_SOURCES += strtoimax.c strtoumax.c ## end gnulib module strtoumax ## begin gnulib module sys_select BUILT_SOURCES += sys/select.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/select.h: sys_select.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \ -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \ -e 's/@''GNULIB_PSELECT''@/$(GNULIB_PSELECT)/g' \ -e 's/@''GNULIB_SELECT''@/$(GNULIB_SELECT)/g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_PSELECT''@|$(HAVE_PSELECT)|g' \ -e 's|@''REPLACE_PSELECT''@|$(REPLACE_PSELECT)|g' \ -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/sys_select.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += sys/select.h sys/select.h-t MOSTLYCLEANDIRS += sys EXTRA_DIST += sys_select.in.h ## end gnulib module sys_select ## begin gnulib module sys_socket BUILT_SOURCES += sys/socket.h libgnu_la_SOURCES += sys_socket.c # We need the following in order to create 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) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ -e 's/@''GNULIB_SOCKET''@/$(GNULIB_SOCKET)/g' \ -e 's/@''GNULIB_CONNECT''@/$(GNULIB_CONNECT)/g' \ -e 's/@''GNULIB_ACCEPT''@/$(GNULIB_ACCEPT)/g' \ -e 's/@''GNULIB_BIND''@/$(GNULIB_BIND)/g' \ -e 's/@''GNULIB_GETPEERNAME''@/$(GNULIB_GETPEERNAME)/g' \ -e 's/@''GNULIB_GETSOCKNAME''@/$(GNULIB_GETSOCKNAME)/g' \ -e 's/@''GNULIB_GETSOCKOPT''@/$(GNULIB_GETSOCKOPT)/g' \ -e 's/@''GNULIB_LISTEN''@/$(GNULIB_LISTEN)/g' \ -e 's/@''GNULIB_RECV''@/$(GNULIB_RECV)/g' \ -e 's/@''GNULIB_SEND''@/$(GNULIB_SEND)/g' \ -e 's/@''GNULIB_RECVFROM''@/$(GNULIB_RECVFROM)/g' \ -e 's/@''GNULIB_SENDTO''@/$(GNULIB_SENDTO)/g' \ -e 's/@''GNULIB_SETSOCKOPT''@/$(GNULIB_SETSOCKOPT)/g' \ -e 's/@''GNULIB_SHUTDOWN''@/$(GNULIB_SHUTDOWN)/g' \ -e 's/@''GNULIB_ACCEPT4''@/$(GNULIB_ACCEPT4)/g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY''@|$(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)|g' \ -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|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)/sys_socket.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t MOSTLYCLEANDIRS += sys EXTRA_DIST += sys_socket.in.h ## end gnulib module sys_socket ## begin gnulib module sys_stat BUILT_SOURCES += sys/stat.h # We need the following in order to create when the system # has one that is incomplete. sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \ -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \ -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \ -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \ -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \ -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \ -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \ -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \ -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \ -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \ -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \ -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \ -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \ -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|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)/sys_stat.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t MOSTLYCLEANDIRS += sys EXTRA_DIST += sys_stat.in.h ## end gnulib module sys_stat ## begin gnulib module sys_time BUILT_SOURCES += sys/time.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_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_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/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)/sys_time.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += sys/time.h sys/time.h-t EXTRA_DIST += sys_time.in.h ## end gnulib module sys_time ## begin gnulib module sys_types BUILT_SOURCES += sys/types.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/types.h: sys_types.in.h $(top_builddir)/config.status $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ < $(srcdir)/sys_types.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += sys/types.h sys/types.h-t EXTRA_DIST += sys_types.in.h ## end gnulib module sys_types ## begin gnulib module sys_uio BUILT_SOURCES += sys/uio.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/uio.h: sys_uio.in.h $(top_builddir)/config.status $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \ -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \ < $(srcdir)/sys_uio.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t MOSTLYCLEANDIRS += sys EXTRA_DIST += sys_uio.in.h ## end gnulib module sys_uio ## begin gnulib module threadlib libgnu_la_SOURCES += glthread/threadlib.c EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath ## end gnulib module threadlib ## begin gnulib module time BUILT_SOURCES += time.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_TIME_H''@|$(NEXT_TIME_H)|g' \ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|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)/time.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += time.h time.h-t EXTRA_DIST += time.in.h ## end gnulib module time ## begin gnulib module time_r EXTRA_DIST += time_r.c EXTRA_libgnu_la_SOURCES += time_r.c ## end gnulib module time_r ## begin gnulib module timespec libgnu_la_SOURCES += timespec.c EXTRA_DIST += timespec.h ## end gnulib module timespec ## begin gnulib module unistd BUILT_SOURCES += unistd.h libgnu_la_SOURCES += unistd.c # We need the following in order to create an empty placeholder for # when the system doesn't have one. unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_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_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \ -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \ -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \ -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \ -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \ -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \ -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \ -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \ -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \ -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \ -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \ -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \ -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \ -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \ -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \ -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \ -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \ -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \ -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \ -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \ -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \ -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \ -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \ -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \ -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \ -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \ -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \ -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \ -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \ -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \ -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \ -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \ -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \ -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \ -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \ -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \ -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \ -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \ -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \ -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \ -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \ -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \ -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \ -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \ -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \ -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \ -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \ -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \ < $(srcdir)/unistd.in.h | \ sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \ -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \ -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \ -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \ -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ | \ sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \ -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \ -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \ -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|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)'; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += unistd.h unistd.h-t EXTRA_DIST += unistd.in.h ## end gnulib module unistd ## begin gnulib module unistr/base BUILT_SOURCES += $(LIBUNISTRING_UNISTR_H) unistr.h: unistr.in.h $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/unistr.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += unistr.h unistr.h-t EXTRA_DIST += unistr.in.h ## end gnulib module unistr/base ## begin gnulib module unistr/u8-mbtoucr if LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR libgnu_la_SOURCES += unistr/u8-mbtoucr.c endif ## end gnulib module unistr/u8-mbtoucr ## begin gnulib module unistr/u8-uctomb if LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB libgnu_la_SOURCES += unistr/u8-uctomb.c unistr/u8-uctomb-aux.c endif ## end gnulib module unistr/u8-uctomb ## begin gnulib module unitypes BUILT_SOURCES += $(LIBUNISTRING_UNITYPES_H) unitypes.h: unitypes.in.h $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/unitypes.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += unitypes.h unitypes.h-t EXTRA_DIST += unitypes.in.h ## end gnulib module unitypes ## begin gnulib module uniwidth/base BUILT_SOURCES += $(LIBUNISTRING_UNIWIDTH_H) uniwidth.h: uniwidth.in.h $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/uniwidth.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += uniwidth.h uniwidth.h-t EXTRA_DIST += localcharset.h uniwidth.in.h ## end gnulib module uniwidth/base ## begin gnulib module uniwidth/width if LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH libgnu_la_SOURCES += uniwidth/width.c endif EXTRA_DIST += uniwidth/cjk.h ## end gnulib module uniwidth/width ## begin gnulib module unsetenv EXTRA_DIST += unsetenv.c EXTRA_libgnu_la_SOURCES += unsetenv.c ## end gnulib module unsetenv ## begin gnulib module vasnprintf EXTRA_DIST += asnprintf.c float+.h printf-args.c printf-args.h printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h EXTRA_libgnu_la_SOURCES += asnprintf.c printf-args.c printf-parse.c vasnprintf.c ## end gnulib module vasnprintf ## begin gnulib module verify EXTRA_DIST += verify.h ## end gnulib module verify ## begin gnulib module vsnprintf EXTRA_DIST += vsnprintf.c EXTRA_libgnu_la_SOURCES += vsnprintf.c ## end gnulib module vsnprintf ## begin gnulib module wchar BUILT_SOURCES += wchar.h # We need the following in order to create when the system # version does not work standalone. wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ -e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \ -e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \ -e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \ -e 's/@''GNULIB_MBRTOWC''@/$(GNULIB_MBRTOWC)/g' \ -e 's/@''GNULIB_MBRLEN''@/$(GNULIB_MBRLEN)/g' \ -e 's/@''GNULIB_MBSRTOWCS''@/$(GNULIB_MBSRTOWCS)/g' \ -e 's/@''GNULIB_MBSNRTOWCS''@/$(GNULIB_MBSNRTOWCS)/g' \ -e 's/@''GNULIB_WCRTOMB''@/$(GNULIB_WCRTOMB)/g' \ -e 's/@''GNULIB_WCSRTOMBS''@/$(GNULIB_WCSRTOMBS)/g' \ -e 's/@''GNULIB_WCSNRTOMBS''@/$(GNULIB_WCSNRTOMBS)/g' \ -e 's/@''GNULIB_WCWIDTH''@/$(GNULIB_WCWIDTH)/g' \ -e 's/@''GNULIB_WMEMCHR''@/$(GNULIB_WMEMCHR)/g' \ -e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \ -e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \ -e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \ -e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \ -e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \ -e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \ -e 's/@''GNULIB_WCSCPY''@/$(GNULIB_WCSCPY)/g' \ -e 's/@''GNULIB_WCPCPY''@/$(GNULIB_WCPCPY)/g' \ -e 's/@''GNULIB_WCSNCPY''@/$(GNULIB_WCSNCPY)/g' \ -e 's/@''GNULIB_WCPNCPY''@/$(GNULIB_WCPNCPY)/g' \ -e 's/@''GNULIB_WCSCAT''@/$(GNULIB_WCSCAT)/g' \ -e 's/@''GNULIB_WCSNCAT''@/$(GNULIB_WCSNCAT)/g' \ -e 's/@''GNULIB_WCSCMP''@/$(GNULIB_WCSCMP)/g' \ -e 's/@''GNULIB_WCSNCMP''@/$(GNULIB_WCSNCMP)/g' \ -e 's/@''GNULIB_WCSCASECMP''@/$(GNULIB_WCSCASECMP)/g' \ -e 's/@''GNULIB_WCSNCASECMP''@/$(GNULIB_WCSNCASECMP)/g' \ -e 's/@''GNULIB_WCSCOLL''@/$(GNULIB_WCSCOLL)/g' \ -e 's/@''GNULIB_WCSXFRM''@/$(GNULIB_WCSXFRM)/g' \ -e 's/@''GNULIB_WCSDUP''@/$(GNULIB_WCSDUP)/g' \ -e 's/@''GNULIB_WCSCHR''@/$(GNULIB_WCSCHR)/g' \ -e 's/@''GNULIB_WCSRCHR''@/$(GNULIB_WCSRCHR)/g' \ -e 's/@''GNULIB_WCSCSPN''@/$(GNULIB_WCSCSPN)/g' \ -e 's/@''GNULIB_WCSSPN''@/$(GNULIB_WCSSPN)/g' \ -e 's/@''GNULIB_WCSPBRK''@/$(GNULIB_WCSPBRK)/g' \ -e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \ -e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \ -e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \ < $(srcdir)/wchar.in.h | \ sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \ -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \ -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \ -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \ -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \ -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \ -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \ -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \ -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \ -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \ -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \ -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \ -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \ -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \ -e 's|@''HAVE_WCSCPY''@|$(HAVE_WCSCPY)|g' \ -e 's|@''HAVE_WCPCPY''@|$(HAVE_WCPCPY)|g' \ -e 's|@''HAVE_WCSNCPY''@|$(HAVE_WCSNCPY)|g' \ -e 's|@''HAVE_WCPNCPY''@|$(HAVE_WCPNCPY)|g' \ -e 's|@''HAVE_WCSCAT''@|$(HAVE_WCSCAT)|g' \ -e 's|@''HAVE_WCSNCAT''@|$(HAVE_WCSNCAT)|g' \ -e 's|@''HAVE_WCSCMP''@|$(HAVE_WCSCMP)|g' \ -e 's|@''HAVE_WCSNCMP''@|$(HAVE_WCSNCMP)|g' \ -e 's|@''HAVE_WCSCASECMP''@|$(HAVE_WCSCASECMP)|g' \ -e 's|@''HAVE_WCSNCASECMP''@|$(HAVE_WCSNCASECMP)|g' \ -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \ -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \ -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \ -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \ -e 's|@''HAVE_WCSRCHR''@|$(HAVE_WCSRCHR)|g' \ -e 's|@''HAVE_WCSCSPN''@|$(HAVE_WCSCSPN)|g' \ -e 's|@''HAVE_WCSSPN''@|$(HAVE_WCSSPN)|g' \ -e 's|@''HAVE_WCSPBRK''@|$(HAVE_WCSPBRK)|g' \ -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \ -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \ -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \ -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ | \ sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \ -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \ -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \ -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \ -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \ -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \ -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \ -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|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)'; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += wchar.h wchar.h-t EXTRA_DIST += wchar.in.h ## end gnulib module wchar ## begin gnulib module wcrtomb EXTRA_DIST += wcrtomb.c EXTRA_libgnu_la_SOURCES += wcrtomb.c ## end gnulib module wcrtomb ## begin gnulib module wctype-h BUILT_SOURCES += wctype.h libgnu_la_SOURCES += wctype-h.c # We need the following in order to create when the system # doesn't have one that works with the given compiler. wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_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_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \ -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \ -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \ -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \ -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \ -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \ -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \ -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/wctype.in.h; \ } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += wctype.h wctype.h-t EXTRA_DIST += wctype.in.h ## end gnulib module wctype-h ## begin gnulib module wcwidth EXTRA_DIST += wcwidth.c EXTRA_libgnu_la_SOURCES += wcwidth.c ## end gnulib module wcwidth ## begin gnulib module xalloc libgnu_la_SOURCES += xmalloc.c EXTRA_DIST += xalloc.h ## end gnulib module xalloc ## begin gnulib module xalloc-die libgnu_la_SOURCES += xalloc-die.c ## end gnulib module xalloc-die ## begin gnulib module xalloc-oversized EXTRA_DIST += xalloc-oversized.h ## end gnulib module xalloc-oversized ## begin gnulib module xsize libgnu_la_SOURCES += xsize.h xsize.c ## end gnulib module xsize ## begin gnulib module xstrtol libgnu_la_SOURCES += xstrtol.c xstrtoul.c xstrtol-error.c EXTRA_DIST += xstrtol.h ## end gnulib module xstrtol ## begin gnulib module xstrtoumax libgnu_la_SOURCES += xstrtoumax.c ## end gnulib module xstrtoumax mostlyclean-local: mostlyclean-generic @for dir in '' $(MOSTLYCLEANDIRS); do \ if test -n "$$dir" && test -d $$dir; then \ echo "rmdir $$dir"; rmdir $$dir; \ fi; \ done; \ : lftp-4.6.3a/lib/sys_socket.in.h0000644000015000007670000005451212466374012013301 00000000000000/* Provide a sys/socket header file for systems lacking it (read: MinGW) and for systems where it is incomplete. Copyright (C) 2005-2015 Free Software Foundation, Inc. Written by Simon Josefsson. 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 . */ /* This file is supposed to be used on platforms that lack , on platforms where cannot be included standalone, and on platforms where does not provide all necessary definitions. It is intended to provide definitions and prototypes needed by an application. */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H /* Special invocation convention: - On Cygwin 1.5.x we have a sequence of nested includes -> -> -> , and the latter includes . In this situation, the functions are not yet declared, therefore we cannot provide the C++ aliases. */ #@INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_SYS_SOCKET_H #if @HAVE_SYS_SOCKET_H@ # define _GL_ALREADY_INCLUDING_SYS_SOCKET_H /* On many platforms, assumes prior inclusion of . */ # include /* On FreeBSD 6.4, defines some macros that assume that NULL is defined. */ # include /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ # undef _GL_ALREADY_INCLUDING_SYS_SOCKET_H #endif #ifndef _@GUARD_PREFIX@_SYS_SOCKET_H #define _@GUARD_PREFIX@_SYS_SOCKET_H #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_SYS_SOCKET_INLINE # define _GL_SYS_SOCKET_INLINE _GL_INLINE #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. */ #if !@HAVE_SA_FAMILY_T@ # if !GNULIB_defined_sa_family_t typedef unsigned short sa_family_t; # define GNULIB_defined_sa_family_t 1 # endif #endif #if @HAVE_STRUCT_SOCKADDR_STORAGE@ /* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1. */ # if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@ # ifndef ss_family # define ss_family __ss_family # endif # endif #else # include /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ # define __ss_aligntype unsigned long int # define _SS_SIZE 256 # define _SS_PADSIZE \ (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \ ? sizeof (sa_family_t) \ : alignof (__ss_aligntype)) \ + sizeof (__ss_aligntype))) # if !GNULIB_defined_struct_sockaddr_storage struct sockaddr_storage { sa_family_t ss_family; /* Address family, etc. */ __ss_aligntype __ss_align; /* Force desired alignment. */ char __ss_padding[_SS_PADSIZE]; }; # define GNULIB_defined_struct_sockaddr_storage 1 # endif #endif /* Get struct iovec. */ /* But avoid namespace pollution on glibc systems. */ #if ! defined __GLIBC__ # include #endif #if @HAVE_SYS_SOCKET_H@ /* A platform that has . */ /* For shutdown(). */ # if !defined SHUT_RD # define SHUT_RD 0 # endif # if !defined SHUT_WR # define SHUT_WR 1 # endif # if !defined SHUT_RDWR # define SHUT_RDWR 2 # endif #else # ifdef __CYGWIN__ # error "Cygwin does have a sys/socket.h, doesn't it?!?" # endif /* A platform that lacks . Currently only MinGW is supported. See the gnulib manual regarding Windows sockets. MinGW has the header files winsock2.h and ws2tcpip.h that declare the sys/socket.h definitions we need. Note that you can influence which definitions you get by setting the WINVER symbol before including these two files. For example, getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that symbol is set indirectly through WINVER). You can set this by adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your code may not run on older Windows releases then. My Windows 2000 box was not able to run the code, for example. The situation is slightly confusing because suggests that getaddrinfo should be available on all Windows releases. */ # if @HAVE_WINSOCK2_H@ # include # endif # if @HAVE_WS2TCPIP_H@ # include # endif /* For shutdown(). */ # if !defined SHUT_RD && defined SD_RECEIVE # define SHUT_RD SD_RECEIVE # endif # if !defined SHUT_WR && defined SD_SEND # define SHUT_WR SD_SEND # endif # if !defined SHUT_RDWR && defined SD_BOTH # define SHUT_RDWR SD_BOTH # endif # if @HAVE_WINSOCK2_H@ /* Include headers needed by the emulation code. */ # include # include # if !GNULIB_defined_socklen_t typedef int socklen_t; # define GNULIB_defined_socklen_t 1 # endif # endif /* Rudimentary 'struct msghdr'; this works as long as you don't try to access msg_control or msg_controllen. */ struct msghdr { void *msg_name; socklen_t msg_namelen; struct iovec *msg_iov; int msg_iovlen; int msg_flags; }; #endif /* Fix some definitions from . */ #if @HAVE_WINSOCK2_H@ # if !GNULIB_defined_rpl_fd_isset /* Re-define FD_ISSET to avoid a WSA call while we are not using network sockets. */ _GL_SYS_SOCKET_INLINE int rpl_fd_isset (SOCKET fd, fd_set * set) { u_int i; if (set == NULL) return 0; for (i = 0; i < set->fd_count; i++) if (set->fd_array[i] == fd) return 1; return 0; } # define GNULIB_defined_rpl_fd_isset 1 # endif # undef FD_ISSET # define FD_ISSET(fd, set) rpl_fd_isset(fd, set) #endif /* Hide some function declarations from . */ #if @HAVE_WINSOCK2_H@ # if !defined _@GUARD_PREFIX@_UNISTD_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef close # define close close_used_without_including_unistd_h # else _GL_WARN_ON_USE (close, "close() used without including "); # endif # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef gethostname # define gethostname gethostname_used_without_including_unistd_h # else _GL_WARN_ON_USE (gethostname, "gethostname() used without including "); # endif # endif # if !defined _@GUARD_PREFIX@_SYS_SELECT_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef select # define select select_used_without_including_sys_select_h # else _GL_WARN_ON_USE (select, "select() used without including "); # endif # endif #endif /* Wrap everything else to use libc file descriptors for sockets. */ #if @GNULIB_SOCKET@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef socket # define socket rpl_socket # endif _GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol)); _GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol)); # else _GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol)); # endif _GL_CXXALIASWARN (socket); #elif @HAVE_WINSOCK2_H@ # undef socket # define socket socket_used_without_requesting_gnulib_module_socket #elif defined GNULIB_POSIXCHECK # undef socket # if HAVE_RAW_DECL_SOCKET _GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - " "use gnulib module socket for portability"); # endif #endif #if @GNULIB_CONNECT@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef connect # define connect rpl_connect # endif _GL_FUNCDECL_RPL (connect, int, (int fd, const struct sockaddr *addr, socklen_t addrlen) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (connect, int, (int fd, const struct sockaddr *addr, socklen_t addrlen)); # else /* Need to cast, because on NonStop Kernel, the third parameter is size_t addrlen. */ _GL_CXXALIAS_SYS_CAST (connect, int, (int fd, const struct sockaddr *addr, socklen_t addrlen)); # endif _GL_CXXALIASWARN (connect); #elif @HAVE_WINSOCK2_H@ # undef connect # define connect socket_used_without_requesting_gnulib_module_connect #elif defined GNULIB_POSIXCHECK # undef connect # if HAVE_RAW_DECL_CONNECT _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - " "use gnulib module connect for portability"); # endif #endif #if @GNULIB_ACCEPT@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef accept # define accept rpl_accept # endif _GL_FUNCDECL_RPL (accept, int, (int fd, struct sockaddr *addr, socklen_t *addrlen)); _GL_CXXALIAS_RPL (accept, int, (int fd, struct sockaddr *addr, socklen_t *addrlen)); # else /* Need to cast, because on Solaris 10 systems, the third parameter is void *addrlen. */ _GL_CXXALIAS_SYS_CAST (accept, int, (int fd, struct sockaddr *addr, socklen_t *addrlen)); # endif _GL_CXXALIASWARN (accept); #elif @HAVE_WINSOCK2_H@ # undef accept # define accept accept_used_without_requesting_gnulib_module_accept #elif defined GNULIB_POSIXCHECK # undef accept # if HAVE_RAW_DECL_ACCEPT _GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - " "use gnulib module accept for portability"); # endif #endif #if @GNULIB_BIND@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef bind # define bind rpl_bind # endif _GL_FUNCDECL_RPL (bind, int, (int fd, const struct sockaddr *addr, socklen_t addrlen) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (bind, int, (int fd, const struct sockaddr *addr, socklen_t addrlen)); # else /* Need to cast, because on NonStop Kernel, the third parameter is size_t addrlen. */ _GL_CXXALIAS_SYS_CAST (bind, int, (int fd, const struct sockaddr *addr, socklen_t addrlen)); # endif _GL_CXXALIASWARN (bind); #elif @HAVE_WINSOCK2_H@ # undef bind # define bind bind_used_without_requesting_gnulib_module_bind #elif defined GNULIB_POSIXCHECK # undef bind # if HAVE_RAW_DECL_BIND _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - " "use gnulib module bind for portability"); # endif #endif #if @GNULIB_GETPEERNAME@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getpeername # define getpeername rpl_getpeername # endif _GL_FUNCDECL_RPL (getpeername, int, (int fd, struct sockaddr *addr, socklen_t *addrlen) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (getpeername, int, (int fd, struct sockaddr *addr, socklen_t *addrlen)); # else /* Need to cast, because on Solaris 10 systems, the third parameter is void *addrlen. */ _GL_CXXALIAS_SYS_CAST (getpeername, int, (int fd, struct sockaddr *addr, socklen_t *addrlen)); # endif _GL_CXXALIASWARN (getpeername); #elif @HAVE_WINSOCK2_H@ # undef getpeername # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername #elif defined GNULIB_POSIXCHECK # undef getpeername # if HAVE_RAW_DECL_GETPEERNAME _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - " "use gnulib module getpeername for portability"); # endif #endif #if @GNULIB_GETSOCKNAME@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getsockname # define getsockname rpl_getsockname # endif _GL_FUNCDECL_RPL (getsockname, int, (int fd, struct sockaddr *addr, socklen_t *addrlen) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (getsockname, int, (int fd, struct sockaddr *addr, socklen_t *addrlen)); # else /* Need to cast, because on Solaris 10 systems, the third parameter is void *addrlen. */ _GL_CXXALIAS_SYS_CAST (getsockname, int, (int fd, struct sockaddr *addr, socklen_t *addrlen)); # endif _GL_CXXALIASWARN (getsockname); #elif @HAVE_WINSOCK2_H@ # undef getsockname # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname #elif defined GNULIB_POSIXCHECK # undef getsockname # if HAVE_RAW_DECL_GETSOCKNAME _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - " "use gnulib module getsockname for portability"); # endif #endif #if @GNULIB_GETSOCKOPT@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getsockopt # define getsockopt rpl_getsockopt # endif _GL_FUNCDECL_RPL (getsockopt, int, (int fd, int level, int optname, void *optval, socklen_t *optlen) _GL_ARG_NONNULL ((4, 5))); _GL_CXXALIAS_RPL (getsockopt, int, (int fd, int level, int optname, void *optval, socklen_t *optlen)); # else /* Need to cast, because on Solaris 10 systems, the fifth parameter is void *optlen. */ _GL_CXXALIAS_SYS_CAST (getsockopt, int, (int fd, int level, int optname, void *optval, socklen_t *optlen)); # endif _GL_CXXALIASWARN (getsockopt); #elif @HAVE_WINSOCK2_H@ # undef getsockopt # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt #elif defined GNULIB_POSIXCHECK # undef getsockopt # if HAVE_RAW_DECL_GETSOCKOPT _GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - " "use gnulib module getsockopt for portability"); # endif #endif #if @GNULIB_LISTEN@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef listen # define listen rpl_listen # endif _GL_FUNCDECL_RPL (listen, int, (int fd, int backlog)); _GL_CXXALIAS_RPL (listen, int, (int fd, int backlog)); # else _GL_CXXALIAS_SYS (listen, int, (int fd, int backlog)); # endif _GL_CXXALIASWARN (listen); #elif @HAVE_WINSOCK2_H@ # undef listen # define listen listen_used_without_requesting_gnulib_module_listen #elif defined GNULIB_POSIXCHECK # undef listen # if HAVE_RAW_DECL_LISTEN _GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - " "use gnulib module listen for portability"); # endif #endif #if @GNULIB_RECV@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef recv # define recv rpl_recv # endif _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); # else _GL_CXXALIAS_SYS (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); # endif _GL_CXXALIASWARN (recv); #elif @HAVE_WINSOCK2_H@ # undef recv # define recv recv_used_without_requesting_gnulib_module_recv #elif defined GNULIB_POSIXCHECK # undef recv # if HAVE_RAW_DECL_RECV _GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - " "use gnulib module recv for portability"); # endif #endif #if @GNULIB_SEND@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef send # define send rpl_send # endif _GL_FUNCDECL_RPL (send, ssize_t, (int fd, const void *buf, size_t len, int flags) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (send, ssize_t, (int fd, const void *buf, size_t len, int flags)); # else _GL_CXXALIAS_SYS (send, ssize_t, (int fd, const void *buf, size_t len, int flags)); # endif _GL_CXXALIASWARN (send); #elif @HAVE_WINSOCK2_H@ # undef send # define send send_used_without_requesting_gnulib_module_send #elif defined GNULIB_POSIXCHECK # undef send # if HAVE_RAW_DECL_SEND _GL_WARN_ON_USE (send, "send is not always POSIX compliant - " "use gnulib module send for portability"); # endif #endif #if @GNULIB_RECVFROM@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef recvfrom # define recvfrom rpl_recvfrom # endif _GL_FUNCDECL_RPL (recvfrom, ssize_t, (int fd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (recvfrom, ssize_t, (int fd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)); # else /* Need to cast, because on Solaris 10 systems, the sixth parameter is void *fromlen. */ _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t, (int fd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)); # endif _GL_CXXALIASWARN (recvfrom); #elif @HAVE_WINSOCK2_H@ # undef recvfrom # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom #elif defined GNULIB_POSIXCHECK # undef recvfrom # if HAVE_RAW_DECL_RECVFROM _GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - " "use gnulib module recvfrom for portability"); # endif #endif #if @GNULIB_SENDTO@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef sendto # define sendto rpl_sendto # endif _GL_FUNCDECL_RPL (sendto, ssize_t, (int fd, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (sendto, ssize_t, (int fd, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)); # else /* Need to cast, because on NonStop Kernel, the sixth parameter is size_t tolen. */ _GL_CXXALIAS_SYS_CAST (sendto, ssize_t, (int fd, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)); # endif _GL_CXXALIASWARN (sendto); #elif @HAVE_WINSOCK2_H@ # undef sendto # define sendto sendto_used_without_requesting_gnulib_module_sendto #elif defined GNULIB_POSIXCHECK # undef sendto # if HAVE_RAW_DECL_SENDTO _GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - " "use gnulib module sendto for portability"); # endif #endif #if @GNULIB_SETSOCKOPT@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef setsockopt # define setsockopt rpl_setsockopt # endif _GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname, const void * optval, socklen_t optlen) _GL_ARG_NONNULL ((4))); _GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname, const void * optval, socklen_t optlen)); # else /* Need to cast, because on NonStop Kernel, the fifth parameter is size_t optlen. */ _GL_CXXALIAS_SYS_CAST (setsockopt, int, (int fd, int level, int optname, const void * optval, socklen_t optlen)); # endif _GL_CXXALIASWARN (setsockopt); #elif @HAVE_WINSOCK2_H@ # undef setsockopt # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt #elif defined GNULIB_POSIXCHECK # undef setsockopt # if HAVE_RAW_DECL_SETSOCKOPT _GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - " "use gnulib module setsockopt for portability"); # endif #endif #if @GNULIB_SHUTDOWN@ # if @HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef shutdown # define shutdown rpl_shutdown # endif _GL_FUNCDECL_RPL (shutdown, int, (int fd, int how)); _GL_CXXALIAS_RPL (shutdown, int, (int fd, int how)); # else _GL_CXXALIAS_SYS (shutdown, int, (int fd, int how)); # endif _GL_CXXALIASWARN (shutdown); #elif @HAVE_WINSOCK2_H@ # undef shutdown # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown #elif defined GNULIB_POSIXCHECK # undef shutdown # if HAVE_RAW_DECL_SHUTDOWN _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - " "use gnulib module shutdown for portability"); # endif #endif #if @GNULIB_ACCEPT4@ /* Accept a connection on a socket, with specific opening flags. The flags are a bitmask, possibly including O_CLOEXEC (defined in ) and O_TEXT, O_BINARY (defined in "binary-io.h"). See also the Linux man page at . */ # if @HAVE_ACCEPT4@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define accept4 rpl_accept4 # endif _GL_FUNCDECL_RPL (accept4, int, (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)); _GL_CXXALIAS_RPL (accept4, int, (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)); # else _GL_FUNCDECL_SYS (accept4, int, (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)); _GL_CXXALIAS_SYS (accept4, int, (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)); # endif _GL_CXXALIASWARN (accept4); #elif defined GNULIB_POSIXCHECK # undef accept4 # if HAVE_RAW_DECL_ACCEPT4 _GL_WARN_ON_USE (accept4, "accept4 is unportable - " "use gnulib module accept4 for portability"); # endif #endif _GL_INLINE_HEADER_END #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */ #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */ #endif lftp-4.6.3a/lib/dirent.in.h0000644000015000007670000002101512477560611012374 00000000000000/* A GNU-like . Copyright (C) 2006-2015 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 . */ #ifndef _@GUARD_PREFIX@_DIRENT_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_DIRENT_H@ # @INCLUDE_NEXT@ @NEXT_DIRENT_H@ #endif #ifndef _@GUARD_PREFIX@_DIRENT_H #define _@GUARD_PREFIX@_DIRENT_H /* Get ino_t. Needed on some systems, including glibc 2.8. */ #include #if !@HAVE_DIRENT_H@ /* Define types DIR and 'struct dirent'. */ # if !GNULIB_defined_struct_dirent struct dirent { char d_type; char d_name[1]; }; /* Possible values for 'd_type'. */ # define DT_UNKNOWN 0 # define DT_FIFO 1 /* FIFO */ # define DT_CHR 2 /* character device */ # define DT_DIR 4 /* directory */ # define DT_BLK 6 /* block device */ # define DT_REG 8 /* regular file */ # define DT_LNK 10 /* symbolic link */ # define DT_SOCK 12 /* socket */ # define DT_WHT 14 /* whiteout */ typedef struct gl_directory DIR; # define GNULIB_defined_struct_dirent 1 # endif #endif /* The __attribute__ feature is available in gcc versions 2.5 and later. The attribute __pure__ was added in gcc 2.96. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else # define _GL_ATTRIBUTE_PURE /* empty */ #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. */ /* Declare overridden functions. */ #if @GNULIB_OPENDIR@ # if @REPLACE_OPENDIR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef opendir # define opendir rpl_opendir # define GNULIB_defined_opendir 1 # endif _GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name)); # else # if !@HAVE_OPENDIR@ _GL_FUNCDECL_SYS (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name)); # endif _GL_CXXALIASWARN (opendir); #elif defined GNULIB_POSIXCHECK # undef opendir # if HAVE_RAW_DECL_OPENDIR _GL_WARN_ON_USE (opendir, "opendir is not portable - " "use gnulib module opendir for portability"); # endif #endif #if @GNULIB_READDIR@ # if !@HAVE_READDIR@ _GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp)); _GL_CXXALIASWARN (readdir); #elif defined GNULIB_POSIXCHECK # undef readdir # if HAVE_RAW_DECL_READDIR _GL_WARN_ON_USE (readdir, "readdir is not portable - " "use gnulib module readdir for portability"); # endif #endif #if @GNULIB_REWINDDIR@ # if !@HAVE_REWINDDIR@ _GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp)); _GL_CXXALIASWARN (rewinddir); #elif defined GNULIB_POSIXCHECK # undef rewinddir # if HAVE_RAW_DECL_REWINDDIR _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - " "use gnulib module rewinddir for portability"); # endif #endif #if @GNULIB_CLOSEDIR@ # if @REPLACE_CLOSEDIR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef closedir # define closedir rpl_closedir # define GNULIB_defined_closedir 1 # endif _GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (closedir, int, (DIR *dirp)); # else # if !@HAVE_CLOSEDIR@ _GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (closedir, int, (DIR *dirp)); # endif _GL_CXXALIASWARN (closedir); #elif defined GNULIB_POSIXCHECK # undef closedir # if HAVE_RAW_DECL_CLOSEDIR _GL_WARN_ON_USE (closedir, "closedir is not portable - " "use gnulib module closedir for portability"); # endif #endif #if @GNULIB_DIRFD@ /* Return the file descriptor associated with the given directory stream, or -1 if none exists. */ # if @REPLACE_DIRFD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef dirfd # define dirfd rpl_dirfd # endif _GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (dirfd, int, (DIR *)); # else # if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd /* dirfd is defined as a macro and not as a function. Turn it into a function and get rid of the macro. */ static inline int (dirfd) (DIR *dp) { return dirfd (dp); } # undef dirfd # endif # if !(@HAVE_DECL_DIRFD@ || defined dirfd) _GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (dirfd, int, (DIR *)); # endif _GL_CXXALIASWARN (dirfd); #elif defined GNULIB_POSIXCHECK # undef dirfd # if HAVE_RAW_DECL_DIRFD _GL_WARN_ON_USE (dirfd, "dirfd is unportable - " "use gnulib module dirfd for portability"); # endif #endif #if @GNULIB_FDOPENDIR@ /* Open a directory stream visiting the given directory file descriptor. Return NULL and set errno if fd is not visiting a directory. On success, this function consumes fd (it will be implicitly closed either by this function or by a subsequent closedir). */ # if @REPLACE_FDOPENDIR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fdopendir # define fdopendir rpl_fdopendir # endif _GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd)); _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd)); # else # if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@ _GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd)); # endif _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd)); # endif _GL_CXXALIASWARN (fdopendir); #elif defined GNULIB_POSIXCHECK # undef fdopendir # if HAVE_RAW_DECL_FDOPENDIR _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - " "use gnulib module fdopendir for portability"); # endif #endif #if @GNULIB_SCANDIR@ /* Scan the directory DIR, calling FILTER on each directory entry. Entries for which FILTER returns nonzero are individually malloc'd, sorted using qsort with CMP, and collected in a malloc'd array in *NAMELIST. Returns the number of entries selected, or -1 on error. */ # if !@HAVE_SCANDIR@ _GL_FUNCDECL_SYS (scandir, int, (const char *dir, struct dirent ***namelist, int (*filter) (const struct dirent *), int (*cmp) (const struct dirent **, const struct dirent **)) _GL_ARG_NONNULL ((1, 2, 4))); # endif /* Need to cast, because on glibc systems, the fourth parameter is int (*cmp) (const void *, const void *). */ _GL_CXXALIAS_SYS_CAST (scandir, int, (const char *dir, struct dirent ***namelist, int (*filter) (const struct dirent *), int (*cmp) (const struct dirent **, const struct dirent **))); _GL_CXXALIASWARN (scandir); #elif defined GNULIB_POSIXCHECK # undef scandir # if HAVE_RAW_DECL_SCANDIR _GL_WARN_ON_USE (scandir, "scandir is unportable - " "use gnulib module scandir for portability"); # endif #endif #if @GNULIB_ALPHASORT@ /* Compare two 'struct dirent' entries alphabetically. */ # if !@HAVE_ALPHASORT@ _GL_FUNCDECL_SYS (alphasort, int, (const struct dirent **, const struct dirent **) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif /* Need to cast, because on glibc systems, the parameters are (const void *, const void *). */ _GL_CXXALIAS_SYS_CAST (alphasort, int, (const struct dirent **, const struct dirent **)); _GL_CXXALIASWARN (alphasort); #elif defined GNULIB_POSIXCHECK # undef alphasort # if HAVE_RAW_DECL_ALPHASORT _GL_WARN_ON_USE (alphasort, "alphasort is unportable - " "use gnulib module alphasort for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_DIRENT_H */ #endif /* _@GUARD_PREFIX@_DIRENT_H */ lftp-4.6.3a/lib/sockets.h0000644000015000007670000000317512466374012012160 00000000000000/* sockets.h - wrappers for Windows socket functions Copyright (C) 2008-2015 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 . */ /* Written by Simon Josefsson */ #ifndef SOCKETS_H # define SOCKETS_H 1 #define SOCKETS_1_0 0x100 /* don't use - does not work on Windows XP */ #define SOCKETS_1_1 0x101 #define SOCKETS_2_0 0x200 /* don't use - does not work on Windows XP */ #define SOCKETS_2_1 0x201 #define SOCKETS_2_2 0x202 int gl_sockets_startup (int version) #if !WINDOWS_SOCKETS _GL_ATTRIBUTE_CONST #endif ; int gl_sockets_cleanup (void) #if !WINDOWS_SOCKETS _GL_ATTRIBUTE_CONST #endif ; /* This function is useful it you create a socket using gnulib's Winsock wrappers but needs to pass on the socket handle to some other library that only accepts sockets. */ #if WINDOWS_SOCKETS #include #include "msvc-nothrow.h" static inline SOCKET gl_fd_to_handle (int fd) { return _get_osfhandle (fd); } #else #define gl_fd_to_handle(x) (x) #endif /* WINDOWS_SOCKETS */ #endif /* SOCKETS_H */ lftp-4.6.3a/lib/iconv_open-hpux.gperf0000644000015000007670000000214212122621312014456 00000000000000struct mapping { int standard_name; const char vendor_name[9 + 1]; }; %struct-type %language=ANSI-C %define slot-name standard_name %define hash-function-name mapping_hash %define lookup-function-name mapping_lookup %readonly-tables %global-table %define word-array-name mappings %pic %% # On HP-UX 11.11, look in /usr/lib/nls/iconv. ISO-8859-1, "iso88591" ISO-8859-2, "iso88592" ISO-8859-5, "iso88595" ISO-8859-6, "iso88596" ISO-8859-7, "iso88597" ISO-8859-8, "iso88598" ISO-8859-9, "iso88599" ISO-8859-15, "iso885915" CP437, "cp437" CP775, "cp775" CP850, "cp850" CP852, "cp852" CP855, "cp855" CP857, "cp857" CP861, "cp861" CP862, "cp862" CP864, "cp864" CP865, "cp865" CP866, "cp866" CP869, "cp869" CP874, "cp874" CP1250, "cp1250" CP1251, "cp1251" CP1252, "cp1252" CP1253, "cp1253" CP1254, "cp1254" CP1255, "cp1255" CP1256, "cp1256" CP1257, "cp1257" CP1258, "cp1258" HP-ROMAN8, "roman8" HP-ARABIC8, "arabic8" HP-GREEK8, "greek8" HP-HEBREW8, "hebrew8" HP-TURKISH8, "turkish8" HP-KANA8, "kana8" TIS-620, "tis620" GB2312, "hp15CN" EUC-JP, "eucJP" EUC-KR, "eucKR" EUC-TW, "eucTW" BIG5, "big5" SHIFT_JIS, "sjis" UTF-8, "utf8" lftp-4.6.3a/lib/stdalign.in.h0000644000015000007670000001031512466374012012711 00000000000000/* A substitute for ISO C11 . Copyright 2011-2015 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 . */ /* Written by Paul Eggert and Bruno Haible. */ #ifndef _GL_STDALIGN_H #define _GL_STDALIGN_H /* ISO C11 for platforms that lack it. References: ISO C11 (latest free draft ) sections 6.5.3.4, 6.7.5, 7.15. C++11 (latest free draft ) section 18.10. */ /* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment requirement of a structure member (i.e., slot or field) that is of type TYPE, as an integer constant expression. This differs from GCC's __alignof__ operator, which can yield a better-performing alignment for an object of that type. For example, on x86 with GCC, __alignof__ (double) and __alignof__ (long long) are 8, whereas alignof (double) and alignof (long long) are 4 unless the option '-malign-double' is used. The result cannot be used as a value for an 'enum' constant, if you want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. Include for offsetof. */ #include /* FreeBSD 9.1 , included by and lots of other standard headers, defines conflicting implementations of _Alignas and _Alignof that are no better than ours; override them. */ #undef _Alignas #undef _Alignof #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 # ifdef __cplusplus # if 201103 <= __cplusplus # define _Alignof(type) alignof (type) # else template struct __alignof_helper { char __a; __t __b; }; # define _Alignof(type) offsetof (__alignof_helper, __b) # endif # else # define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) # endif #endif #define alignof _Alignof #define __alignof_is_defined 1 /* alignas (A), also known as _Alignas (A), aligns a variable or type to the alignment A, where A is an integer constant expression. For example: int alignas (8) foo; struct s { int a; int alignas (8) bar; }; aligns the address of FOO and the offset of BAR to be multiples of 8. A should be a power of two that is at least the type's alignment and at most the implementation's alignment limit. This limit is 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable to MSVC through at least version 10.0, A should be an integer constant, as MSVC does not support expressions such as 1 << 3. To be portable to Sun C 5.11, do not align auto variables to anything stricter than their default alignment. The following C11 requirements are not supported here: - If A is zero, alignas has no effect. - alignas can be used multiple times; the strictest one wins. - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). */ #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 # if defined __cplusplus && 201103 <= __cplusplus # define _Alignas(a) alignas (a) # elif ((defined __APPLE__ && defined __MACH__ \ ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ : __GNUC__) \ || __HP_cc || __HP_aCC || __IBMC__ || __IBMCPP__ \ || __ICC || 0x5110 <= __SUNPRO_C) # define _Alignas(a) __attribute__ ((__aligned__ (a))) # elif 1300 <= _MSC_VER # define _Alignas(a) __declspec (align (a)) # endif #endif #if defined _Alignas || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__) # define alignas _Alignas # define __alignas_is_defined 1 #endif #endif /* _GL_STDALIGN_H */ lftp-4.6.3a/lib/iconv_open-solaris.h0000644000015000007670000001570012122621410014275 00000000000000/* ANSI-C code produced by gperf version 3.0.4 */ /* Command-line: gperf -m 10 ./iconv_open-solaris.gperf */ /* Computed positions: -k'10' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "./iconv_open-solaris.gperf" struct mapping { int standard_name; const char vendor_name[10 + 1]; }; #define TOTAL_KEYWORDS 13 #define MIN_WORD_LENGTH 5 #define MAX_WORD_LENGTH 11 #define MIN_HASH_VALUE 5 #define MAX_HASH_VALUE 19 /* maximum key range = 15, duplicates = 0 */ #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static unsigned int mapping_hash (register const char *str, register unsigned int len) { static const unsigned char asso_values[] = { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 9, 8, 7, 6, 5, 4, 3, 2, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }; register int hval = len; switch (hval) { default: hval += asso_values[(unsigned char)str[9]]; /*FALLTHROUGH*/ case 9: case 8: case 7: case 6: case 5: break; } return hval; } struct stringpool_t { char stringpool_str5[sizeof("ASCII")]; char stringpool_str6[sizeof("CP1251")]; char stringpool_str7[sizeof("$ abc")]; char stringpool_str10[sizeof("ISO-8859-1")]; char stringpool_str11[sizeof("ISO-8859-15")]; char stringpool_str12[sizeof("ISO-8859-9")]; char stringpool_str13[sizeof("ISO-8859-8")]; char stringpool_str14[sizeof("ISO-8859-7")]; char stringpool_str15[sizeof("ISO-8859-6")]; char stringpool_str16[sizeof("ISO-8859-5")]; char stringpool_str17[sizeof("ISO-8859-4")]; char stringpool_str18[sizeof("ISO-8859-3")]; char stringpool_str19[sizeof("ISO-8859-2")]; }; static const struct stringpool_t stringpool_contents = { "ASCII", "CP1251", "$ abc", "ISO-8859-1", "ISO-8859-15", "ISO-8859-9", "ISO-8859-8", "ISO-8859-7", "ISO-8859-6", "ISO-8859-5", "ISO-8859-4", "ISO-8859-3", "ISO-8859-2" }; #define stringpool ((const char *) &stringpool_contents) static const struct mapping mappings[] = { {-1}, {-1}, {-1}, {-1}, {-1}, #line 19 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str5, "646"}, #line 30 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str6, "ansi-1251"}, #line 18 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str7}, {-1}, {-1}, #line 20 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str10, "ISO8859-1"}, #line 29 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str11, "ISO8859-15"}, #line 28 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str12, "ISO8859-9"}, #line 27 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str13, "ISO8859-8"}, #line 26 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str14, "ISO8859-7"}, #line 25 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, "ISO8859-6"}, #line 24 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str16, "ISO8859-5"}, #line 23 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str17, "ISO8859-4"}, #line 22 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, "ISO8859-3"}, #line 21 "./iconv_open-solaris.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str19, "ISO8859-2"} }; #ifdef __GNUC__ __inline #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ __attribute__ ((__gnu_inline__)) #endif #endif const struct mapping * mapping_lookup (register const char *str, register unsigned int len) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { register int key = mapping_hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) { register int o = mappings[key].standard_name; if (o >= 0) { register const char *s = o + stringpool; if (*str == *s && !strcmp (str + 1, s + 1)) return &mappings[key]; } } } return 0; } lftp-4.6.3a/lib/getopt.c0000644000015000007670000012140612477560611012004 00000000000000/* Getopt for GNU. NOTE: getopt is part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2015 Free Software Foundation, Inc. This file is part of 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 . */ #ifndef _LIBC # include #endif #include "getopt.h" #include #include #include #include #ifdef _LIBC # include #else # include "gettext.h" # define _(msgid) gettext (msgid) #endif #if defined _LIBC && defined USE_IN_LIBIO # include #endif /* This version of 'getopt' appears to the caller like standard Unix 'getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As 'getopt_long' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Using 'getopt' or setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt_int.h" /* For communication from 'getopt' to the caller. When 'getopt' finds an option that takes an argument, the argument value is returned here. Also, when 'ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to 'getopt'. On entry to 'getopt', zero means this is the first call; initialize. When 'getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, 'optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Keep a global copy of all internal members of getopt_data. */ static struct _getopt_data getopt_data; #if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV extern char *getenv (); #endif #ifdef _LIBC /* Stored original parameters. XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ extern int __libc_argc; extern char **__libc_argv; /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ # ifdef USE_NONOPTION_FLAGS /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; # endif # ifdef USE_NONOPTION_FLAGS # define SWAP_FLAGS(ch1, ch2) \ if (d->__nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } # else # define SWAP_FLAGS(ch1, ch2) # endif #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. 'first_nonopt' and 'last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ static void exchange (char **argv, struct _getopt_data *d) { int bottom = d->__first_nonopt; int middle = d->__last_nonopt; int top = d->optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ #if defined _LIBC && defined USE_NONOPTION_FLAGS /* First make sure the handling of the '__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0; else { memset (__mempcpy (new_str, __getopt_nonoption_flags, d->__nonoption_flags_max_len), '\0', top + 1 - d->__nonoption_flags_max_len); d->__nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ d->__first_nonopt += (d->optind - d->__last_nonopt); d->__last_nonopt = d->optind; } /* Initialize the internal data when the first call is made. */ static const char * _getopt_initialize (int argc _GL_UNUSED, char **argv _GL_UNUSED, const char *optstring, struct _getopt_data *d, int posixly_correct) { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ d->__first_nonopt = d->__last_nonopt = d->optind; d->__nextchar = NULL; d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { d->__ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { d->__ordering = REQUIRE_ORDER; ++optstring; } else if (d->__posixly_correct) d->__ordering = REQUIRE_ORDER; else d->__ordering = PERMUTE; #if defined _LIBC && defined USE_NONOPTION_FLAGS if (!d->__posixly_correct && argc == __libc_argc && argv == __libc_argv) { if (d->__nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') d->__nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = d->__nonoption_flags_max_len = strlen (orig_str); if (d->__nonoption_flags_max_len < argc) d->__nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (d->__nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) d->__nonoption_flags_max_len = -1; else memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), '\0', d->__nonoption_flags_max_len - len); } } d->__nonoption_flags_len = d->__nonoption_flags_max_len; } else d->__nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If 'getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If 'getopt' finds another option character, it returns that character, updating 'optind' and 'nextchar' so that the next call to 'getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, 'getopt' returns -1. Then 'optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set 'opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in 'optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in 'optarg', otherwise 'optarg' is set to zero. If OPTSTRING starts with '-' or '+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with '--' instead of '-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a '=', or else the in next ARGV-element. When 'getopt' finds a long-named option, it returns 0 if that option's 'flag' field is nonzero, the value of the option's 'val' field if the 'flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of 'struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal_r (int argc, char **argv, const char *optstring, const struct option *longopts, int *longind, int long_only, struct _getopt_data *d, int posixly_correct) { int print_errors = d->opterr; if (argc < 1) return -1; d->optarg = NULL; if (d->optind == 0 || !d->__initialized) { if (d->optind == 0) d->optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring, d, posixly_correct); d->__initialized = 1; } else if (optstring[0] == '-' || optstring[0] == '+') optstring++; if (optstring[0] == ':') print_errors = 0; /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #if defined _LIBC && defined USE_NONOPTION_FLAGS # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \ || (d->optind < d->__nonoption_flags_len \ && __getopt_nonoption_flags[d->optind] == '1')) #else # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') #endif if (d->__nextchar == NULL || *d->__nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (d->__last_nonopt > d->optind) d->__last_nonopt = d->optind; if (d->__first_nonopt > d->optind) d->__first_nonopt = d->optind; if (d->__ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) exchange ((char **) argv, d); else if (d->__last_nonopt != d->optind) d->__first_nonopt = d->optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (d->optind < argc && NONOPTION_P) d->optind++; d->__last_nonopt = d->optind; } /* The special ARGV-element '--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (d->optind != argc && !strcmp (argv[d->optind], "--")) { d->optind++; if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) exchange ((char **) argv, d); else if (d->__first_nonopt == d->__last_nonopt) d->__first_nonopt = d->optind; d->__last_nonopt = argc; d->optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (d->optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (d->__first_nonopt != d->__last_nonopt) d->optind = d->__first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (d->__ordering == REQUIRE_ORDER) return -1; d->optarg = argv[d->optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ d->__nextchar = (argv[d->optind] + 1 + (longopts != NULL && argv[d->optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[d->optind][1] == '-' || (long_only && (argv[d->optind][2] || !strchr (optstring, argv[d->optind][1]))))) { char *nameend; unsigned int namelen; const struct option *p; const struct option *pfound = NULL; struct option_list { const struct option *p; struct option_list *next; } *ambig_list = NULL; #ifdef _LIBC /* malloc() not used for _LIBC to simplify failure messages. */ # define free_option_list(l) #else # define free_option_list(l) \ while (l != NULL) \ { \ struct option_list *pn = l->next; \ free (l); \ l = pn; \ } #endif int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; namelen = nameend - d->__nextchar; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, d->__nextchar, namelen)) { if (namelen == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else if (ambig) ; /* Taking simpler path to handling ambiguities. */ else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) { /* Second or later nonexact match found. */ #ifdef _LIBC struct option_list *newp = alloca (sizeof (*newp)); #else struct option_list *newp = malloc (sizeof (*newp)); if (newp == NULL) { free_option_list (ambig_list); ambig_list = NULL; ambig = 1; /* Use simpler fallback message. */ } else #endif { newp->p = p; newp->next = ambig_list; ambig_list = newp; } } } if ((ambig || ambig_list) && !exact) { if (print_errors && ambig_list) { struct option_list first; first.p = pfound; first.next = ambig_list; ambig_list = &first; #if defined _LIBC && defined USE_IN_LIBIO char *buf = NULL; size_t buflen = 0; FILE *fp = open_memstream (&buf, &buflen); if (fp != NULL) { fprintf (fp, _("%s: option '%s' is ambiguous; possibilities:"), argv[0], argv[d->optind]); do { fprintf (fp, " '--%s'", ambig_list->p->name); ambig_list = ambig_list->next; } while (ambig_list != NULL); fputc_unlocked ('\n', fp); if (__builtin_expect (fclose (fp) != EOF, 1)) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } } #else fprintf (stderr, _("%s: option '%s' is ambiguous; possibilities:"), argv[0], argv[d->optind]); do { fprintf (stderr, " '--%s'", ambig_list->p->name); ambig_list = ambig_list->next; } while (ambig_list != NULL); fputc ('\n', stderr); #endif } else if (print_errors && ambig) { fprintf (stderr, _("%s: option '%s' is ambiguous\n"), argv[0], argv[d->optind]); } d->__nextchar += strlen (d->__nextchar); d->optind++; d->optopt = 0; free_option_list (ambig_list); return '?'; } free_option_list (ambig_list); if (pfound != NULL) { option_index = indfound; d->optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) d->optarg = nameend + 1; else { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; int n; #endif if (argv[d->optind - 1][1] == '-') { /* --option */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("\ %s: option '--%s' doesn't allow an argument\n"), argv[0], pfound->name); #else fprintf (stderr, _("\ %s: option '--%s' doesn't allow an argument\n"), argv[0], pfound->name); #endif } else { /* +option or -option */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("\ %s: option '%c%s' doesn't allow an argument\n"), argv[0], argv[d->optind - 1][0], pfound->name); #else fprintf (stderr, _("\ %s: option '%c%s' doesn't allow an argument\n"), argv[0], argv[d->optind - 1][0], pfound->name); #endif } #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #endif } d->__nextchar += strlen (d->__nextchar); d->optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (d->optind < argc) d->optarg = argv[d->optind++]; else { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("\ %s: option '--%s' requires an argument\n"), argv[0], pfound->name) >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #else fprintf (stderr, _("%s: option '--%s' requires an argument\n"), argv[0], pfound->name); #endif } d->__nextchar += strlen (d->__nextchar); d->optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } d->__nextchar += strlen (d->__nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[d->optind][1] == '-' || strchr (optstring, *d->__nextchar) == NULL) { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; int n; #endif if (argv[d->optind][1] == '-') { /* --option */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"), argv[0], d->__nextchar); #else fprintf (stderr, _("%s: unrecognized option '--%s'\n"), argv[0], d->__nextchar); #endif } else { /* +option or -option */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"), argv[0], argv[d->optind][0], d->__nextchar); #else fprintf (stderr, _("%s: unrecognized option '%c%s'\n"), argv[0], argv[d->optind][0], d->__nextchar); #endif } #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #endif } d->__nextchar = (char *) ""; d->optind++; d->optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *d->__nextchar++; const char *temp = strchr (optstring, c); /* Increment 'optind' when we start to process its last character. */ if (*d->__nextchar == '\0') ++d->optind; if (temp == NULL || c == ':' || c == ';') { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; int n; #endif #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"), argv[0], c); #else fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); #endif #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #endif } d->optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; if (longopts == NULL) goto no_longs; /* This is an option that requires an argument. */ if (*d->__nextchar != '\0') { d->optarg = d->__nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ d->optind++; } else if (d->optind == argc) { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("%s: option requires an argument -- '%c'\n"), argv[0], c) >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #else fprintf (stderr, _("%s: option requires an argument -- '%c'\n"), argv[0], c); #endif } d->optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented 'd->optind' once; increment it again when taking next ARGV-elt as argument. */ d->optarg = argv[d->optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) { if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), argv[0], d->optarg) >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #else fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), argv[0], d->optarg); #endif } d->__nextchar += strlen (d->__nextchar); d->optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) d->optarg = nameend + 1; else { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("\ %s: option '-W %s' doesn't allow an argument\n"), argv[0], pfound->name) >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #else fprintf (stderr, _("\ %s: option '-W %s' doesn't allow an argument\n"), argv[0], pfound->name); #endif } d->__nextchar += strlen (d->__nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (d->optind < argc) d->optarg = argv[d->optind++]; else { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("\ %s: option '-W %s' requires an argument\n"), argv[0], pfound->name) >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #else fprintf (stderr, _("\ %s: option '-W %s' requires an argument\n"), argv[0], pfound->name); #endif } d->__nextchar += strlen (d->__nextchar); return optstring[0] == ':' ? ':' : '?'; } } else d->optarg = NULL; d->__nextchar += strlen (d->__nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } no_longs: d->__nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*d->__nextchar != '\0') { d->optarg = d->__nextchar; d->optind++; } else d->optarg = NULL; d->__nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*d->__nextchar != '\0') { d->optarg = d->__nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ d->optind++; } else if (d->optind == argc) { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("\ %s: option requires an argument -- '%c'\n"), argv[0], c) >= 0) { _IO_flockfile (stderr); int old_flags2 = ((_IO_FILE *) stderr)->_flags2; ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; __fxprintf (NULL, "%s", buf); ((_IO_FILE *) stderr)->_flags2 = old_flags2; _IO_funlockfile (stderr); free (buf); } #else fprintf (stderr, _("%s: option requires an argument -- '%c'\n"), argv[0], c); #endif } d->optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented 'optind' once; increment it again when taking next ARGV-elt as argument. */ d->optarg = argv[d->optind++]; d->__nextchar = NULL; } } return c; } } int _getopt_internal (int argc, char **argv, const char *optstring, const struct option *longopts, int *longind, int long_only, int posixly_correct) { int result; getopt_data.optind = optind; getopt_data.opterr = opterr; result = _getopt_internal_r (argc, argv, optstring, longopts, longind, long_only, &getopt_data, posixly_correct); optind = getopt_data.optind; optarg = getopt_data.optarg; optopt = getopt_data.optopt; return result; } /* glibc gets a LSB-compliant getopt. Standalone applications get a POSIX-compliant getopt. */ #if _LIBC enum { POSIXLY_CORRECT = 0 }; #else enum { POSIXLY_CORRECT = 1 }; #endif int getopt (int argc, char *const *argv, const char *optstring) { return _getopt_internal (argc, (char **) argv, optstring, (const struct option *) 0, (int *) 0, 0, POSIXLY_CORRECT); } #ifdef _LIBC int __posix_getopt (int argc, char *const *argv, const char *optstring) { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0, 1); } #endif #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of 'getopt'. */ int main (int argc, char **argv) { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value '%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ lftp-4.6.3a/lib/glob.in.h0000644000015000007670000000505712466374011012035 00000000000000/* glob.h -- Find a path matching a pattern. Copyright (C) 2005-2007, 2009-2015 Free Software Foundation, Inc. Written by Derek Price & Paul Eggert 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 . */ #ifndef _GL_GLOB_H #define _GL_GLOB_H #if @HAVE_SYS_CDEFS_H@ # include #endif #include /* On some systems, such as AIX 5.1, does a "#define stat stat64". Make sure this definition is seen before glob-libc.h defines types that rely on 'struct stat'. */ #include #ifndef __BEGIN_DECLS # ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } # else # define __BEGIN_DECLS # define __END_DECLS # endif #endif #ifndef __THROW # define __THROW #endif #ifndef __THROWNL # define __THROWNL #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. */ #ifndef __size_t # define __size_t size_t #endif #ifndef __USE_GNU # define __USE_GNU 1 #endif #define glob rpl_glob #define globfree rpl_globfree #define glob_pattern_p rpl_glob_pattern_p #define __GLOB_GNULIB 1 /* Now the standard GNU C Library header should work. */ #include "glob-libc.h" __BEGIN_DECLS typedef int (*_gl_glob_errfunc_fn) (const char *, int); __END_DECLS #if defined __cplusplus && defined GNULIB_NAMESPACE # undef glob # undef globfree # undef glob_pattern_p _GL_CXXALIAS_RPL (glob, int, (const char *_Restrict_ __pattern, int __flags, _gl_glob_errfunc_fn __errfunc, glob_t *_Restrict_ __pglob)); _GL_CXXALIAS_RPL (globfree, void, (glob_t *__pglob)); _GL_CXXALIAS_RPL (glob_pattern_p, int, (const char *__pattern, int __quote)); # if 0 /* The C function name is rpl_glob, not glob. */ _GL_CXXALIASWARN (glob); _GL_CXXALIASWARN (globfree); _GL_CXXALIASWARN (glob_pattern_p); # endif #endif #endif /* _GL_GLOB_H */ lftp-4.6.3a/lib/select.c0000644000015000007670000003762112466374012011762 00000000000000/* Emulation for select(2) Contributed by Paolo Bonzini. Copyright 2008-2015 Free Software Foundation, Inc. This file is part of gnulib. 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 . */ #include #include #include #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Native Windows. */ #include #include #include #include #include #include #include #include #include /* Get the overridden 'struct timeval'. */ #include #include "msvc-nothrow.h" #undef select struct bitset { unsigned char in[FD_SETSIZE / CHAR_BIT]; unsigned char out[FD_SETSIZE / CHAR_BIT]; }; /* Declare data structures for ntdll functions. */ typedef struct _FILE_PIPE_LOCAL_INFORMATION { ULONG NamedPipeType; ULONG NamedPipeConfiguration; ULONG MaximumInstances; ULONG CurrentInstances; ULONG InboundQuota; ULONG ReadDataAvailable; ULONG OutboundQuota; ULONG WriteQuotaAvailable; ULONG NamedPipeState; ULONG NamedPipeEnd; } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; typedef struct _IO_STATUS_BLOCK { union { DWORD Status; PVOID Pointer; } u; ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; typedef enum _FILE_INFORMATION_CLASS { FilePipeLocalInformation = 24 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; typedef DWORD (WINAPI *PNtQueryInformationFile) (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS); #ifndef PIPE_BUF #define PIPE_BUF 512 #endif static BOOL IsConsoleHandle (HANDLE h) { DWORD mode; return GetConsoleMode (h, &mode) != 0; } static BOOL IsSocketHandle (HANDLE h) { WSANETWORKEVENTS ev; if (IsConsoleHandle (h)) return FALSE; /* Under Wine, it seems that getsockopt returns 0 for pipes too. WSAEnumNetworkEvents instead distinguishes the two correctly. */ ev.lNetworkEvents = 0xDEADBEEF; WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev); return ev.lNetworkEvents != 0xDEADBEEF; } /* Compute output fd_sets for libc descriptor FD (whose Windows handle is H). */ static int windows_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits, struct bitset *xbits) { BOOL read, write, except; int i, ret; INPUT_RECORD *irbuffer; DWORD avail, nbuffer; BOOL bRet; IO_STATUS_BLOCK iosb; FILE_PIPE_LOCAL_INFORMATION fpli; static PNtQueryInformationFile NtQueryInformationFile; static BOOL once_only; read = write = except = FALSE; switch (GetFileType (h)) { case FILE_TYPE_DISK: read = TRUE; write = TRUE; break; case FILE_TYPE_PIPE: if (!once_only) { NtQueryInformationFile = (PNtQueryInformationFile) GetProcAddress (GetModuleHandle ("ntdll.dll"), "NtQueryInformationFile"); once_only = TRUE; } if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0) { if (avail) read = TRUE; } else if (GetLastError () == ERROR_BROKEN_PIPE) ; else { /* It was the write-end of the pipe. Check if it is writable. If NtQueryInformationFile fails, optimistically assume the pipe is writable. This could happen on Windows 9x, where NtQueryInformationFile is not available, or if we inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES access on the write end (I think this should not happen since Windows XP SP2; WINE seems fine too). Otherwise, ensure that enough space is available for atomic writes. */ memset (&iosb, 0, sizeof (iosb)); memset (&fpli, 0, sizeof (fpli)); if (!NtQueryInformationFile || NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli), FilePipeLocalInformation) || fpli.WriteQuotaAvailable >= PIPE_BUF || (fpli.OutboundQuota < PIPE_BUF && fpli.WriteQuotaAvailable == fpli.OutboundQuota)) write = TRUE; } break; case FILE_TYPE_CHAR: write = TRUE; if (!(rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) break; ret = WaitForSingleObject (h, 0); if (ret == WAIT_OBJECT_0) { if (!IsConsoleHandle (h)) { read = TRUE; break; } nbuffer = avail = 0; bRet = GetNumberOfConsoleInputEvents (h, &nbuffer); /* Screen buffers handles are filtered earlier. */ assert (bRet); if (nbuffer == 0) { except = TRUE; break; } irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD)); bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail); if (!bRet || avail == 0) { except = TRUE; break; } for (i = 0; i < avail; i++) if (irbuffer[i].EventType == KEY_EVENT) read = TRUE; } break; default: ret = WaitForSingleObject (h, 0); write = TRUE; if (ret == WAIT_OBJECT_0) read = TRUE; break; } ret = 0; if (read && (rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) { rbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1))); ret++; } if (write && (wbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) { wbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1))); ret++; } if (except && (xbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) { xbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1))); ret++; } return ret; } int rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, struct timeval *timeout) #undef timeval { static struct timeval tv0; static HANDLE hEvent; HANDLE h, handle_array[FD_SETSIZE + 2]; fd_set handle_rfds, handle_wfds, handle_xfds; struct bitset rbits, wbits, xbits; unsigned char anyfds_in[FD_SETSIZE / CHAR_BIT]; DWORD ret, wait_timeout, nhandles, nsock, nbuffer; MSG msg; int i, fd, rc; clock_t tend; if (nfds > FD_SETSIZE) nfds = FD_SETSIZE; if (!timeout) wait_timeout = INFINITE; else { wait_timeout = timeout->tv_sec * 1000 + timeout->tv_usec / 1000; /* select is also used as a portable usleep. */ if (!rfds && !wfds && !xfds) { Sleep (wait_timeout); return 0; } } if (!hEvent) hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); handle_array[0] = hEvent; nhandles = 1; nsock = 0; /* Copy descriptors to bitsets. At the same time, eliminate bits in the "wrong" direction for console input buffers and screen buffers, because screen buffers are waitable and they will block until a character is available. */ memset (&rbits, 0, sizeof (rbits)); memset (&wbits, 0, sizeof (wbits)); memset (&xbits, 0, sizeof (xbits)); memset (anyfds_in, 0, sizeof (anyfds_in)); if (rfds) for (i = 0; i < rfds->fd_count; i++) { fd = rfds->fd_array[i]; h = (HANDLE) _get_osfhandle (fd); if (IsConsoleHandle (h) && !GetNumberOfConsoleInputEvents (h, &nbuffer)) continue; rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); } else rfds = (fd_set *) alloca (sizeof (fd_set)); if (wfds) for (i = 0; i < wfds->fd_count; i++) { fd = wfds->fd_array[i]; h = (HANDLE) _get_osfhandle (fd); if (IsConsoleHandle (h) && GetNumberOfConsoleInputEvents (h, &nbuffer)) continue; wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); } else wfds = (fd_set *) alloca (sizeof (fd_set)); if (xfds) for (i = 0; i < xfds->fd_count; i++) { fd = xfds->fd_array[i]; xbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); } else xfds = (fd_set *) alloca (sizeof (fd_set)); /* Zero all the fd_sets, including the application's. */ FD_ZERO (rfds); FD_ZERO (wfds); FD_ZERO (xfds); FD_ZERO (&handle_rfds); FD_ZERO (&handle_wfds); FD_ZERO (&handle_xfds); /* Classify handles. Create fd sets for sockets, poll the others. */ for (i = 0; i < nfds; i++) { if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0) continue; h = (HANDLE) _get_osfhandle (i); if (!h) { errno = EBADF; return -1; } if (IsSocketHandle (h)) { int requested = FD_CLOSE; /* See above; socket handles are mapped onto select, but we need to map descriptors to handles. */ if (rbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) { requested |= FD_READ | FD_ACCEPT; FD_SET ((SOCKET) h, rfds); FD_SET ((SOCKET) h, &handle_rfds); } if (wbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) { requested |= FD_WRITE | FD_CONNECT; FD_SET ((SOCKET) h, wfds); FD_SET ((SOCKET) h, &handle_wfds); } if (xbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) { requested |= FD_OOB; FD_SET ((SOCKET) h, xfds); FD_SET ((SOCKET) h, &handle_xfds); } WSAEventSelect ((SOCKET) h, hEvent, requested); nsock++; } else { handle_array[nhandles++] = h; /* Poll now. If we get an event, do not wait below. */ if (wait_timeout != 0 && windows_poll_handle (h, i, &rbits, &wbits, &xbits)) wait_timeout = 0; } } /* Place a sentinel at the end of the array. */ handle_array[nhandles] = NULL; /* When will the waiting period expire? */ if (wait_timeout != INFINITE) tend = clock () + wait_timeout; restart: if (wait_timeout == 0 || nsock == 0) rc = 0; else { /* See if we need to wait in the loop below. If any select is ready, do MsgWaitForMultipleObjects anyway to dispatch messages, but no need to call select again. */ rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0); if (rc == 0) { /* Restore the fd_sets for the other select we do below. */ memcpy (&handle_rfds, rfds, sizeof (fd_set)); memcpy (&handle_wfds, wfds, sizeof (fd_set)); memcpy (&handle_xfds, xfds, sizeof (fd_set)); } else wait_timeout = 0; } /* How much is left to wait? */ if (wait_timeout != INFINITE) { clock_t tnow = clock (); if (tend >= tnow) wait_timeout = tend - tnow; else wait_timeout = 0; } for (;;) { ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE, wait_timeout, QS_ALLINPUT); if (ret == WAIT_OBJECT_0 + nhandles) { /* new input of some other kind */ BOOL bRet; while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0) { TranslateMessage (&msg); DispatchMessage (&msg); } } else break; } /* If we haven't done it yet, check the status of the sockets. */ if (rc == 0 && nsock > 0) rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0); if (nhandles > 1) { /* Count results that are not counted in the return value of select. */ nhandles = 1; for (i = 0; i < nfds; i++) { if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0) continue; h = (HANDLE) _get_osfhandle (i); if (h == handle_array[nhandles]) { /* Not a socket. */ nhandles++; windows_poll_handle (h, i, &rbits, &wbits, &xbits); if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))) || wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))) || xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) rc++; } } if (rc == 0 && (wait_timeout == INFINITE /* If NHANDLES > 1, but no bits are set, it means we've been told incorrectly that some handle was signaled. This happens with anonymous pipes, which always cause MsgWaitForMultipleObjects to exit immediately, but no data is found ready to be read by windows_poll_handle. To avoid a total failure (whereby we return zero and don't wait at all), let's poll in a more busy loop. */ || (wait_timeout != 0 && nhandles > 1))) { /* Sleep 1 millisecond to avoid busy wait and retry with the original fd_sets. */ memcpy (&handle_rfds, rfds, sizeof (fd_set)); memcpy (&handle_wfds, wfds, sizeof (fd_set)); memcpy (&handle_xfds, xfds, sizeof (fd_set)); SleepEx (1, TRUE); goto restart; } if (timeout && wait_timeout == 0 && rc == 0) timeout->tv_sec = timeout->tv_usec = 0; } /* Now fill in the results. */ FD_ZERO (rfds); FD_ZERO (wfds); FD_ZERO (xfds); nhandles = 1; for (i = 0; i < nfds; i++) { if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0) continue; h = (HANDLE) _get_osfhandle (i); if (h != handle_array[nhandles]) { /* Perform handle->descriptor mapping. */ WSAEventSelect ((SOCKET) h, NULL, 0); if (FD_ISSET (h, &handle_rfds)) FD_SET (i, rfds); if (FD_ISSET (h, &handle_wfds)) FD_SET (i, wfds); if (FD_ISSET (h, &handle_xfds)) FD_SET (i, xfds); } else { /* Not a socket. */ nhandles++; if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) FD_SET (i, rfds); if (wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) FD_SET (i, wfds); if (xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) FD_SET (i, xfds); } } return rc; } #else /* ! Native Windows. */ #include #include /* NULL */ #include #include #undef select int rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, struct timeval *timeout) { int i; /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */ if (nfds < 0 || nfds > FD_SETSIZE) { errno = EINVAL; return -1; } for (i = 0; i < nfds; i++) { if (((rfds && FD_ISSET (i, rfds)) || (wfds && FD_ISSET (i, wfds)) || (xfds && FD_ISSET (i, xfds))) && dup2 (i, i) != i) return -1; } /* Interix 3.5 has a bug: it does not support nfds == 0. */ if (nfds == 0) { nfds = 1; rfds = NULL; wfds = NULL; xfds = NULL; } return select (nfds, rfds, wfds, xfds, timeout); } #endif lftp-4.6.3a/lib/xstrtoul.c0000644000015000007670000000025412122621313012363 00000000000000#define __strtol strtoul #define __strtol_t unsigned long int #define __xstrtol xstrtoul #define STRTOL_T_MINIMUM 0 #define STRTOL_T_MAXIMUM ULONG_MAX #include "xstrtol.c" lftp-4.6.3a/lib/gettime.c0000644000015000007670000000231512466374011012130 00000000000000/* gettime -- get the system clock Copyright (C) 2002, 2004-2007, 2009-2015 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 . */ /* Written by Paul Eggert. */ #include #include "timespec.h" #include /* Get the system time into *TS. */ void gettime (struct timespec *ts) { #if HAVE_NANOTIME nanotime (ts); #else # if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME if (clock_gettime (CLOCK_REALTIME, ts) == 0) return; # endif { struct timeval tv; gettimeofday (&tv, NULL); ts->tv_sec = tv.tv_sec; ts->tv_nsec = tv.tv_usec * 1000; } #endif } lftp-4.6.3a/lib/config.h.in0000644000015000007670000016214612540277210012356 00000000000000/* lib/config.h.in. Generated from configure.ac by autoheader. */ #ifndef CONFIG_H #define CONFIG_H /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Define to the number of bits in type 'ptrdiff_t'. */ #undef BITSIZEOF_PTRDIFF_T /* Define to the number of bits in type 'sig_atomic_t'. */ #undef BITSIZEOF_SIG_ATOMIC_T /* Define to the number of bits in type 'size_t'. */ #undef BITSIZEOF_SIZE_T /* Define to the number of bits in type 'wchar_t'. */ #undef BITSIZEOF_WCHAR_T /* Define to the number of bits in type 'wint_t'. */ #undef BITSIZEOF_WINT_T /* Define if you wish *printf() functions that have a safe handling of non-IEEE-754 'long double' values. */ #undef CHECK_PRINTF_SAFE /* Define to 1 if chown fails to change ctime when at least one argument was not -1. */ #undef CHOWN_CHANGE_TIME_BUG /* Define if chown is not POSIX compliant regarding IDs of -1. */ #undef CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE /* Define if chown modifies symlinks. */ #undef CHOWN_MODIFIES_SYMLINK /* Define to 1 if chown mishandles trailing slash. */ #undef CHOWN_TRAILING_SLASH_BUG /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define as the bit index in the word where to find bit 0 of the exponent of 'double'. */ #undef DBL_EXPBIT0_BIT /* Define as the word index where to find the exponent of 'double'. */ #undef DBL_EXPBIT0_WORD /* Define as the bit index in the word where to find the sign of 'double'. */ #undef DBL_SIGNBIT_BIT /* Define as the word index where to find the sign of 'double'. */ #undef DBL_SIGNBIT_WORD /* Default pager command */ #undef DEFAULT_PAGER /* the name of the file descriptor member of DIR */ #undef DIR_FD_MEMBER_NAME #ifdef DIR_FD_MEMBER_NAME # define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME) #else # define DIR_TO_FD(Dir_p) -1 #endif /* Define if you want local DNSSEC validation support */ #undef DNSSEC_LOCAL_VALIDATION /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS /* Define this to 1 if F_DUPFD behavior does not match POSIX */ #undef FCNTL_DUPFD_BUGGY /* Define as the bit index in the word where to find bit 0 of the exponent of 'float'. */ #undef FLT_EXPBIT0_BIT /* Define as the word index where to find the exponent of 'float'. */ #undef FLT_EXPBIT0_WORD /* Define as the bit index in the word where to find the sign of 'float'. */ #undef FLT_SIGNBIT_BIT /* Define as the word index where to find the sign of 'float'. */ #undef FLT_SIGNBIT_WORD /* Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string. */ #undef FUNC_NL_LANGINFO_YESEXPR_WORKS /* Define to 1 if the `getpgrp' function requires zero arguments. */ #undef GETPGRP_VOID /* Define if gettimeofday clobbers the localtime buffer. */ #undef GETTIMEOFDAY_CLOBBERS_LOCALTIME /* Define this to 'void' or 'struct timezone' to match the system's declaration of the second argument to gettimeofday. */ #undef GETTIMEOFDAY_TIMEZONE /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module fscanf shall be considered present. */ #undef GNULIB_FSCANF /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module lock shall be considered present. */ #undef GNULIB_LOCK /* Define to 1 if printf and friends should be labeled with attribute "__gnu_printf__" instead of "__printf__" */ #undef GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module scanf shall be considered present. */ #undef GNULIB_SCANF /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module strerror shall be considered present. */ #undef GNULIB_STRERROR /* Define to 1 when the gnulib module btowc should be tested. */ #undef GNULIB_TEST_BTOWC /* Define to 1 when the gnulib module chown should be tested. */ #undef GNULIB_TEST_CHOWN /* Define to 1 when the gnulib module cloexec should be tested. */ #undef GNULIB_TEST_CLOEXEC /* Define to 1 when the gnulib module close should be tested. */ #undef GNULIB_TEST_CLOSE /* Define to 1 when the gnulib module closedir should be tested. */ #undef GNULIB_TEST_CLOSEDIR /* Define to 1 when the gnulib module dirfd should be tested. */ #undef GNULIB_TEST_DIRFD /* Define to 1 when the gnulib module dup2 should be tested. */ #undef GNULIB_TEST_DUP2 /* Define to 1 when the gnulib module environ should be tested. */ #undef GNULIB_TEST_ENVIRON /* Define to 1 when the gnulib module fcntl should be tested. */ #undef GNULIB_TEST_FCNTL /* Define to 1 when the gnulib module frexp should be tested. */ #undef GNULIB_TEST_FREXP /* Define to 1 when the gnulib module frexpl should be tested. */ #undef GNULIB_TEST_FREXPL /* Define to 1 when the gnulib module fstat should be tested. */ #undef GNULIB_TEST_FSTAT /* Define to 1 when the gnulib module getdtablesize should be tested. */ #undef GNULIB_TEST_GETDTABLESIZE /* Define to 1 when the gnulib module getlogin_r should be tested. */ #undef GNULIB_TEST_GETLOGIN_R /* Define to 1 when the gnulib module getopt-gnu should be tested. */ #undef GNULIB_TEST_GETOPT_GNU /* Define to 1 when the gnulib module gettimeofday should be tested. */ #undef GNULIB_TEST_GETTIMEOFDAY /* Define to 1 when the gnulib module lchown should be tested. */ #undef GNULIB_TEST_LCHOWN /* Define to 1 when the gnulib module localeconv should be tested. */ #undef GNULIB_TEST_LOCALECONV /* Define to 1 when the gnulib module lstat should be tested. */ #undef GNULIB_TEST_LSTAT /* Define to 1 when the gnulib module malloc-posix should be tested. */ #undef GNULIB_TEST_MALLOC_POSIX /* Define to 1 when the gnulib module mbrtowc should be tested. */ #undef GNULIB_TEST_MBRTOWC /* Define to 1 when the gnulib module mbsinit should be tested. */ #undef GNULIB_TEST_MBSINIT /* Define to 1 when the gnulib module mbsrtowcs should be tested. */ #undef GNULIB_TEST_MBSRTOWCS /* Define to 1 when the gnulib module mbtowc should be tested. */ #undef GNULIB_TEST_MBTOWC /* Define to 1 when the gnulib module memchr should be tested. */ #undef GNULIB_TEST_MEMCHR /* Define to 1 when the gnulib module memmem should be tested. */ #undef GNULIB_TEST_MEMMEM /* Define to 1 when the gnulib module mempcpy should be tested. */ #undef GNULIB_TEST_MEMPCPY /* Define to 1 when the gnulib module mktime should be tested. */ #undef GNULIB_TEST_MKTIME /* Define to 1 when the gnulib module nl_langinfo should be tested. */ #undef GNULIB_TEST_NL_LANGINFO /* Define to 1 when the gnulib module open should be tested. */ #undef GNULIB_TEST_OPEN /* Define to 1 when the gnulib module opendir should be tested. */ #undef GNULIB_TEST_OPENDIR /* Define to 1 when the gnulib module poll should be tested. */ #undef GNULIB_TEST_POLL /* Define to 1 when the gnulib module readdir should be tested. */ #undef GNULIB_TEST_READDIR /* Define to 1 when the gnulib module readlink should be tested. */ #undef GNULIB_TEST_READLINK /* Define to 1 when the gnulib module select should be tested. */ #undef GNULIB_TEST_SELECT /* Define to 1 when the gnulib module setenv should be tested. */ #undef GNULIB_TEST_SETENV /* Define to 1 when the gnulib module signbit should be tested. */ #undef GNULIB_TEST_SIGNBIT /* Define to 1 when the gnulib module stat should be tested. */ #undef GNULIB_TEST_STAT /* Define to 1 when the gnulib module strdup should be tested. */ #undef GNULIB_TEST_STRDUP /* Define to 1 when the gnulib module strerror should be tested. */ #undef GNULIB_TEST_STRERROR /* Define to 1 when the gnulib module strptime should be tested. */ #undef GNULIB_TEST_STRPTIME /* Define to 1 when the gnulib module strstr should be tested. */ #undef GNULIB_TEST_STRSTR /* Define to 1 when the gnulib module strtok_r should be tested. */ #undef GNULIB_TEST_STRTOK_R /* Define to 1 when the gnulib module strtoull should be tested. */ #undef GNULIB_TEST_STRTOULL /* Define to 1 when the gnulib module time_r should be tested. */ #undef GNULIB_TEST_TIME_R /* Define to 1 when the gnulib module unsetenv should be tested. */ #undef GNULIB_TEST_UNSETENV /* Define to 1 when the gnulib module vsnprintf should be tested. */ #undef GNULIB_TEST_VSNPRINTF /* Define to 1 when the gnulib module wcrtomb should be tested. */ #undef GNULIB_TEST_WCRTOMB /* Define to 1 when the gnulib module wcwidth should be tested. */ #undef GNULIB_TEST_WCWIDTH /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module unistr/u8-mbtoucr shall be considered present. */ #undef GNULIB_UNISTR_U8_MBTOUCR /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module unistr/u8-uctomb shall be considered present. */ #undef GNULIB_UNISTR_U8_UCTOMB /* Define to 1 if you have 'alloca' after including , a header that may be supplied by this distribution. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_NAMESER_H /* Define to 1 if you have the header file. */ #undef HAVE_BP_SYM_H /* Define to 1 if you have the `btowc' function. */ #undef HAVE_BTOWC /* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework. */ #undef HAVE_CFLOCALECOPYCURRENT /* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework. */ #undef HAVE_CFPREFERENCESCOPYAPPVALUE /* Define to 1 if you have the `chown' function. */ #undef HAVE_CHOWN /* Define to 1 if you have the `clock_gettime' function. */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the `clock_settime' function. */ #undef HAVE_CLOCK_SETTIME /* Define to 1 if you have the `closedir' function. */ #undef HAVE_CLOSEDIR /* Define if you have compound literals. */ #undef HAVE_COMPOUND_LITERALS /* Define if the copysignf function is declared in and available in libc. */ #undef HAVE_COPYSIGNF_IN_LIBC /* Define if the copysignl function is declared in and available in libc. */ #undef HAVE_COPYSIGNL_IN_LIBC /* Define if the copysign function is declared in and available in libc. */ #undef HAVE_COPYSIGN_IN_LIBC /* Define to 1 if you have the header file. */ #undef HAVE_CURSES_H /* define if c++ compiler supports bool */ #undef HAVE_CXX_BOOL /* define if c++ compiler supports _Bool */ #undef HAVE_CXX__BOOL /* Define if the GNU dcgettext() function is already present or preinstalled. */ #undef HAVE_DCGETTEXT /* Define to 1 if you have the declaration of `alarm', and to 0 if you don't. */ #undef HAVE_DECL_ALARM /* Define to 1 if you have the declaration of `copysign', and to 0 if you don't. */ #undef HAVE_DECL_COPYSIGN /* Define to 1 if you have the declaration of `copysignf', and to 0 if you don't. */ #undef HAVE_DECL_COPYSIGNF /* Define to 1 if you have the declaration of `copysignl', and to 0 if you don't. */ #undef HAVE_DECL_COPYSIGNL /* Define to 1 if you have the declaration of `dirfd', and to 0 if you don't. */ #undef HAVE_DECL_DIRFD /* Define to 1 if you have the declaration of `dn_expand', and to 0 if you don't. */ #undef HAVE_DECL_DN_EXPAND /* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you don't. */ #undef HAVE_DECL_GETC_UNLOCKED /* Define to 1 if you have the declaration of `getdtablesize', and to 0 if you don't. */ #undef HAVE_DECL_GETDTABLESIZE /* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. */ #undef HAVE_DECL_GETENV /* Define to 1 if you have the declaration of `getlogin', and to 0 if you don't. */ #undef HAVE_DECL_GETLOGIN /* Define to 1 if you have the declaration of `getlogin_r', and to 0 if you don't. */ #undef HAVE_DECL_GETLOGIN_R /* Define to 1 if you have the declaration of `hstrerror', and to 0 if you don't. */ #undef HAVE_DECL_HSTRERROR /* Define to 1 if you have the declaration of `h_errlist', and to 0 if you don't. */ #undef HAVE_DECL_H_ERRLIST /* Define to 1 if you have the declaration of `h_errno', and to 0 if you don't. */ #undef HAVE_DECL_H_ERRNO /* Define to 1 if you have the declaration of `inet_aton', and to 0 if you don't. */ #undef HAVE_DECL_INET_ATON /* Define to 1 if you have the declaration of `inet_pton', and to 0 if you don't. */ #undef HAVE_DECL_INET_PTON /* Define to 1 if you have the declaration of `isblank', and to 0 if you don't. */ #undef HAVE_DECL_ISBLANK /* Define to 1 if you have the declaration of `localtime_r', and to 0 if you don't. */ #undef HAVE_DECL_LOCALTIME_R /* Define to 1 if you have the declaration of `mbrtowc', and to 0 if you don't. */ #undef HAVE_DECL_MBRTOWC /* Define to 1 if you have the declaration of `mbsinit', and to 0 if you don't. */ #undef HAVE_DECL_MBSINIT /* Define to 1 if you have the declaration of `mbsrtowcs', and to 0 if you don't. */ #undef HAVE_DECL_MBSRTOWCS /* Define to 1 if you have a declaration of mbswidth() in , and to 0 otherwise. */ #undef HAVE_DECL_MBSWIDTH_IN_WCHAR_H /* Define to 1 if you have the declaration of `memmem', and to 0 if you don't. */ #undef HAVE_DECL_MEMMEM /* Define to 1 if you have the declaration of `random', and to 0 if you don't. */ #undef HAVE_DECL_RANDOM /* Define to 1 if you have the declaration of `res_search', and to 0 if you don't. */ #undef HAVE_DECL_RES_SEARCH /* Define to 1 if you have the declaration of `setenv', and to 0 if you don't. */ #undef HAVE_DECL_SETENV /* Define to 1 if you have the declaration of `snprintf', and to 0 if you don't. */ #undef HAVE_DECL_SNPRINTF /* Define to 1 if you have the declaration of `strdup', and to 0 if you don't. */ #undef HAVE_DECL_STRDUP /* Define to 1 if you have the declaration of `strerror_r', and to 0 if you don't. */ #undef HAVE_DECL_STRERROR_R /* Define to 1 if you have the declaration of `strmode', and to 0 if you don't. */ #undef HAVE_DECL_STRMODE /* Define to 1 if you have the declaration of `strncasecmp', and to 0 if you don't. */ #undef HAVE_DECL_STRNCASECMP /* Define to 1 if you have the declaration of `strptime', and to 0 if you don't. */ #undef HAVE_DECL_STRPTIME /* Define to 1 if you have the declaration of `strtok_r', and to 0 if you don't. */ #undef HAVE_DECL_STRTOK_R /* Define to 1 if you have the declaration of `strtoull', and to 0 if you don't. */ #undef HAVE_DECL_STRTOULL /* Define to 1 if you have the declaration of `strtoumax', and to 0 if you don't. */ #undef HAVE_DECL_STRTOUMAX /* Define to 1 if you have the declaration of `towlower', and to 0 if you don't. */ #undef HAVE_DECL_TOWLOWER /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. */ #undef HAVE_DECL_TZNAME /* Define to 1 if you have the declaration of `unsetenv', and to 0 if you don't. */ #undef HAVE_DECL_UNSETENV /* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you don't. */ #undef HAVE_DECL_VSNPRINTF /* Define to 1 if you have the declaration of `wcrtomb', and to 0 if you don't. */ #undef HAVE_DECL_WCRTOMB /* Define to 1 if you have the declaration of `wcwidth', and to 0 if you don't. */ #undef HAVE_DECL_WCWIDTH /* Define to 1 if you have the declaration of `_snprintf', and to 0 if you don't. */ #undef HAVE_DECL__SNPRINTF /* define if you have /dev/ptmx device */ #undef HAVE_DEV_PTMX /* define if you have /dev/ptc device */ #undef HAVE_DEV_PTS_AND_PTC /* Define to 1 if you have the header file. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the `dirfd' function. */ #undef HAVE_DIRFD /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* have dlopen */ #undef HAVE_DLOPEN /* Define to 1 if you have the `dn_expand' function. */ #undef HAVE_DN_EXPAND /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the 'dup2' function. */ #undef HAVE_DUP2 /* Define to 1 if you have the header file. */ #undef HAVE_ENDIAN_H /* define if you have global environ variable */ #undef HAVE_ENVIRON /* Define if you have the declaration of environ. */ #undef HAVE_ENVIRON_DECL /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the header file. */ #undef HAVE_EXPAT_H /* Define to 1 if you have the `fchown' function. */ #undef HAVE_FCHOWN /* Define to 1 if you have the `fcntl' function. */ #undef HAVE_FCNTL /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_FEATURES_H /* Define if the frexpl function is available in libc. */ #undef HAVE_FREXPL_IN_LIBC /* Define if the frexp function is available in libc. */ #undef HAVE_FREXP_IN_LIBC /* Define to 1 if you have the `fstatat' function. */ #undef HAVE_FSTATAT /* Define to 1 if you have the `getaddrinfo' function. */ #undef HAVE_GETADDRINFO /* Define to 1 if you have the `getdtablesize' function. */ #undef HAVE_GETDTABLESIZE /* Define to 1 if you have the `gethostbyname2' function. */ #undef HAVE_GETHOSTBYNAME2 /* Define to 1 if you have the `getipnodebyname' function. */ #undef HAVE_GETIPNODEBYNAME /* Define to 1 if you have the `getlogin_r' function. */ #undef HAVE_GETLOGIN_R /* Define to 1 if you have the `getnameinfo' function. */ #undef HAVE_GETNAMEINFO /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H /* Define to 1 if you have the `getopt_long_only' function. */ #undef HAVE_GETOPT_LONG_ONLY /* Define to 1 if you have the `getpwnam_r' function. */ #undef HAVE_GETPWNAM_R /* Define if the GNU gettext() function is already present or preinstalled. */ #undef HAVE_GETTEXT /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_GLOB_H /* System has usable hstrerror */ #undef HAVE_HSTRERROR /* system has h_errno */ #undef HAVE_H_ERRNO /* Define if you have the iconv() function and it works. */ #undef HAVE_ICONV /* Define to 1 if you have the header file. */ #undef HAVE_ICONV_H /* Define to 1 if you have the header file. */ #undef HAVE_IFADDRS_H /* Define to 1 if you have the `inet_aton' function. */ #undef HAVE_INET_ATON /* Define to 1 if you have the `inet_pton' function. */ #undef HAVE_INET_PTON /* Define to 1 if the compiler supports one of the keywords 'inline', '__inline__', '__inline' and effectively inlines functions marked as such. */ #undef HAVE_INLINE /* Define if you have the 'intmax_t' type in or . */ #undef HAVE_INTMAX_T /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define if exists, doesn't clash with , and declares uintmax_t. */ #undef HAVE_INTTYPES_H_WITH_UINTMAX /* Define to 1 if defines AF_INET. */ #undef HAVE_IPV4 /* Define to 1 if defines AF_INET6. */ #undef HAVE_IPV6 /* Define to 1 if you have the `isascii' function. */ #undef HAVE_ISASCII /* Define to 1 if you have the `isblank' function. */ #undef HAVE_ISBLANK /* Define if the isnan(double) function is available in libc. */ #undef HAVE_ISNAND_IN_LIBC /* Define if the isnan(float) function is available in libc. */ #undef HAVE_ISNANF_IN_LIBC /* Define if the isnan(long double) function is available in libc. */ #undef HAVE_ISNANL_IN_LIBC /* Define to 1 if you have the `iswcntrl' function. */ #undef HAVE_ISWCNTRL /* Define to 1 if you have the `iswctype' function. */ #undef HAVE_ISWCTYPE /* Define to 1 if you have the `killpg' function. */ #undef HAVE_KILLPG /* Define if you have and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET /* Define to 1 if you have the header file. */ #undef HAVE_LANGINFO_H /* Define to 1 if you have the `lchmod' function. */ #undef HAVE_LCHMOD /* Define to 1 if you have the `lchown' function. */ #undef HAVE_LCHOWN /* Define if the ldexpl function is available in libc. */ #undef HAVE_LDEXPL_IN_LIBC /* Define if the ldexp function is available in libc. */ #undef HAVE_LDEXP_IN_LIBC /* Define if you have expat library */ #undef HAVE_LIBEXPAT /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD /* Define to 1 if you have the `sres' library (-lsres). */ #undef HAVE_LIBSRES /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_MAGIC_H /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if you have the `localtime_r' function. */ #undef HAVE_LOCALTIME_R /* Define to 1 if the system has the type 'long long int'. */ #undef HAVE_LONG_LONG_INT /* Define to 1 if you have the `lstat' function. */ #undef HAVE_LSTAT /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define if the 'malloc' function is POSIX compliant. */ #undef HAVE_MALLOC_POSIX /* Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including config.h and . */ #undef HAVE_MAP_ANONYMOUS /* Define to 1 if you have the header file. */ #undef HAVE_MATH_H /* Define to 1 if you have the `mbrtowc' function. */ #undef HAVE_MBRTOWC /* Define to 1 if you have the `mbsinit' function. */ #undef HAVE_MBSINIT /* Define to 1 if you have the `mbsrtowcs' function. */ #undef HAVE_MBSRTOWCS /* Define to 1 if declares mbstate_t. */ #undef HAVE_MBSTATE_T /* Define to 1 if you have the `memmem' function. */ #undef HAVE_MEMMEM /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mempcpy' function. */ #undef HAVE_MEMPCPY /* Define to 1 if you have the `mprotect' function. */ #undef HAVE_MPROTECT /* Define to 1 on MSVC platforms that have the "invalid parameter handler" concept. */ #undef HAVE_MSVC_INVALID_PARAMETER_HANDLER /* Define to 1 if you have the `nanotime' function. */ #undef HAVE_NANOTIME /* Define to 1 if you have the header file. */ #undef HAVE_NCURSES_CURSES_H /* Define to 1 if you have the header file. */ #undef HAVE_NCURSES_TERM_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_SYSTM_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IP_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if you have the `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO /* Define to 1 if you have the `opendir' function. */ #undef HAVE_OPENDIR /* define if you have openpty function */ #undef HAVE_OPENPTY /* Define to 1 if libcrypto is used for MD5. */ #undef HAVE_OPENSSL_MD5 /* Define to 1 if libcrypto is used for SHA1. */ #undef HAVE_OPENSSL_SHA1 /* Define to 1 if you have the 'poll' function and it works. */ #undef HAVE_POLL /* Define to 1 if you have the header file. */ #undef HAVE_POLL_H /* Define if posix_fadvise() is available */ #undef HAVE_POSIX_FADVISE /* Define if you have a working posix_fallocate() */ #undef HAVE_POSIX_FALLOCATE /* Define if the defines PTHREAD_MUTEX_RECURSIVE. */ #undef HAVE_PTHREAD_MUTEX_RECURSIVE /* Define if the POSIX multithreading library has read/write locks. */ #undef HAVE_PTHREAD_RWLOCK /* Define to 1 if you have the header file. */ #undef HAVE_PTY_H /* Define to 1 if you have the `random' function. */ #undef HAVE_RANDOM /* Define to 1 if you have the `readdir' function. */ #undef HAVE_READDIR /* Define to 1 if you have the `readlink' function. */ #undef HAVE_READLINK /* Define to 1 if you have the `recvmsg' function. */ #undef HAVE_RECVMSG /* Define to 1 if you have the header file. */ #undef HAVE_RESOLV_H /* have res_9_search */ #undef HAVE_RES_9_SEARCH /* have res_search */ #undef HAVE_RES_SEARCH /* Define to 1 if you have the `Rpoll' function. */ #undef HAVE_RPOLL /* Define to 1 if 'long double' and 'double' have the same representation. */ #undef HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Define to 1 if the system has the type `sa_family_t'. */ #undef HAVE_SA_FAMILY_T /* Define to 1 if you have the header file. */ #undef HAVE_SEARCH_H /* Define to 1 if you have the `sendmsg' function. */ #undef HAVE_SENDMSG /* Define to 1 if you have the `setdtablesize' function. */ #undef HAVE_SETDTABLESIZE /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE /* Define to 1 if you have the `setpgid' function. */ #undef HAVE_SETPGID /* Define to 1 if you have the `setsid' function. */ #undef HAVE_SETSID /* Define to 1 if you have the `shutdown' function. */ #undef HAVE_SHUTDOWN /* Define to 1 if 'sig_atomic_t' is a signed integer type. */ #undef HAVE_SIGNED_SIG_ATOMIC_T /* Define to 1 if 'wchar_t' is a signed integer type. */ #undef HAVE_SIGNED_WCHAR_T /* Define to 1 if 'wint_t' is a signed integer type. */ #undef HAVE_SIGNED_WINT_T /* Define to 1 if the system has the type `sigset_t'. */ #undef HAVE_SIGSET_T /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF /* Define if the return value of the snprintf function is the number of of bytes (excluding the terminating NUL) that would have been produced if the buffer had been large enough. */ #undef HAVE_SNPRINTF_RETVAL_C99 /* Define to 1 if you have the `socketpair' function. */ #undef HAVE_SOCKETPAIR /* Define to 1 if you have the header file. */ #undef HAVE_SOCKS_H /* Define to 1 if you have the `sscanf' function. */ #undef HAVE_SSCANF /* Define to 1 if you have the `statfs' function. */ #undef HAVE_STATFS /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define if exists, doesn't clash with , and declares uintmax_t. */ #undef HAVE_STDINT_H_WITH_UINTMAX /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror_r' function. */ #undef HAVE_STRERROR_R /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strncasecmp' function. */ #undef HAVE_STRNCASECMP /* Define to 1 if you have the `strnlen' function. */ #undef HAVE_STRNLEN /* Define to 1 if you have the `strptime' function. */ #undef HAVE_STRPTIME /* Define to 1 if you have the `strtok_r' function. */ #undef HAVE_STRTOK_R /* Define to 1 if you have the `strtoull' function. */ #undef HAVE_STRTOULL /* Define to 1 if you have the `strtoumax' function. */ #undef HAVE_STRTOUMAX /* Define if there is a member named d_type in the struct describing directory headers. */ #undef HAVE_STRUCT_DIRENT_D_TYPE /* Define to 1 if `decimal_point' is a member of `struct lconv'. */ #undef HAVE_STRUCT_LCONV_DECIMAL_POINT /* Define to 1 if `msg_accrights' is a member of `struct msghdr'. */ #undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS /* Define to 1 if `sin6_scope_id' is a member of `struct sockaddr_in6'. */ #undef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID /* Define to 1 if `sa_len' is a member of `struct sockaddr'. */ #undef HAVE_STRUCT_SOCKADDR_SA_LEN /* Define to 1 if the system has the type `struct sockaddr_storage'. */ #undef HAVE_STRUCT_SOCKADDR_STORAGE /* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ #undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY /* Define to 1 if `tm_zone' is a member of `struct tm'. */ #undef HAVE_STRUCT_TM_TM_ZONE /* Define if struct stat has an st_dm_mode member. */ #undef HAVE_ST_DM_MODE /* Define to 1 if you have the `symlink' function. */ #undef HAVE_SYMLINK /* Define to 1 if you have the header file. */ #undef HAVE_SYS_BITYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_CDEFS_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_FILIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MMAN_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STATFS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STROPTS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIMEB_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UIO_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the `tcgetattr' function. */ #undef HAVE_TCGETATTR /* Define to 1 if you have the header file. */ #undef HAVE_TERMCAP_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIO_H /* Define to 1 if you have the header file. */ #undef HAVE_TERM_H /* Define to 1 if you have the `tgetstr' function. */ #undef HAVE_TGETSTR /* Define to 1 if you have the `tigetstr' function. */ #undef HAVE_TIGETSTR /* Define if struct tm has the tm_gmtoff member. */ #undef HAVE_TM_GMTOFF /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use `HAVE_STRUCT_TM_TM_ZONE' instead. */ #undef HAVE_TM_ZONE /* Define to 1 if you have the `towlower' function. */ #undef HAVE_TOWLOWER /* Define to 1 if you have the `tsearch' function. */ #undef HAVE_TSEARCH /* Define to 1 if you don't have `tm_zone' but do have the external array `tzname'. */ #undef HAVE_TZNAME /* Define to 1 if you have the `tzset' function. */ #undef HAVE_TZSET /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `unsetenv' function. */ #undef HAVE_UNSETENV /* Define to 1 if the system has the type 'unsigned long long int'. */ #undef HAVE_UNSIGNED_LONG_LONG_INT /* Define to 1 if you have the header file. */ #undef HAVE_UTIL_H /* Define to 1 if you have the header file. */ #undef HAVE_UTIME_H /* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */ #undef HAVE_UTIME_NULL /* Define to 1 if you have the header file. */ #undef HAVE_VALIDATOR_VALIDATOR_H /* Define to 1 if you have the header file. */ #undef HAVE_VARARGS_H /* Define to 1 if you have the `vasnprintf' function. */ #undef HAVE_VASNPRINTF /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H /* Define if you have the 'wchar_t' type. */ #undef HAVE_WCHAR_T /* Define to 1 if you have the `wcrtomb' function. */ #undef HAVE_WCRTOMB /* Define to 1 if you have the `wcslen' function. */ #undef HAVE_WCSLEN /* Define to 1 if you have the `wcsnlen' function. */ #undef HAVE_WCSNLEN /* Define to 1 if you have the header file. */ #undef HAVE_WCTYPE_H /* Define to 1 if you have the `wcwidth' function. */ #undef HAVE_WCWIDTH /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Define if you have the 'wint_t' type. */ #undef HAVE_WINT_T /* Define to 1 if you have the `wmemchr' function. */ #undef HAVE_WMEMCHR /* Define to 1 if you have the `wmemcpy' function. */ #undef HAVE_WMEMCPY /* Define to 1 if you have the `wmempcpy' function. */ #undef HAVE_WMEMPCPY /* Define to 1 if O_NOATIME works. */ #undef HAVE_WORKING_O_NOATIME /* Define to 1 if O_NOFOLLOW works. */ #undef HAVE_WORKING_O_NOFOLLOW /* Define to 1 if you have the header file. */ #undef HAVE_WS2TCPIP_H /* Define to 1 if you have the header file. */ #undef HAVE_XLOCALE_H /* Define if you have zlib library */ #undef HAVE_ZLIB /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to 1 if you have the `_ftime' function. */ #undef HAVE__FTIME /* Define to 1 if you have the `_getpty' function. */ #undef HAVE__GETPTY /* Define to 1 if you have the `_set_invalid_parameter_handler' function. */ #undef HAVE__SET_INVALID_PARAMETER_HANDLER /* Define as const if the declaration of iconv() needs const. */ #undef ICONV_CONST /* Define to a symbolic name denoting the flavor of iconv_open() implementation. */ #undef ICONV_FLAVOR /* Define as the bit index in the word where to find bit 0 of the exponent of 'long double'. */ #undef LDBL_EXPBIT0_BIT /* Define as the word index where to find the exponent of 'long double'. */ #undef LDBL_EXPBIT0_WORD /* Define as the bit index in the word where to find the sign of 'long double'. */ #undef LDBL_SIGNBIT_BIT /* Define as the word index where to find the sign of 'long double'. */ #undef LDBL_SIGNBIT_WORD /* Define to libgnutls version, e.g. 0x010203 for 1.2.3 */ #undef LFTP_LIBGNUTLS_VERSION_CODE /* Define to 1 if you want IDN support. */ #undef LIBIDN /* Define to 1 if 'lstat' dereferences a symlink specified with a trailing slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK /* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* If malloc(0) is != NULL, define this to 1. Otherwise define this to 0. */ #undef MALLOC_0_IS_NONNULL /* Define to a substitute value for mmap()'s MAP_ANONYMOUS flag. */ #undef MAP_ANONYMOUS /* Define if the mbrtowc function does not return (size_t) -2 for empty input. */ #undef MBRTOWC_EMPTY_INPUT_BUG /* Define if the mbrtowc function has the NULL pwc argument bug. */ #undef MBRTOWC_NULL_ARG1_BUG /* Define if the mbrtowc function has the NULL string argument bug. */ #undef MBRTOWC_NULL_ARG2_BUG /* Define if the mbrtowc function does not return 0 for a NUL character. */ #undef MBRTOWC_NUL_RETVAL_BUG /* Define if the mbrtowc function returns a wrong return value. */ #undef MBRTOWC_RETVAL_BUG /* Define if the vasnprintf implementation needs special code for the 'a' and 'A' directives. */ #undef NEED_PRINTF_DIRECTIVE_A /* Define if the vasnprintf implementation needs special code for the 'F' directive. */ #undef NEED_PRINTF_DIRECTIVE_F /* Define if the vasnprintf implementation needs special code for the 'ls' directive. */ #undef NEED_PRINTF_DIRECTIVE_LS /* Define if the vasnprintf implementation needs special code for 'double' arguments. */ #undef NEED_PRINTF_DOUBLE /* Define if the vasnprintf implementation needs special code for surviving out-of-memory conditions. */ #undef NEED_PRINTF_ENOMEM /* Define if the vasnprintf implementation needs special code for the ' flag. */ #undef NEED_PRINTF_FLAG_GROUPING /* Define if the vasnprintf implementation needs special code for the '-' flag. */ #undef NEED_PRINTF_FLAG_LEFTADJUST /* Define if the vasnprintf implementation needs special code for the 0 flag. */ #undef NEED_PRINTF_FLAG_ZERO /* Define if the vasnprintf implementation needs special code for infinite 'double' arguments. */ #undef NEED_PRINTF_INFINITE_DOUBLE /* Define if the vasnprintf implementation needs special code for infinite 'long double' arguments. */ #undef NEED_PRINTF_INFINITE_LONG_DOUBLE /* Define if the vasnprintf implementation needs special code for 'long double' arguments. */ #undef NEED_PRINTF_LONG_DOUBLE /* Define if the vasnprintf implementation needs special code for supporting large precisions without arbitrary bounds. */ #undef NEED_PRINTF_UNBOUNDED_PRECISION /* need yywrap */ #undef NEED_YYWRAP /* Define to 1 if open() fails to recognize a trailing slash. */ #undef OPEN_TRAILING_SLASH_BUG #if defined(__cplusplus) && !defined(HAVE_CXX_BOOL) typedef unsigned _bool; #define bool _bool #define false 0U #define true 1U #endif #if defined(__cplusplus) && !defined(HAVE_CXX__BOOL) typedef bool _Bool; #endif /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to the type that is the result of default argument promotions of type mode_t. */ #undef PROMOTED_MODE_T /* Define if the pthread_in_use() detection is hard. */ #undef PTHREAD_IN_USE_DETECTION_HARD /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'ptrdiff_t'. */ #undef PTRDIFF_T_SUFFIX /* Define to 1 if readlink fails to recognize a trailing slash. */ #undef READLINK_TRAILING_SLASH_BUG /* Define to 1 if stat needs help when passed a directory name with a trailing slash */ #undef REPLACE_FUNC_STAT_DIR /* Define to 1 if stat needs help when passed a file name with a trailing slash */ #undef REPLACE_FUNC_STAT_FILE /* Define if nl_langinfo exists but is overridden by gnulib. */ #undef REPLACE_NL_LANGINFO /* Define to 1 if strerror(0) does not return a message implying success. */ #undef REPLACE_STRERROR_0 /* Define if vasnprintf exists but is overridden by gnulib. */ #undef REPLACE_VASNPRINTF /* Define when using wcwidth replacement */ #undef REPLACE_WCWIDTH /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'sig_atomic_t'. */ #undef SIG_ATOMIC_T_SUFFIX /* Define as the maximum value of type 'size_t', if the system doesn't define it. */ #ifndef SIZE_MAX # undef SIZE_MAX #endif /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'size_t'. */ #undef SIZE_T_SUFFIX /* define if you are building with SOCKS support */ #undef SOCKS4 /* define if you are building with SOCKSv5 support */ #undef SOCKS5 /* define if you are building with SOCKS-Dante support */ #undef SOCKS_DANTE /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if the `S_IS*' macros in do not work properly. */ #undef STAT_MACROS_BROKEN /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if strerror_r returns char *. */ #undef STRERROR_R_CHAR_P /* Define to 1 if all 'time_t' values fit in a 'long int'. */ #undef TIME_T_FITS_IN_LONG_INT /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* replace system's printf functions */ #undef TRIO_REPLACE_STDIO /* Define to 1 when using GNU TLS library */ #undef USE_GNUTLS /* define if you are using openssl */ #undef USE_OPENSSL /* Define if the POSIX multithreading library can be used. */ #undef USE_POSIX_THREADS /* Define if references to the POSIX multithreading library should be made weak. */ #undef USE_POSIX_THREADS_WEAK /* Define if the GNU Pth multithreading library can be used. */ #undef USE_PTH_THREADS /* Define if references to the GNU Pth multithreading library should be made weak. */ #undef USE_PTH_THREADS_WEAK /* Define if the old Solaris multithreading library can be used. */ #undef USE_SOLARIS_THREADS /* Define if references to the old Solaris multithreading library should be made weak. */ #undef USE_SOLARIS_THREADS_WEAK /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable general extensions on OS X. */ #ifndef _DARWIN_C_SOURCE # undef _DARWIN_C_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Use GNU style printf and scanf. */ #ifndef __USE_MINGW_ANSI_STDIO # undef __USE_MINGW_ANSI_STDIO #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable X/Open extensions if necessary. HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1. */ #ifndef _XOPEN_SOURCE # undef _XOPEN_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Define if the native Windows multithreading API can be used. */ #undef USE_WINDOWS_THREADS /* A 'va_copy' style function */ #undef VA_COPY /* Define to 1 if va_lists can be copied by pointer */ #undef VA_PTR_COPY /* Define to 1 if va_lists can be copied by value */ #undef VA_VAL_COPY /* Version number of package */ #undef VERSION /* Define to 1 if unsetenv returns void instead of int. */ #undef VOID_UNSETENV /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'wchar_t'. */ #undef WCHAR_T_SUFFIX /* Define if WSAStartup is needed. */ #undef WINDOWS_SOCKETS /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'wint_t'. */ #undef WINT_T_SUFFIX /* build modular lftp */ #undef WITH_MODULES /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Enable large inode numbers on Mac OS X 10.5. */ #undef _DARWIN_USE_64_BIT_INODE /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define to 1 if Gnulib overrides 'struct stat' on Windows so that struct stat.st_size becomes 64-bit. */ #undef _GL_WINDOWS_64_BIT_ST_SIZE /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Define to 1 on Solaris. */ #undef _LCONV_C99 /* Define in order to get some macros on AIX systems. */ #undef _LINUX_SOURCE_COMPAT /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 1 to make NetBSD features available. MINIX 3 needs this. */ #undef _NETBSD_SOURCE /* The _Noreturn keyword of C11. */ #if ! (defined _Noreturn \ || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) # if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ || 0x5110 <= __SUNPRO_C) # define _Noreturn __attribute__ ((__noreturn__)) # elif defined _MSC_VER && 1200 <= _MSC_VER # define _Noreturn __declspec (noreturn) # else # define _Noreturn # endif #endif /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 in order to get the POSIX compatible declarations of socket functions. */ #undef _POSIX_PII_SOCKET /* Define to 1 if you need to in order for 'stat' and other things to work. */ #undef _POSIX_SOURCE /* Define if you want to include , so that it consistently overrides 's RE_DUP_MAX. */ #undef _REGEX_INCLUDE_LIMITS_H /* Define if you want regoff_t to be at least as wide POSIX requires. */ #undef _REGEX_LARGE_OFFSETS #if !defined (VA_COPY) # if defined (VA_PTR_COPY) # define VA_COPY(ap1, ap2) (*(ap1) = *(ap2)) # elif defined (VA_VAL_COPY) # include # define VA_COPY(to,from) (memcpy(&(to),&(from),sizeof((to)))) # endif #endif /* !VA_COPY */ /* Define to rpl_ if the getopt replacement functions and variables should be used. */ #undef __GETOPT_PREFIX /* Use STDC Limit Macros in C++ */ #undef __STDC_LIMIT_MACROS /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Please see the Gnulib manual for how to use these macros. Suppress extern inline with HP-UX cc, as it appears to be broken; see . Suppress extern inline with Sun C in standards-conformance mode, as it mishandles inline functions that call each other. E.g., for 'inline void f (void) { } inline void g (void) { f (); }', c99 incorrectly complains 'reference to static identifier "f" in extern inline function'. This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) on configurations that mistakenly use 'static inline' to implement functions or macros in standard C headers like . For example, if isdigit is mistakenly implemented via a static inline function, a program containing an extern inline function that calls isdigit may not work since the C standard prohibits extern inline functions from calling static functions. This bug is known to occur on: OS X 10.8 and earlier; see: http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html DragonFly; see http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log FreeBSD; see: http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and for clang but remains for g++; see . Assume DragonFly and FreeBSD will be similar. */ #if (((defined __APPLE__ && defined __MACH__) \ || defined __DragonFly__ || defined __FreeBSD__) \ && (defined __header_inline \ ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ && ! defined __clang__) \ : ((! defined _DONT_USE_CTYPE_INLINE_ \ && (defined __GNUC__ || defined __cplusplus)) \ || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ && defined __GNUC__ && ! defined __cplusplus)))) # define _GL_EXTERN_INLINE_STDHEADER_BUG #endif #if ((__GNUC__ \ ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ : (199901L <= __STDC_VERSION__ \ && !defined __HP_cc \ && !(defined __SUNPRO_C && __STDC__))) \ && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) # define _GL_INLINE inline # define _GL_EXTERN_INLINE extern inline # define _GL_EXTERN_INLINE_IN_USE #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) # if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) # else # define _GL_INLINE extern inline # endif # define _GL_EXTERN_INLINE extern # define _GL_EXTERN_INLINE_IN_USE #else # define _GL_INLINE static _GL_UNUSED # define _GL_EXTERN_INLINE static _GL_UNUSED #endif /* In GCC 4.6 (inclusive) to 5.1 (exclusive), suppress bogus "no previous prototype for 'FOO'" and "no previous declaration for 'FOO'" diagnostics, when FOO is an inline function in the header; see and . */ #if __GNUC__ == 4 && 6 <= __GNUC_MINOR__ # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ # define _GL_INLINE_HEADER_CONST_PRAGMA # else # define _GL_INLINE_HEADER_CONST_PRAGMA \ _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") # endif # define _GL_INLINE_HEADER_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \ _GL_INLINE_HEADER_CONST_PRAGMA # define _GL_INLINE_HEADER_END \ _Pragma ("GCC diagnostic pop") #else # define _GL_INLINE_HEADER_BEGIN # define _GL_INLINE_HEADER_END #endif /* Define to a replacement function name for fnmatch(). */ #undef fnmatch /* Define to `int' if doesn't define. */ #undef gid_t /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to long or long long if and don't define. */ #undef intmax_t /* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. __APPLE__ && __MACH__ test for Mac OS X. __APPLE_CC__ tests for the Apple compiler and its version. __STDC_VERSION__ tests for the C99 mode. */ #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ # define __GNUC_STDC_INLINE__ 1 #endif /* Define to a type if does not define. */ #undef mbstate_t /* Define to `int' if does not define. */ #undef mode_t /* Define to the name of the strftime replacement function. */ #undef my_strftime /* Define to the type of st_nlink in struct stat, or a supertype. */ #undef nlink_t /* Define to `long int' if does not define. */ #undef off_t /* Define to `int' if does not define. */ #undef pid_t /* Define as the type of the result of subtracting two pointers, if the system doesn't define it. */ #undef ptrdiff_t /* Define to rpl_re_comp if the replacement should be used. */ #undef re_comp /* Define to rpl_re_compile_fastmap if the replacement should be used. */ #undef re_compile_fastmap /* Define to rpl_re_compile_pattern if the replacement should be used. */ #undef re_compile_pattern /* Define to rpl_re_exec if the replacement should be used. */ #undef re_exec /* Define to rpl_re_match if the replacement should be used. */ #undef re_match /* Define to rpl_re_match_2 if the replacement should be used. */ #undef re_match_2 /* Define to rpl_re_search if the replacement should be used. */ #undef re_search /* Define to rpl_re_search_2 if the replacement should be used. */ #undef re_search_2 /* Define to rpl_re_set_registers if the replacement should be used. */ #undef re_set_registers /* Define to rpl_re_set_syntax if the replacement should be used. */ #undef re_set_syntax /* Define to rpl_re_syntax_options if the replacement should be used. */ #undef re_syntax_options /* Define to rpl_regcomp if the replacement should be used. */ #undef regcomp /* Define to rpl_regerror if the replacement should be used. */ #undef regerror /* Define to rpl_regexec if the replacement should be used. */ #undef regexec /* Define to rpl_regfree if the replacement should be used. */ #undef regfree /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ #undef restrict /* Work around a bug in Sun C++: it does not support _Restrict or __restrict__, even though the corresponding Sun C compiler ends up with "#define restrict _Restrict" or "#define restrict __restrict__" in the previous line. Perhaps some future version of Sun C++ will work with restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ #if defined __SUNPRO_CC && !defined __RESTRICT # define _Restrict # define __restrict__ #endif /* Define to `unsigned int' if does not define. */ #undef size_t /* type to use in place of socklen_t if not defined */ #undef socklen_t /* Define as a signed type of the same size as size_t. */ #undef ssize_t /* Define to `int' if doesn't define. */ #undef uid_t /* Define as a marker that can be attached to declarations that might not be used. This helps to reduce warnings, such as from GCC -Wunused-parameter. */ #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) # define _GL_UNUSED __attribute__ ((__unused__)) #else # define _GL_UNUSED #endif /* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name is a misnomer outside of parameter lists. */ #define _UNUSED_PARAMETER_ _GL_UNUSED /* gcc supports the "unused" attribute on possibly unused labels, and g++ has since version 4.5. Note to support C++ as well as C, _GL_UNUSED_LABEL should be used with a trailing ; */ #if !defined __cplusplus || __GNUC__ > 4 \ || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) # define _GL_UNUSED_LABEL _GL_UNUSED #else # define _GL_UNUSED_LABEL #endif /* The __pure__ attribute was added in gcc 2.96. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else # define _GL_ATTRIBUTE_PURE /* empty */ #endif /* The __const__ attribute was added in gcc 2.95. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) #else # define _GL_ATTRIBUTE_CONST /* empty */ #endif #if defined(__cplusplus) && defined(inline) # undef /**/ inline #endif #if !defined(HAVE_SETPGID) && !defined(SETPGRP_VOID) # define setpgid(pid, pgrp) setpgrp((pid),(pgrp)) #endif #ifdef __cplusplus # define CDECL extern "C" # define CDECL_BEGIN CDECL { # define CDECL_END } template static inline T replace_value(T &var,T new_value) { T tmp=var; var=new_value; return tmp; } #else # define CDECL # define CDECL_BEGIN # define CDECL_END #endif /* should be included before any real code. */ #include #include "gettext.h" #define _(msgid) gettext (msgid) #define N_(msgid) msgid #ifndef PARAMS # if defined __STDC__ || defined __cplusplus # define PARAMS(x) x # else # define PARAMS(x) () # endif #endif #define INET6 (defined(AF_INET6) \ && defined(HAVE_GETNAMEINFO) \ && defined(HAVE_GETADDRINFO)) #define USE_EXPAT (defined(HAVE_EXPAT_H) && defined(HAVE_LIBEXPAT)) #if defined(SOCKS4) || defined(SOCKS5) || defined(SOCKS_DANTE) # define SOCKS 1 #endif #ifdef SOCKS # if defined(HAVE_SOCKS_H) CDECL_BEGIN # include CDECL_END # undef /**/ getc /* fix a problem with redefined getc */ # else // !HAVE_SOCKS_H # if defined(SOCKS4) || defined(SOCKS_DANTE) # define connect Rconnect # define getsockname Rgetsockname # define bind Rbind # define accept Raccept # define listen Rlisten # define select Rselect # ifdef HAVE_RPOLL # define poll Rpoll # endif CDECL int SOCKSinit(const char *); # endif # ifdef SOCKS_DANTE # define rresvport Rrresvport # define bindresvport Rbindresvport # define gethostbyname Rgethostbyname # define gethostbyname2 Rgethostbyname2 # define sendto Rsendto # define recvfrom Rrecvfrom # define recvfrom Rrecvfrom # define write Rwrite # define writev Rwritev # define send Rsend # define sendmsg Rsendmsg # define read Rread # define readv Rreadv # define recv Rrecv # define recvmsg Rrecvmsg # endif # endif // !HAVE_SOCKS_H #endif // SOCKS #if defined __MSDOS__ || defined __CYGWIN32__ # define NATIVE_CRLF 1 #endif #define E_RETRY(e) ((e)==EAGAIN || (e)==EWOULDBLOCK || (e)==EINTR) #define E_LOCK_IGNORE(e) ((e)==EINVAL || (e)==ENOLCK) #ifndef HAVE_RANDOM #define srandom(x) srand((x)) #define random() ((long)(rand()/(RAND_MAX+1.0)*2147483648.0)) #endif /* Tell the compiler when a conditional or integer expression is almost always true or almost always false. */ #ifndef HAVE_BUILTIN_EXPECT # define __builtin_expect(expr, val) (expr) #endif #ifdef __GNUC__ # define PRINTF_LIKE(n,m) __attribute__((format(__printf__,n,m))) #else # define PRINTF_LIKE(n,m) # define __attribute__(x) #endif /* Attribute `sentinel' was valid as of gcc 3.5. */ #if defined(__GNUC__) && \ (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 5)) # define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) #else # define ATTRIBUTE_SENTINEL #endif #ifdef TRIO_REPLACE_STDIO /* replace all the functions */ # undef /**/ HAVE_PRINTF # undef /**/ HAVE_VPRINTF # undef /**/ HAVE_FPRINTF # undef /**/ HAVE_VFPRINTF # undef /**/ HAVE_SPRINTF # undef /**/ HAVE_VSPRINTF # undef /**/ HAVE_SNPRINTF # undef /**/ HAVE_VSNPRINTF # undef /**/ HAVE_SCANF # undef /**/ HAVE_VSCANF # undef /**/ HAVE_FSCANF # undef /**/ HAVE_VFSCANF # undef /**/ HAVE_SSCANF # undef /**/ HAVE_VSSCANF # include "trio.h" #endif #define USE_SSL (defined(USE_GNUTLS) || defined(USE_OPENSSL)) #endif /* CONFIG_H */ lftp-4.6.3a/lib/nl_langinfo.c0000644000015000007670000002160212466374011012760 00000000000000/* nl_langinfo() replacement: query locale dependent information. Copyright (C) 2007-2015 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 . */ #include /* Specification. */ #include #include #include #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN /* avoid including junk */ # include # include #endif /* Return the codeset of the current locale, if this is easily deducible. Otherwise, return "". */ static char * ctype_codeset (void) { static char buf[2 + 10 + 1]; size_t buflen = 0; char const *locale = setlocale (LC_CTYPE, NULL); char *codeset = buf; size_t codesetlen; codeset[0] = '\0'; if (locale && locale[0]) { /* If the locale name contains an encoding after the dot, return it. */ char *dot = strchr (locale, '.'); if (dot) { /* Look for the possible @... trailer and remove it, if any. */ char *codeset_start = dot + 1; char const *modifier = strchr (codeset_start, '@'); if (! modifier) codeset = codeset_start; else { codesetlen = modifier - codeset_start; if (codesetlen < sizeof buf) { codeset = memcpy (buf, codeset_start, codesetlen); codeset[codesetlen] = '\0'; } } } } #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* If setlocale is successful, it returns the number of the codepage, as a string. Otherwise, fall back on Windows API GetACP, which returns the locale's codepage as a number (although this doesn't change according to what the 'setlocale' call specified). Either way, prepend "CP" to make it a valid codeset name. */ codesetlen = strlen (codeset); if (0 < codesetlen && codesetlen < sizeof buf - 2) memmove (buf + 2, codeset, codesetlen + 1); else sprintf (buf + 2, "%u", GetACP ()); codeset = memcpy (buf, "CP", 2); #endif return codeset; } #if REPLACE_NL_LANGINFO /* Override nl_langinfo with support for added nl_item values. */ # undef nl_langinfo char * rpl_nl_langinfo (nl_item item) { switch (item) { # if GNULIB_defined_CODESET case CODESET: return ctype_codeset (); # endif # if GNULIB_defined_T_FMT_AMPM case T_FMT_AMPM: return "%I:%M:%S %p"; # endif # if GNULIB_defined_ERA case ERA: /* The format is not standardized. In glibc it is a sequence of strings of the form "direction:offset:start_date:end_date:era_name:era_format" with an empty string at the end. */ return ""; case ERA_D_FMT: /* The %Ex conversion in strftime behaves like %x if the locale does not have an alternative time format. */ item = D_FMT; break; case ERA_D_T_FMT: /* The %Ec conversion in strftime behaves like %c if the locale does not have an alternative time format. */ item = D_T_FMT; break; case ERA_T_FMT: /* The %EX conversion in strftime behaves like %X if the locale does not have an alternative time format. */ item = T_FMT; break; case ALT_DIGITS: /* The format is not standardized. In glibc it is a sequence of 10 strings, appended in memory. */ return "\0\0\0\0\0\0\0\0\0\0"; # endif # if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS case YESEXPR: return "^[yY]"; case NOEXPR: return "^[nN]"; # endif default: break; } return nl_langinfo (item); } #else /* Provide nl_langinfo from scratch, either for native MS-Windows, or for old Unix platforms without locales, such as Linux libc5 or BeOS. */ # include char * nl_langinfo (nl_item item) { static char nlbuf[100]; struct tm tmm = { 0 }; switch (item) { /* nl_langinfo items of the LC_CTYPE category */ case CODESET: { char *codeset = ctype_codeset (); if (*codeset) return codeset; } # ifdef __BEOS__ return "UTF-8"; # else return "ISO-8859-1"; # endif /* nl_langinfo items of the LC_NUMERIC category */ case RADIXCHAR: return localeconv () ->decimal_point; case THOUSEP: return localeconv () ->thousands_sep; case GROUPING: return localeconv () ->grouping; /* nl_langinfo items of the LC_TIME category. TODO: Really use the locale. */ case D_T_FMT: case ERA_D_T_FMT: return "%a %b %e %H:%M:%S %Y"; case D_FMT: case ERA_D_FMT: return "%m/%d/%y"; case T_FMT: case ERA_T_FMT: return "%H:%M:%S"; case T_FMT_AMPM: return "%I:%M:%S %p"; case AM_STR: if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm)) return "AM"; return nlbuf; case PM_STR: tmm.tm_hour = 12; if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm)) return "PM"; return nlbuf; case DAY_1: case DAY_2: case DAY_3: case DAY_4: case DAY_5: case DAY_6: case DAY_7: { static char const days[][sizeof "Wednesday"] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; tmm.tm_wday = item - DAY_1; if (!strftime (nlbuf, sizeof nlbuf, "%A", &tmm)) return (char *) days[item - DAY_1]; return nlbuf; } case ABDAY_1: case ABDAY_2: case ABDAY_3: case ABDAY_4: case ABDAY_5: case ABDAY_6: case ABDAY_7: { static char const abdays[][sizeof "Sun"] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; tmm.tm_wday = item - ABDAY_1; if (!strftime (nlbuf, sizeof nlbuf, "%a", &tmm)) return (char *) abdays[item - ABDAY_1]; return nlbuf; } case MON_1: case MON_2: case MON_3: case MON_4: case MON_5: case MON_6: case MON_7: case MON_8: case MON_9: case MON_10: case MON_11: case MON_12: { static char const months[][sizeof "September"] = { "January", "February", "March", "April", "May", "June", "July", "September", "October", "November", "December" }; tmm.tm_mon = item - MON_1; if (!strftime (nlbuf, sizeof nlbuf, "%B", &tmm)) return (char *) months[item - MON_1]; return nlbuf; } case ABMON_1: case ABMON_2: case ABMON_3: case ABMON_4: case ABMON_5: case ABMON_6: case ABMON_7: case ABMON_8: case ABMON_9: case ABMON_10: case ABMON_11: case ABMON_12: { static char const abmonths[][sizeof "Jan"] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Sep", "Oct", "Nov", "Dec" }; tmm.tm_mon = item - ABMON_1; if (!strftime (nlbuf, sizeof nlbuf, "%b", &tmm)) return (char *) abmonths[item - ABMON_1]; return nlbuf; } case ERA: return ""; case ALT_DIGITS: return "\0\0\0\0\0\0\0\0\0\0"; /* nl_langinfo items of the LC_MONETARY category. */ case CRNCYSTR: return localeconv () ->currency_symbol; case INT_CURR_SYMBOL: return localeconv () ->int_curr_symbol; case MON_DECIMAL_POINT: return localeconv () ->mon_decimal_point; case MON_THOUSANDS_SEP: return localeconv () ->mon_thousands_sep; case MON_GROUPING: return localeconv () ->mon_grouping; case POSITIVE_SIGN: return localeconv () ->positive_sign; case NEGATIVE_SIGN: return localeconv () ->negative_sign; case FRAC_DIGITS: return & localeconv () ->frac_digits; case INT_FRAC_DIGITS: return & localeconv () ->int_frac_digits; case P_CS_PRECEDES: return & localeconv () ->p_cs_precedes; case N_CS_PRECEDES: return & localeconv () ->n_cs_precedes; case P_SEP_BY_SPACE: return & localeconv () ->p_sep_by_space; case N_SEP_BY_SPACE: return & localeconv () ->n_sep_by_space; case P_SIGN_POSN: return & localeconv () ->p_sign_posn; case N_SIGN_POSN: return & localeconv () ->n_sign_posn; /* nl_langinfo items of the LC_MESSAGES category TODO: Really use the locale. */ case YESEXPR: return "^[yY]"; case NOEXPR: return "^[nN]"; default: return ""; } } #endif lftp-4.6.3a/lib/malloca.valgrind0000644000015000007670000000025712122621312013455 00000000000000# Suppress a valgrind message about use of uninitialized memory in freea(). # This use is OK because it provides only a speedup. { freea Memcheck:Cond fun:freea } lftp-4.6.3a/lib/regex_internal.c0000644000015000007670000013673212466374012013514 00000000000000/* Extended regular expression matching and search library. Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . The GNU C Library 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. The GNU C Library 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 the GNU C Library; if not, see . */ static void re_string_construct_common (const char *str, Idx len, re_string_t *pstr, RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) internal_function; static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, re_hashval_t hash) internal_function; static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, unsigned int context, re_hashval_t hash) internal_function; /* Functions for string operation. */ /* This function allocate the buffers. It is necessary to call re_string_reconstruct before using the object. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len, RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) { reg_errcode_t ret; Idx init_buf_len; /* Ensure at least one character fits into the buffers. */ if (init_len < dfa->mb_cur_max) init_len = dfa->mb_cur_max; init_buf_len = (len + 1 < init_len) ? len + 1: init_len; re_string_construct_common (str, len, pstr, trans, icase, dfa); ret = re_string_realloc_buffers (pstr, init_buf_len); if (BE (ret != REG_NOERROR, 0)) return ret; pstr->word_char = dfa->word_char; pstr->word_ops_used = dfa->word_ops_used; pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len; pstr->valid_raw_len = pstr->valid_len; return REG_NOERROR; } /* This function allocate the buffers, and initialize them. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ re_string_construct (re_string_t *pstr, const char *str, Idx len, RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) { reg_errcode_t ret; memset (pstr, '\0', sizeof (re_string_t)); re_string_construct_common (str, len, pstr, trans, icase, dfa); if (len > 0) { ret = re_string_realloc_buffers (pstr, len + 1); if (BE (ret != REG_NOERROR, 0)) return ret; } pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; if (icase) { #ifdef RE_ENABLE_I18N if (dfa->mb_cur_max > 1) { while (1) { ret = build_wcs_upper_buffer (pstr); if (BE (ret != REG_NOERROR, 0)) return ret; if (pstr->valid_raw_len >= len) break; if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max) break; ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); if (BE (ret != REG_NOERROR, 0)) return ret; } } else #endif /* RE_ENABLE_I18N */ build_upper_buffer (pstr); } else { #ifdef RE_ENABLE_I18N if (dfa->mb_cur_max > 1) build_wcs_buffer (pstr); else #endif /* RE_ENABLE_I18N */ { if (trans != NULL) re_string_translate_buffer (pstr); else { pstr->valid_len = pstr->bufs_len; pstr->valid_raw_len = pstr->bufs_len; } } } return REG_NOERROR; } /* Helper functions for re_string_allocate, and re_string_construct. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) { #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) { wint_t *new_wcs; /* Avoid overflow in realloc. */ const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx)); if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_buf_len, 0)) return REG_ESPACE; new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); if (BE (new_wcs == NULL, 0)) return REG_ESPACE; pstr->wcs = new_wcs; if (pstr->offsets != NULL) { Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len); if (BE (new_offsets == NULL, 0)) return REG_ESPACE; pstr->offsets = new_offsets; } } #endif /* RE_ENABLE_I18N */ if (pstr->mbs_allocated) { unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, new_buf_len); if (BE (new_mbs == NULL, 0)) return REG_ESPACE; pstr->mbs = new_mbs; } pstr->bufs_len = new_buf_len; return REG_NOERROR; } static void internal_function re_string_construct_common (const char *str, Idx len, re_string_t *pstr, RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) { pstr->raw_mbs = (const unsigned char *) str; pstr->len = len; pstr->raw_len = len; pstr->trans = trans; pstr->icase = icase; pstr->mbs_allocated = (trans != NULL || icase); pstr->mb_cur_max = dfa->mb_cur_max; pstr->is_utf8 = dfa->is_utf8; pstr->map_notascii = dfa->map_notascii; pstr->stop = pstr->len; pstr->raw_stop = pstr->stop; } #ifdef RE_ENABLE_I18N /* Build wide character buffer PSTR->WCS. If the byte sequence of the string are: (0), (1), (0), (1), Then wide character buffer will be: , WEOF , , WEOF , We use WEOF for padding, they indicate that the position isn't a first byte of a multibyte character. Note that this function assumes PSTR->VALID_LEN elements are already built and starts from PSTR->VALID_LEN. */ static void internal_function build_wcs_buffer (re_string_t *pstr) { #ifdef _LIBC unsigned char buf[MB_LEN_MAX]; assert (MB_LEN_MAX >= pstr->mb_cur_max); #else unsigned char buf[64]; #endif mbstate_t prev_st; Idx byte_idx, end_idx, remain_len; size_t mbclen; /* Build the buffers from pstr->valid_len to either pstr->len or pstr->bufs_len. */ end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; for (byte_idx = pstr->valid_len; byte_idx < end_idx;) { wchar_t wc; const char *p; remain_len = end_idx - byte_idx; prev_st = pstr->cur_state; /* Apply the translation if we need. */ if (BE (pstr->trans != NULL, 0)) { int i, ch; for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) { ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i]; buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch]; } p = (const char *) buf; } else p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); if (BE (mbclen == (size_t) -1 || mbclen == 0 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0)) { /* We treat these cases as a singlebyte character. */ mbclen = 1; wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; if (BE (pstr->trans != NULL, 0)) wc = pstr->trans[wc]; pstr->cur_state = prev_st; } else if (BE (mbclen == (size_t) -2, 0)) { /* The buffer doesn't have enough space, finish to build. */ pstr->cur_state = prev_st; break; } /* Write wide character and padding. */ pstr->wcs[byte_idx++] = wc; /* Write paddings. */ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) pstr->wcs[byte_idx++] = WEOF; } pstr->valid_len = byte_idx; pstr->valid_raw_len = byte_idx; } /* Build wide character buffer PSTR->WCS like build_wcs_buffer, but for REG_ICASE. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ build_wcs_upper_buffer (re_string_t *pstr) { mbstate_t prev_st; Idx src_idx, byte_idx, end_idx, remain_len; size_t mbclen; #ifdef _LIBC char buf[MB_LEN_MAX]; assert (MB_LEN_MAX >= pstr->mb_cur_max); #else char buf[64]; #endif byte_idx = pstr->valid_len; end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; /* The following optimization assumes that ASCII characters can be mapped to wide characters with a simple cast. */ if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed) { while (byte_idx < end_idx) { wchar_t wc; if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]) && mbsinit (&pstr->cur_state)) { /* In case of a singlebyte character. */ pstr->mbs[byte_idx] = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]); /* The next step uses the assumption that wchar_t is encoded ASCII-safe: all ASCII values can be converted like this. */ pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx]; ++byte_idx; continue; } remain_len = end_idx - byte_idx; prev_st = pstr->cur_state; mbclen = __mbrtowc (&wc, ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx), remain_len, &pstr->cur_state); if (BE (mbclen < (size_t) -2, 1)) { wchar_t wcu = towupper (wc); if (wcu != wc) { size_t mbcdlen; mbcdlen = wcrtomb (buf, wcu, &prev_st); if (BE (mbclen == mbcdlen, 1)) memcpy (pstr->mbs + byte_idx, buf, mbclen); else { src_idx = byte_idx; goto offsets_needed; } } else memcpy (pstr->mbs + byte_idx, pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen); pstr->wcs[byte_idx++] = wcu; /* Write paddings. */ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) pstr->wcs[byte_idx++] = WEOF; } else if (mbclen == (size_t) -1 || mbclen == 0 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len)) { /* It is an invalid character, an incomplete character at the end of the string, or '\0'. Just use the byte. */ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; pstr->mbs[byte_idx] = ch; /* And also cast it to wide char. */ pstr->wcs[byte_idx++] = (wchar_t) ch; if (BE (mbclen == (size_t) -1, 0)) pstr->cur_state = prev_st; } else { /* The buffer doesn't have enough space, finish to build. */ pstr->cur_state = prev_st; break; } } pstr->valid_len = byte_idx; pstr->valid_raw_len = byte_idx; return REG_NOERROR; } else for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;) { wchar_t wc; const char *p; offsets_needed: remain_len = end_idx - byte_idx; prev_st = pstr->cur_state; if (BE (pstr->trans != NULL, 0)) { int i, ch; for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) { ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i]; buf[i] = pstr->trans[ch]; } p = (const char *) buf; } else p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); if (BE (mbclen < (size_t) -2, 1)) { wchar_t wcu = towupper (wc); if (wcu != wc) { size_t mbcdlen; mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st); if (BE (mbclen == mbcdlen, 1)) memcpy (pstr->mbs + byte_idx, buf, mbclen); else if (mbcdlen != (size_t) -1) { size_t i; if (byte_idx + mbcdlen > pstr->bufs_len) { pstr->cur_state = prev_st; break; } if (pstr->offsets == NULL) { pstr->offsets = re_malloc (Idx, pstr->bufs_len); if (pstr->offsets == NULL) return REG_ESPACE; } if (!pstr->offsets_needed) { for (i = 0; i < (size_t) byte_idx; ++i) pstr->offsets[i] = i; pstr->offsets_needed = 1; } memcpy (pstr->mbs + byte_idx, buf, mbcdlen); pstr->wcs[byte_idx] = wcu; pstr->offsets[byte_idx] = src_idx; for (i = 1; i < mbcdlen; ++i) { pstr->offsets[byte_idx + i] = src_idx + (i < mbclen ? i : mbclen - 1); pstr->wcs[byte_idx + i] = WEOF; } pstr->len += mbcdlen - mbclen; if (pstr->raw_stop > src_idx) pstr->stop += mbcdlen - mbclen; end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; byte_idx += mbcdlen; src_idx += mbclen; continue; } else memcpy (pstr->mbs + byte_idx, p, mbclen); } else memcpy (pstr->mbs + byte_idx, p, mbclen); if (BE (pstr->offsets_needed != 0, 0)) { size_t i; for (i = 0; i < mbclen; ++i) pstr->offsets[byte_idx + i] = src_idx + i; } src_idx += mbclen; pstr->wcs[byte_idx++] = wcu; /* Write paddings. */ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) pstr->wcs[byte_idx++] = WEOF; } else if (mbclen == (size_t) -1 || mbclen == 0 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len)) { /* It is an invalid character or '\0'. Just use the byte. */ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; if (BE (pstr->trans != NULL, 0)) ch = pstr->trans [ch]; pstr->mbs[byte_idx] = ch; if (BE (pstr->offsets_needed != 0, 0)) pstr->offsets[byte_idx] = src_idx; ++src_idx; /* And also cast it to wide char. */ pstr->wcs[byte_idx++] = (wchar_t) ch; if (BE (mbclen == (size_t) -1, 0)) pstr->cur_state = prev_st; } else { /* The buffer doesn't have enough space, finish to build. */ pstr->cur_state = prev_st; break; } } pstr->valid_len = byte_idx; pstr->valid_raw_len = src_idx; return REG_NOERROR; } /* Skip characters until the index becomes greater than NEW_RAW_IDX. Return the index. */ static Idx internal_function re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc) { mbstate_t prev_st; Idx rawbuf_idx; size_t mbclen; wint_t wc = WEOF; /* Skip the characters which are not necessary to check. */ for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; rawbuf_idx < new_raw_idx;) { wchar_t wc2; Idx remain_len = pstr->raw_len - rawbuf_idx; prev_st = pstr->cur_state; mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, remain_len, &pstr->cur_state); if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) { /* We treat these cases as a single byte character. */ if (mbclen == 0 || remain_len == 0) wc = L'\0'; else wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx); mbclen = 1; pstr->cur_state = prev_st; } else wc = wc2; /* Then proceed the next character. */ rawbuf_idx += mbclen; } *last_wc = wc; return rawbuf_idx; } #endif /* RE_ENABLE_I18N */ /* Build the buffer PSTR->MBS, and apply the translation if we need. This function is used in case of REG_ICASE. */ static void internal_function build_upper_buffer (re_string_t *pstr) { Idx char_idx, end_idx; end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx) { int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx]; if (BE (pstr->trans != NULL, 0)) ch = pstr->trans[ch]; pstr->mbs[char_idx] = toupper (ch); } pstr->valid_len = char_idx; pstr->valid_raw_len = char_idx; } /* Apply TRANS to the buffer in PSTR. */ static void internal_function re_string_translate_buffer (re_string_t *pstr) { Idx buf_idx, end_idx; end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx) { int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx]; pstr->mbs[buf_idx] = pstr->trans[ch]; } pstr->valid_len = buf_idx; pstr->valid_raw_len = buf_idx; } /* This function re-construct the buffers. Concretely, convert to wide character in case of pstr->mb_cur_max > 1, convert to upper case in case of REG_ICASE, apply translation. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) { Idx offset; if (BE (pstr->raw_mbs_idx <= idx, 0)) offset = idx - pstr->raw_mbs_idx; else { /* Reset buffer. */ #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); #endif /* RE_ENABLE_I18N */ pstr->len = pstr->raw_len; pstr->stop = pstr->raw_stop; pstr->valid_len = 0; pstr->raw_mbs_idx = 0; pstr->valid_raw_len = 0; pstr->offsets_needed = 0; pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF : CONTEXT_NEWLINE | CONTEXT_BEGBUF); if (!pstr->mbs_allocated) pstr->mbs = (unsigned char *) pstr->raw_mbs; offset = idx; } if (BE (offset != 0, 1)) { /* Should the already checked characters be kept? */ if (BE (offset < pstr->valid_raw_len, 1)) { /* Yes, move them to the front of the buffer. */ #ifdef RE_ENABLE_I18N if (BE (pstr->offsets_needed, 0)) { Idx low = 0, high = pstr->valid_len, mid; do { mid = (high + low) / 2; if (pstr->offsets[mid] > offset) high = mid; else if (pstr->offsets[mid] < offset) low = mid + 1; else break; } while (low < high); if (pstr->offsets[mid] < offset) ++mid; pstr->tip_context = re_string_context_at (pstr, mid - 1, eflags); /* This can be quite complicated, so handle specially only the common and easy case where the character with different length representation of lower and upper case is present at or after offset. */ if (pstr->valid_len > offset && mid == offset && pstr->offsets[mid] == offset) { memmove (pstr->wcs, pstr->wcs + offset, (pstr->valid_len - offset) * sizeof (wint_t)); memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset); pstr->valid_len -= offset; pstr->valid_raw_len -= offset; for (low = 0; low < pstr->valid_len; low++) pstr->offsets[low] = pstr->offsets[low + offset] - offset; } else { /* Otherwise, just find out how long the partial multibyte character at offset is and fill it with WEOF/255. */ pstr->len = pstr->raw_len - idx + offset; pstr->stop = pstr->raw_stop - idx + offset; pstr->offsets_needed = 0; while (mid > 0 && pstr->offsets[mid - 1] == offset) --mid; while (mid < pstr->valid_len) if (pstr->wcs[mid] != WEOF) break; else ++mid; if (mid == pstr->valid_len) pstr->valid_len = 0; else { pstr->valid_len = pstr->offsets[mid] - offset; if (pstr->valid_len) { for (low = 0; low < pstr->valid_len; ++low) pstr->wcs[low] = WEOF; memset (pstr->mbs, 255, pstr->valid_len); } } pstr->valid_raw_len = pstr->valid_len; } } else #endif { pstr->tip_context = re_string_context_at (pstr, offset - 1, eflags); #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) memmove (pstr->wcs, pstr->wcs + offset, (pstr->valid_len - offset) * sizeof (wint_t)); #endif /* RE_ENABLE_I18N */ if (BE (pstr->mbs_allocated, 0)) memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset); pstr->valid_len -= offset; pstr->valid_raw_len -= offset; #if defined DEBUG && DEBUG assert (pstr->valid_len > 0); #endif } } else { #ifdef RE_ENABLE_I18N /* No, skip all characters until IDX. */ Idx prev_valid_len = pstr->valid_len; if (BE (pstr->offsets_needed, 0)) { pstr->len = pstr->raw_len - idx + offset; pstr->stop = pstr->raw_stop - idx + offset; pstr->offsets_needed = 0; } #endif pstr->valid_len = 0; #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) { Idx wcs_idx; wint_t wc = WEOF; if (pstr->is_utf8) { const unsigned char *raw, *p, *end; /* Special case UTF-8. Multi-byte chars start with any byte other than 0x80 - 0xbf. */ raw = pstr->raw_mbs + pstr->raw_mbs_idx; end = raw + (offset - pstr->mb_cur_max); if (end < pstr->raw_mbs) end = pstr->raw_mbs; p = raw + offset - 1; #ifdef _LIBC /* We know the wchar_t encoding is UCS4, so for the simple case, ASCII characters, skip the conversion step. */ if (isascii (*p) && BE (pstr->trans == NULL, 1)) { memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); /* pstr->valid_len = 0; */ wc = (wchar_t) *p; } else #endif for (; p >= end; --p) if ((*p & 0xc0) != 0x80) { mbstate_t cur_state; wchar_t wc2; Idx mlen = raw + pstr->len - p; unsigned char buf[6]; size_t mbclen; const unsigned char *pp = p; if (BE (pstr->trans != NULL, 0)) { int i = mlen < 6 ? mlen : 6; while (--i >= 0) buf[i] = pstr->trans[p[i]]; pp = buf; } /* XXX Don't use mbrtowc, we know which conversion to use (UTF-8 -> UCS4). */ memset (&cur_state, 0, sizeof (cur_state)); mbclen = __mbrtowc (&wc2, (const char *) pp, mlen, &cur_state); if (raw + offset - p <= mbclen && mbclen < (size_t) -2) { memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); pstr->valid_len = mbclen - (raw + offset - p); wc = wc2; } break; } } if (wc == WEOF) pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx; if (wc == WEOF) pstr->tip_context = re_string_context_at (pstr, prev_valid_len - 1, eflags); else pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) ? CONTEXT_WORD : ((IS_WIDE_NEWLINE (wc) && pstr->newline_anchor) ? CONTEXT_NEWLINE : 0)); if (BE (pstr->valid_len, 0)) { for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) pstr->wcs[wcs_idx] = WEOF; if (pstr->mbs_allocated) memset (pstr->mbs, 255, pstr->valid_len); } pstr->valid_raw_len = pstr->valid_len; } else #endif /* RE_ENABLE_I18N */ { int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; pstr->valid_raw_len = 0; if (pstr->trans) c = pstr->trans[c]; pstr->tip_context = (bitset_contain (pstr->word_char, c) ? CONTEXT_WORD : ((IS_NEWLINE (c) && pstr->newline_anchor) ? CONTEXT_NEWLINE : 0)); } } if (!BE (pstr->mbs_allocated, 0)) pstr->mbs += offset; } pstr->raw_mbs_idx = idx; pstr->len -= offset; pstr->stop -= offset; /* Then build the buffers. */ #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) { if (pstr->icase) { reg_errcode_t ret = build_wcs_upper_buffer (pstr); if (BE (ret != REG_NOERROR, 0)) return ret; } else build_wcs_buffer (pstr); } else #endif /* RE_ENABLE_I18N */ if (BE (pstr->mbs_allocated, 0)) { if (pstr->icase) build_upper_buffer (pstr); else if (pstr->trans != NULL) re_string_translate_buffer (pstr); } else pstr->valid_len = pstr->len; pstr->cur_idx = 0; return REG_NOERROR; } static unsigned char internal_function __attribute__ ((pure)) re_string_peek_byte_case (const re_string_t *pstr, Idx idx) { int ch; Idx off; /* Handle the common (easiest) cases first. */ if (BE (!pstr->mbs_allocated, 1)) return re_string_peek_byte (pstr, idx); #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1 && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx)) return re_string_peek_byte (pstr, idx); #endif off = pstr->cur_idx + idx; #ifdef RE_ENABLE_I18N if (pstr->offsets_needed) off = pstr->offsets[off]; #endif ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; #ifdef RE_ENABLE_I18N /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I this function returns CAPITAL LETTER I instead of first byte of DOTLESS SMALL LETTER I. The latter would confuse the parser, since peek_byte_case doesn't advance cur_idx in any way. */ if (pstr->offsets_needed && !isascii (ch)) return re_string_peek_byte (pstr, idx); #endif return ch; } static unsigned char internal_function re_string_fetch_byte_case (re_string_t *pstr) { if (BE (!pstr->mbs_allocated, 1)) return re_string_fetch_byte (pstr); #ifdef RE_ENABLE_I18N if (pstr->offsets_needed) { Idx off; int ch; /* For tr_TR.UTF-8 [[:islower:]] there is [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip in that case the whole multi-byte character and return the original letter. On the other side, with [[: DOTLESS SMALL LETTER I return [[:I, as doing anything else would complicate things too much. */ if (!re_string_first_byte (pstr, pstr->cur_idx)) return re_string_fetch_byte (pstr); off = pstr->offsets[pstr->cur_idx]; ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; if (! isascii (ch)) return re_string_fetch_byte (pstr); re_string_skip_bytes (pstr, re_string_char_size_at (pstr, pstr->cur_idx)); return ch; } #endif return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; } static void internal_function re_string_destruct (re_string_t *pstr) { #ifdef RE_ENABLE_I18N re_free (pstr->wcs); re_free (pstr->offsets); #endif /* RE_ENABLE_I18N */ if (pstr->mbs_allocated) re_free (pstr->mbs); } /* Return the context at IDX in INPUT. */ static unsigned int internal_function re_string_context_at (const re_string_t *input, Idx idx, int eflags) { int c; if (BE (! REG_VALID_INDEX (idx), 0)) /* In this case, we use the value stored in input->tip_context, since we can't know the character in input->mbs[-1] here. */ return input->tip_context; if (BE (idx == input->len, 0)) return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF : CONTEXT_NEWLINE | CONTEXT_ENDBUF); #ifdef RE_ENABLE_I18N if (input->mb_cur_max > 1) { wint_t wc; Idx wc_idx = idx; while(input->wcs[wc_idx] == WEOF) { #if defined DEBUG && DEBUG /* It must not happen. */ assert (REG_VALID_INDEX (wc_idx)); #endif --wc_idx; if (! REG_VALID_INDEX (wc_idx)) return input->tip_context; } wc = input->wcs[wc_idx]; if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) return CONTEXT_WORD; return (IS_WIDE_NEWLINE (wc) && input->newline_anchor ? CONTEXT_NEWLINE : 0); } else #endif { c = re_string_byte_at (input, idx); if (bitset_contain (input->word_char, c)) return CONTEXT_WORD; return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0; } } /* Functions for set operation. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ re_node_set_alloc (re_node_set *set, Idx size) { set->alloc = size; set->nelem = 0; set->elems = re_malloc (Idx, size); if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0)) return REG_ESPACE; return REG_NOERROR; } static reg_errcode_t internal_function __attribute_warn_unused_result__ re_node_set_init_1 (re_node_set *set, Idx elem) { set->alloc = 1; set->nelem = 1; set->elems = re_malloc (Idx, 1); if (BE (set->elems == NULL, 0)) { set->alloc = set->nelem = 0; return REG_ESPACE; } set->elems[0] = elem; return REG_NOERROR; } static reg_errcode_t internal_function __attribute_warn_unused_result__ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2) { set->alloc = 2; set->elems = re_malloc (Idx, 2); if (BE (set->elems == NULL, 0)) return REG_ESPACE; if (elem1 == elem2) { set->nelem = 1; set->elems[0] = elem1; } else { set->nelem = 2; if (elem1 < elem2) { set->elems[0] = elem1; set->elems[1] = elem2; } else { set->elems[0] = elem2; set->elems[1] = elem1; } } return REG_NOERROR; } static reg_errcode_t internal_function __attribute_warn_unused_result__ re_node_set_init_copy (re_node_set *dest, const re_node_set *src) { dest->nelem = src->nelem; if (src->nelem > 0) { dest->alloc = dest->nelem; dest->elems = re_malloc (Idx, dest->alloc); if (BE (dest->elems == NULL, 0)) { dest->alloc = dest->nelem = 0; return REG_ESPACE; } memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); } else re_node_set_init_empty (dest); return REG_NOERROR; } /* Calculate the intersection of the sets SRC1 and SRC2. And merge it to DEST. Return value indicate the error code or REG_NOERROR if succeeded. Note: We assume dest->elems is NULL, when dest->alloc is 0. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, const re_node_set *src2) { Idx i1, i2, is, id, delta, sbase; if (src1->nelem == 0 || src2->nelem == 0) return REG_NOERROR; /* We need dest->nelem + 2 * elems_in_intersection; this is a conservative estimate. */ if (src1->nelem + src2->nelem + dest->nelem > dest->alloc) { Idx new_alloc = src1->nelem + src2->nelem + dest->alloc; Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc); if (BE (new_elems == NULL, 0)) return REG_ESPACE; dest->elems = new_elems; dest->alloc = new_alloc; } /* Find the items in the intersection of SRC1 and SRC2, and copy into the top of DEST those that are not already in DEST itself. */ sbase = dest->nelem + src1->nelem + src2->nelem; i1 = src1->nelem - 1; i2 = src2->nelem - 1; id = dest->nelem - 1; for (;;) { if (src1->elems[i1] == src2->elems[i2]) { /* Try to find the item in DEST. Maybe we could binary search? */ while (REG_VALID_INDEX (id) && dest->elems[id] > src1->elems[i1]) --id; if (! REG_VALID_INDEX (id) || dest->elems[id] != src1->elems[i1]) dest->elems[--sbase] = src1->elems[i1]; if (! REG_VALID_INDEX (--i1) || ! REG_VALID_INDEX (--i2)) break; } /* Lower the highest of the two items. */ else if (src1->elems[i1] < src2->elems[i2]) { if (! REG_VALID_INDEX (--i2)) break; } else { if (! REG_VALID_INDEX (--i1)) break; } } id = dest->nelem - 1; is = dest->nelem + src1->nelem + src2->nelem - 1; delta = is - sbase + 1; /* Now copy. When DELTA becomes zero, the remaining DEST elements are already in place; this is more or less the same loop that is in re_node_set_merge. */ dest->nelem += delta; if (delta > 0 && REG_VALID_INDEX (id)) for (;;) { if (dest->elems[is] > dest->elems[id]) { /* Copy from the top. */ dest->elems[id + delta--] = dest->elems[is--]; if (delta == 0) break; } else { /* Slide from the bottom. */ dest->elems[id + delta] = dest->elems[id]; if (! REG_VALID_INDEX (--id)) break; } } /* Copy remaining SRC elements. */ memcpy (dest->elems, dest->elems + sbase, delta * sizeof (Idx)); return REG_NOERROR; } /* Calculate the union set of the sets SRC1 and SRC2. And store it to DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ re_node_set_init_union (re_node_set *dest, const re_node_set *src1, const re_node_set *src2) { Idx i1, i2, id; if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0) { dest->alloc = src1->nelem + src2->nelem; dest->elems = re_malloc (Idx, dest->alloc); if (BE (dest->elems == NULL, 0)) return REG_ESPACE; } else { if (src1 != NULL && src1->nelem > 0) return re_node_set_init_copy (dest, src1); else if (src2 != NULL && src2->nelem > 0) return re_node_set_init_copy (dest, src2); else re_node_set_init_empty (dest); return REG_NOERROR; } for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;) { if (src1->elems[i1] > src2->elems[i2]) { dest->elems[id++] = src2->elems[i2++]; continue; } if (src1->elems[i1] == src2->elems[i2]) ++i2; dest->elems[id++] = src1->elems[i1++]; } if (i1 < src1->nelem) { memcpy (dest->elems + id, src1->elems + i1, (src1->nelem - i1) * sizeof (Idx)); id += src1->nelem - i1; } else if (i2 < src2->nelem) { memcpy (dest->elems + id, src2->elems + i2, (src2->nelem - i2) * sizeof (Idx)); id += src2->nelem - i2; } dest->nelem = id; return REG_NOERROR; } /* Calculate the union set of the sets DEST and SRC. And store it to DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ re_node_set_merge (re_node_set *dest, const re_node_set *src) { Idx is, id, sbase, delta; if (src == NULL || src->nelem == 0) return REG_NOERROR; if (dest->alloc < 2 * src->nelem + dest->nelem) { Idx new_alloc = 2 * (src->nelem + dest->alloc); Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc); if (BE (new_buffer == NULL, 0)) return REG_ESPACE; dest->elems = new_buffer; dest->alloc = new_alloc; } if (BE (dest->nelem == 0, 0)) { dest->nelem = src->nelem; memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); return REG_NOERROR; } /* Copy into the top of DEST the items of SRC that are not found in DEST. Maybe we could binary search in DEST? */ for (sbase = dest->nelem + 2 * src->nelem, is = src->nelem - 1, id = dest->nelem - 1; REG_VALID_INDEX (is) && REG_VALID_INDEX (id); ) { if (dest->elems[id] == src->elems[is]) is--, id--; else if (dest->elems[id] < src->elems[is]) dest->elems[--sbase] = src->elems[is--]; else /* if (dest->elems[id] > src->elems[is]) */ --id; } if (REG_VALID_INDEX (is)) { /* If DEST is exhausted, the remaining items of SRC must be unique. */ sbase -= is + 1; memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (Idx)); } id = dest->nelem - 1; is = dest->nelem + 2 * src->nelem - 1; delta = is - sbase + 1; if (delta == 0) return REG_NOERROR; /* Now copy. When DELTA becomes zero, the remaining DEST elements are already in place. */ dest->nelem += delta; for (;;) { if (dest->elems[is] > dest->elems[id]) { /* Copy from the top. */ dest->elems[id + delta--] = dest->elems[is--]; if (delta == 0) break; } else { /* Slide from the bottom. */ dest->elems[id + delta] = dest->elems[id]; if (! REG_VALID_INDEX (--id)) { /* Copy remaining SRC elements. */ memcpy (dest->elems, dest->elems + sbase, delta * sizeof (Idx)); break; } } } return REG_NOERROR; } /* Insert the new element ELEM to the re_node_set* SET. SET should not already have ELEM. Return true if successful. */ static bool internal_function __attribute_warn_unused_result__ re_node_set_insert (re_node_set *set, Idx elem) { Idx idx; /* In case the set is empty. */ if (set->alloc == 0) return BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1); if (BE (set->nelem, 0) == 0) { /* We already guaranteed above that set->alloc != 0. */ set->elems[0] = elem; ++set->nelem; return true; } /* Realloc if we need. */ if (set->alloc == set->nelem) { Idx *new_elems; set->alloc = set->alloc * 2; new_elems = re_realloc (set->elems, Idx, set->alloc); if (BE (new_elems == NULL, 0)) return false; set->elems = new_elems; } /* Move the elements which follows the new element. Test the first element separately to skip a check in the inner loop. */ if (elem < set->elems[0]) { idx = 0; for (idx = set->nelem; idx > 0; idx--) set->elems[idx] = set->elems[idx - 1]; } else { for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) set->elems[idx] = set->elems[idx - 1]; } /* Insert the new element. */ set->elems[idx] = elem; ++set->nelem; return true; } /* Insert the new element ELEM to the re_node_set* SET. SET should not already have any element greater than or equal to ELEM. Return true if successful. */ static bool internal_function __attribute_warn_unused_result__ re_node_set_insert_last (re_node_set *set, Idx elem) { /* Realloc if we need. */ if (set->alloc == set->nelem) { Idx *new_elems; set->alloc = (set->alloc + 1) * 2; new_elems = re_realloc (set->elems, Idx, set->alloc); if (BE (new_elems == NULL, 0)) return false; set->elems = new_elems; } /* Insert the new element. */ set->elems[set->nelem++] = elem; return true; } /* Compare two node sets SET1 and SET2. Return true if SET1 and SET2 are equivalent. */ static bool internal_function __attribute__ ((pure)) re_node_set_compare (const re_node_set *set1, const re_node_set *set2) { Idx i; if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem) return false; for (i = set1->nelem ; REG_VALID_INDEX (--i) ; ) if (set1->elems[i] != set2->elems[i]) return false; return true; } /* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ static Idx internal_function __attribute__ ((pure)) re_node_set_contains (const re_node_set *set, Idx elem) { __re_size_t idx, right, mid; if (! REG_VALID_NONZERO_INDEX (set->nelem)) return 0; /* Binary search the element. */ idx = 0; right = set->nelem - 1; while (idx < right) { mid = (idx + right) / 2; if (set->elems[mid] < elem) idx = mid + 1; else right = mid; } return set->elems[idx] == elem ? idx + 1 : 0; } static void internal_function re_node_set_remove_at (re_node_set *set, Idx idx) { if (idx < 0 || idx >= set->nelem) return; --set->nelem; for (; idx < set->nelem; idx++) set->elems[idx] = set->elems[idx + 1]; } /* Add the token TOKEN to dfa->nodes, and return the index of the token. Or return REG_MISSING if an error occurred. */ static Idx internal_function re_dfa_add_node (re_dfa_t *dfa, re_token_t token) { if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) { size_t new_nodes_alloc = dfa->nodes_alloc * 2; Idx *new_nexts, *new_indices; re_node_set *new_edests, *new_eclosures; re_token_t *new_nodes; /* Avoid overflows in realloc. */ const size_t max_object_size = MAX (sizeof (re_token_t), MAX (sizeof (re_node_set), sizeof (Idx))); if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0)) return REG_MISSING; new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); if (BE (new_nodes == NULL, 0)) return REG_MISSING; dfa->nodes = new_nodes; new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc); new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc); new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); if (BE (new_nexts == NULL || new_indices == NULL || new_edests == NULL || new_eclosures == NULL, 0)) return REG_MISSING; dfa->nexts = new_nexts; dfa->org_indices = new_indices; dfa->edests = new_edests; dfa->eclosures = new_eclosures; dfa->nodes_alloc = new_nodes_alloc; } dfa->nodes[dfa->nodes_len] = token; dfa->nodes[dfa->nodes_len].constraint = 0; #ifdef RE_ENABLE_I18N dfa->nodes[dfa->nodes_len].accept_mb = ((token.type == OP_PERIOD && dfa->mb_cur_max > 1) || token.type == COMPLEX_BRACKET); #endif dfa->nexts[dfa->nodes_len] = REG_MISSING; re_node_set_init_empty (dfa->edests + dfa->nodes_len); re_node_set_init_empty (dfa->eclosures + dfa->nodes_len); return dfa->nodes_len++; } static re_hashval_t internal_function calc_state_hash (const re_node_set *nodes, unsigned int context) { re_hashval_t hash = nodes->nelem + context; Idx i; for (i = 0 ; i < nodes->nelem ; i++) hash += nodes->elems[i]; return hash; } /* Search for the state whose node_set is equivalent to NODES. Return the pointer to the state, if we found it in the DFA. Otherwise create the new one and return it. In case of an error return NULL and set the error code in ERR. Note: - We assume NULL as the invalid state, then it is possible that return value is NULL and ERR is REG_NOERROR. - We never return non-NULL value in case of any errors, it is for optimization. */ static re_dfastate_t * internal_function __attribute_warn_unused_result__ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, const re_node_set *nodes) { re_hashval_t hash; re_dfastate_t *new_state; struct re_state_table_entry *spot; Idx i; #ifdef lint /* Suppress bogus uninitialized-variable warnings. */ *err = REG_NOERROR; #endif if (BE (nodes->nelem == 0, 0)) { *err = REG_NOERROR; return NULL; } hash = calc_state_hash (nodes, 0); spot = dfa->state_table + (hash & dfa->state_hash_mask); for (i = 0 ; i < spot->num ; i++) { re_dfastate_t *state = spot->array[i]; if (hash != state->hash) continue; if (re_node_set_compare (&state->nodes, nodes)) return state; } /* There are no appropriate state in the dfa, create the new one. */ new_state = create_ci_newstate (dfa, nodes, hash); if (BE (new_state == NULL, 0)) *err = REG_ESPACE; return new_state; } /* Search for the state whose node_set is equivalent to NODES and whose context is equivalent to CONTEXT. Return the pointer to the state, if we found it in the DFA. Otherwise create the new one and return it. In case of an error return NULL and set the error code in ERR. Note: - We assume NULL as the invalid state, then it is possible that return value is NULL and ERR is REG_NOERROR. - We never return non-NULL value in case of any errors, it is for optimization. */ static re_dfastate_t * internal_function __attribute_warn_unused_result__ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, const re_node_set *nodes, unsigned int context) { re_hashval_t hash; re_dfastate_t *new_state; struct re_state_table_entry *spot; Idx i; #ifdef lint /* Suppress bogus uninitialized-variable warnings. */ *err = REG_NOERROR; #endif if (nodes->nelem == 0) { *err = REG_NOERROR; return NULL; } hash = calc_state_hash (nodes, context); spot = dfa->state_table + (hash & dfa->state_hash_mask); for (i = 0 ; i < spot->num ; i++) { re_dfastate_t *state = spot->array[i]; if (state->hash == hash && state->context == context && re_node_set_compare (state->entrance_nodes, nodes)) return state; } /* There are no appropriate state in 'dfa', create the new one. */ new_state = create_cd_newstate (dfa, nodes, context, hash); if (BE (new_state == NULL, 0)) *err = REG_ESPACE; return new_state; } /* Finish initialization of the new state NEWSTATE, and using its hash value HASH put in the appropriate bucket of DFA's state table. Return value indicates the error code if failed. */ static reg_errcode_t __attribute_warn_unused_result__ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, re_hashval_t hash) { struct re_state_table_entry *spot; reg_errcode_t err; Idx i; newstate->hash = hash; err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem); if (BE (err != REG_NOERROR, 0)) return REG_ESPACE; for (i = 0; i < newstate->nodes.nelem; i++) { Idx elem = newstate->nodes.elems[i]; if (!IS_EPSILON_NODE (dfa->nodes[elem].type)) if (! re_node_set_insert_last (&newstate->non_eps_nodes, elem)) return REG_ESPACE; } spot = dfa->state_table + (hash & dfa->state_hash_mask); if (BE (spot->alloc <= spot->num, 0)) { Idx new_alloc = 2 * spot->num + 2; re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *, new_alloc); if (BE (new_array == NULL, 0)) return REG_ESPACE; spot->array = new_array; spot->alloc = new_alloc; } spot->array[spot->num++] = newstate; return REG_NOERROR; } static void free_state (re_dfastate_t *state) { re_node_set_free (&state->non_eps_nodes); re_node_set_free (&state->inveclosure); if (state->entrance_nodes != &state->nodes) { re_node_set_free (state->entrance_nodes); re_free (state->entrance_nodes); } re_node_set_free (&state->nodes); re_free (state->word_trtable); re_free (state->trtable); re_free (state); } /* Create the new state which is independent of contexts. Return the new state if succeeded, otherwise return NULL. */ static re_dfastate_t * internal_function __attribute_warn_unused_result__ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, re_hashval_t hash) { Idx i; reg_errcode_t err; re_dfastate_t *newstate; newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); if (BE (newstate == NULL, 0)) return NULL; err = re_node_set_init_copy (&newstate->nodes, nodes); if (BE (err != REG_NOERROR, 0)) { re_free (newstate); return NULL; } newstate->entrance_nodes = &newstate->nodes; for (i = 0 ; i < nodes->nelem ; i++) { re_token_t *node = dfa->nodes + nodes->elems[i]; re_token_type_t type = node->type; if (type == CHARACTER && !node->constraint) continue; #ifdef RE_ENABLE_I18N newstate->accept_mb |= node->accept_mb; #endif /* RE_ENABLE_I18N */ /* If the state has the halt node, the state is a halt state. */ if (type == END_OF_RE) newstate->halt = 1; else if (type == OP_BACK_REF) newstate->has_backref = 1; else if (type == ANCHOR || node->constraint) newstate->has_constraint = 1; } err = register_state (dfa, newstate, hash); if (BE (err != REG_NOERROR, 0)) { free_state (newstate); newstate = NULL; } return newstate; } /* Create the new state which is depend on the context CONTEXT. Return the new state if succeeded, otherwise return NULL. */ static re_dfastate_t * internal_function __attribute_warn_unused_result__ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, unsigned int context, re_hashval_t hash) { Idx i, nctx_nodes = 0; reg_errcode_t err; re_dfastate_t *newstate; newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); if (BE (newstate == NULL, 0)) return NULL; err = re_node_set_init_copy (&newstate->nodes, nodes); if (BE (err != REG_NOERROR, 0)) { re_free (newstate); return NULL; } newstate->context = context; newstate->entrance_nodes = &newstate->nodes; for (i = 0 ; i < nodes->nelem ; i++) { re_token_t *node = dfa->nodes + nodes->elems[i]; re_token_type_t type = node->type; unsigned int constraint = node->constraint; if (type == CHARACTER && !constraint) continue; #ifdef RE_ENABLE_I18N newstate->accept_mb |= node->accept_mb; #endif /* RE_ENABLE_I18N */ /* If the state has the halt node, the state is a halt state. */ if (type == END_OF_RE) newstate->halt = 1; else if (type == OP_BACK_REF) newstate->has_backref = 1; if (constraint) { if (newstate->entrance_nodes == &newstate->nodes) { newstate->entrance_nodes = re_malloc (re_node_set, 1); if (BE (newstate->entrance_nodes == NULL, 0)) { free_state (newstate); return NULL; } if (re_node_set_init_copy (newstate->entrance_nodes, nodes) != REG_NOERROR) return NULL; nctx_nodes = 0; newstate->has_constraint = 1; } if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context)) { re_node_set_remove_at (&newstate->nodes, i - nctx_nodes); ++nctx_nodes; } } } err = register_state (dfa, newstate, hash); if (BE (err != REG_NOERROR, 0)) { free_state (newstate); newstate = NULL; } return newstate; } lftp-4.6.3a/lib/printf-parse.h0000644000015000007670000001216312466374011013113 00000000000000/* Parse printf format string. Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2015 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 . */ #ifndef _PRINTF_PARSE_H #define _PRINTF_PARSE_H /* This file can be parametrized with the following macros: ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. STATIC Set to 'static' to declare the function static. */ #if HAVE_FEATURES_H # include /* for __GLIBC__, __UCLIBC__ */ #endif #include "printf-args.h" /* Flags */ #define FLAG_GROUP 1 /* ' flag */ #define FLAG_LEFT 2 /* - flag */ #define FLAG_SHOWSIGN 4 /* + flag */ #define FLAG_SPACE 8 /* space flag */ #define FLAG_ALT 16 /* # flag */ #define FLAG_ZERO 32 #if __GLIBC__ >= 2 && !defined __UCLIBC__ # define FLAG_LOCALIZED 64 /* I flag, uses localized digits */ #endif /* arg_index value indicating that no argument is consumed. */ #define ARG_NONE (~(size_t)0) /* xxx_directive: A parsed directive. xxx_directives: A parsed format string. */ /* Number of directly allocated directives (no malloc() needed). */ #define N_DIRECT_ALLOC_DIRECTIVES 7 /* A parsed directive. */ typedef struct { const char* dir_start; const char* dir_end; int flags; const char* width_start; const char* width_end; size_t width_arg_index; const char* precision_start; const char* precision_end; size_t precision_arg_index; char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } char_directive; /* A parsed format string. */ typedef struct { size_t count; char_directive *dir; size_t max_width_length; size_t max_precision_length; char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; } char_directives; #if ENABLE_UNISTDIO /* A parsed directive. */ typedef struct { const uint8_t* dir_start; const uint8_t* dir_end; int flags; const uint8_t* width_start; const uint8_t* width_end; size_t width_arg_index; const uint8_t* precision_start; const uint8_t* precision_end; size_t precision_arg_index; uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u8_directive; /* A parsed format string. */ typedef struct { size_t count; u8_directive *dir; size_t max_width_length; size_t max_precision_length; u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; } u8_directives; /* A parsed directive. */ typedef struct { const uint16_t* dir_start; const uint16_t* dir_end; int flags; const uint16_t* width_start; const uint16_t* width_end; size_t width_arg_index; const uint16_t* precision_start; const uint16_t* precision_end; size_t precision_arg_index; uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u16_directive; /* A parsed format string. */ typedef struct { size_t count; u16_directive *dir; size_t max_width_length; size_t max_precision_length; u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; } u16_directives; /* A parsed directive. */ typedef struct { const uint32_t* dir_start; const uint32_t* dir_end; int flags; const uint32_t* width_start; const uint32_t* width_end; size_t width_arg_index; const uint32_t* precision_start; const uint32_t* precision_end; size_t precision_arg_index; uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u32_directive; /* A parsed format string. */ typedef struct { size_t count; u32_directive *dir; size_t max_width_length; size_t max_precision_length; u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; } u32_directives; #endif /* Parses the format string. Fills in the number N of directives, and fills in directives[0], ..., directives[N-1], and sets directives[N].dir_start to the end of the format string. Also fills in the arg_type fields of the arguments and the needed count of arguments. */ #if ENABLE_UNISTDIO extern int ulc_printf_parse (const char *format, char_directives *d, arguments *a); extern int u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a); extern int u16_printf_parse (const uint16_t *format, u16_directives *d, arguments *a); extern int u32_printf_parse (const uint32_t *format, u32_directives *d, arguments *a); #else # ifdef STATIC STATIC # else extern # endif int printf_parse (const char *format, char_directives *d, arguments *a); #endif #endif /* _PRINTF_PARSE_H */ lftp-4.6.3a/lib/strtok_r.c0000644000015000007670000000411412466374012012341 00000000000000/* Reentrant string tokenizer. Generic version. Copyright (C) 1991, 1996-1999, 2001, 2004, 2007, 2009-2015 Free Software Foundation, Inc. This file is part of 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 . */ #ifdef HAVE_CONFIG_H # include #endif #include #ifdef _LIBC # undef strtok_r # undef __strtok_r #else # define __strtok_r strtok_r # define __rawmemchr strchr #endif /* Parse S into tokens separated by characters in DELIM. If S is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: char s[] = "-abc-=-def"; char *sp; x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL x = strtok_r(NULL, "=", &sp); // x = NULL // s = "abc\0-def\0" */ char * __strtok_r (char *s, const char *delim, char **save_ptr) { char *token; if (s == NULL) s = *save_ptr; /* Scan leading delimiters. */ s += strspn (s, delim); if (*s == '\0') { *save_ptr = s; return NULL; } /* Find the end of the token. */ token = s; s = strpbrk (token, delim); if (s == NULL) /* This token finishes the string. */ *save_ptr = __rawmemchr (token, '\0'); else { /* Terminate the token and make *SAVE_PTR point past it. */ *s = '\0'; *save_ptr = s + 1; } return token; } #ifdef weak_alias libc_hidden_def (__strtok_r) weak_alias (__strtok_r, strtok_r) #endif lftp-4.6.3a/lib/poll.in.h0000644000015000007670000000577412466374011012066 00000000000000/* Header for poll(2) emulation Contributed by Paolo Bonzini. Copyright 2001-2003, 2007, 2009-2015 Free Software Foundation, Inc. This file is part of gnulib. 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 . */ #ifndef _@GUARD_PREFIX@_POLL_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_POLL_H@ # @INCLUDE_NEXT@ @NEXT_POLL_H@ #endif #ifndef _@GUARD_PREFIX@_POLL_H #define _@GUARD_PREFIX@_POLL_H /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_WARN_ON_USE is copied here. */ #if !@HAVE_POLL_H@ /* fake a poll(2) environment */ # define POLLIN 0x0001 /* any readable data available */ # define POLLPRI 0x0002 /* OOB/Urgent readable data */ # define POLLOUT 0x0004 /* file descriptor is writable */ # define POLLERR 0x0008 /* some poll error occurred */ # define POLLHUP 0x0010 /* file descriptor was "hung up" */ # define POLLNVAL 0x0020 /* requested events "invalid" */ # define POLLRDNORM 0x0040 # define POLLRDBAND 0x0080 # define POLLWRNORM 0x0100 # define POLLWRBAND 0x0200 # if !GNULIB_defined_poll_types struct pollfd { int fd; /* which file descriptor to poll */ short events; /* events we are interested in */ short revents; /* events found on return */ }; typedef unsigned long nfds_t; # define GNULIB_defined_poll_types 1 # endif /* Define INFTIM only if doing so conforms to POSIX. */ # if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE) # define INFTIM (-1) # endif #endif #if @GNULIB_POLL@ # if @REPLACE_POLL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef poll # define poll rpl_poll # endif _GL_FUNCDECL_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout)); _GL_CXXALIAS_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout)); # else # if !@HAVE_POLL@ _GL_FUNCDECL_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout)); # endif _GL_CXXALIAS_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout)); # endif _GL_CXXALIASWARN (poll); #elif defined GNULIB_POSIXCHECK # undef poll # if HAVE_RAW_DECL_POLL _GL_WARN_ON_USE (poll, "poll is unportable - " "use gnulib module poll for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_POLL_H */ #endif /* _@GUARD_PREFIX@_POLL_H */ lftp-4.6.3a/lib/filename.h0000644000015000007670000000365212466374011012264 00000000000000/* Basic filename support macros. Copyright (C) 2001-2004, 2007-2015 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 . */ #ifndef _FILENAME_H #define _FILENAME_H #ifdef __cplusplus extern "C" { #endif /* Pathname support. ISSLASH(C) tests whether C is a directory separator character. IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not, it may be concatenated to a directory pathname. IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. */ #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Native Windows, Cygwin, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') # define HAS_DEVICE(P) \ ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ && (P)[1] == ':') # define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P)) # define IS_PATH_WITH_DIR(P) \ (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P)) # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0) #else /* Unix */ # define ISSLASH(C) ((C) == '/') # define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0]) # define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL) # define FILE_SYSTEM_PREFIX_LEN(P) 0 #endif #ifdef __cplusplus } #endif #endif /* _FILENAME_H */ lftp-4.6.3a/lib/opendir.c0000644000015000007670000000652112466374011012135 00000000000000/* Start reading the entries of a directory. Copyright (C) 2006-2015 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 . */ #include /* Specification. */ #include #include #include #if HAVE_OPENDIR /* Override opendir(), to keep track of the open file descriptors. Needed because there is a function dirfd(). */ #else # include # include "dirent-private.h" # include "filename.h" #endif #if REPLACE_FCHDIR # include #endif DIR * opendir (const char *dir_name) { #if HAVE_OPENDIR # undef opendir DIR *dirp; dirp = opendir (dir_name); if (dirp == NULL) return NULL; #else char dir_name_mask[MAX_PATH + 1 + 1 + 1]; int status; HANDLE current; WIN32_FIND_DATA entry; struct gl_directory *dirp; if (dir_name[0] == '\0') { errno = ENOENT; return NULL; } /* Make the dir_name absolute, so that we continue reading the same directory if the current directory changed between this opendir() call and a subsequent rewinddir() call. */ if (!GetFullPathName (dir_name, MAX_PATH, dir_name_mask, NULL)) { errno = EINVAL; return NULL; } /* Append the mask. "*" and "*.*" appear to be equivalent. */ { char *p; p = dir_name_mask + strlen (dir_name_mask); if (p > dir_name_mask && !ISSLASH (p[-1])) *p++ = '\\'; *p++ = '*'; *p = '\0'; } /* Start searching the directory. */ status = -1; current = FindFirstFile (dir_name_mask, &entry); if (current == INVALID_HANDLE_VALUE) { switch (GetLastError ()) { case ERROR_FILE_NOT_FOUND: status = -2; break; case ERROR_PATH_NOT_FOUND: errno = ENOENT; return NULL; case ERROR_DIRECTORY: errno = ENOTDIR; return NULL; case ERROR_ACCESS_DENIED: errno = EACCES; return NULL; default: errno = EIO; return NULL; } } /* Allocate the result. */ dirp = (struct gl_directory *) malloc (offsetof (struct gl_directory, dir_name_mask[0]) + strlen (dir_name_mask) + 1); if (dirp == NULL) { if (current != INVALID_HANDLE_VALUE) FindClose (current); errno = ENOMEM; return NULL; } dirp->status = status; dirp->current = current; if (status == -1) memcpy (&dirp->entry, &entry, sizeof (WIN32_FIND_DATA)); strcpy (dirp->dir_name_mask, dir_name_mask); #endif #if REPLACE_FCHDIR { int fd = dirfd (dirp); if (0 <= fd && _gl_register_fd (fd, dir_name) != fd) { int saved_errno = errno; closedir (dirp); errno = saved_errno; return NULL; } } #endif return dirp; } lftp-4.6.3a/lib/fcntl.in.h0000644000015000007670000002355512466374011012223 00000000000000/* Like , but with non-working flags defined to 0. Copyright (C) 2006-2015 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 . */ /* written by Paul Eggert */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined __need_system_fcntl_h /* Special invocation convention. */ /* Needed before . May also define off_t to a 64-bit type on native Windows. */ #include /* On some systems other than glibc, is a prerequisite of . On glibc systems, we would like to avoid namespace pollution. But on glibc systems, includes inside an extern "C" { ... } block, which leads to errors in C++ mode with the overridden from gnulib. These errors are known to be gone with g++ version >= 4.3. */ #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) # include #endif #@INCLUDE_NEXT@ @NEXT_FCNTL_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_FCNTL_H /* Needed before . May also define off_t to a 64-bit type on native Windows. */ #include /* On some systems other than glibc, is a prerequisite of . On glibc systems, we would like to avoid namespace pollution. But on glibc systems, includes inside an extern "C" { ... } block, which leads to errors in C++ mode with the overridden from gnulib. These errors are known to be gone with g++ version >= 4.3. */ #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) # include #endif /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_FCNTL_H@ #ifndef _@GUARD_PREFIX@_FCNTL_H #define _@GUARD_PREFIX@_FCNTL_H #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ # include #endif /* Native Windows platforms declare open(), creat() in . */ #if (@GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) # include #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. */ /* Declare overridden functions. */ #if @GNULIB_FCNTL@ # if @REPLACE_FCNTL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fcntl # define fcntl rpl_fcntl # endif _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); # else # if !@HAVE_FCNTL@ _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); # endif _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...)); # endif _GL_CXXALIASWARN (fcntl); #elif defined GNULIB_POSIXCHECK # undef fcntl # if HAVE_RAW_DECL_FCNTL _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " "use gnulib module fcntl for portability"); # endif #endif #if @GNULIB_OPEN@ # if @REPLACE_OPEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef open # define open rpl_open # endif _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); # else _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); # endif /* On HP-UX 11, in C++ mode, open() is defined as an inline function with a default argument. _GL_CXXALIASWARN does not work in this case. */ # if !defined __hpux _GL_CXXALIASWARN (open); # endif #elif defined GNULIB_POSIXCHECK # undef open /* Assume open is always declared. */ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - " "use gnulib module open for portability"); #endif #if @GNULIB_OPENAT@ # if @REPLACE_OPENAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef openat # define openat rpl_openat # endif _GL_FUNCDECL_RPL (openat, int, (int fd, char const *file, int flags, /* mode_t mode */ ...) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (openat, int, (int fd, char const *file, int flags, /* mode_t mode */ ...)); # else # if !@HAVE_OPENAT@ _GL_FUNCDECL_SYS (openat, int, (int fd, char const *file, int flags, /* mode_t mode */ ...) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (openat, int, (int fd, char const *file, int flags, /* mode_t mode */ ...)); # endif _GL_CXXALIASWARN (openat); #elif defined GNULIB_POSIXCHECK # undef openat # if HAVE_RAW_DECL_OPENAT _GL_WARN_ON_USE (openat, "openat is not portable - " "use gnulib module openat for portability"); # endif #endif /* Fix up the FD_* macros, only known to be missing on mingw. */ #ifndef FD_CLOEXEC # define FD_CLOEXEC 1 #endif /* Fix up the supported F_* macros. Intentionally leave other F_* macros undefined. Only known to be missing on mingw. */ #ifndef F_DUPFD_CLOEXEC # define F_DUPFD_CLOEXEC 0x40000000 /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ # define GNULIB_defined_F_DUPFD_CLOEXEC 1 #else # define GNULIB_defined_F_DUPFD_CLOEXEC 0 #endif #ifndef F_DUPFD # define F_DUPFD 1 #endif #ifndef F_GETFD # define F_GETFD 2 #endif /* Fix up the O_* macros. */ /* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT to values outside 'int' range, so omit these misdefinitions. But avoid namespace pollution on non-AIX systems. */ #ifdef _AIX # include # if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX) # undef O_CLOEXEC # endif # if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX) # undef O_NOFOLLOW # endif # if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX) # undef O_TTY_INIT # endif #endif #if !defined O_DIRECT && defined O_DIRECTIO /* Tru64 spells it 'O_DIRECTIO'. */ # define O_DIRECT O_DIRECTIO #endif #if !defined O_CLOEXEC && defined O_NOINHERIT /* Mingw spells it 'O_NOINHERIT'. */ # define O_CLOEXEC O_NOINHERIT #endif #ifndef O_CLOEXEC # define O_CLOEXEC 0 #endif #ifndef O_DIRECT # define O_DIRECT 0 #endif #ifndef O_DIRECTORY # define O_DIRECTORY 0 #endif #ifndef O_DSYNC # define O_DSYNC 0 #endif #ifndef O_EXEC # define O_EXEC O_RDONLY /* This is often close enough in older systems. */ #endif #ifndef O_IGNORE_CTTY # define O_IGNORE_CTTY 0 #endif #ifndef O_NDELAY # define O_NDELAY 0 #endif #ifndef O_NOATIME # define O_NOATIME 0 #endif #ifndef O_NONBLOCK # define O_NONBLOCK O_NDELAY #endif /* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY or to 0 as fallback. */ #if @GNULIB_NONBLOCKING@ # if O_NONBLOCK # define GNULIB_defined_O_NONBLOCK 0 # else # define GNULIB_defined_O_NONBLOCK 1 # undef O_NONBLOCK # define O_NONBLOCK 0x40000000 # endif #endif #ifndef O_NOCTTY # define O_NOCTTY 0 #endif #ifndef O_NOFOLLOW # define O_NOFOLLOW 0 #endif #ifndef O_NOLINK # define O_NOLINK 0 #endif #ifndef O_NOLINKS # define O_NOLINKS 0 #endif #ifndef O_NOTRANS # define O_NOTRANS 0 #endif #ifndef O_RSYNC # define O_RSYNC 0 #endif #ifndef O_SEARCH # define O_SEARCH O_RDONLY /* This is often close enough in older systems. */ #endif #ifndef O_SYNC # define O_SYNC 0 #endif #ifndef O_TTY_INIT # define O_TTY_INIT 0 #endif #if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH) # undef O_ACCMODE # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH) #endif /* For systems that distinguish between text and binary I/O. O_BINARY is usually declared in fcntl.h */ #if !defined O_BINARY && defined _O_BINARY /* For MSC-compatible compilers. */ # define O_BINARY _O_BINARY # define O_TEXT _O_TEXT #endif #if defined __BEOS__ || defined __HAIKU__ /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */ # undef O_BINARY # undef O_TEXT #endif #ifndef O_BINARY # define O_BINARY 0 # define O_TEXT 0 #endif /* Fix up the AT_* macros. */ /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its value exceeds INT_MAX, so its use as an int doesn't conform to the C standard, and GCC and Sun C complain in some cases. If the bug is present, undef AT_FDCWD here, so it can be redefined below. */ #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 # undef AT_FDCWD #endif /* Use the same bit pattern as Solaris 9, but with the proper signedness. The bit pattern is important, in case this actually is Solaris with the above workaround. */ #ifndef AT_FDCWD # define AT_FDCWD (-3041965) #endif /* Use the same values as Solaris 9. This shouldn't matter, but there's no real reason to differ. */ #ifndef AT_SYMLINK_NOFOLLOW # define AT_SYMLINK_NOFOLLOW 4096 #endif #ifndef AT_REMOVEDIR # define AT_REMOVEDIR 1 #endif /* Solaris 9 lacks these two, so just pick unique values. */ #ifndef AT_SYMLINK_FOLLOW # define AT_SYMLINK_FOLLOW 2 #endif #ifndef AT_EACCESS # define AT_EACCESS 4 #endif #endif /* _@GUARD_PREFIX@_FCNTL_H */ #endif /* _@GUARD_PREFIX@_FCNTL_H */ #endif lftp-4.6.3a/lib/float.c0000644000015000007670000000250412466374011011577 00000000000000/* Auxiliary definitions for . Copyright (C) 2011-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2011. 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 . */ #include /* Specification. */ #include #if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ const union gl_long_double_union gl_LDBL_MAX = { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } }; #elif defined __i386__ const union gl_long_double_union gl_LDBL_MAX = { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } }; #else /* This declaration is solely to ensure that after preprocessing this file is never empty. */ typedef int dummy; #endif lftp-4.6.3a/lib/uniwidth.in.h0000644000015000007670000000434012466374012012740 00000000000000/* Display width functions. Copyright (C) 2001-2002, 2005, 2007, 2009-2015 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 . */ #ifndef _UNIWIDTH_H #define _UNIWIDTH_H #include "unitypes.h" /* Get size_t. */ #include /* Get locale_charset() declaration. */ #include "localcharset.h" #ifdef __cplusplus extern "C" { #endif /* Display width. */ /* These functions are locale dependent. The encoding argument identifies the encoding (e.g. "ISO-8859-2" for Polish). */ /* Determine number of column positions required for UC. */ extern int uc_width (ucs4_t uc, const char *encoding) _UC_ATTRIBUTE_PURE; extern int uc_width1 (ucs4_t uc) #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) __attribute__ ((__pure__)) #endif ; /* Determine number of column positions required for first N units (or fewer if S ends before this) in S. */ extern int u8_width (const uint8_t *s, size_t n, const char *encoding) _UC_ATTRIBUTE_PURE; extern int u16_width (const uint16_t *s, size_t n, const char *encoding) _UC_ATTRIBUTE_PURE; extern int u32_width (const uint32_t *s, size_t n, const char *encoding) _UC_ATTRIBUTE_PURE; /* Determine number of column positions required for S. */ extern int u8_strwidth (const uint8_t *s, const char *encoding) _UC_ATTRIBUTE_PURE; extern int u16_strwidth (const uint16_t *s, const char *encoding) _UC_ATTRIBUTE_PURE; extern int u32_strwidth (const uint32_t *s, const char *encoding) _UC_ATTRIBUTE_PURE; #ifdef __cplusplus } #endif #endif /* _UNIWIDTH_H */ lftp-4.6.3a/lib/malloca.c0000644000015000007670000001157612466374011012113 00000000000000/* Safe automatic memory allocation. Copyright (C) 2003, 2006-2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2003. 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 . */ #define _GL_USE_STDLIB_ALLOC 1 #include /* Specification. */ #include "malloca.h" #include #include "verify.h" /* The speed critical point in this file is freea() applied to an alloca() result: it must be fast, to match the speed of alloca(). The speed of mmalloca() and freea() in the other case are not critical, because they are only invoked for big memory sizes. */ #if HAVE_ALLOCA /* Store the mmalloca() results in a hash table. This is needed to reliably distinguish a mmalloca() result and an alloca() result. Although it is possible that the same pointer is returned by alloca() and by mmalloca() at different times in the same application, it does not lead to a bug in freea(), because: - Before a pointer returned by alloca() can point into malloc()ed memory, the function must return, and once this has happened the programmer must not call freea() on it anyway. - Before a pointer returned by mmalloca() can point into the stack, it must be freed. The only function that can free it is freea(), and when freea() frees it, it also removes it from the hash table. */ #define MAGIC_NUMBER 0x1415fb4a #define MAGIC_SIZE sizeof (int) /* This is how the header info would look like without any alignment considerations. */ struct preliminary_header { void *next; int magic; }; /* But the header's size must be a multiple of sa_alignment_max. */ #define HEADER_SIZE \ (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max) union header { void *next; struct { char room[HEADER_SIZE - MAGIC_SIZE]; int word; } magic; }; verify (HEADER_SIZE == sizeof (union header)); /* We make the hash table quite big, so that during lookups the probability of empty hash buckets is quite high. There is no need to make the hash table resizable, because when the hash table gets filled so much that the lookup becomes slow, it means that the application has memory leaks. */ #define HASH_TABLE_SIZE 257 static void * mmalloca_results[HASH_TABLE_SIZE]; #endif void * mmalloca (size_t n) { #if HAVE_ALLOCA /* Allocate one more word, that serves as an indicator for malloc()ed memory, so that freea() of an alloca() result is fast. */ size_t nplus = n + HEADER_SIZE; if (nplus >= n) { void *p = malloc (nplus); if (p != NULL) { size_t slot; union header *h = p; p = h + 1; /* Put a magic number into the indicator word. */ h->magic.word = MAGIC_NUMBER; /* Enter p into the hash table. */ slot = (uintptr_t) p % HASH_TABLE_SIZE; h->next = mmalloca_results[slot]; mmalloca_results[slot] = p; return p; } } /* Out of memory. */ return NULL; #else # if !MALLOC_0_IS_NONNULL if (n == 0) n = 1; # endif return malloc (n); #endif } #if HAVE_ALLOCA void freea (void *p) { /* mmalloca() may have returned NULL. */ if (p != NULL) { /* Attempt to quickly distinguish the mmalloca() result - which has a magic indicator word - and the alloca() result - which has an uninitialized indicator word. It is for this test that sa_increment additional bytes are allocated in the alloca() case. */ if (((int *) p)[-1] == MAGIC_NUMBER) { /* Looks like a mmalloca() result. To see whether it really is one, perform a lookup in the hash table. */ size_t slot = (uintptr_t) p % HASH_TABLE_SIZE; void **chain = &mmalloca_results[slot]; for (; *chain != NULL;) { union header *h = p; if (*chain == p) { /* Found it. Remove it from the hash table and free it. */ union header *p_begin = h - 1; *chain = p_begin->next; free (p_begin); return; } h = *chain; chain = &h[-1].next; } } /* At this point, we know it was not a mmalloca() result. */ } } #endif lftp-4.6.3a/lib/error.c0000644000015000007670000002441712466374011011632 00000000000000/* Error handler for noninteractive utilities Copyright (C) 1990-1998, 2000-2007, 2009-2015 Free Software Foundation, Inc. This file is part of 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 . */ /* Written by David MacKenzie . */ #if !_LIBC # include #endif #include "error.h" #include #include #include #include #if !_LIBC && ENABLE_NLS # include "gettext.h" # define _(msgid) gettext (msgid) #endif #ifdef _LIBC # include # include # include # include # define mbsrtowcs __mbsrtowcs # define USE_UNLOCKED_IO 0 # define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b) # define _GL_ARG_NONNULL(a) #endif #if USE_UNLOCKED_IO # include "unlocked-io.h" #endif #ifndef _ # define _(String) String #endif /* If NULL, error will flush stdout, then print on stderr the program name, a colon and a space. Otherwise, error will call this function without parameters instead. */ void (*error_print_progname) (void); /* This variable is incremented each time 'error' is called. */ unsigned int error_message_count; #ifdef _LIBC /* In the GNU C library, there is a predefined variable for this. */ # define program_name program_invocation_name # include # include # include /* In GNU libc we want do not want to use the common name 'error' directly. Instead make it a weak alias. */ extern void __error (int status, int errnum, const char *message, ...) __attribute__ ((__format__ (__printf__, 3, 4))); extern void __error_at_line (int status, int errnum, const char *file_name, unsigned int line_number, const char *message, ...) __attribute__ ((__format__ (__printf__, 5, 6))); # define error __error # define error_at_line __error_at_line # include # define fflush(s) _IO_fflush (s) # undef putc # define putc(c, fp) _IO_putc (c, fp) # include #else /* not _LIBC */ # include # include # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include /* Get _get_osfhandle. */ # include "msvc-nothrow.h" # endif /* The gnulib override of fcntl is not needed in this file. */ # undef fcntl # if !HAVE_DECL_STRERROR_R # ifndef HAVE_DECL_STRERROR_R "this configure-time declaration test was not run" # endif # if STRERROR_R_CHAR_P char *strerror_r (); # else int strerror_r (); # endif # endif /* The calling program should define program_name and set it to the name of the executing program. */ extern char *program_name; # if HAVE_STRERROR_R || defined strerror_r # define __strerror_r strerror_r # endif /* HAVE_STRERROR_R || defined strerror_r */ #endif /* not _LIBC */ #if !_LIBC /* Return non-zero if FD is open. */ static int is_open (int fd) { # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* On native Windows: The initial state of unassigned standard file descriptors is that they are open but point to an INVALID_HANDLE_VALUE. There is no fcntl, and the gnulib replacement fcntl does not support F_GETFL. */ return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; # else # ifndef F_GETFL # error Please port fcntl to your platform # endif return 0 <= fcntl (fd, F_GETFL); # endif } #endif static void flush_stdout (void) { #if !_LIBC int stdout_fd; # if GNULIB_FREOPEN_SAFER /* Use of gnulib's freopen-safer module normally ensures that fileno (stdout) == 1 whenever stdout is open. */ stdout_fd = STDOUT_FILENO; # else /* POSIX states that fileno (stdout) after fclose is unspecified. But in practice it is not a problem, because stdout is statically allocated and the fd of a FILE stream is stored as a field in its allocated memory. */ stdout_fd = fileno (stdout); # endif /* POSIX states that fflush (stdout) after fclose is unspecified; it is safe in glibc, but not on all other platforms. fflush (NULL) is always defined, but too draconian. */ if (0 <= stdout_fd && is_open (stdout_fd)) #endif fflush (stdout); } static void print_errno_message (int errnum) { char const *s; #if defined HAVE_STRERROR_R || _LIBC char errbuf[1024]; # if _LIBC || STRERROR_R_CHAR_P s = __strerror_r (errnum, errbuf, sizeof errbuf); # else if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) s = errbuf; else s = 0; # endif #else s = strerror (errnum); #endif #if !_LIBC if (! s) s = _("Unknown system error"); #endif #if _LIBC __fxprintf (NULL, ": %s", s); #else fprintf (stderr, ": %s", s); #endif } static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3)) error_tail (int status, int errnum, const char *message, va_list args) { #if _LIBC if (_IO_fwide (stderr, 0) > 0) { size_t len = strlen (message) + 1; wchar_t *wmessage = NULL; mbstate_t st; size_t res; const char *tmp; bool use_malloc = false; while (1) { if (__libc_use_alloca (len * sizeof (wchar_t))) wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); else { if (!use_malloc) wmessage = NULL; wchar_t *p = (wchar_t *) realloc (wmessage, len * sizeof (wchar_t)); if (p == NULL) { free (wmessage); fputws_unlocked (L"out of memory\n", stderr); return; } wmessage = p; use_malloc = true; } memset (&st, '\0', sizeof (st)); tmp = message; res = mbsrtowcs (wmessage, &tmp, len, &st); if (res != len) break; if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0)) { /* This really should not happen if everything is fine. */ res = (size_t) -1; break; } len *= 2; } if (res == (size_t) -1) { /* The string cannot be converted. */ if (use_malloc) { free (wmessage); use_malloc = false; } wmessage = (wchar_t *) L"???"; } __vfwprintf (stderr, wmessage, args); if (use_malloc) free (wmessage); } else #endif vfprintf (stderr, message, args); va_end (args); ++error_message_count; if (errnum) print_errno_message (errnum); #if _LIBC __fxprintf (NULL, "\n"); #else putc ('\n', stderr); #endif fflush (stderr); if (status) exit (status); } /* Print the program name and error message MESSAGE, which is a printf-style format string with optional args. If ERRNUM is nonzero, print its corresponding system error message. Exit with status STATUS if it is nonzero. */ void error (int status, int errnum, const char *message, ...) { va_list args; #if defined _LIBC && defined __libc_ptf_call /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), 0); #endif flush_stdout (); #ifdef _LIBC _IO_flockfile (stderr); #endif if (error_print_progname) (*error_print_progname) (); else { #if _LIBC __fxprintf (NULL, "%s: ", program_name); #else fprintf (stderr, "%s: ", program_name); #endif } va_start (args, message); error_tail (status, errnum, message, args); #ifdef _LIBC _IO_funlockfile (stderr); # ifdef __libc_ptf_call __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); # endif #endif } /* Sometimes we want to have at most one error per line. This variable controls whether this mode is selected or not. */ int error_one_per_line; void error_at_line (int status, int errnum, const char *file_name, unsigned int line_number, const char *message, ...) { va_list args; if (error_one_per_line) { static const char *old_file_name; static unsigned int old_line_number; if (old_line_number == line_number && (file_name == old_file_name || (old_file_name != NULL && file_name != NULL && strcmp (old_file_name, file_name) == 0))) /* Simply return and print nothing. */ return; old_file_name = file_name; old_line_number = line_number; } #if defined _LIBC && defined __libc_ptf_call /* We do not want this call to be cut short by a thread cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), 0); #endif flush_stdout (); #ifdef _LIBC _IO_flockfile (stderr); #endif if (error_print_progname) (*error_print_progname) (); else { #if _LIBC __fxprintf (NULL, "%s:", program_name); #else fprintf (stderr, "%s:", program_name); #endif } #if _LIBC __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", file_name, line_number); #else fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", file_name, line_number); #endif va_start (args, message); error_tail (status, errnum, message, args); #ifdef _LIBC _IO_funlockfile (stderr); # ifdef __libc_ptf_call __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); # endif #endif } #ifdef _LIBC /* Make the weak alias. */ # undef error # undef error_at_line weak_alias (__error, error) weak_alias (__error_at_line, error_at_line) #endif lftp-4.6.3a/lib/isnan.c0000644000015000007670000001560512466374011011610 00000000000000/* Test for NaN that does not need libm. Copyright (C) 2007-2015 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 . */ /* Written by Bruno Haible , 2007. */ #include /* Specification. */ #ifdef USE_LONG_DOUBLE /* Specification found in math.h or isnanl-nolibm.h. */ extern int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; #elif ! defined USE_FLOAT /* Specification found in math.h or isnand-nolibm.h. */ extern int rpl_isnand (double x); #else /* defined USE_FLOAT */ /* Specification found in math.h or isnanf-nolibm.h. */ extern int rpl_isnanf (float x); #endif #include #include #include "float+.h" #ifdef USE_LONG_DOUBLE # define FUNC rpl_isnanl # define DOUBLE long double # define MAX_EXP LDBL_MAX_EXP # define MIN_EXP LDBL_MIN_EXP # if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT # define KNOWN_EXPBIT0_LOCATION # define EXPBIT0_WORD LDBL_EXPBIT0_WORD # define EXPBIT0_BIT LDBL_EXPBIT0_BIT # endif # define SIZE SIZEOF_LDBL # define L_(literal) literal##L #elif ! defined USE_FLOAT # define FUNC rpl_isnand # define DOUBLE double # define MAX_EXP DBL_MAX_EXP # define MIN_EXP DBL_MIN_EXP # if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT # define KNOWN_EXPBIT0_LOCATION # define EXPBIT0_WORD DBL_EXPBIT0_WORD # define EXPBIT0_BIT DBL_EXPBIT0_BIT # endif # define SIZE SIZEOF_DBL # define L_(literal) literal #else /* defined USE_FLOAT */ # define FUNC rpl_isnanf # define DOUBLE float # define MAX_EXP FLT_MAX_EXP # define MIN_EXP FLT_MIN_EXP # if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT # define KNOWN_EXPBIT0_LOCATION # define EXPBIT0_WORD FLT_EXPBIT0_WORD # define EXPBIT0_BIT FLT_EXPBIT0_BIT # endif # define SIZE SIZEOF_FLT # define L_(literal) literal##f #endif #define EXP_MASK ((MAX_EXP - MIN_EXP) | 7) #define NWORDS \ ((sizeof (DOUBLE) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { DOUBLE value; unsigned int word[NWORDS]; } memory_double; /* Most hosts nowadays use IEEE floating point, so they use IEC 60559 representations, have infinities and NaNs, and do not trap on exceptions. Define IEEE_FLOATING_POINT if this host is one of the typical ones. The C11 macro __STDC_IEC_559__ is close to what is wanted here, but is not quite right because this file does not require all the features of C11 Annex F (and does not require C11 at all, for that matter). */ #define IEEE_FLOATING_POINT (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) int FUNC (DOUBLE x) { #if defined KNOWN_EXPBIT0_LOCATION && IEEE_FLOATING_POINT # if defined USE_LONG_DOUBLE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Special CPU dependent code is needed to treat bit patterns outside the IEEE 754 specification (such as Pseudo-NaNs, Pseudo-Infinities, Pseudo-Zeroes, Unnormalized Numbers, and Pseudo-Denormals) as NaNs. These bit patterns are: - exponent = 0x0001..0x7FFF, mantissa bit 63 = 0, - exponent = 0x0000, mantissa bit 63 = 1. The NaN bit pattern is: - exponent = 0x7FFF, mantissa >= 0x8000000000000001. */ memory_double m; unsigned int exponent; m.value = x; exponent = (m.word[EXPBIT0_WORD] >> EXPBIT0_BIT) & EXP_MASK; # ifdef WORDS_BIGENDIAN /* Big endian: EXPBIT0_WORD = 0, EXPBIT0_BIT = 16. */ if (exponent == 0) return 1 & (m.word[0] >> 15); else if (exponent == EXP_MASK) return (((m.word[0] ^ 0x8000U) << 16) | m.word[1] | (m.word[2] >> 16)) != 0; else return 1 & ~(m.word[0] >> 15); # else /* Little endian: EXPBIT0_WORD = 2, EXPBIT0_BIT = 0. */ if (exponent == 0) return (m.word[1] >> 31); else if (exponent == EXP_MASK) return ((m.word[1] ^ 0x80000000U) | m.word[0]) != 0; else return (m.word[1] >> 31) ^ 1; # endif # else /* Be careful to not do any floating-point operation on x, such as x == x, because x may be a signaling NaN. */ # if defined __SUNPRO_C || defined __ICC || defined _MSC_VER \ || defined __DECC || defined __TINYC__ \ || (defined __sgi && !defined __GNUC__) /* The Sun C 5.0, Intel ICC 10.0, Microsoft Visual C/C++ 9.0, Compaq (ex-DEC) 6.4, and TinyCC compilers don't recognize the initializers as constant expressions. The Compaq compiler also fails when constant-folding 0.0 / 0.0 even when constant-folding is not required. The Microsoft Visual C/C++ compiler also fails when constant-folding 1.0 / 0.0 even when constant-folding is not required. The SGI MIPSpro C compiler complains about "floating-point operation result is out of range". */ static DOUBLE zero = L_(0.0); memory_double nan; DOUBLE plus_inf = L_(1.0) / zero; DOUBLE minus_inf = -L_(1.0) / zero; nan.value = zero / zero; # else static memory_double nan = { L_(0.0) / L_(0.0) }; static DOUBLE plus_inf = L_(1.0) / L_(0.0); static DOUBLE minus_inf = -L_(1.0) / L_(0.0); # endif { memory_double m; /* A NaN can be recognized through its exponent. But exclude +Infinity and -Infinity, which have the same exponent. */ m.value = x; if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD]) & (EXP_MASK << EXPBIT0_BIT)) == 0) return (memcmp (&m.value, &plus_inf, SIZE) != 0 && memcmp (&m.value, &minus_inf, SIZE) != 0); else return 0; } # endif #else /* The configuration did not find sufficient information, or does not use IEEE floating point. Give up about the signaling NaNs; handle only the quiet NaNs. */ if (x == x) { # if defined USE_LONG_DOUBLE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Detect any special bit patterns that pass ==; see comment above. */ memory_double m1; memory_double m2; memset (&m1.value, 0, SIZE); memset (&m2.value, 0, SIZE); m1.value = x; m2.value = x + (x ? 0.0L : -0.0L); if (memcmp (&m1.value, &m2.value, SIZE) != 0) return 1; # endif return 0; } else return 1; #endif } lftp-4.6.3a/lib/localeconv.c0000644000015000007670000000656212466374011012627 00000000000000/* Query locale dependent information for formatting numbers. Copyright (C) 2012-2015 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 . */ #include /* Specification. */ #include #if HAVE_STRUCT_LCONV_DECIMAL_POINT /* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* members. */ struct lconv * localeconv (void) { static struct lconv result; # undef lconv # undef localeconv struct lconv *sys_result = localeconv (); result.decimal_point = sys_result->decimal_point; result.thousands_sep = sys_result->thousands_sep; result.grouping = sys_result->grouping; result.mon_decimal_point = sys_result->mon_decimal_point; result.mon_thousands_sep = sys_result->mon_thousands_sep; result.mon_grouping = sys_result->mon_grouping; result.positive_sign = sys_result->positive_sign; result.negative_sign = sys_result->negative_sign; result.currency_symbol = sys_result->currency_symbol; result.frac_digits = sys_result->frac_digits; result.p_cs_precedes = sys_result->p_cs_precedes; result.p_sign_posn = sys_result->p_sign_posn; result.p_sep_by_space = sys_result->p_sep_by_space; result.n_cs_precedes = sys_result->n_cs_precedes; result.n_sign_posn = sys_result->n_sign_posn; result.n_sep_by_space = sys_result->n_sep_by_space; result.int_curr_symbol = sys_result->int_curr_symbol; result.int_frac_digits = sys_result->int_frac_digits; result.int_p_cs_precedes = sys_result->p_cs_precedes; result.int_p_sign_posn = sys_result->p_sign_posn; result.int_p_sep_by_space = sys_result->p_sep_by_space; result.int_n_cs_precedes = sys_result->n_cs_precedes; result.int_n_sign_posn = sys_result->n_sign_posn; result.int_n_sep_by_space = sys_result->n_sep_by_space; return &result; } #else /* Override for platforms where 'struct lconv' is a dummy. */ # include struct lconv * localeconv (void) { static /*const*/ struct lconv result = { /* decimal_point */ ".", /* thousands_sep */ "", /* grouping */ "", /* mon_decimal_point */ "", /* mon_thousands_sep */ "", /* mon_grouping */ "", /* positive_sign */ "", /* negative_sign */ "", /* currency_symbol */ "", /* frac_digits */ CHAR_MAX, /* p_cs_precedes */ CHAR_MAX, /* p_sign_posn */ CHAR_MAX, /* p_sep_by_space */ CHAR_MAX, /* n_cs_precedes */ CHAR_MAX, /* n_sign_posn */ CHAR_MAX, /* n_sep_by_space */ CHAR_MAX, /* int_curr_symbol */ "", /* int_frac_digits */ CHAR_MAX, /* int_p_cs_precedes */ CHAR_MAX, /* int_p_sign_posn */ CHAR_MAX, /* int_p_sep_by_space */ CHAR_MAX, /* int_n_cs_precedes */ CHAR_MAX, /* int_n_sign_posn */ CHAR_MAX, /* int_n_sep_by_space */ CHAR_MAX }; return &result; } #endif lftp-4.6.3a/lib/hstrerror.c0000644000015000007670000000252112122056452012516 00000000000000/* A replacement version of hstrerror Copyright (C) 1996 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 2, 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 . */ #ifdef HAVE_CONFIG_H #include #endif #include #include #if defined (HAVE_H_ERRLIST) && !defined (HAVE_H_ERRLIST_DECL) extern int h_nerrs; extern char *h_errlist[]; #endif /* Return a string describing the host lookup error code HERR. The returned value may be in a static buffer (and in any case shouldn't be written to). */ const char * hstrerror (herr) int herr; { #ifdef HAVE_H_ERRLIST if (herr >= 0 && herr < h_nerrs && h_errlist[herr]) return h_errlist[herr]; else #endif { static char buf[100]; sprintf (buf, "Host lookup error %d", herr); return buf; } } lftp-4.6.3a/lib/parse-datetime.c0000644000015000007670000032260112466374066013413 00000000000000/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2012 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 . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Copy the first part of user declarations. */ /* Line 371 of yacc.c */ #line 1 "./parse-datetime.y" /* Parse a string into an internal time stamp. Copyright (C) 1999-2000, 2002-2015 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 . */ /* Originally written by Steven M. Bellovin while at the University of North Carolina at Chapel Hill. Later tweaked by a couple of people on Usenet. Completely overhauled by Rich $alz and Jim Berets in August, 1990. Modified by Paul Eggert in August 1999 to do the right thing about local DST. Also modified by Paul Eggert in February 2004 to support nanosecond-resolution time stamps, and in October 2004 to support TZ strings in dates. */ /* FIXME: Check for arithmetic overflow in all cases, not just some of them. */ #include #include "parse-datetime.h" #include "intprops.h" #include "timespec.h" #include "verify.h" /* There's no need to extend the stack, so there's no need to involve alloca. */ #define YYSTACK_USE_ALLOCA 0 /* Tell Bison how much stack space is needed. 20 should be plenty for this grammar, which is not right recursive. Beware setting it too high, since that might cause problems on machines whose implementations have lame stack-overflow checking. */ #define YYMAXDEPTH 20 #define YYINITDEPTH YYMAXDEPTH /* Since the code of parse-datetime.y is not included in the Emacs executable itself, there is no need to #define static in this file. Even if the code were included in the Emacs executable, it probably wouldn't do any harm to #undef it here; this will only cause problems if we try to write to a static variable, which I don't think this code needs to do. */ #ifdef emacs # undef static #endif #include #include #include #include #include #include "xalloc.h" /* Bison's skeleton tests _STDLIB_H, while some stdlib.h headers use _STDLIB_H_ as witness. Map the latter to the one bison uses. */ /* FIXME: this is temporary. Remove when we have a mechanism to ensure that the version we're using is fixed, too. */ #ifdef _STDLIB_H_ # undef _STDLIB_H # define _STDLIB_H 1 #endif /* ISDIGIT differs from isdigit, as follows: - Its arg may be any int or unsigned int; it need not be an unsigned char or EOF. - It's typically faster. POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to isdigit unless it's important to use the locale's definition of "digit" even when the host does not conform to POSIX. */ #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) /* Shift A right by B bits portably, by dividing A by 2**B and truncating towards minus infinity. A and B should be free of side effects, and B should be in the range 0 <= B <= INT_BITS - 2, where INT_BITS is the number of useful bits in an int. GNU code can assume that INT_BITS is at least 32. ISO C99 says that A >> B is implementation-defined if A < 0. Some implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ #define SHR(a, b) \ (-1 >> 1 == -1 \ ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) #define EPOCH_YEAR 1970 #define TM_YEAR_BASE 1900 #define HOUR(x) ((x) * 60) /* long_time_t is a signed integer type that contains all time_t values. */ verify (TYPE_IS_INTEGER (time_t)); #if TIME_T_FITS_IN_LONG_INT typedef long int long_time_t; #else typedef time_t long_time_t; #endif /* Convert a possibly-signed character to an unsigned character. This is a bit safer than casting to unsigned char, since it catches some type errors that the cast doesn't. */ static unsigned char to_uchar (char ch) { return ch; } /* Lots of this code assumes time_t and time_t-like values fit into long_time_t. */ verify (TYPE_MINIMUM (long_time_t) <= TYPE_MINIMUM (time_t) && TYPE_MAXIMUM (time_t) <= TYPE_MAXIMUM (long_time_t)); /* FIXME: It also assumes that signed integer overflow silently wraps around, but this is not true any more with recent versions of GCC 4. */ /* An integer value, and the number of digits in its textual representation. */ typedef struct { bool negative; long int value; size_t digits; } textint; /* An entry in the lexical lookup table. */ typedef struct { char const *name; int type; int value; } table; /* Meridian: am, pm, or 24-hour style. */ enum { MERam, MERpm, MER24 }; enum { BILLION = 1000000000, LOG10_BILLION = 9 }; /* Relative times. */ typedef struct { /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */ long int year; long int month; long int day; long int hour; long int minutes; long_time_t seconds; long int ns; } relative_time; #if HAVE_COMPOUND_LITERALS # define RELATIVE_TIME_0 ((relative_time) { 0, 0, 0, 0, 0, 0, 0 }) #else static relative_time const RELATIVE_TIME_0; #endif /* Information passed to and from the parser. */ typedef struct { /* The input string remaining to be parsed. */ const char *input; /* N, if this is the Nth Tuesday. */ long int day_ordinal; /* Day of week; Sunday is 0. */ int day_number; /* tm_isdst flag for the local zone. */ int local_isdst; /* Time zone, in minutes east of UTC. */ long int time_zone; /* Style used for time. */ int meridian; /* Gregorian year, month, day, hour, minutes, seconds, and nanoseconds. */ textint year; long int month; long int day; long int hour; long int minutes; struct timespec seconds; /* includes nanoseconds */ /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */ relative_time rel; /* Presence or counts of nonterminals of various flavors parsed so far. */ bool timespec_seen; bool rels_seen; size_t dates_seen; size_t days_seen; size_t local_zones_seen; size_t dsts_seen; size_t times_seen; size_t zones_seen; /* Table of local time zone abbreviations, terminated by a null entry. */ table local_time_zone_table[3]; } parser_control; union YYSTYPE; static int yylex (union YYSTYPE *, parser_control *); static int yyerror (parser_control const *, char const *); static long int time_zone_hhmm (parser_control *, textint, long int); /* Extract into *PC any date and time info from a string of digits of the form e.g., YYYYMMDD, YYMMDD, HHMM, HH (and sometimes YYY, YYYY, ...). */ static void digits_to_date_time (parser_control *pc, textint text_int) { if (pc->dates_seen && ! pc->year.digits && ! pc->rels_seen && (pc->times_seen || 2 < text_int.digits)) pc->year = text_int; else { if (4 < text_int.digits) { pc->dates_seen++; pc->day = text_int.value % 100; pc->month = (text_int.value / 100) % 100; pc->year.value = text_int.value / 10000; pc->year.digits = text_int.digits - 4; } else { pc->times_seen++; if (text_int.digits <= 2) { pc->hour = text_int.value; pc->minutes = 0; } else { pc->hour = text_int.value / 100; pc->minutes = text_int.value % 100; } pc->seconds.tv_sec = 0; pc->seconds.tv_nsec = 0; pc->meridian = MER24; } } } /* Increment PC->rel by FACTOR * REL (FACTOR is 1 or -1). */ static void apply_relative_time (parser_control *pc, relative_time rel, int factor) { pc->rel.ns += factor * rel.ns; pc->rel.seconds += factor * rel.seconds; pc->rel.minutes += factor * rel.minutes; pc->rel.hour += factor * rel.hour; pc->rel.day += factor * rel.day; pc->rel.month += factor * rel.month; pc->rel.year += factor * rel.year; pc->rels_seen = true; } /* Set PC-> hour, minutes, seconds and nanoseconds members from arguments. */ static void set_hhmmss (parser_control *pc, long int hour, long int minutes, time_t sec, long int nsec) { pc->hour = hour; pc->minutes = minutes; pc->seconds.tv_sec = sec; pc->seconds.tv_nsec = nsec; } /* Line 371 of yacc.c */ #line 354 "parse-datetime.c" # ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus # define YY_NULL nullptr # else # define YY_NULL 0 # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int yydebug; #endif /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { tAGO = 258, tDST = 259, tYEAR_UNIT = 260, tMONTH_UNIT = 261, tHOUR_UNIT = 262, tMINUTE_UNIT = 263, tSEC_UNIT = 264, tDAY_UNIT = 265, tDAY_SHIFT = 266, tDAY = 267, tDAYZONE = 268, tLOCAL_ZONE = 269, tMERIDIAN = 270, tMONTH = 271, tORDINAL = 272, tZONE = 273, tSNUMBER = 274, tUNUMBER = 275, tSDECIMAL_NUMBER = 276, tUDECIMAL_NUMBER = 277 }; #endif /* Tokens. */ #define tAGO 258 #define tDST 259 #define tYEAR_UNIT 260 #define tMONTH_UNIT 261 #define tHOUR_UNIT 262 #define tMINUTE_UNIT 263 #define tSEC_UNIT 264 #define tDAY_UNIT 265 #define tDAY_SHIFT 266 #define tDAY 267 #define tDAYZONE 268 #define tLOCAL_ZONE 269 #define tMERIDIAN 270 #define tMONTH 271 #define tORDINAL 272 #define tZONE 273 #define tSNUMBER 274 #define tUNUMBER 275 #define tSDECIMAL_NUMBER 276 #define tUDECIMAL_NUMBER 277 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { /* Line 387 of yacc.c */ #line 297 "./parse-datetime.y" long int intval; textint textintval; struct timespec timespec; relative_time rel; /* Line 387 of yacc.c */ #line 446 "parse-datetime.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (parser_control *pc); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /* Copy the second part of user declarations. */ /* Line 390 of yacc.c */ #line 473 "parse-datetime.c" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(N) (N) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int yyi) #else static int YYID (yyi) int yyi; #endif { return yyi; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (YYID (0)) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 12 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 112 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 28 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 26 /* YYNRULES -- Number of rules. */ #define YYNRULES 91 /* YYNRULES -- Number of states. */ #define YYNSTATES 114 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 277 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 2, 2, 27, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 25, 2, 2, 2, 2, 2, 23, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 24, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint8 yyprhs[] = { 0, 0, 3, 5, 7, 10, 11, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 38, 41, 46, 53, 55, 58, 63, 70, 71, 73, 76, 78, 81, 83, 85, 88, 91, 95, 97, 100, 102, 105, 108, 111, 115, 121, 125, 129, 132, 137, 140, 144, 146, 150, 153, 155, 157, 160, 163, 165, 168, 171, 173, 176, 179, 181, 184, 187, 189, 192, 195, 197, 200, 203, 206, 209, 211, 213, 216, 219, 222, 225, 228, 231, 233, 235, 237, 239, 241, 243, 245, 247, 250, 251 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { 29, 0, -1, 30, -1, 31, -1, 23, 48, -1, -1, 31, 32, -1, 33, -1, 35, -1, 39, -1, 40, -1, 42, -1, 41, -1, 44, -1, 51, -1, 52, -1, 34, -1, 43, 24, 36, -1, 20, 15, -1, 20, 25, 20, 15, -1, 20, 25, 20, 25, 50, 15, -1, 36, -1, 20, 38, -1, 20, 25, 20, 37, -1, 20, 25, 20, 25, 50, 37, -1, -1, 38, -1, 19, 53, -1, 14, -1, 14, 4, -1, 18, -1, 24, -1, 18, 46, -1, 24, 46, -1, 18, 19, 53, -1, 13, -1, 18, 4, -1, 12, -1, 12, 26, -1, 17, 12, -1, 20, 12, -1, 20, 27, 20, -1, 20, 27, 20, 27, 20, -1, 20, 16, 19, -1, 16, 19, 19, -1, 16, 20, -1, 16, 20, 26, 20, -1, 20, 16, -1, 20, 16, 20, -1, 43, -1, 20, 19, 19, -1, 45, 3, -1, 45, -1, 47, -1, 17, 5, -1, 20, 5, -1, 5, -1, 17, 6, -1, 20, 6, -1, 6, -1, 17, 10, -1, 20, 10, -1, 10, -1, 17, 7, -1, 20, 7, -1, 7, -1, 17, 8, -1, 20, 8, -1, 8, -1, 17, 9, -1, 20, 9, -1, 21, 9, -1, 22, 9, -1, 9, -1, 46, -1, 19, 5, -1, 19, 6, -1, 19, 10, -1, 19, 7, -1, 19, 8, -1, 19, 9, -1, 11, -1, 49, -1, 50, -1, 21, -1, 19, -1, 22, -1, 20, -1, 20, -1, 20, 46, -1, -1, 25, 20, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 324, 324, 325, 329, 336, 338, 342, 344, 346, 348, 350, 352, 354, 355, 356, 360, 364, 368, 373, 378, 383, 387, 392, 397, 404, 406, 410, 418, 423, 433, 435, 437, 440, 443, 445, 447, 452, 457, 462, 467, 475, 480, 500, 508, 516, 521, 527, 532, 538, 542, 552, 554, 556, 561, 563, 565, 567, 569, 571, 573, 575, 577, 579, 581, 583, 585, 587, 589, 591, 593, 595, 597, 599, 601, 605, 607, 609, 611, 613, 615, 620, 624, 624, 627, 628, 633, 634, 639, 644, 655, 656 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "tAGO", "tDST", "tYEAR_UNIT", "tMONTH_UNIT", "tHOUR_UNIT", "tMINUTE_UNIT", "tSEC_UNIT", "tDAY_UNIT", "tDAY_SHIFT", "tDAY", "tDAYZONE", "tLOCAL_ZONE", "tMERIDIAN", "tMONTH", "tORDINAL", "tZONE", "tSNUMBER", "tUNUMBER", "tSDECIMAL_NUMBER", "tUDECIMAL_NUMBER", "'@'", "'T'", "':'", "','", "'/'", "$accept", "spec", "timespec", "items", "item", "datetime", "iso_8601_datetime", "time", "iso_8601_time", "o_zone_offset", "zone_offset", "local_zone", "zone", "day", "date", "iso_8601_date", "rel", "relunit", "relunit_snumber", "dayshift", "seconds", "signed_seconds", "unsigned_seconds", "number", "hybrid", "o_colon_minutes", YY_NULL }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 64, 84, 58, 44, 47 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 28, 29, 29, 30, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 34, 35, 35, 35, 35, 36, 36, 36, 37, 37, 38, 39, 39, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 46, 46, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51, 52, 53, 53 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 2, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 4, 6, 1, 2, 4, 6, 0, 1, 2, 1, 2, 1, 1, 2, 2, 3, 1, 2, 1, 2, 2, 2, 3, 5, 3, 3, 2, 4, 2, 3, 1, 3, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 2 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 5, 0, 0, 2, 3, 85, 87, 84, 86, 4, 82, 83, 1, 56, 59, 65, 68, 73, 62, 81, 37, 35, 28, 0, 0, 30, 0, 88, 0, 0, 31, 6, 7, 16, 8, 21, 9, 10, 12, 11, 49, 13, 52, 74, 53, 14, 15, 38, 29, 0, 45, 54, 57, 63, 66, 69, 60, 39, 36, 90, 32, 75, 76, 78, 79, 80, 77, 55, 58, 64, 67, 70, 61, 40, 18, 47, 90, 0, 0, 22, 89, 71, 72, 33, 0, 51, 44, 0, 0, 34, 43, 48, 50, 27, 25, 41, 0, 17, 46, 91, 19, 90, 0, 23, 26, 0, 0, 25, 42, 25, 20, 24, 0, 25 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 2, 3, 4, 31, 32, 33, 34, 35, 103, 104, 36, 37, 38, 39, 40, 41, 42, 43, 44, 9, 10, 11, 45, 46, 93 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -93 static const yytype_int8 yypact[] = { 38, 27, 77, -93, 46, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, 62, -93, 82, -3, 66, 3, 74, -4, 83, 84, 75, -93, -93, -93, -93, -93, -93, -93, -93, -93, 71, -93, 93, -93, -93, -93, -93, -93, -93, 78, 72, -93, -93, -93, -93, -93, -93, -93, -93, 25, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, 21, 19, 79, 80, -93, -93, -93, -93, -93, 81, -93, -93, 85, 86, -93, -93, -93, -93, -93, -6, 76, 17, -93, -93, -93, -93, 87, 69, -93, -93, 88, 89, -1, -93, 18, -93, -93, 69, 91 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -93, -93, -93, -93, -93, -93, -93, -93, 20, -68, -27, -93, -93, -93, -93, -93, -93, -93, 60, -93, -93, -93, -92, -93, -93, 43 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { 79, 67, 68, 69, 70, 71, 72, 58, 73, 100, 107, 74, 75, 101, 110, 76, 49, 50, 101, 102, 113, 77, 59, 78, 61, 62, 63, 64, 65, 66, 61, 62, 63, 64, 65, 66, 101, 101, 92, 111, 90, 91, 106, 112, 88, 111, 5, 6, 7, 8, 88, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 1, 23, 24, 25, 26, 27, 28, 29, 79, 30, 51, 52, 53, 54, 55, 56, 12, 57, 61, 62, 63, 64, 65, 66, 60, 48, 80, 47, 6, 83, 8, 81, 82, 26, 84, 85, 86, 87, 94, 95, 96, 89, 105, 97, 98, 99, 0, 108, 109, 101, 0, 88 }; #define yypact_value_is_default(Yystate) \ (!!((Yystate) == (-93))) #define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = { 27, 5, 6, 7, 8, 9, 10, 4, 12, 15, 102, 15, 16, 19, 15, 19, 19, 20, 19, 25, 112, 25, 19, 27, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 19, 19, 19, 107, 19, 20, 25, 25, 25, 113, 19, 20, 21, 22, 25, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 23, 16, 17, 18, 19, 20, 21, 22, 96, 24, 5, 6, 7, 8, 9, 10, 0, 12, 5, 6, 7, 8, 9, 10, 25, 4, 27, 26, 20, 30, 22, 9, 9, 19, 24, 3, 19, 26, 20, 20, 20, 59, 27, 84, 20, 20, -1, 20, 20, 19, -1, 25 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 23, 29, 30, 31, 19, 20, 21, 22, 48, 49, 50, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 24, 32, 33, 34, 35, 36, 39, 40, 41, 42, 43, 44, 45, 46, 47, 51, 52, 26, 4, 19, 20, 5, 6, 7, 8, 9, 10, 12, 4, 19, 46, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 12, 15, 16, 19, 25, 27, 38, 46, 9, 9, 46, 24, 3, 19, 26, 25, 53, 19, 20, 19, 53, 20, 20, 20, 36, 20, 20, 15, 19, 25, 37, 38, 27, 25, 50, 20, 20, 15, 37, 25, 50 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. However, YYFAIL appears to be in use. Nevertheless, it is formally deprecated in Bison 2.4.2's NEWS entry, where a plan to phase it out is discussed. */ #define YYFAIL goto yyerrlab #if defined YYFAIL /* This is here to suppress warnings from the GCC cpp's -Wunused-macros. Normally we don't worry about that warning, but some users do, and we want to make it easy for users to remove YYFAIL uses, which will produce warnings from Bison 2.5. */ #endif #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (pc, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else # define YYLEX yylex (&yylval, pc) #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, pc); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; parser_control *pc; #endif { FILE *yyo = yyoutput; YYUSE (yyo); if (!yyvaluep) return; YYUSE (pc); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep, pc) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; parser_control *pc; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void yy_stack_print (yybottom, yytop) yytype_int16 *yybottom; yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, int yyrule, parser_control *pc) #else static void yy_reduce_print (yyvsp, yyrule, pc) YYSTYPE *yyvsp; int yyrule; parser_control *pc; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , pc); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, Rule, pc); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - Assume YYFAIL is not used. It's too flawed to consider. See for details. YYERROR is fine as it does not invoke this function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, parser_control *pc) #else static void yydestruct (yymsg, yytype, yyvaluep, pc) const char *yymsg; int yytype; YYSTYPE *yyvaluep; parser_control *pc; #endif { YYUSE (yyvaluep); YYUSE (pc); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: break; } } /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (parser_control *pc) #else int yyparse (pc) parser_control *pc; #endif #endif { /* The lookahead symbol. */ int yychar; #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else /* Default value used for initialization, for pacifying older GCCs or non-GCC compilers. */ static YYSTYPE yyval_default; # define YY_INITIAL_VALUE(Value) = Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif /* The semantic value of the lookahead symbol. */ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); /* Number of syntax errors so far. */ int yynerrs; int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: `yyss': related to states. `yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 4: /* Line 1792 of yacc.c */ #line 330 "./parse-datetime.y" { pc->seconds = (yyvsp[(2) - (2)].timespec); pc->timespec_seen = true; } break; case 7: /* Line 1792 of yacc.c */ #line 343 "./parse-datetime.y" { pc->times_seen++; pc->dates_seen++; } break; case 8: /* Line 1792 of yacc.c */ #line 345 "./parse-datetime.y" { pc->times_seen++; } break; case 9: /* Line 1792 of yacc.c */ #line 347 "./parse-datetime.y" { pc->local_zones_seen++; } break; case 10: /* Line 1792 of yacc.c */ #line 349 "./parse-datetime.y" { pc->zones_seen++; } break; case 11: /* Line 1792 of yacc.c */ #line 351 "./parse-datetime.y" { pc->dates_seen++; } break; case 12: /* Line 1792 of yacc.c */ #line 353 "./parse-datetime.y" { pc->days_seen++; } break; case 18: /* Line 1792 of yacc.c */ #line 369 "./parse-datetime.y" { set_hhmmss (pc, (yyvsp[(1) - (2)].textintval).value, 0, 0, 0); pc->meridian = (yyvsp[(2) - (2)].intval); } break; case 19: /* Line 1792 of yacc.c */ #line 374 "./parse-datetime.y" { set_hhmmss (pc, (yyvsp[(1) - (4)].textintval).value, (yyvsp[(3) - (4)].textintval).value, 0, 0); pc->meridian = (yyvsp[(4) - (4)].intval); } break; case 20: /* Line 1792 of yacc.c */ #line 379 "./parse-datetime.y" { set_hhmmss (pc, (yyvsp[(1) - (6)].textintval).value, (yyvsp[(3) - (6)].textintval).value, (yyvsp[(5) - (6)].timespec).tv_sec, (yyvsp[(5) - (6)].timespec).tv_nsec); pc->meridian = (yyvsp[(6) - (6)].intval); } break; case 22: /* Line 1792 of yacc.c */ #line 388 "./parse-datetime.y" { set_hhmmss (pc, (yyvsp[(1) - (2)].textintval).value, 0, 0, 0); pc->meridian = MER24; } break; case 23: /* Line 1792 of yacc.c */ #line 393 "./parse-datetime.y" { set_hhmmss (pc, (yyvsp[(1) - (4)].textintval).value, (yyvsp[(3) - (4)].textintval).value, 0, 0); pc->meridian = MER24; } break; case 24: /* Line 1792 of yacc.c */ #line 398 "./parse-datetime.y" { set_hhmmss (pc, (yyvsp[(1) - (6)].textintval).value, (yyvsp[(3) - (6)].textintval).value, (yyvsp[(5) - (6)].timespec).tv_sec, (yyvsp[(5) - (6)].timespec).tv_nsec); pc->meridian = MER24; } break; case 27: /* Line 1792 of yacc.c */ #line 411 "./parse-datetime.y" { pc->zones_seen++; pc->time_zone = time_zone_hhmm (pc, (yyvsp[(1) - (2)].textintval), (yyvsp[(2) - (2)].intval)); } break; case 28: /* Line 1792 of yacc.c */ #line 419 "./parse-datetime.y" { pc->local_isdst = (yyvsp[(1) - (1)].intval); pc->dsts_seen += (0 < (yyvsp[(1) - (1)].intval)); } break; case 29: /* Line 1792 of yacc.c */ #line 424 "./parse-datetime.y" { pc->local_isdst = 1; pc->dsts_seen += (0 < (yyvsp[(1) - (2)].intval)) + 1; } break; case 30: /* Line 1792 of yacc.c */ #line 434 "./parse-datetime.y" { pc->time_zone = (yyvsp[(1) - (1)].intval); } break; case 31: /* Line 1792 of yacc.c */ #line 436 "./parse-datetime.y" { pc->time_zone = HOUR(7); } break; case 32: /* Line 1792 of yacc.c */ #line 438 "./parse-datetime.y" { pc->time_zone = (yyvsp[(1) - (2)].intval); apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); } break; case 33: /* Line 1792 of yacc.c */ #line 441 "./parse-datetime.y" { pc->time_zone = HOUR(7); apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); } break; case 34: /* Line 1792 of yacc.c */ #line 444 "./parse-datetime.y" { pc->time_zone = (yyvsp[(1) - (3)].intval) + time_zone_hhmm (pc, (yyvsp[(2) - (3)].textintval), (yyvsp[(3) - (3)].intval)); } break; case 35: /* Line 1792 of yacc.c */ #line 446 "./parse-datetime.y" { pc->time_zone = (yyvsp[(1) - (1)].intval) + 60; } break; case 36: /* Line 1792 of yacc.c */ #line 448 "./parse-datetime.y" { pc->time_zone = (yyvsp[(1) - (2)].intval) + 60; } break; case 37: /* Line 1792 of yacc.c */ #line 453 "./parse-datetime.y" { pc->day_ordinal = 0; pc->day_number = (yyvsp[(1) - (1)].intval); } break; case 38: /* Line 1792 of yacc.c */ #line 458 "./parse-datetime.y" { pc->day_ordinal = 0; pc->day_number = (yyvsp[(1) - (2)].intval); } break; case 39: /* Line 1792 of yacc.c */ #line 463 "./parse-datetime.y" { pc->day_ordinal = (yyvsp[(1) - (2)].intval); pc->day_number = (yyvsp[(2) - (2)].intval); } break; case 40: /* Line 1792 of yacc.c */ #line 468 "./parse-datetime.y" { pc->day_ordinal = (yyvsp[(1) - (2)].textintval).value; pc->day_number = (yyvsp[(2) - (2)].intval); } break; case 41: /* Line 1792 of yacc.c */ #line 476 "./parse-datetime.y" { pc->month = (yyvsp[(1) - (3)].textintval).value; pc->day = (yyvsp[(3) - (3)].textintval).value; } break; case 42: /* Line 1792 of yacc.c */ #line 481 "./parse-datetime.y" { /* Interpret as YYYY/MM/DD if the first value has 4 or more digits, otherwise as MM/DD/YY. The goal in recognizing YYYY/MM/DD is solely to support legacy machine-generated dates like those in an RCS log listing. If you want portability, use the ISO 8601 format. */ if (4 <= (yyvsp[(1) - (5)].textintval).digits) { pc->year = (yyvsp[(1) - (5)].textintval); pc->month = (yyvsp[(3) - (5)].textintval).value; pc->day = (yyvsp[(5) - (5)].textintval).value; } else { pc->month = (yyvsp[(1) - (5)].textintval).value; pc->day = (yyvsp[(3) - (5)].textintval).value; pc->year = (yyvsp[(5) - (5)].textintval); } } break; case 43: /* Line 1792 of yacc.c */ #line 501 "./parse-datetime.y" { /* e.g. 17-JUN-1992. */ pc->day = (yyvsp[(1) - (3)].textintval).value; pc->month = (yyvsp[(2) - (3)].intval); pc->year.value = -(yyvsp[(3) - (3)].textintval).value; pc->year.digits = (yyvsp[(3) - (3)].textintval).digits; } break; case 44: /* Line 1792 of yacc.c */ #line 509 "./parse-datetime.y" { /* e.g. JUN-17-1992. */ pc->month = (yyvsp[(1) - (3)].intval); pc->day = -(yyvsp[(2) - (3)].textintval).value; pc->year.value = -(yyvsp[(3) - (3)].textintval).value; pc->year.digits = (yyvsp[(3) - (3)].textintval).digits; } break; case 45: /* Line 1792 of yacc.c */ #line 517 "./parse-datetime.y" { pc->month = (yyvsp[(1) - (2)].intval); pc->day = (yyvsp[(2) - (2)].textintval).value; } break; case 46: /* Line 1792 of yacc.c */ #line 522 "./parse-datetime.y" { pc->month = (yyvsp[(1) - (4)].intval); pc->day = (yyvsp[(2) - (4)].textintval).value; pc->year = (yyvsp[(4) - (4)].textintval); } break; case 47: /* Line 1792 of yacc.c */ #line 528 "./parse-datetime.y" { pc->day = (yyvsp[(1) - (2)].textintval).value; pc->month = (yyvsp[(2) - (2)].intval); } break; case 48: /* Line 1792 of yacc.c */ #line 533 "./parse-datetime.y" { pc->day = (yyvsp[(1) - (3)].textintval).value; pc->month = (yyvsp[(2) - (3)].intval); pc->year = (yyvsp[(3) - (3)].textintval); } break; case 50: /* Line 1792 of yacc.c */ #line 543 "./parse-datetime.y" { /* ISO 8601 format. YYYY-MM-DD. */ pc->year = (yyvsp[(1) - (3)].textintval); pc->month = -(yyvsp[(2) - (3)].textintval).value; pc->day = -(yyvsp[(3) - (3)].textintval).value; } break; case 51: /* Line 1792 of yacc.c */ #line 553 "./parse-datetime.y" { apply_relative_time (pc, (yyvsp[(1) - (2)].rel), (yyvsp[(2) - (2)].intval)); } break; case 52: /* Line 1792 of yacc.c */ #line 555 "./parse-datetime.y" { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); } break; case 53: /* Line 1792 of yacc.c */ #line 557 "./parse-datetime.y" { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); } break; case 54: /* Line 1792 of yacc.c */ #line 562 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].intval); } break; case 55: /* Line 1792 of yacc.c */ #line 564 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; } break; case 56: /* Line 1792 of yacc.c */ #line 566 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = 1; } break; case 57: /* Line 1792 of yacc.c */ #line 568 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].intval); } break; case 58: /* Line 1792 of yacc.c */ #line 570 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; } break; case 59: /* Line 1792 of yacc.c */ #line 572 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = 1; } break; case 60: /* Line 1792 of yacc.c */ #line 574 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); } break; case 61: /* Line 1792 of yacc.c */ #line 576 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); } break; case 62: /* Line 1792 of yacc.c */ #line 578 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); } break; case 63: /* Line 1792 of yacc.c */ #line 580 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].intval); } break; case 64: /* Line 1792 of yacc.c */ #line 582 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; } break; case 65: /* Line 1792 of yacc.c */ #line 584 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = 1; } break; case 66: /* Line 1792 of yacc.c */ #line 586 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].intval); } break; case 67: /* Line 1792 of yacc.c */ #line 588 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; } break; case 68: /* Line 1792 of yacc.c */ #line 590 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = 1; } break; case 69: /* Line 1792 of yacc.c */ #line 592 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].intval); } break; case 70: /* Line 1792 of yacc.c */ #line 594 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; } break; case 71: /* Line 1792 of yacc.c */ #line 596 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; } break; case 72: /* Line 1792 of yacc.c */ #line 598 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; } break; case 73: /* Line 1792 of yacc.c */ #line 600 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = 1; } break; case 75: /* Line 1792 of yacc.c */ #line 606 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; } break; case 76: /* Line 1792 of yacc.c */ #line 608 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; } break; case 77: /* Line 1792 of yacc.c */ #line 610 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); } break; case 78: /* Line 1792 of yacc.c */ #line 612 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; } break; case 79: /* Line 1792 of yacc.c */ #line 614 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; } break; case 80: /* Line 1792 of yacc.c */ #line 616 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; } break; case 81: /* Line 1792 of yacc.c */ #line 621 "./parse-datetime.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); } break; case 85: /* Line 1792 of yacc.c */ #line 629 "./parse-datetime.y" { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; } break; case 87: /* Line 1792 of yacc.c */ #line 635 "./parse-datetime.y" { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; } break; case 88: /* Line 1792 of yacc.c */ #line 640 "./parse-datetime.y" { digits_to_date_time (pc, (yyvsp[(1) - (1)].textintval)); } break; case 89: /* Line 1792 of yacc.c */ #line 645 "./parse-datetime.y" { /* Hybrid all-digit and relative offset, so that we accept e.g., "YYYYMMDD +N days" as well as "YYYYMMDD N days". */ digits_to_date_time (pc, (yyvsp[(1) - (2)].textintval)); apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); } break; case 90: /* Line 1792 of yacc.c */ #line 655 "./parse-datetime.y" { (yyval.intval) = -1; } break; case 91: /* Line 1792 of yacc.c */ #line 657 "./parse-datetime.y" { (yyval.intval) = (yyvsp[(2) - (2)].textintval).value; } break; /* Line 1792 of yacc.c */ #line 2332 "parse-datetime.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (pc, YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (pc, yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, pc); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp, pc); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (pc, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, pc); } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, pc); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } /* Line 2055 of yacc.c */ #line 660 "./parse-datetime.y" static table const meridian_table[] = { { "AM", tMERIDIAN, MERam }, { "A.M.", tMERIDIAN, MERam }, { "PM", tMERIDIAN, MERpm }, { "P.M.", tMERIDIAN, MERpm }, { NULL, 0, 0 } }; static table const dst_table[] = { { "DST", tDST, 0 } }; static table const month_and_day_table[] = { { "JANUARY", tMONTH, 1 }, { "FEBRUARY", tMONTH, 2 }, { "MARCH", tMONTH, 3 }, { "APRIL", tMONTH, 4 }, { "MAY", tMONTH, 5 }, { "JUNE", tMONTH, 6 }, { "JULY", tMONTH, 7 }, { "AUGUST", tMONTH, 8 }, { "SEPTEMBER",tMONTH, 9 }, { "SEPT", tMONTH, 9 }, { "OCTOBER", tMONTH, 10 }, { "NOVEMBER", tMONTH, 11 }, { "DECEMBER", tMONTH, 12 }, { "SUNDAY", tDAY, 0 }, { "MONDAY", tDAY, 1 }, { "TUESDAY", tDAY, 2 }, { "TUES", tDAY, 2 }, { "WEDNESDAY",tDAY, 3 }, { "WEDNES", tDAY, 3 }, { "THURSDAY", tDAY, 4 }, { "THUR", tDAY, 4 }, { "THURS", tDAY, 4 }, { "FRIDAY", tDAY, 5 }, { "SATURDAY", tDAY, 6 }, { NULL, 0, 0 } }; static table const time_units_table[] = { { "YEAR", tYEAR_UNIT, 1 }, { "MONTH", tMONTH_UNIT, 1 }, { "FORTNIGHT",tDAY_UNIT, 14 }, { "WEEK", tDAY_UNIT, 7 }, { "DAY", tDAY_UNIT, 1 }, { "HOUR", tHOUR_UNIT, 1 }, { "MINUTE", tMINUTE_UNIT, 1 }, { "MIN", tMINUTE_UNIT, 1 }, { "SECOND", tSEC_UNIT, 1 }, { "SEC", tSEC_UNIT, 1 }, { NULL, 0, 0 } }; /* Assorted relative-time words. */ static table const relative_time_table[] = { { "TOMORROW", tDAY_SHIFT, 1 }, { "YESTERDAY",tDAY_SHIFT, -1 }, { "TODAY", tDAY_SHIFT, 0 }, { "NOW", tDAY_SHIFT, 0 }, { "LAST", tORDINAL, -1 }, { "THIS", tORDINAL, 0 }, { "NEXT", tORDINAL, 1 }, { "FIRST", tORDINAL, 1 }, /*{ "SECOND", tORDINAL, 2 }, */ { "THIRD", tORDINAL, 3 }, { "FOURTH", tORDINAL, 4 }, { "FIFTH", tORDINAL, 5 }, { "SIXTH", tORDINAL, 6 }, { "SEVENTH", tORDINAL, 7 }, { "EIGHTH", tORDINAL, 8 }, { "NINTH", tORDINAL, 9 }, { "TENTH", tORDINAL, 10 }, { "ELEVENTH", tORDINAL, 11 }, { "TWELFTH", tORDINAL, 12 }, { "AGO", tAGO, -1 }, { "HENCE", tAGO, 1 }, { NULL, 0, 0 } }; /* The universal time zone table. These labels can be used even for time stamps that would not otherwise be valid, e.g., GMT time stamps in London during summer. */ static table const universal_time_zone_table[] = { { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */ { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */ { "UTC", tZONE, HOUR ( 0) }, { NULL, 0, 0 } }; /* The time zone table. This table is necessarily incomplete, as time zone abbreviations are ambiguous; e.g. Australians interpret "EST" as Eastern time in Australia, not as US Eastern Standard Time. You cannot rely on parse_datetime to handle arbitrary time zone abbreviations; use numeric abbreviations like "-0500" instead. */ static table const time_zone_table[] = { { "WET", tZONE, HOUR ( 0) }, /* Western European */ { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */ { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */ { "ART", tZONE, -HOUR ( 3) }, /* Argentina */ { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */ { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */ { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */ { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */ { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */ { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */ { "CLT", tZONE, -HOUR ( 4) }, /* Chile */ { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */ { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */ { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */ { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */ { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */ { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */ { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */ { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */ { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */ { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */ { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */ { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */ { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */ { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */ { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */ { "WAT", tZONE, HOUR ( 1) }, /* West Africa */ { "CET", tZONE, HOUR ( 1) }, /* Central European */ { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */ { "MET", tZONE, HOUR ( 1) }, /* Middle European */ { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */ { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ { "EET", tZONE, HOUR ( 2) }, /* Eastern European */ { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */ { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */ { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */ { "EAT", tZONE, HOUR ( 3) }, /* East Africa */ { "MSK", tZONE, HOUR ( 3) }, /* Moscow */ { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */ { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */ { "SGT", tZONE, HOUR ( 8) }, /* Singapore */ { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */ { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */ { "GST", tZONE, HOUR (10) }, /* Guam Standard */ { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */ { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */ { NULL, 0, 0 } }; /* Military time zone table. Note 'T' is a special case, as it is used as the separator in ISO 8601 date and time of day representation. */ static table const military_table[] = { { "A", tZONE, -HOUR ( 1) }, { "B", tZONE, -HOUR ( 2) }, { "C", tZONE, -HOUR ( 3) }, { "D", tZONE, -HOUR ( 4) }, { "E", tZONE, -HOUR ( 5) }, { "F", tZONE, -HOUR ( 6) }, { "G", tZONE, -HOUR ( 7) }, { "H", tZONE, -HOUR ( 8) }, { "I", tZONE, -HOUR ( 9) }, { "K", tZONE, -HOUR (10) }, { "L", tZONE, -HOUR (11) }, { "M", tZONE, -HOUR (12) }, { "N", tZONE, HOUR ( 1) }, { "O", tZONE, HOUR ( 2) }, { "P", tZONE, HOUR ( 3) }, { "Q", tZONE, HOUR ( 4) }, { "R", tZONE, HOUR ( 5) }, { "S", tZONE, HOUR ( 6) }, { "T", 'T', 0 }, { "U", tZONE, HOUR ( 8) }, { "V", tZONE, HOUR ( 9) }, { "W", tZONE, HOUR (10) }, { "X", tZONE, HOUR (11) }, { "Y", tZONE, HOUR (12) }, { "Z", tZONE, HOUR ( 0) }, { NULL, 0, 0 } }; /* Convert a time zone expressed as HH:MM into an integer count of minutes. If MM is negative, then S is of the form HHMM and needs to be picked apart; otherwise, S is of the form HH. As specified in http://www.opengroup.org/susv3xbd/xbd_chap08.html#tag_08_03, allow only valid TZ range, and consider first two digits as hours, if no minutes specified. */ static long int time_zone_hhmm (parser_control *pc, textint s, long int mm) { long int n_minutes; /* If the length of S is 1 or 2 and no minutes are specified, interpret it as a number of hours. */ if (s.digits <= 2 && mm < 0) s.value *= 100; if (mm < 0) n_minutes = (s.value / 100) * 60 + s.value % 100; else n_minutes = s.value * 60 + (s.negative ? -mm : mm); /* If the absolute number of minutes is larger than 24 hours, arrange to reject it by incrementing pc->zones_seen. Thus, we allow only values in the range UTC-24:00 to UTC+24:00. */ if (24 * 60 < abs (n_minutes)) pc->zones_seen++; return n_minutes; } static int to_hour (long int hours, int meridian) { switch (meridian) { default: /* Pacify GCC. */ case MER24: return 0 <= hours && hours < 24 ? hours : -1; case MERam: return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1; case MERpm: return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1; } } static long int to_year (textint textyear) { long int year = textyear.value; if (year < 0) year = -year; /* XPG4 suggests that years 00-68 map to 2000-2068, and years 69-99 map to 1969-1999. */ else if (textyear.digits == 2) year += year < 69 ? 2000 : 1900; return year; } static table const * _GL_ATTRIBUTE_PURE lookup_zone (parser_control const *pc, char const *name) { table const *tp; for (tp = universal_time_zone_table; tp->name; tp++) if (strcmp (name, tp->name) == 0) return tp; /* Try local zone abbreviations before those in time_zone_table, as the local ones are more likely to be right. */ for (tp = pc->local_time_zone_table; tp->name; tp++) if (strcmp (name, tp->name) == 0) return tp; for (tp = time_zone_table; tp->name; tp++) if (strcmp (name, tp->name) == 0) return tp; return NULL; } #if ! HAVE_TM_GMTOFF /* Yield the difference between *A and *B, measured in seconds, ignoring leap seconds. The body of this function is taken directly from the GNU C Library; see src/strftime.c. */ static long int tm_diff (struct tm const *a, struct tm const *b) { /* Compute intervening leap days correctly even if year is negative. Take care to avoid int overflow in leap day calculations. */ int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); int a100 = a4 / 25 - (a4 % 25 < 0); int b100 = b4 / 25 - (b4 % 25 < 0); int a400 = SHR (a100, 2); int b400 = SHR (b100, 2); int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); long int ayear = a->tm_year; long int years = ayear - b->tm_year; long int days = (365 * years + intervening_leap_days + (a->tm_yday - b->tm_yday)); return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); } #endif /* ! HAVE_TM_GMTOFF */ static table const * lookup_word (parser_control const *pc, char *word) { char *p; char *q; size_t wordlen; table const *tp; bool period_found; bool abbrev; /* Make it uppercase. */ for (p = word; *p; p++) { unsigned char ch = *p; *p = c_toupper (ch); } for (tp = meridian_table; tp->name; tp++) if (strcmp (word, tp->name) == 0) return tp; /* See if we have an abbreviation for a month. */ wordlen = strlen (word); abbrev = wordlen == 3 || (wordlen == 4 && word[3] == '.'); for (tp = month_and_day_table; tp->name; tp++) if ((abbrev ? strncmp (word, tp->name, 3) : strcmp (word, tp->name)) == 0) return tp; if ((tp = lookup_zone (pc, word))) return tp; if (strcmp (word, dst_table[0].name) == 0) return dst_table; for (tp = time_units_table; tp->name; tp++) if (strcmp (word, tp->name) == 0) return tp; /* Strip off any plural and try the units table again. */ if (word[wordlen - 1] == 'S') { word[wordlen - 1] = '\0'; for (tp = time_units_table; tp->name; tp++) if (strcmp (word, tp->name) == 0) return tp; word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */ } for (tp = relative_time_table; tp->name; tp++) if (strcmp (word, tp->name) == 0) return tp; /* Military time zones. */ if (wordlen == 1) for (tp = military_table; tp->name; tp++) if (word[0] == tp->name[0]) return tp; /* Drop out any periods and try the time zone table again. */ for (period_found = false, p = q = word; (*p = *q); q++) if (*q == '.') period_found = true; else p++; if (period_found && (tp = lookup_zone (pc, word))) return tp; return NULL; } static int yylex (union YYSTYPE *lvalp, parser_control *pc) { unsigned char c; size_t count; for (;;) { while (c = *pc->input, c_isspace (c)) pc->input++; if (ISDIGIT (c) || c == '-' || c == '+') { char const *p; int sign; unsigned long int value; if (c == '-' || c == '+') { sign = c == '-' ? -1 : 1; while (c = *++pc->input, c_isspace (c)) continue; if (! ISDIGIT (c)) /* skip the '-' sign */ continue; } else sign = 0; p = pc->input; for (value = 0; ; value *= 10) { unsigned long int value1 = value + (c - '0'); if (value1 < value) return '?'; value = value1; c = *++p; if (! ISDIGIT (c)) break; if (ULONG_MAX / 10 < value) return '?'; } if ((c == '.' || c == ',') && ISDIGIT (p[1])) { time_t s; int ns; int digits; unsigned long int value1; /* Check for overflow when converting value to time_t. */ if (sign < 0) { s = - value; if (0 < s) return '?'; value1 = -s; } else { s = value; if (s < 0) return '?'; value1 = s; } if (value != value1) return '?'; /* Accumulate fraction, to ns precision. */ p++; ns = *p++ - '0'; for (digits = 2; digits <= LOG10_BILLION; digits++) { ns *= 10; if (ISDIGIT (*p)) ns += *p++ - '0'; } /* Skip excess digits, truncating toward -Infinity. */ if (sign < 0) for (; ISDIGIT (*p); p++) if (*p != '0') { ns++; break; } while (ISDIGIT (*p)) p++; /* Adjust to the timespec convention, which is that tv_nsec is always a positive offset even if tv_sec is negative. */ if (sign < 0 && ns) { s--; if (! (s < 0)) return '?'; ns = BILLION - ns; } lvalp->timespec.tv_sec = s; lvalp->timespec.tv_nsec = ns; pc->input = p; return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER; } else { lvalp->textintval.negative = sign < 0; if (sign < 0) { lvalp->textintval.value = - value; if (0 < lvalp->textintval.value) return '?'; } else { lvalp->textintval.value = value; if (lvalp->textintval.value < 0) return '?'; } lvalp->textintval.digits = p - pc->input; pc->input = p; return sign ? tSNUMBER : tUNUMBER; } } if (c_isalpha (c)) { char buff[20]; char *p = buff; table const *tp; do { if (p < buff + sizeof buff - 1) *p++ = c; c = *++pc->input; } while (c_isalpha (c) || c == '.'); *p = '\0'; tp = lookup_word (pc, buff); if (! tp) return '?'; lvalp->intval = tp->value; return tp->type; } if (c != '(') return to_uchar (*pc->input++); count = 0; do { c = *pc->input++; if (c == '\0') return c; if (c == '(') count++; else if (c == ')') count--; } while (count != 0); } } /* Do nothing if the parser reports an error. */ static int yyerror (parser_control const *pc _GL_UNUSED, char const *s _GL_UNUSED) { return 0; } /* If *TM0 is the old and *TM1 is the new value of a struct tm after passing it to mktime, return true if it's OK that mktime returned T. It's not OK if *TM0 has out-of-range members. */ static bool mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t) { if (t == (time_t) -1) { /* Guard against falsely reporting an error when parsing a time stamp that happens to equal (time_t) -1, on a host that supports such a time stamp. */ tm1 = localtime (&t); if (!tm1) return false; } return ! ((tm0->tm_sec ^ tm1->tm_sec) | (tm0->tm_min ^ tm1->tm_min) | (tm0->tm_hour ^ tm1->tm_hour) | (tm0->tm_mday ^ tm1->tm_mday) | (tm0->tm_mon ^ tm1->tm_mon) | (tm0->tm_year ^ tm1->tm_year)); } /* A reasonable upper bound for the size of ordinary TZ strings. Use heap allocation if TZ's length exceeds this. */ enum { TZBUFSIZE = 100 }; /* Return a copy of TZ, stored in TZBUF if it fits, and heap-allocated otherwise. */ static char * get_tz (char tzbuf[TZBUFSIZE]) { char *tz = getenv ("TZ"); if (tz) { size_t tzsize = strlen (tz) + 1; tz = (tzsize <= TZBUFSIZE ? memcpy (tzbuf, tz, tzsize) : xmemdup (tz, tzsize)); } return tz; } /* Parse a date/time string, storing the resulting time value into *RESULT. The string itself is pointed to by P. Return true if successful. P can be an incomplete or relative time specification; if so, use *NOW as the basis for the returned time. */ bool parse_datetime (struct timespec *result, char const *p, struct timespec const *now) { time_t Start; long int Start_ns; struct tm const *tmp; struct tm tm; struct tm tm0; parser_control pc; struct timespec gettime_buffer; unsigned char c; bool tz_was_altered = false; char *tz0 = NULL; char tz0buf[TZBUFSIZE]; bool ok = true; if (! now) { gettime (&gettime_buffer); now = &gettime_buffer; } Start = now->tv_sec; Start_ns = now->tv_nsec; tmp = localtime (&now->tv_sec); if (! tmp) return false; while (c = *p, c_isspace (c)) p++; if (strncmp (p, "TZ=\"", 4) == 0) { char const *tzbase = p + 4; size_t tzsize = 1; char const *s; for (s = tzbase; *s; s++, tzsize++) if (*s == '\\') { s++; if (! (*s == '\\' || *s == '"')) break; } else if (*s == '"') { char *z; char *tz1; char tz1buf[TZBUFSIZE]; bool large_tz = TZBUFSIZE < tzsize; bool setenv_ok; tz0 = get_tz (tz0buf); z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf; for (s = tzbase; *s != '"'; s++) *z++ = *(s += *s == '\\'); *z = '\0'; setenv_ok = setenv ("TZ", tz1, 1) == 0; if (large_tz) free (tz1); if (!setenv_ok) goto fail; tz_was_altered = true; p = s + 1; while (c = *p, c_isspace (c)) p++; break; } } /* As documented, be careful to treat the empty string just like a date string of "0". Without this, an empty string would be declared invalid when parsed during a DST transition. */ if (*p == '\0') p = "0"; pc.input = p; pc.year.value = tmp->tm_year; pc.year.value += TM_YEAR_BASE; pc.year.digits = 0; pc.month = tmp->tm_mon + 1; pc.day = tmp->tm_mday; pc.hour = tmp->tm_hour; pc.minutes = tmp->tm_min; pc.seconds.tv_sec = tmp->tm_sec; pc.seconds.tv_nsec = Start_ns; tm.tm_isdst = tmp->tm_isdst; pc.meridian = MER24; pc.rel = RELATIVE_TIME_0; pc.timespec_seen = false; pc.rels_seen = false; pc.dates_seen = 0; pc.days_seen = 0; pc.times_seen = 0; pc.local_zones_seen = 0; pc.dsts_seen = 0; pc.zones_seen = 0; #if HAVE_STRUCT_TM_TM_ZONE pc.local_time_zone_table[0].name = tmp->tm_zone; pc.local_time_zone_table[0].type = tLOCAL_ZONE; pc.local_time_zone_table[0].value = tmp->tm_isdst; pc.local_time_zone_table[1].name = NULL; /* Probe the names used in the next three calendar quarters, looking for a tm_isdst different from the one we already have. */ { int quarter; for (quarter = 1; quarter <= 3; quarter++) { time_t probe = Start + quarter * (90 * 24 * 60 * 60); struct tm const *probe_tm = localtime (&probe); if (probe_tm && probe_tm->tm_zone && probe_tm->tm_isdst != pc.local_time_zone_table[0].value) { { pc.local_time_zone_table[1].name = probe_tm->tm_zone; pc.local_time_zone_table[1].type = tLOCAL_ZONE; pc.local_time_zone_table[1].value = probe_tm->tm_isdst; pc.local_time_zone_table[2].name = NULL; } break; } } } #else #if HAVE_TZNAME { # if !HAVE_DECL_TZNAME extern char *tzname[]; # endif int i; for (i = 0; i < 2; i++) { pc.local_time_zone_table[i].name = tzname[i]; pc.local_time_zone_table[i].type = tLOCAL_ZONE; pc.local_time_zone_table[i].value = i; } pc.local_time_zone_table[i].name = NULL; } #else pc.local_time_zone_table[0].name = NULL; #endif #endif if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name && ! strcmp (pc.local_time_zone_table[0].name, pc.local_time_zone_table[1].name)) { /* This locale uses the same abbreviation for standard and daylight times. So if we see that abbreviation, we don't know whether it's daylight time. */ pc.local_time_zone_table[0].value = -1; pc.local_time_zone_table[1].name = NULL; } if (yyparse (&pc) != 0) goto fail; if (pc.timespec_seen) *result = pc.seconds; else { if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen | (pc.local_zones_seen + pc.zones_seen))) goto fail; tm.tm_year = to_year (pc.year) - TM_YEAR_BASE; tm.tm_mon = pc.month - 1; tm.tm_mday = pc.day; if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen)) { tm.tm_hour = to_hour (pc.hour, pc.meridian); if (tm.tm_hour < 0) goto fail; tm.tm_min = pc.minutes; tm.tm_sec = pc.seconds.tv_sec; } else { tm.tm_hour = tm.tm_min = tm.tm_sec = 0; pc.seconds.tv_nsec = 0; } /* Let mktime deduce tm_isdst if we have an absolute time stamp. */ if (pc.dates_seen | pc.days_seen | pc.times_seen) tm.tm_isdst = -1; /* But if the input explicitly specifies local time with or without DST, give mktime that information. */ if (pc.local_zones_seen) tm.tm_isdst = pc.local_isdst; tm0 = tm; Start = mktime (&tm); if (! mktime_ok (&tm0, &tm, Start)) { if (! pc.zones_seen) goto fail; else { /* Guard against falsely reporting errors near the time_t boundaries when parsing times in other time zones. For example, suppose the input string "1969-12-31 23:00:00 -0100", the current time zone is 8 hours ahead of UTC, and the min time_t value is 1970-01-01 00:00:00 UTC. Then the min localtime value is 1970-01-01 08:00:00, and mktime will therefore fail on 1969-12-31 23:00:00. To work around the problem, set the time zone to 1 hour behind UTC temporarily by setting TZ="XXX1:00" and try mktime again. */ long int time_zone = pc.time_zone; long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone; long int abs_time_zone_hour = abs_time_zone / 60; int abs_time_zone_min = abs_time_zone % 60; char tz1buf[sizeof "XXX+0:00" + sizeof pc.time_zone * CHAR_BIT / 3]; if (!tz_was_altered) tz0 = get_tz (tz0buf); sprintf (tz1buf, "XXX%s%ld:%02d", &"-"[time_zone < 0], abs_time_zone_hour, abs_time_zone_min); if (setenv ("TZ", tz1buf, 1) != 0) goto fail; tz_was_altered = true; tm = tm0; Start = mktime (&tm); if (! mktime_ok (&tm0, &tm, Start)) goto fail; } } if (pc.days_seen && ! pc.dates_seen) { tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7 + 7 * (pc.day_ordinal - (0 < pc.day_ordinal && tm.tm_wday != pc.day_number))); tm.tm_isdst = -1; Start = mktime (&tm); if (Start == (time_t) -1) goto fail; } /* Add relative date. */ if (pc.rel.year | pc.rel.month | pc.rel.day) { int year = tm.tm_year + pc.rel.year; int month = tm.tm_mon + pc.rel.month; int day = tm.tm_mday + pc.rel.day; if (((year < tm.tm_year) ^ (pc.rel.year < 0)) | ((month < tm.tm_mon) ^ (pc.rel.month < 0)) | ((day < tm.tm_mday) ^ (pc.rel.day < 0))) goto fail; tm.tm_year = year; tm.tm_mon = month; tm.tm_mday = day; tm.tm_hour = tm0.tm_hour; tm.tm_min = tm0.tm_min; tm.tm_sec = tm0.tm_sec; tm.tm_isdst = tm0.tm_isdst; Start = mktime (&tm); if (Start == (time_t) -1) goto fail; } /* The only "output" of this if-block is an updated Start value, so this block must follow others that clobber Start. */ if (pc.zones_seen) { long int delta = pc.time_zone * 60; time_t t1; #ifdef HAVE_TM_GMTOFF delta -= tm.tm_gmtoff; #else time_t t = Start; struct tm const *gmt = gmtime (&t); if (! gmt) goto fail; delta -= tm_diff (&tm, gmt); #endif t1 = Start - delta; if ((Start < t1) != (delta < 0)) goto fail; /* time_t overflow */ Start = t1; } /* Add relative hours, minutes, and seconds. On hosts that support leap seconds, ignore the possibility of leap seconds; e.g., "+ 10 minutes" adds 600 seconds, even if one of them is a leap second. Typically this is not what the user wants, but it's too hard to do it the other way, because the time zone indicator must be applied before relative times, and if mktime is applied again the time zone will be lost. */ { long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns; long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION; time_t t0 = Start; long int d1 = 60 * 60 * pc.rel.hour; time_t t1 = t0 + d1; long int d2 = 60 * pc.rel.minutes; time_t t2 = t1 + d2; long_time_t d3 = pc.rel.seconds; long_time_t t3 = t2 + d3; long int d4 = (sum_ns - normalized_ns) / BILLION; long_time_t t4 = t3 + d4; time_t t5 = t4; if ((d1 / (60 * 60) ^ pc.rel.hour) | (d2 / 60 ^ pc.rel.minutes) | ((t1 < t0) ^ (d1 < 0)) | ((t2 < t1) ^ (d2 < 0)) | ((t3 < t2) ^ (d3 < 0)) | ((t4 < t3) ^ (d4 < 0)) | (t5 != t4)) goto fail; result->tv_sec = t5; result->tv_nsec = normalized_ns; } } goto done; fail: ok = false; done: if (tz_was_altered) ok &= (tz0 ? setenv ("TZ", tz0, 1) : unsetenv ("TZ")) == 0; if (tz0 != tz0buf) free (tz0); return ok; } #if TEST int main (int ac, char **av) { char buff[BUFSIZ]; printf ("Enter date, or blank line to exit.\n\t> "); fflush (stdout); buff[BUFSIZ - 1] = '\0'; while (fgets (buff, BUFSIZ - 1, stdin) && buff[0]) { struct timespec d; struct tm const *tm; if (! parse_datetime (&d, buff, NULL)) printf ("Bad format - couldn't convert.\n"); else if (! (tm = localtime (&d.tv_sec))) { long int sec = d.tv_sec; printf ("localtime (%ld) failed\n", sec); } else { int ns = d.tv_nsec; printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, ns); } printf ("\t> "); fflush (stdout); } return 0; } #endif /* TEST */ lftp-4.6.3a/lib/memchr.valgrind0000644000015000007670000000065212122621312013317 00000000000000# Suppress a valgrind message about use of uninitialized memory in memchr(). # POSIX states that when the character is found, memchr must not read extra # bytes in an overestimated length (for example, where memchr is used to # implement strnlen). However, we use a safe word read to provide a speedup. { memchr-value4 Memcheck:Value4 fun:rpl_memchr } { memchr-value8 Memcheck:Value8 fun:rpl_memchr } lftp-4.6.3a/lib/timespec.c0000644000015000007670000000013012122621313012261 00000000000000#include #define _GL_TIMESPEC_INLINE _GL_EXTERN_INLINE #include "timespec.h" lftp-4.6.3a/lib/sha1.c0000644000015000007670000003220612466374012011331 00000000000000/* sha1.c - Functions to compute SHA1 message digest of files or memory blocks according to the NIST specification FIPS-180-1. Copyright (C) 2000-2001, 2003-2006, 2008-2015 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 . */ /* Written by Scott G. Miller Credits: Robert Klep -- Expansion function fix */ #include #if HAVE_OPENSSL_SHA1 # define GL_OPENSSL_INLINE _GL_EXTERN_INLINE #endif #include "sha1.h" #include #include #include #include #if USE_UNLOCKED_IO # include "unlocked-io.h" #endif #ifdef WORDS_BIGENDIAN # define SWAP(n) (n) #else # define SWAP(n) \ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #endif #define BLOCKSIZE 32768 #if BLOCKSIZE % 64 != 0 # error "invalid BLOCKSIZE" #endif #if ! HAVE_OPENSSL_SHA1 /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* Take a pointer to a 160 bit block of data (five 32 bit ints) and initialize it to the start constants of the SHA1 algorithm. This must be called before using hash in the call to sha1_hash. */ void sha1_init_ctx (struct sha1_ctx *ctx) { ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; ctx->D = 0x10325476; ctx->E = 0xc3d2e1f0; ctx->total[0] = ctx->total[1] = 0; ctx->buflen = 0; } /* Copy the 4 byte value from v into the memory location pointed to by *cp, If your architecture allows unaligned access this is equivalent to * (uint32_t *) cp = v */ static void set_uint32 (char *cp, uint32_t v) { memcpy (cp, &v, sizeof v); } /* Put result from CTX in first 20 bytes following RESBUF. The result must be in little endian byte order. */ void * sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf) { char *r = resbuf; set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A)); set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B)); set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C)); set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D)); set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E)); return resbuf; } /* Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF. */ void * sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ uint32_t bytes = ctx->buflen; size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4; /* Now count remaining bytes. */ ctx->total[0] += bytes; if (ctx->total[0] < bytes) ++ctx->total[1]; /* Put the 64-bit file length in *bits* at the end of the buffer. */ ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3); memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); /* Process last bytes. */ sha1_process_block (ctx->buffer, size * 4, ctx); return sha1_read_ctx (ctx, resbuf); } #endif /* Compute SHA1 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ int sha1_stream (FILE *stream, void *resblock) { struct sha1_ctx ctx; size_t sum; char *buffer = malloc (BLOCKSIZE + 72); if (!buffer) return 1; /* Initialize the computation context. */ sha1_init_ctx (&ctx); /* Iterate over full file contents. */ while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the computation function processes the whole buffer so that with the next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ while (1) { n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; if (sum == BLOCKSIZE) break; if (n == 0) { /* Check for the error flag IFF N == 0, so that we don't exit the loop after a partial read due to e.g., EAGAIN or EWOULDBLOCK. */ if (ferror (stream)) { free (buffer); return 1; } goto process_partial_block; } /* We've read at least one byte, so ignore errors. But always check for EOF, since feof may be true even though N > 0. Otherwise, we could end up calling fread after EOF. */ if (feof (stream)) goto process_partial_block; } /* Process buffer with BLOCKSIZE bytes. Note that BLOCKSIZE % 64 == 0 */ sha1_process_block (buffer, BLOCKSIZE, &ctx); } process_partial_block:; /* Process any remaining bytes. */ if (sum > 0) sha1_process_bytes (buffer, sum, &ctx); /* Construct result in desired memory. */ sha1_finish_ctx (&ctx, resblock); free (buffer); return 0; } #if ! HAVE_OPENSSL_SHA1 /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ void * sha1_buffer (const char *buffer, size_t len, void *resblock) { struct sha1_ctx ctx; /* Initialize the computation context. */ sha1_init_ctx (&ctx); /* Process whole buffer but last len % 64 bytes. */ sha1_process_bytes (buffer, len, &ctx); /* Put result in desired memory area. */ return sha1_finish_ctx (&ctx, resblock); } void sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) { /* When we already have some bits in our internal buffer concatenate both inputs first. */ if (ctx->buflen != 0) { size_t left_over = ctx->buflen; size_t add = 128 - left_over > len ? len : 128 - left_over; memcpy (&((char *) ctx->buffer)[left_over], buffer, add); ctx->buflen += add; if (ctx->buflen > 64) { sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx); ctx->buflen &= 63; /* The regions in the following copy operation cannot overlap. */ memcpy (ctx->buffer, &((char *) ctx->buffer)[(left_over + add) & ~63], ctx->buflen); } buffer = (const char *) buffer + add; len -= add; } /* Process available complete blocks. */ if (len >= 64) { #if !_STRING_ARCH_unaligned # define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); buffer = (const char *) buffer + 64; len -= 64; } else #endif { sha1_process_block (buffer, len & ~63, ctx); buffer = (const char *) buffer + (len & ~63); len &= 63; } } /* Move remaining bytes in internal buffer. */ if (len > 0) { size_t left_over = ctx->buflen; memcpy (&((char *) ctx->buffer)[left_over], buffer, len); left_over += len; if (left_over >= 64) { sha1_process_block (ctx->buffer, 64, ctx); left_over -= 64; memcpy (ctx->buffer, &ctx->buffer[16], left_over); } ctx->buflen = left_over; } } /* --- Code below is the primary difference between md5.c and sha1.c --- */ /* SHA1 round constants */ #define K1 0x5a827999 #define K2 0x6ed9eba1 #define K3 0x8f1bbcdc #define K4 0xca62c1d6 /* Round functions. Note that F2 is the same as F4. */ #define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) ) #define F2(B,C,D) (B ^ C ^ D) #define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) ) #define F4(B,C,D) (B ^ C ^ D) /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. Most of this code comes from GnuPG's cipher/sha1.c. */ void sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) { const uint32_t *words = buffer; size_t nwords = len / sizeof (uint32_t); const uint32_t *endp = words + nwords; uint32_t x[16]; uint32_t a = ctx->A; uint32_t b = ctx->B; uint32_t c = ctx->C; uint32_t d = ctx->D; uint32_t e = ctx->E; uint32_t lolen = len; /* First increment the byte count. RFC 1321 specifies the possible length of the file up to 2^64 bits. Here we only compute the number of bytes. Do a double word increment. */ ctx->total[0] += lolen; ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen); #define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n)))) #define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \ ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \ , (x[I&0x0f] = rol(tm, 1)) ) #define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \ + F( B, C, D ) \ + K \ + M; \ B = rol( B, 30 ); \ } while(0) while (words < endp) { uint32_t tm; int t; for (t = 0; t < 16; t++) { x[t] = SWAP (*words); words++; } R( a, b, c, d, e, F1, K1, x[ 0] ); R( e, a, b, c, d, F1, K1, x[ 1] ); R( d, e, a, b, c, F1, K1, x[ 2] ); R( c, d, e, a, b, F1, K1, x[ 3] ); R( b, c, d, e, a, F1, K1, x[ 4] ); R( a, b, c, d, e, F1, K1, x[ 5] ); R( e, a, b, c, d, F1, K1, x[ 6] ); R( d, e, a, b, c, F1, K1, x[ 7] ); R( c, d, e, a, b, F1, K1, x[ 8] ); R( b, c, d, e, a, F1, K1, x[ 9] ); R( a, b, c, d, e, F1, K1, x[10] ); R( e, a, b, c, d, F1, K1, x[11] ); R( d, e, a, b, c, F1, K1, x[12] ); R( c, d, e, a, b, F1, K1, x[13] ); R( b, c, d, e, a, F1, K1, x[14] ); R( a, b, c, d, e, F1, K1, x[15] ); R( e, a, b, c, d, F1, K1, M(16) ); R( d, e, a, b, c, F1, K1, M(17) ); R( c, d, e, a, b, F1, K1, M(18) ); R( b, c, d, e, a, F1, K1, M(19) ); R( a, b, c, d, e, F2, K2, M(20) ); R( e, a, b, c, d, F2, K2, M(21) ); R( d, e, a, b, c, F2, K2, M(22) ); R( c, d, e, a, b, F2, K2, M(23) ); R( b, c, d, e, a, F2, K2, M(24) ); R( a, b, c, d, e, F2, K2, M(25) ); R( e, a, b, c, d, F2, K2, M(26) ); R( d, e, a, b, c, F2, K2, M(27) ); R( c, d, e, a, b, F2, K2, M(28) ); R( b, c, d, e, a, F2, K2, M(29) ); R( a, b, c, d, e, F2, K2, M(30) ); R( e, a, b, c, d, F2, K2, M(31) ); R( d, e, a, b, c, F2, K2, M(32) ); R( c, d, e, a, b, F2, K2, M(33) ); R( b, c, d, e, a, F2, K2, M(34) ); R( a, b, c, d, e, F2, K2, M(35) ); R( e, a, b, c, d, F2, K2, M(36) ); R( d, e, a, b, c, F2, K2, M(37) ); R( c, d, e, a, b, F2, K2, M(38) ); R( b, c, d, e, a, F2, K2, M(39) ); R( a, b, c, d, e, F3, K3, M(40) ); R( e, a, b, c, d, F3, K3, M(41) ); R( d, e, a, b, c, F3, K3, M(42) ); R( c, d, e, a, b, F3, K3, M(43) ); R( b, c, d, e, a, F3, K3, M(44) ); R( a, b, c, d, e, F3, K3, M(45) ); R( e, a, b, c, d, F3, K3, M(46) ); R( d, e, a, b, c, F3, K3, M(47) ); R( c, d, e, a, b, F3, K3, M(48) ); R( b, c, d, e, a, F3, K3, M(49) ); R( a, b, c, d, e, F3, K3, M(50) ); R( e, a, b, c, d, F3, K3, M(51) ); R( d, e, a, b, c, F3, K3, M(52) ); R( c, d, e, a, b, F3, K3, M(53) ); R( b, c, d, e, a, F3, K3, M(54) ); R( a, b, c, d, e, F3, K3, M(55) ); R( e, a, b, c, d, F3, K3, M(56) ); R( d, e, a, b, c, F3, K3, M(57) ); R( c, d, e, a, b, F3, K3, M(58) ); R( b, c, d, e, a, F3, K3, M(59) ); R( a, b, c, d, e, F4, K4, M(60) ); R( e, a, b, c, d, F4, K4, M(61) ); R( d, e, a, b, c, F4, K4, M(62) ); R( c, d, e, a, b, F4, K4, M(63) ); R( b, c, d, e, a, F4, K4, M(64) ); R( a, b, c, d, e, F4, K4, M(65) ); R( e, a, b, c, d, F4, K4, M(66) ); R( d, e, a, b, c, F4, K4, M(67) ); R( c, d, e, a, b, F4, K4, M(68) ); R( b, c, d, e, a, F4, K4, M(69) ); R( a, b, c, d, e, F4, K4, M(70) ); R( e, a, b, c, d, F4, K4, M(71) ); R( d, e, a, b, c, F4, K4, M(72) ); R( c, d, e, a, b, F4, K4, M(73) ); R( b, c, d, e, a, F4, K4, M(74) ); R( a, b, c, d, e, F4, K4, M(75) ); R( e, a, b, c, d, F4, K4, M(76) ); R( d, e, a, b, c, F4, K4, M(77) ); R( c, d, e, a, b, F4, K4, M(78) ); R( b, c, d, e, a, F4, K4, M(79) ); a = ctx->A += a; b = ctx->B += b; c = ctx->C += c; d = ctx->D += d; e = ctx->E += e; } } #endif lftp-4.6.3a/lib/localcharset.h0000644000015000007670000000243212466374011013143 00000000000000/* Determine a canonical name for the current locale's character encoding. Copyright (C) 2000-2003, 2009-2015 Free Software Foundation, Inc. This file is part of the GNU CHARSET 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, 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 . */ #ifndef _LOCALCHARSET_H #define _LOCALCHARSET_H #ifdef __cplusplus extern "C" { #endif /* Determine the current locale's character encoding, and canonicalize it into one of the canonical names listed in config.charset. The result must not be freed; it is statically allocated. If the canonical name cannot be determined, the result is a non-canonical name. */ extern const char * locale_charset (void); #ifdef __cplusplus } #endif #endif /* _LOCALCHARSET_H */ lftp-4.6.3a/lib/xmalloc.c0000644000015000007670000000646712466374012012146 00000000000000/* xmalloc.c -- malloc with out of memory checking Copyright (C) 1990-2000, 2002-2006, 2008-2015 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 . */ #include #define XALLOC_INLINE _GL_EXTERN_INLINE #include "xalloc.h" #include #include /* 1 if calloc is known to be compatible with GNU calloc. This matters if we are not also using the calloc module, which defines HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */ #if defined HAVE_CALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__) enum { HAVE_GNU_CALLOC = 1 }; #else enum { HAVE_GNU_CALLOC = 0 }; #endif /* Allocate N bytes of memory dynamically, with error checking. */ void * xmalloc (size_t n) { void *p = malloc (n); if (!p && n != 0) xalloc_die (); return p; } /* Change the size of an allocated block of memory P to N bytes, with error checking. */ void * xrealloc (void *p, size_t n) { if (!n && p) { /* The GNU and C99 realloc behaviors disagree here. Act like GNU, even if the underlying realloc is C99. */ free (p); return NULL; } p = realloc (p, n); if (!p && n) xalloc_die (); return p; } /* If P is null, allocate a block of at least *PN bytes; otherwise, reallocate P so that it contains more than *PN bytes. *PN must be nonzero unless P is null. Set *PN to the new block's size, and return the pointer to the new block. *PN is never set to zero, and the returned pointer is never null. */ void * x2realloc (void *p, size_t *pn) { return x2nrealloc (p, pn, 1); } /* Allocate S bytes of zeroed memory dynamically, with error checking. There's no need for xnzalloc (N, S), since it would be equivalent to xcalloc (N, S). */ void * xzalloc (size_t s) { return memset (xmalloc (s), 0, s); } /* Allocate zeroed memory for N elements of S bytes, with error checking. S must be nonzero. */ void * xcalloc (size_t n, size_t s) { void *p; /* Test for overflow, since some calloc implementations don't have proper overflow checks. But omit overflow and size-zero tests if HAVE_GNU_CALLOC, since GNU calloc catches overflow and never returns NULL if successful. */ if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s)) || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0))) xalloc_die (); return p; } /* Clone an object P of size S, with error checking. There's no need for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any need for an arithmetic overflow check. */ void * xmemdup (void const *p, size_t s) { return memcpy (xmalloc (s), p, s); } /* Clone STRING. */ char * xstrdup (char const *string) { return xmemdup (string, strlen (string) + 1); } lftp-4.6.3a/lib/glob.c0000644000015000007670000013622312477560611011430 00000000000000/* Copyright (C) 1991-2015 Free Software Foundation, Inc. This file is part of 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 . */ #ifndef _LIBC /* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc optimizes away the pattern == NULL || pglob == NULL tests below. */ # define _GL_ARG_NONNULL(params) # include #endif #include #include #include #include #include /* Outcomment the following line for production quality code. */ /* #define NDEBUG 1 */ #include #include #include /* Needed on stupid SunOS for assert. */ #if !defined _LIBC || !defined GLOB_ONLY_P #include #if !defined POSIX && defined _POSIX_VERSION # define POSIX #endif #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WINDOWS32 #endif #ifndef WINDOWS32 # include #endif #include #ifndef __set_errno # define __set_errno(val) errno = (val) #endif #include /* In GNU systems, defines this macro for us. */ #ifndef _D_EXACT_NAMLEN # define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name) #endif /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available if the 'd_type' member for 'struct dirent' is available. HAVE_STRUCT_DIRENT_D_TYPE plays the same role in GNULIB. */ #if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE /* True if the directory entry D must be of type T. */ # define DIRENT_MUST_BE(d, t) ((d)->d_type == (t)) /* True if the directory entry D might be a symbolic link. */ # define DIRENT_MIGHT_BE_SYMLINK(d) \ ((d)->d_type == DT_UNKNOWN || (d)->d_type == DT_LNK) /* True if the directory entry D might be a directory. */ # define DIRENT_MIGHT_BE_DIR(d) \ ((d)->d_type == DT_DIR || DIRENT_MIGHT_BE_SYMLINK (d)) #else /* !HAVE_D_TYPE */ # define DIRENT_MUST_BE(d, t) false # define DIRENT_MIGHT_BE_SYMLINK(d) true # define DIRENT_MIGHT_BE_DIR(d) true #endif /* HAVE_D_TYPE */ /* If the system has the 'struct dirent64' type we use it internally. */ #if defined _LIBC && !defined COMPILE_GLOB64 # if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__ # define CONVERT_D_INO(d64, d32) # else # define CONVERT_D_INO(d64, d32) \ (d64)->d_ino = (d32)->d_ino; # endif # ifdef _DIRENT_HAVE_D_TYPE # define CONVERT_D_TYPE(d64, d32) \ (d64)->d_type = (d32)->d_type; # else # define CONVERT_D_TYPE(d64, d32) # endif # define CONVERT_DIRENT_DIRENT64(d64, d32) \ memcpy ((d64)->d_name, (d32)->d_name, _D_EXACT_NAMLEN (d32) + 1); \ CONVERT_D_INO (d64, d32) \ CONVERT_D_TYPE (d64, d32) #endif #if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__ /* Posix does not require that the d_ino field be present, and some systems do not provide it. */ # define REAL_DIR_ENTRY(dp) 1 #else # define REAL_DIR_ENTRY(dp) (dp->d_ino != 0) #endif /* POSIX */ #include #include /* NAME_MAX is usually defined in or . */ #include #ifndef NAME_MAX # define NAME_MAX (sizeof (((struct dirent *) 0)->d_name)) #endif #include #ifdef _LIBC # undef strdup # define strdup(str) __strdup (str) # define sysconf(id) __sysconf (id) # define closedir(dir) __closedir (dir) # define opendir(name) __opendir (name) # define readdir(str) __readdir64 (str) # define getpwnam_r(name, bufp, buf, len, res) \ __getpwnam_r (name, bufp, buf, len, res) # ifndef __stat64 # define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf) # endif # define struct_stat64 struct stat64 #else /* !_LIBC */ # define __stat64(fname, buf) stat (fname, buf) # define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag) # define struct_stat64 struct stat # define __alloca alloca # define __readdir readdir # define __glob_pattern_p glob_pattern_p #endif /* _LIBC */ #include #ifdef _SC_GETPW_R_SIZE_MAX # define GETPW_R_SIZE_MAX() sysconf (_SC_GETPW_R_SIZE_MAX) #else # define GETPW_R_SIZE_MAX() (-1) #endif #ifdef _SC_LOGIN_NAME_MAX # define GET_LOGIN_NAME_MAX() sysconf (_SC_LOGIN_NAME_MAX) #else # define GET_LOGIN_NAME_MAX() (-1) #endif static const char *next_brace_sub (const char *begin, int flags) __THROWNL; #endif /* !defined _LIBC || !defined GLOB_ONLY_P */ #ifndef attribute_hidden # define attribute_hidden #endif #ifndef __attribute_noinline__ # if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1) # define __attribute_noinline__ /* Ignore */ #else # define __attribute_noinline__ __attribute__ ((__noinline__)) # endif #endif #if ! defined __builtin_expect && __GNUC__ < 3 # define __builtin_expect(expr, expected) (expr) #endif #ifndef _LIBC /* The results of opendir() in this file are not used with dirfd and fchdir, and we do not leak fds to any single-threaded code that could use stdio, therefore save some unnecessary recursion in fchdir.c and opendir_safer.c. FIXME - if the kernel ever adds support for multi-thread safety for avoiding standard fds, then we should use opendir_safer. */ # ifdef GNULIB_defined_opendir # undef opendir # endif # ifdef GNULIB_defined_closedir # undef closedir # endif # if HAVE_ALLOCA /* The OS usually guarantees only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely allocate anything larger than 4096 bytes. Also care for the possibility of a few compiler-allocated temporary stack slots. */ # define __libc_use_alloca(n) ((n) < 4032) # else /* alloca is implemented with malloc, so just use malloc. */ # define __libc_use_alloca(n) 0 # endif #endif static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), glob_t *pglob); extern int __glob_pattern_type (const char *pattern, int quote) attribute_hidden; #if !defined _LIBC || !defined GLOB_ONLY_P static int prefix_array (const char *prefix, char **array, size_t n) __THROWNL; static int collated_compare (const void *, const void *) __THROWNL; /* Find the end of the sub-pattern in a brace expression. */ static const char * next_brace_sub (const char *cp, int flags) { unsigned int depth = 0; while (*cp != '\0') if ((flags & GLOB_NOESCAPE) == 0 && *cp == '\\') { if (*++cp == '\0') break; ++cp; } else { if ((*cp == '}' && depth-- == 0) || (*cp == ',' && depth == 0)) break; if (*cp++ == '{') depth++; } return *cp != '\0' ? cp : NULL; } #endif /* !defined _LIBC || !defined GLOB_ONLY_P */ /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. If a directory cannot be opened or read and ERRFUNC is not nil, it is called with the pathname that caused the error, and the 'errno' value from the failing call; if it returns non-zero 'glob' returns GLOB_ABORTED; if it returns zero, the error is ignored. If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned. Otherwise, 'glob' returns zero. */ int #ifdef GLOB_ATTRIBUTE GLOB_ATTRIBUTE #endif glob (pattern, flags, errfunc, pglob) const char * restrict pattern; int flags; int (*errfunc) (const char *, int); glob_t * restrict pglob; { const char *filename; const char *dirname; size_t dirlen; int status; size_t oldcount; int meta; int dirname_modified; glob_t dirs; if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0) { __set_errno (EINVAL); return -1; } if (!(flags & GLOB_DOOFFS)) /* Have to do this so 'globfree' knows where to start freeing. It also makes all the code that uses gl_offs simpler. */ pglob->gl_offs = 0; if (flags & GLOB_BRACE) { const char *begin; if (flags & GLOB_NOESCAPE) begin = strchr (pattern, '{'); else { begin = pattern; while (1) { if (*begin == '\0') { begin = NULL; break; } if (*begin == '\\' && begin[1] != '\0') ++begin; else if (*begin == '{') break; ++begin; } } if (begin != NULL) { /* Allocate working buffer large enough for our work. Note that we have at least an opening and closing brace. */ size_t firstc; char *alt_start; const char *p; const char *next; const char *rest; size_t rest_len; #ifdef __GNUC__ char onealt[strlen (pattern) - 1]; #else char *onealt = malloc (strlen (pattern) - 1); if (onealt == NULL) { if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; pglob->gl_pathv = NULL; } return GLOB_NOSPACE; } #endif /* We know the prefix for all sub-patterns. */ alt_start = mempcpy (onealt, pattern, begin - pattern); /* Find the first sub-pattern and at the same time find the rest after the closing brace. */ next = next_brace_sub (begin + 1, flags); if (next == NULL) { /* It is an invalid expression. */ #ifndef __GNUC__ free (onealt); #endif return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob); } /* Now find the end of the whole brace expression. */ rest = next; while (*rest != '}') { rest = next_brace_sub (rest + 1, flags); if (rest == NULL) { /* It is an invalid expression. */ #ifndef __GNUC__ free (onealt); #endif return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob); } } /* Please note that we now can be sure the brace expression is well-formed. */ rest_len = strlen (++rest) + 1; /* We have a brace expression. BEGIN points to the opening {, NEXT points past the terminator of the first element, and END points past the final }. We will accumulate result names from recursive runs for each brace alternative in the buffer using GLOB_APPEND. */ if (!(flags & GLOB_APPEND)) { /* This call is to set a new vector, so clear out the vector so we can append to it. */ pglob->gl_pathc = 0; pglob->gl_pathv = NULL; } firstc = pglob->gl_pathc; p = begin + 1; while (1) { int result; /* Construct the new glob expression. */ mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len); result = glob (onealt, ((flags & ~(GLOB_NOCHECK | GLOB_NOMAGIC)) | GLOB_APPEND), errfunc, pglob); /* If we got an error, return it. */ if (result && result != GLOB_NOMATCH) { #ifndef __GNUC__ free (onealt); #endif if (!(flags & GLOB_APPEND)) { globfree (pglob); pglob->gl_pathc = 0; } return result; } if (*next == '}') /* We saw the last entry. */ break; p = next + 1; next = next_brace_sub (p, flags); assert (next != NULL); } #ifndef __GNUC__ free (onealt); #endif if (pglob->gl_pathc != firstc) /* We found some entries. */ return 0; else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC))) return GLOB_NOMATCH; } } /* Find the filename. */ filename = strrchr (pattern, '/'); #if defined __MSDOS__ || defined WINDOWS32 /* The case of "d:pattern". Since ':' is not allowed in file names, we can safely assume that wherever it happens in pattern, it signals the filename part. This is so we could some day support patterns like "[a-z]:foo". */ if (filename == NULL) filename = strchr (pattern, ':'); #endif /* __MSDOS__ || WINDOWS32 */ dirname_modified = 0; if (filename == NULL) { /* This can mean two things: a simple name or "~name". The latter case is nothing but a notation for a directory. */ if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~') { dirname = pattern; dirlen = strlen (pattern); /* Set FILENAME to NULL as a special flag. This is ugly but other solutions would require much more code. We test for this special case below. */ filename = NULL; } else { filename = pattern; #ifdef _AMIGA dirname = ""; #else dirname = "."; #endif dirlen = 0; } } else if (filename == pattern || (filename == pattern + 1 && pattern[0] == '\\' && (flags & GLOB_NOESCAPE) == 0)) { /* "/pattern" or "\\/pattern". */ dirname = "/"; dirlen = 1; ++filename; } else { char *newp; dirlen = filename - pattern; #if defined __MSDOS__ || defined WINDOWS32 if (*filename == ':' || (filename > pattern + 1 && filename[-1] == ':')) { char *drive_spec; ++dirlen; drive_spec = __alloca (dirlen + 1); *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0'; /* For now, disallow wildcards in the drive spec, to prevent infinite recursion in glob. */ if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE))) return GLOB_NOMATCH; /* If this is "d:pattern", we need to copy ':' to DIRNAME as well. If it's "d:/pattern", don't remove the slash from "d:/", since "d:" and "d:/" are not the same.*/ } #endif newp = __alloca (dirlen + 1); *((char *) mempcpy (newp, pattern, dirlen)) = '\0'; dirname = newp; ++filename; if (filename[0] == '\0' #if defined __MSDOS__ || defined WINDOWS32 && dirname[dirlen - 1] != ':' && (dirlen < 3 || dirname[dirlen - 2] != ':' || dirname[dirlen - 1] != '/') #endif && dirlen > 1) /* "pattern/". Expand "pattern", appending slashes. */ { int orig_flags = flags; int val; if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\') { /* "pattern\\/". Remove the final backslash if it hasn't been quoted. */ char *p = (char *) &dirname[dirlen - 1]; while (p > dirname && p[-1] == '\\') --p; if ((&dirname[dirlen] - p) & 1) { *(char *) &dirname[--dirlen] = '\0'; flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC); } } val = glob (dirname, flags | GLOB_MARK, errfunc, pglob); if (val == 0) pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK)); else if (val == GLOB_NOMATCH && flags != orig_flags) { /* Make sure globfree (&dirs); is a nop. */ dirs.gl_pathv = NULL; flags = orig_flags; oldcount = pglob->gl_pathc + pglob->gl_offs; goto no_matches; } return val; } } if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; if (!(flags & GLOB_DOOFFS)) pglob->gl_pathv = NULL; else { size_t i; pglob->gl_pathv = malloc ((pglob->gl_offs + 1) * sizeof (char *)); if (pglob->gl_pathv == NULL) return GLOB_NOSPACE; for (i = 0; i <= pglob->gl_offs; ++i) pglob->gl_pathv[i] = NULL; } } oldcount = pglob->gl_pathc + pglob->gl_offs; if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') { if (dirname[1] == '\0' || dirname[1] == '/' || (!(flags & GLOB_NOESCAPE) && dirname[1] == '\\' && (dirname[2] == '\0' || dirname[2] == '/'))) { /* Look up home directory. */ const char *home_dir = getenv ("HOME"); # ifdef _AMIGA if (home_dir == NULL || home_dir[0] == '\0') home_dir = "SYS:"; # else # ifdef WINDOWS32 /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference to HOME, because the user can change HOME. */ if (home_dir == NULL || home_dir[0] == '\0') { const char *home_drive = getenv ("HOMEDRIVE"); const char *home_path = getenv ("HOMEPATH"); if (home_drive != NULL && home_path != NULL) { size_t home_drive_len = strlen (home_drive); size_t home_path_len = strlen (home_path); char *mem = alloca (home_drive_len + home_path_len + 1); memcpy (mem, home_drive, home_drive_len); memcpy (mem + home_drive_len, home_path, home_path_len + 1); home_dir = mem; } else home_dir = "c:/users/default"; /* poor default */ } # else if (home_dir == NULL || home_dir[0] == '\0') { int success; char *name; size_t buflen = GET_LOGIN_NAME_MAX () + 1; if (buflen == 0) /* 'sysconf' does not support _SC_LOGIN_NAME_MAX. Try a moderate value. */ buflen = 20; name = __alloca (buflen); success = getlogin_r (name, buflen) == 0; if (success) { struct passwd *p; # if defined HAVE_GETPWNAM_R || defined _LIBC long int pwbuflen = GETPW_R_SIZE_MAX (); char *pwtmpbuf; struct passwd pwbuf; int save = errno; # ifndef _LIBC if (pwbuflen == -1) /* 'sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a moderate value. */ pwbuflen = 1024; # endif pwtmpbuf = __alloca (pwbuflen); while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p) != 0) { if (errno != ERANGE) { p = NULL; break; } # ifdef _LIBC pwtmpbuf = extend_alloca (pwtmpbuf, pwbuflen, 2 * pwbuflen); # else pwbuflen *= 2; pwtmpbuf = __alloca (pwbuflen); # endif __set_errno (save); } # else p = getpwnam (name); # endif if (p != NULL) home_dir = p->pw_dir; } } if (home_dir == NULL || home_dir[0] == '\0') { if (flags & GLOB_TILDE_CHECK) return GLOB_NOMATCH; else home_dir = "~"; /* No luck. */ } # endif /* WINDOWS32 */ # endif /* Now construct the full directory. */ if (dirname[1] == '\0') { dirname = home_dir; dirlen = strlen (dirname); } else { char *newp; size_t home_len = strlen (home_dir); newp = __alloca (home_len + dirlen); mempcpy (mempcpy (newp, home_dir, home_len), &dirname[1], dirlen); dirname = newp; dirlen += home_len - 1; } dirname_modified = 1; } # if !defined _AMIGA && !defined WINDOWS32 else { char *end_name = strchr (dirname, '/'); const char *user_name; const char *home_dir; char *unescape = NULL; if (!(flags & GLOB_NOESCAPE)) { if (end_name == NULL) { unescape = strchr (dirname, '\\'); if (unescape) end_name = strchr (unescape, '\0'); } else unescape = memchr (dirname, '\\', end_name - dirname); } if (end_name == NULL) user_name = dirname + 1; else { char *newp; newp = __alloca (end_name - dirname); *((char *) mempcpy (newp, dirname + 1, end_name - dirname)) = '\0'; if (unescape != NULL) { char *p = mempcpy (newp, dirname + 1, unescape - dirname - 1); char *q = unescape; while (*q != '\0') { if (*q == '\\') { if (q[1] == '\0') { /* "~fo\\o\\" unescape to user_name "foo\\", but "~fo\\o\\/" unescape to user_name "foo". */ if (filename == NULL) *p++ = '\\'; break; } ++q; } *p++ = *q++; } *p = '\0'; } else *((char *) mempcpy (newp, dirname + 1, end_name - dirname)) = '\0'; user_name = newp; } /* Look up specific user's home directory. */ { struct passwd *p; # if defined HAVE_GETPWNAM_R || defined _LIBC long int buflen = GETPW_R_SIZE_MAX (); char *pwtmpbuf; struct passwd pwbuf; int save = errno; # ifndef _LIBC if (buflen == -1) /* 'sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a moderate value. */ buflen = 1024; # endif pwtmpbuf = __alloca (buflen); while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0) { if (errno != ERANGE) { p = NULL; break; } # ifdef _LIBC pwtmpbuf = extend_alloca (pwtmpbuf, buflen, 2 * buflen); # else buflen *= 2; pwtmpbuf = __alloca (buflen); # endif __set_errno (save); } # else p = getpwnam (user_name); # endif if (p != NULL) home_dir = p->pw_dir; else home_dir = NULL; } /* If we found a home directory use this. */ if (home_dir != NULL) { char *newp; size_t home_len = strlen (home_dir); size_t rest_len = end_name == NULL ? 0 : strlen (end_name); newp = __alloca (home_len + rest_len + 1); *((char *) mempcpy (mempcpy (newp, home_dir, home_len), end_name, rest_len)) = '\0'; dirname = newp; dirlen = home_len + rest_len; dirname_modified = 1; } else if (flags & GLOB_TILDE_CHECK) /* We have to regard it as an error if we cannot find the home directory. */ return GLOB_NOMATCH; } # endif /* Not Amiga && not WINDOWS32. */ } /* Now test whether we looked for "~" or "~NAME". In this case we can give the answer now. */ if (filename == NULL) { struct stat st; struct_stat64 st64; /* Return the directory if we don't check for error or if it exists. */ if ((flags & GLOB_NOCHECK) || (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)) ? ((*pglob->gl_stat) (dirname, &st) == 0 && S_ISDIR (st.st_mode)) : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode))))) { int newcount = pglob->gl_pathc + pglob->gl_offs; char **new_gl_pathv; new_gl_pathv = realloc (pglob->gl_pathv, (newcount + 1 + 1) * sizeof (char *)); if (new_gl_pathv == NULL) { nospace: free (pglob->gl_pathv); pglob->gl_pathv = NULL; pglob->gl_pathc = 0; return GLOB_NOSPACE; } pglob->gl_pathv = new_gl_pathv; if (flags & GLOB_MARK) { char *p; pglob->gl_pathv[newcount] = malloc (dirlen + 2); if (pglob->gl_pathv[newcount] == NULL) goto nospace; p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen); p[0] = '/'; p[1] = '\0'; } else { pglob->gl_pathv[newcount] = strdup (dirname); if (pglob->gl_pathv[newcount] == NULL) goto nospace; } pglob->gl_pathv[++newcount] = NULL; ++pglob->gl_pathc; pglob->gl_flags = flags; return 0; } /* Not found. */ return GLOB_NOMATCH; } meta = __glob_pattern_type (dirname, !(flags & GLOB_NOESCAPE)); /* meta is 1 if correct glob pattern containing metacharacters. If meta has bit (1 << 2) set, it means there was an unterminated [ which we handle the same, using fnmatch. Broken unterminated pattern bracket expressions ought to be rare enough that it is not worth special casing them, fnmatch will do the right thing. */ if (meta & 5) { /* The directory name contains metacharacters, so we have to glob for the directory, and then glob for the pattern in each directory found. */ size_t i; if (!(flags & GLOB_NOESCAPE) && dirlen > 0 && dirname[dirlen - 1] == '\\') { /* "foo\\/bar". Remove the final backslash from dirname if it has not been quoted. */ char *p = (char *) &dirname[dirlen - 1]; while (p > dirname && p[-1] == '\\') --p; if ((&dirname[dirlen] - p) & 1) *(char *) &dirname[--dirlen] = '\0'; } if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) != 0, 0)) { /* Use the alternative access functions also in the recursive call. */ dirs.gl_opendir = pglob->gl_opendir; dirs.gl_readdir = pglob->gl_readdir; dirs.gl_closedir = pglob->gl_closedir; dirs.gl_stat = pglob->gl_stat; dirs.gl_lstat = pglob->gl_lstat; } status = glob (dirname, ((flags & (GLOB_ERR | GLOB_NOESCAPE | GLOB_ALTDIRFUNC)) | GLOB_NOSORT | GLOB_ONLYDIR), errfunc, &dirs); if (status != 0) { if ((flags & GLOB_NOCHECK) == 0 || status != GLOB_NOMATCH) return status; goto no_matches; } /* We have successfully globbed the preceding directory name. For each name we found, call glob_in_dir on it and FILENAME, appending the results to PGLOB. */ for (i = 0; i < dirs.gl_pathc; ++i) { int old_pathc; #ifdef SHELL { /* Make globbing interruptible in the bash shell. */ extern int interrupt_state; if (interrupt_state) { globfree (&dirs); return GLOB_ABORTED; } } #endif /* SHELL. */ old_pathc = pglob->gl_pathc; status = glob_in_dir (filename, dirs.gl_pathv[i], ((flags | GLOB_APPEND) & ~(GLOB_NOCHECK | GLOB_NOMAGIC)), errfunc, pglob); if (status == GLOB_NOMATCH) /* No matches in this directory. Try the next. */ continue; if (status != 0) { globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; return status; } /* Stick the directory on the front of each name. */ if (prefix_array (dirs.gl_pathv[i], &pglob->gl_pathv[old_pathc + pglob->gl_offs], pglob->gl_pathc - old_pathc)) { globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; return GLOB_NOSPACE; } } flags |= GLOB_MAGCHAR; /* We have ignored the GLOB_NOCHECK flag in the 'glob_in_dir' calls. But if we have not found any matching entry and the GLOB_NOCHECK flag was set we must return the input pattern itself. */ if (pglob->gl_pathc + pglob->gl_offs == oldcount) { no_matches: /* No matches. */ if (flags & GLOB_NOCHECK) { int newcount = pglob->gl_pathc + pglob->gl_offs; char **new_gl_pathv; new_gl_pathv = realloc (pglob->gl_pathv, (newcount + 2) * sizeof (char *)); if (new_gl_pathv == NULL) { globfree (&dirs); return GLOB_NOSPACE; } pglob->gl_pathv = new_gl_pathv; pglob->gl_pathv[newcount] = strdup (pattern); if (pglob->gl_pathv[newcount] == NULL) { globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; return GLOB_NOSPACE; } ++pglob->gl_pathc; ++newcount; pglob->gl_pathv[newcount] = NULL; pglob->gl_flags = flags; } else { globfree (&dirs); return GLOB_NOMATCH; } } globfree (&dirs); } else { int old_pathc = pglob->gl_pathc; int orig_flags = flags; if (meta & 2) { char *p = strchr (dirname, '\\'), *q; /* We need to unescape the dirname string. It is certainly allocated by alloca, as otherwise filename would be NULL or dirname wouldn't contain backslashes. */ q = p; do { if (*p == '\\') { *q = *++p; --dirlen; } else *q = *p; ++q; } while (*p++ != '\0'); dirname_modified = 1; } if (dirname_modified) flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC); status = glob_in_dir (filename, dirname, flags, errfunc, pglob); if (status != 0) { if (status == GLOB_NOMATCH && flags != orig_flags && pglob->gl_pathc + pglob->gl_offs == oldcount) { /* Make sure globfree (&dirs); is a nop. */ dirs.gl_pathv = NULL; flags = orig_flags; goto no_matches; } return status; } if (dirlen > 0) { /* Stick the directory on the front of each name. */ if (prefix_array (dirname, &pglob->gl_pathv[old_pathc + pglob->gl_offs], pglob->gl_pathc - old_pathc)) { globfree (pglob); pglob->gl_pathc = 0; return GLOB_NOSPACE; } } } if (flags & GLOB_MARK) { /* Append slashes to directory names. */ size_t i; struct stat st; struct_stat64 st64; for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i) if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) ? ((*pglob->gl_stat) (pglob->gl_pathv[i], &st) == 0 && S_ISDIR (st.st_mode)) : (__stat64 (pglob->gl_pathv[i], &st64) == 0 && S_ISDIR (st64.st_mode)))) { size_t len = strlen (pglob->gl_pathv[i]) + 2; char *new = realloc (pglob->gl_pathv[i], len); if (new == NULL) { globfree (pglob); pglob->gl_pathc = 0; return GLOB_NOSPACE; } strcpy (&new[len - 2], "/"); pglob->gl_pathv[i] = new; } } if (!(flags & GLOB_NOSORT)) { /* Sort the vector. */ qsort (&pglob->gl_pathv[oldcount], pglob->gl_pathc + pglob->gl_offs - oldcount, sizeof (char *), collated_compare); } return 0; } #if defined _LIBC && !defined glob libc_hidden_def (glob) #endif #if !defined _LIBC || !defined GLOB_ONLY_P /* Free storage allocated in PGLOB by a previous 'glob' call. */ void globfree (pglob) register glob_t *pglob; { if (pglob->gl_pathv != NULL) { size_t i; for (i = 0; i < pglob->gl_pathc; ++i) if (pglob->gl_pathv[pglob->gl_offs + i] != NULL) free (pglob->gl_pathv[pglob->gl_offs + i]); free (pglob->gl_pathv); pglob->gl_pathv = NULL; } } #if defined _LIBC && !defined globfree libc_hidden_def (globfree) #endif /* Do a collated comparison of A and B. */ static int collated_compare (const void *a, const void *b) { char *const *ps1 = a; char *s1 = *ps1; char *const *ps2 = b; char *s2 = *ps2; if (s1 == s2) return 0; if (s1 == NULL) return 1; if (s2 == NULL) return -1; return strcoll (s1, s2); } /* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's elements in place. Return nonzero if out of memory, zero if successful. A slash is inserted between DIRNAME and each elt of ARRAY, unless DIRNAME is just "/". Each old element of ARRAY is freed. */ static int prefix_array (const char *dirname, char **array, size_t n) { register size_t i; size_t dirlen = strlen (dirname); #if defined __MSDOS__ || defined WINDOWS32 int sep_char = '/'; # define DIRSEP_CHAR sep_char #else # define DIRSEP_CHAR '/' #endif if (dirlen == 1 && dirname[0] == '/') /* DIRNAME is just "/", so normal prepending would get us "//foo". We want "/foo" instead, so don't prepend any chars from DIRNAME. */ dirlen = 0; #if defined __MSDOS__ || defined WINDOWS32 else if (dirlen > 1) { if (dirname[dirlen - 1] == '/' && dirname[dirlen - 2] == ':') /* DIRNAME is "d:/". Don't prepend the slash from DIRNAME. */ --dirlen; else if (dirname[dirlen - 1] == ':') { /* DIRNAME is "d:". Use ':' instead of '/'. */ --dirlen; sep_char = ':'; } } #endif for (i = 0; i < n; ++i) { size_t eltlen = strlen (array[i]) + 1; char *new = malloc (dirlen + 1 + eltlen); if (new == NULL) { while (i > 0) free (array[--i]); return 1; } { char *endp = mempcpy (new, dirname, dirlen); *endp++ = DIRSEP_CHAR; mempcpy (endp, array[i], eltlen); } free (array[i]); array[i] = new; } return 0; } /* We must not compile this function twice. */ #if !defined _LIBC || !defined NO_GLOB_PATTERN_P int __glob_pattern_type (pattern, quote) const char *pattern; int quote; { register const char *p; int ret = 0; for (p = pattern; *p != '\0'; ++p) switch (*p) { case '?': case '*': return 1; case '\\': if (quote) { if (p[1] != '\0') ++p; ret |= 2; } break; case '[': ret |= 4; break; case ']': if (ret & 4) return 1; break; } return ret; } /* Return nonzero if PATTERN contains any metacharacters. Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ int __glob_pattern_p (pattern, quote) const char *pattern; int quote; { return __glob_pattern_type (pattern, quote) == 1; } # ifdef _LIBC weak_alias (__glob_pattern_p, glob_pattern_p) # endif #endif #endif /* !GLOB_ONLY_P */ #if !defined _LIBC || !defined GLOB_ONLY_P /* We put this in a separate function mainly to allow the memory allocated with alloca to be recycled. */ static int __attribute_noinline__ link_exists2_p (const char *dir, size_t dirlen, const char *fname, glob_t *pglob # if !defined _LIBC && !HAVE_FSTATAT , int flags # endif ) { size_t fnamelen = strlen (fname); char *fullname = __alloca (dirlen + 1 + fnamelen + 1); struct stat st; mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1), fname, fnamelen + 1); # if !defined _LIBC && !HAVE_FSTATAT if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) == 0, 1)) { struct_stat64 st64; return __stat64 (fullname, &st64) == 0; } # endif return (*pglob->gl_stat) (fullname, &st) == 0; } /* Return true if DIR/FNAME exists. */ static int link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname, glob_t *pglob, int flags) { # if defined _LIBC || HAVE_FSTATAT if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)) return link_exists2_p (dir, dirlen, fname, pglob); else { /* dfd cannot be -1 here, because dirfd never returns -1 on glibc, or on hosts that have fstatat. */ struct_stat64 st64; return __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0; } # else return link_exists2_p (dir, dirlen, fname, pglob, flags); # endif } #endif /* Like 'glob', but PATTERN is a final pathname component, and matches are searched for in DIRECTORY. The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done. The GLOB_APPEND flag is assumed to be set (always appends). */ static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), glob_t *pglob) { size_t dirlen = strlen (directory); void *stream = NULL; struct globnames { struct globnames *next; size_t count; char *name[64]; }; #define INITIAL_COUNT sizeof (init_names.name) / sizeof (init_names.name[0]) struct globnames init_names; struct globnames *names = &init_names; struct globnames *names_alloca = &init_names; size_t nfound = 0; size_t allocasize = sizeof (init_names); size_t cur = 0; int meta; int save; int result; init_names.next = NULL; init_names.count = INITIAL_COUNT; meta = __glob_pattern_type (pattern, !(flags & GLOB_NOESCAPE)); if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC))) { /* We need not do any tests. The PATTERN contains no meta characters and we must not return an error therefore the result will always contain exactly one name. */ flags |= GLOB_NOCHECK; } else if (meta == 0) { /* Since we use the normal file functions we can also use stat() to verify the file is there. */ struct stat st; struct_stat64 st64; size_t patlen = strlen (pattern); char *fullname = __alloca (dirlen + 1 + patlen + 1); mempcpy (mempcpy (mempcpy (fullname, directory, dirlen), "/", 1), pattern, patlen + 1); if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) ? (*pglob->gl_stat) (fullname, &st) : __stat64 (fullname, &st64)) == 0) /* We found this file to be existing. Now tell the rest of the function to copy this name into the result. */ flags |= GLOB_NOCHECK; } else { stream = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) ? (*pglob->gl_opendir) (directory) : opendir (directory)); if (stream == NULL) { if (errno != ENOTDIR && ((errfunc != NULL && (*errfunc) (directory, errno)) || (flags & GLOB_ERR))) return GLOB_ABORTED; } else { int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) ? -1 : dirfd ((DIR *) stream)); int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) #if defined _AMIGA || defined VMS | FNM_CASEFOLD #endif ); flags |= GLOB_MAGCHAR; while (1) { const char *name; size_t len; #if defined _LIBC && !defined COMPILE_GLOB64 struct dirent64 *d; union { struct dirent64 d64; char room [offsetof (struct dirent64, d_name[0]) + NAME_MAX + 1]; } d64buf; if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)) { struct dirent *d32 = (*pglob->gl_readdir) (stream); if (d32 != NULL) { CONVERT_DIRENT_DIRENT64 (&d64buf.d64, d32); d = &d64buf.d64; } else d = NULL; } else d = __readdir64 (stream); #else struct dirent *d = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) ? ((struct dirent *) (*pglob->gl_readdir) (stream)) : __readdir (stream)); #endif if (d == NULL) break; if (! REAL_DIR_ENTRY (d)) continue; /* If we shall match only directories use the information provided by the dirent call if possible. */ if ((flags & GLOB_ONLYDIR) && !DIRENT_MIGHT_BE_DIR (d)) continue; name = d->d_name; if (fnmatch (pattern, name, fnm_flags) == 0) { /* If the file we found is a symlink we have to make sure the target file exists. */ if (!DIRENT_MIGHT_BE_SYMLINK (d) || link_exists_p (dfd, directory, dirlen, name, pglob, flags)) { if (cur == names->count) { struct globnames *newnames; size_t count = names->count * 2; size_t size = (sizeof (struct globnames) + ((count - INITIAL_COUNT) * sizeof (char *))); allocasize += size; if (__libc_use_alloca (allocasize)) newnames = names_alloca = __alloca (size); else if ((newnames = malloc (size)) == NULL) goto memory_error; newnames->count = count; newnames->next = names; names = newnames; cur = 0; } len = _D_EXACT_NAMLEN (d); names->name[cur] = malloc (len + 1); if (names->name[cur] == NULL) goto memory_error; *((char *) mempcpy (names->name[cur++], name, len)) = '\0'; ++nfound; } } } } } if (nfound == 0 && (flags & GLOB_NOCHECK)) { size_t len = strlen (pattern); nfound = 1; names->name[cur] = malloc (len + 1); if (names->name[cur] == NULL) goto memory_error; *((char *) mempcpy (names->name[cur++], pattern, len)) = '\0'; } result = GLOB_NOMATCH; if (nfound != 0) { char **new_gl_pathv = realloc (pglob->gl_pathv, (pglob->gl_pathc + pglob->gl_offs + nfound + 1) * sizeof (char *)); result = 0; if (new_gl_pathv == NULL) { memory_error: while (1) { struct globnames *old = names; size_t i; for (i = 0; i < cur; ++i) free (names->name[i]); names = names->next; /* NB: we will not leak memory here if we exit without freeing the current block assigned to OLD. At least the very first block is always allocated on the stack and this is the block assigned to OLD here. */ if (names == NULL) { assert (old == &init_names); break; } cur = names->count; if (old == names_alloca) names_alloca = names; else free (old); } result = GLOB_NOSPACE; } else { while (1) { struct globnames *old = names; size_t i; for (i = 0; i < cur; ++i) new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++] = names->name[i]; names = names->next; /* NB: we will not leak memory here if we exit without freeing the current block assigned to OLD. At least the very first block is always allocated on the stack and this is the block assigned to OLD here. */ if (names == NULL) { assert (old == &init_names); break; } cur = names->count; if (old == names_alloca) names_alloca = names; else free (old); } pglob->gl_pathv = new_gl_pathv; pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; pglob->gl_flags = flags; } } if (stream != NULL) { save = errno; if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)) (*pglob->gl_closedir) (stream); else closedir (stream); __set_errno (save); } return result; } lftp-4.6.3a/lib/memchr.c0000644000015000007670000001334612466374011011753 00000000000000/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2015 Free Software Foundation, Inc. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and commentary by Jim Blandy (jimb@ai.mit.edu); adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), and implemented by Roland McGrath (roland@ai.mit.edu). NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. 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 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 . */ #ifndef _LIBC # include #endif #include #include #if defined _LIBC # include #else # define reg_char char #endif #include #if HAVE_BP_SYM_H || defined _LIBC # include #else # define BP_SYM(sym) sym #endif #undef __memchr #ifdef _LIBC # undef memchr #endif #ifndef weak_alias # define __memchr memchr #endif /* Search no more than N bytes of S for C. */ void * __memchr (void const *s, int c_in, size_t n) { /* On 32-bit hardware, choosing longword to be a 32-bit unsigned long instead of a 64-bit uintmax_t tends to give better performance. On 64-bit hardware, unsigned long is generally 64 bits already. Change this typedef to experiment with performance. */ typedef unsigned long int longword; const unsigned char *char_ptr; const longword *longword_ptr; longword repeated_one; longword repeated_c; unsigned reg_char c; c = (unsigned char) c_in; /* Handle the first few bytes by reading one byte at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = (const unsigned char *) s; n > 0 && (size_t) char_ptr % sizeof (longword) != 0; --n, ++char_ptr) if (*char_ptr == c) return (void *) char_ptr; longword_ptr = (const longword *) char_ptr; /* All these elucidatory comments refer to 4-byte longwords, but the theory applies equally well to any size longwords. */ /* Compute auxiliary longword values: repeated_one is a value which has a 1 in every byte. repeated_c has c in every byte. */ repeated_one = 0x01010101; repeated_c = c | (c << 8); repeated_c |= repeated_c << 16; if (0xffffffffU < (longword) -1) { repeated_one |= repeated_one << 31 << 1; repeated_c |= repeated_c << 31 << 1; if (8 < sizeof (longword)) { size_t i; for (i = 64; i < sizeof (longword) * 8; i *= 2) { repeated_one |= repeated_one << i; repeated_c |= repeated_c << i; } } } /* Instead of the traditional loop which tests each byte, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are equal to c. We first use an xor with repeated_c. This reduces the task to testing whether *any of the four* bytes in longword1 is zero. We compute tmp = ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). That is, we perform the following operations: 1. Subtract repeated_one. 2. & ~longword1. 3. & a mask consisting of 0x80 in every byte. Consider what happens in each byte: - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, and step 3 transforms it into 0x80. A carry can also be propagated to more significant bytes. - If a byte of longword1 is nonzero, let its lowest 1 bit be at position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, the byte ends in a single bit of value 0 and k bits of value 1. After step 2, the result is just k bits of value 1: 2^k - 1. After step 3, the result is 0. And no carry is produced. So, if longword1 has only non-zero bytes, tmp is zero. Whereas if longword1 has a zero byte, call j the position of the least significant zero byte. Then the result has a zero at positions 0, ..., j-1 and a 0x80 at position j. We cannot predict the result at the more significant bytes (positions j+1..3), but it does not matter since we already have a non-zero bit at position 8*j+7. So, the test whether any byte in longword1 is zero is equivalent to testing whether tmp is nonzero. */ while (n >= sizeof (longword)) { longword longword1 = *longword_ptr ^ repeated_c; if ((((longword1 - repeated_one) & ~longword1) & (repeated_one << 7)) != 0) break; longword_ptr++; n -= sizeof (longword); } char_ptr = (const unsigned char *) longword_ptr; /* At this point, we know that either n < sizeof (longword), or one of the sizeof (longword) bytes starting at char_ptr is == c. On little-endian machines, we could determine the first such byte without any further memory accesses, just by looking at the tmp result from the last loop iteration. But this does not work on big-endian machines. Choose code that works in both cases. */ for (; n > 0; --n, ++char_ptr) { if (*char_ptr == c) return (void *) char_ptr; } return NULL; } #ifdef weak_alias weak_alias (__memchr, BP_SYM (memchr)) #endif lftp-4.6.3a/lib/mktime-internal.h0000644000015000007670000000024112122621312013557 00000000000000#include time_t mktime_internal (struct tm *, struct tm * (*) (time_t const *, struct tm *), time_t *); lftp-4.6.3a/lib/vasnprintf.c0000644000015000007670000066407612477560613012715 00000000000000/* vsprintf with automatic memory allocation. Copyright (C) 1999, 2002-2015 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 . */ /* This file can be parametrized with the following macros: VASNPRINTF The name of the function being defined. FCHAR_T The element type of the format string. DCHAR_T The element type of the destination (result) string. FCHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters in the format string are ASCII. MUST be set if FCHAR_T and DCHAR_T are not the same type. DIRECTIVE Structure denoting a format directive. Depends on FCHAR_T. DIRECTIVES Structure denoting the set of format directives of a format string. Depends on FCHAR_T. PRINTF_PARSE Function that parses a format string. Depends on FCHAR_T. DCHAR_CPY memcpy like function for DCHAR_T[] arrays. DCHAR_SET memset like function for DCHAR_T[] arrays. DCHAR_MBSNLEN mbsnlen like function for DCHAR_T[] arrays. SNPRINTF The system's snprintf (or similar) function. This may be either snprintf or swprintf. TCHAR_T The element type of the argument and result string of the said SNPRINTF function. This may be either char or wchar_t. The code exploits that sizeof (TCHAR_T) | sizeof (DCHAR_T) and alignof (TCHAR_T) <= alignof (DCHAR_T). DCHAR_IS_TCHAR Set to 1 if DCHAR_T and TCHAR_T are the same type. DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[]. DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t. DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t. DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. */ /* Tell glibc's to provide a prototype for snprintf(). This must come before because may include , and once has been included, it's too late. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif #ifndef VASNPRINTF # include #endif #ifndef IN_LIBINTL # include #endif /* Specification. */ #ifndef VASNPRINTF # if WIDE_CHAR_VERSION # include "vasnwprintf.h" # else # include "vasnprintf.h" # endif #endif #include /* localeconv() */ #include /* snprintf(), sprintf() */ #include /* abort(), malloc(), realloc(), free() */ #include /* memcpy(), strlen() */ #include /* errno */ #include /* CHAR_BIT */ #include /* DBL_MAX_EXP, LDBL_MAX_EXP */ #if HAVE_NL_LANGINFO # include #endif #ifndef VASNPRINTF # if WIDE_CHAR_VERSION # include "wprintf-parse.h" # else # include "printf-parse.h" # endif #endif /* Checked size_t computations. */ #include "xsize.h" #include "verify.h" #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL # include # include "float+.h" #endif #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL # include # include "isnand-nolibm.h" #endif #if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL # include # include "isnanl-nolibm.h" # include "fpucw.h" #endif #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL # include # include "isnand-nolibm.h" # include "printf-frexp.h" #endif #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL # include # include "isnanl-nolibm.h" # include "printf-frexpl.h" # include "fpucw.h" #endif /* Default parameters. */ #ifndef VASNPRINTF # if WIDE_CHAR_VERSION # define VASNPRINTF vasnwprintf # define FCHAR_T wchar_t # define DCHAR_T wchar_t # define TCHAR_T wchar_t # define DCHAR_IS_TCHAR 1 # define DIRECTIVE wchar_t_directive # define DIRECTIVES wchar_t_directives # define PRINTF_PARSE wprintf_parse # define DCHAR_CPY wmemcpy # define DCHAR_SET wmemset # else # define VASNPRINTF vasnprintf # define FCHAR_T char # define DCHAR_T char # define TCHAR_T char # define DCHAR_IS_TCHAR 1 # define DIRECTIVE char_directive # define DIRECTIVES char_directives # define PRINTF_PARSE printf_parse # define DCHAR_CPY memcpy # define DCHAR_SET memset # endif #endif #if WIDE_CHAR_VERSION /* TCHAR_T is wchar_t. */ # define USE_SNPRINTF 1 # if HAVE_DECL__SNWPRINTF /* On Windows, the function swprintf() has a different signature than on Unix; we use the function _snwprintf() or - on mingw - snwprintf() instead. The mingw function snwprintf() has fewer bugs than the MSVCRT function _snwprintf(), so prefer that. */ # if defined __MINGW32__ # define SNPRINTF snwprintf # else # define SNPRINTF _snwprintf # endif # else /* Unix. */ # define SNPRINTF swprintf # endif #else /* TCHAR_T is char. */ /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. But don't use it on BeOS, since BeOS snprintf produces no output if the size argument is >= 0x3000000. Also don't use it on Linux libc5, since there snprintf with size = 1 writes any output without bounds, like sprintf. */ # if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ && !(__GNU_LIBRARY__ == 1) # define USE_SNPRINTF 1 # else # define USE_SNPRINTF 0 # endif # if HAVE_DECL__SNPRINTF /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT function _snprintf(), so prefer that. */ # if defined __MINGW32__ # define SNPRINTF snprintf /* Here we need to call the native snprintf, not rpl_snprintf. */ # undef snprintf # else # define SNPRINTF _snprintf # endif # else /* Unix. */ # define SNPRINTF snprintf /* Here we need to call the native snprintf, not rpl_snprintf. */ # undef snprintf # endif #endif /* Here we need to call the native sprintf, not rpl_sprintf. */ #undef sprintf /* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized" warnings in this file. Use -Dlint to suppress them. */ #ifdef lint # define IF_LINT(Code) Code #else # define IF_LINT(Code) /* empty */ #endif /* Avoid some warnings from "gcc -Wshadow". This file doesn't use the exp() and remainder() functions. */ #undef exp #define exp expo #undef remainder #define remainder rem #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION # if (HAVE_STRNLEN && !defined _AIX) # define local_strnlen strnlen # else # ifndef local_strnlen_defined # define local_strnlen_defined 1 static size_t local_strnlen (const char *string, size_t maxlen) { const char *end = memchr (string, '\0', maxlen); return end ? (size_t) (end - string) : maxlen; } # endif # endif #endif #if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T # if HAVE_WCSLEN # define local_wcslen wcslen # else /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid a dependency towards this library, here is a local substitute. Define this substitute only once, even if this file is included twice in the same compilation unit. */ # ifndef local_wcslen_defined # define local_wcslen_defined 1 static size_t local_wcslen (const wchar_t *s) { const wchar_t *ptr; for (ptr = s; *ptr != (wchar_t) 0; ptr++) ; return ptr - s; } # endif # endif #endif #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION # if HAVE_WCSNLEN # define local_wcsnlen wcsnlen # else # ifndef local_wcsnlen_defined # define local_wcsnlen_defined 1 static size_t local_wcsnlen (const wchar_t *s, size_t maxlen) { const wchar_t *ptr; for (ptr = s; maxlen > 0 && *ptr != (wchar_t) 0; ptr++, maxlen--) ; return ptr - s; } # endif # endif #endif #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL /* Determine the decimal-point character according to the current locale. */ # ifndef decimal_point_char_defined # define decimal_point_char_defined 1 static char decimal_point_char (void) { const char *point; /* Determine it in a multithread-safe way. We know nl_langinfo is multithread-safe on glibc systems and Mac OS X systems, but is not required to be multithread-safe by POSIX. sprintf(), however, is multithread-safe. localeconv() is rarely multithread-safe. */ # if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__)) point = nl_langinfo (RADIXCHAR); # elif 1 char pointbuf[5]; sprintf (pointbuf, "%#.0f", 1.0); point = &pointbuf[1]; # else point = localeconv () -> decimal_point; # endif /* The decimal point is always a single byte: either '.' or ','. */ return (point[0] != '\0' ? point[0] : '.'); } # endif #endif #if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE && !defined IN_LIBINTL /* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ static int is_infinite_or_zero (double x) { return isnand (x) || x + x == x; } #endif #if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL /* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ static int is_infinite_or_zerol (long double x) { return isnanl (x) || x + x == x; } #endif #if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL /* Converting 'long double' to decimal without rare rounding bugs requires real bignums. We use the naming conventions of GNU gmp, but vastly simpler (and slower) algorithms. */ typedef unsigned int mp_limb_t; # define GMP_LIMB_BITS 32 verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS); typedef unsigned long long mp_twolimb_t; # define GMP_TWOLIMB_BITS 64 verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS); /* Representation of a bignum >= 0. */ typedef struct { size_t nlimbs; mp_limb_t *limbs; /* Bits in little-endian order, allocated with malloc(). */ } mpn_t; /* Compute the product of two bignums >= 0. Return the allocated memory in case of success, NULL in case of memory allocation failure. */ static void * multiply (mpn_t src1, mpn_t src2, mpn_t *dest) { const mp_limb_t *p1; const mp_limb_t *p2; size_t len1; size_t len2; if (src1.nlimbs <= src2.nlimbs) { len1 = src1.nlimbs; p1 = src1.limbs; len2 = src2.nlimbs; p2 = src2.limbs; } else { len1 = src2.nlimbs; p1 = src2.limbs; len2 = src1.nlimbs; p2 = src1.limbs; } /* Now 0 <= len1 <= len2. */ if (len1 == 0) { /* src1 or src2 is zero. */ dest->nlimbs = 0; dest->limbs = (mp_limb_t *) malloc (1); } else { /* Here 1 <= len1 <= len2. */ size_t dlen; mp_limb_t *dp; size_t k, i, j; dlen = len1 + len2; dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t)); if (dp == NULL) return NULL; for (k = len2; k > 0; ) dp[--k] = 0; for (i = 0; i < len1; i++) { mp_limb_t digit1 = p1[i]; mp_twolimb_t carry = 0; for (j = 0; j < len2; j++) { mp_limb_t digit2 = p2[j]; carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; carry += dp[i + j]; dp[i + j] = (mp_limb_t) carry; carry = carry >> GMP_LIMB_BITS; } dp[i + len2] = (mp_limb_t) carry; } /* Normalise. */ while (dlen > 0 && dp[dlen - 1] == 0) dlen--; dest->nlimbs = dlen; dest->limbs = dp; } return dest->limbs; } /* Compute the quotient of a bignum a >= 0 and a bignum b > 0. a is written as a = q * b + r with 0 <= r < b. q is the quotient, r the remainder. Finally, round-to-even is performed: If r > b/2 or if r = b/2 and q is odd, q is incremented. Return the allocated memory in case of success, NULL in case of memory allocation failure. */ static void * divide (mpn_t a, mpn_t b, mpn_t *q) { /* Algorithm: First normalise a and b: a=[a[m-1],...,a[0]], b=[b[n-1],...,b[0]] with m>=0 and n>0 (in base beta = 2^GMP_LIMB_BITS). If m=n=1, perform a single-precision division: r:=0, j:=m, while j>0 do {Here (q[m-1]*beta^(m-1)+...+q[j]*beta^j) * b[0] + r*beta^j = = a[m-1]*beta^(m-1)+...+a[j]*beta^j und 0<=r=n>1, perform a multiple-precision division: We have a/b < beta^(m-n+1). s:=intDsize-1-(highest bit in b[n-1]), 0<=s=beta/2. For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).} Compute q* : q* := floor((r[j+n]*beta+r[j+n-1])/b[n-1]). In case of overflow (q* >= beta) set q* := beta-1. Compute c2 := ((r[j+n]*beta+r[j+n-1]) - q* * b[n-1])*beta + r[j+n-2] and c3 := b[n-2] * q*. {We have 0 <= c2 < 2*beta^2, even 0 <= c2 < beta^2 if no overflow occurred. Furthermore 0 <= c3 < beta^2. If there was overflow and r[j+n]*beta+r[j+n-1] - q* * b[n-1] >= beta, i.e. c2 >= beta^2, the next test can be skipped.} While c3 > c2, {Here 0 <= c2 < c3 < beta^2} Put q* := q* - 1, c2 := c2 + b[n-1]*beta, c3 := c3 - b[n-2]. If q* > 0: Put r := r - b * q* * beta^j. In detail: [r[n+j],...,r[j]] := [r[n+j],...,r[j]] - q* * [b[n-1],...,b[0]]. hence: u:=0, for i:=0 to n-1 do u := u + q* * b[i], r[j+i]:=r[j+i]-(u mod beta) (+ beta, if carry), u:=u div beta (+ 1, if carry in subtraction) r[n+j]:=r[n+j]-u. {Since always u = (q* * [b[i-1],...,b[0]] div beta^i) + 1 < q* + 1 <= beta, the carry u does not overflow.} If a negative carry occurs, put q* := q* - 1 and [r[n+j],...,r[j]] := [r[n+j],...,r[j]] + [0,b[n-1],...,b[0]]. Set q[j] := q*. Normalise [q[m-n],..,q[0]]; this yields the quotient q. Shift [r[n-1],...,r[0]] right by s bits and normalise; this yields the rest r. The room for q[j] can be allocated at the memory location of r[n+j]. Finally, round-to-even: Shift r left by 1 bit. If r > b or if r = b and q[0] is odd, q := q+1. */ const mp_limb_t *a_ptr = a.limbs; size_t a_len = a.nlimbs; const mp_limb_t *b_ptr = b.limbs; size_t b_len = b.nlimbs; mp_limb_t *roomptr; mp_limb_t *tmp_roomptr = NULL; mp_limb_t *q_ptr; size_t q_len; mp_limb_t *r_ptr; size_t r_len; /* Allocate room for a_len+2 digits. (Need a_len+1 digits for the real division and 1 more digit for the final rounding of q.) */ roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t)); if (roomptr == NULL) return NULL; /* Normalise a. */ while (a_len > 0 && a_ptr[a_len - 1] == 0) a_len--; /* Normalise b. */ for (;;) { if (b_len == 0) /* Division by zero. */ abort (); if (b_ptr[b_len - 1] == 0) b_len--; else break; } /* Here m = a_len >= 0 and n = b_len > 0. */ if (a_len < b_len) { /* m beta^(m-2) <= a/b < beta^m */ r_ptr = roomptr; q_ptr = roomptr + 1; { mp_limb_t den = b_ptr[0]; mp_limb_t remainder = 0; const mp_limb_t *sourceptr = a_ptr + a_len; mp_limb_t *destptr = q_ptr + a_len; size_t count; for (count = a_len; count > 0; count--) { mp_twolimb_t num = ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr; *--destptr = num / den; remainder = num % den; } /* Normalise and store r. */ if (remainder > 0) { r_ptr[0] = remainder; r_len = 1; } else r_len = 0; /* Normalise q. */ q_len = a_len; if (q_ptr[q_len - 1] == 0) q_len--; } } else { /* n>1: multiple precision division. beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==> beta^(m-n-1) <= a/b < beta^(m-n+1). */ /* Determine s. */ size_t s; { mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ /* Determine s = GMP_LIMB_BITS - integer_length (msd). Code copied from gnulib's integer_length.c. */ # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) s = __builtin_clz (msd); # else # if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT if (GMP_LIMB_BITS <= DBL_MANT_BIT) { /* Use 'double' operations. Assumes an IEEE 754 'double' implementation. */ # define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) # define DBL_EXP_BIAS (DBL_EXP_MASK / 2 - 1) # define NWORDS \ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) union { double value; unsigned int word[NWORDS]; } m; /* Use a single integer to floating-point conversion. */ m.value = msd; s = GMP_LIMB_BITS - (((m.word[DBL_EXPBIT0_WORD] >> DBL_EXPBIT0_BIT) & DBL_EXP_MASK) - DBL_EXP_BIAS); } else # undef NWORDS # endif { s = 31; if (msd >= 0x10000) { msd = msd >> 16; s -= 16; } if (msd >= 0x100) { msd = msd >> 8; s -= 8; } if (msd >= 0x10) { msd = msd >> 4; s -= 4; } if (msd >= 0x4) { msd = msd >> 2; s -= 2; } if (msd >= 0x2) { msd = msd >> 1; s -= 1; } } # endif } /* 0 <= s < GMP_LIMB_BITS. Copy b, shifting it left by s bits. */ if (s > 0) { tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t)); if (tmp_roomptr == NULL) { free (roomptr); return NULL; } { const mp_limb_t *sourceptr = b_ptr; mp_limb_t *destptr = tmp_roomptr; mp_twolimb_t accu = 0; size_t count; for (count = b_len; count > 0; count--) { accu += (mp_twolimb_t) *sourceptr++ << s; *destptr++ = (mp_limb_t) accu; accu = accu >> GMP_LIMB_BITS; } /* accu must be zero, since that was how s was determined. */ if (accu != 0) abort (); } b_ptr = tmp_roomptr; } /* Copy a, shifting it left by s bits, yields r. Memory layout: At the beginning: r = roomptr[0..a_len], at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */ r_ptr = roomptr; if (s == 0) { memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); r_ptr[a_len] = 0; } else { const mp_limb_t *sourceptr = a_ptr; mp_limb_t *destptr = r_ptr; mp_twolimb_t accu = 0; size_t count; for (count = a_len; count > 0; count--) { accu += (mp_twolimb_t) *sourceptr++ << s; *destptr++ = (mp_limb_t) accu; accu = accu >> GMP_LIMB_BITS; } *destptr++ = (mp_limb_t) accu; } q_ptr = roomptr + b_len; q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */ { size_t j = a_len - b_len; /* m-n */ mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */ mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */ mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */ ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd; /* Division loop, traversed m-n+1 times. j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */ for (;;) { mp_limb_t q_star; mp_limb_t c1; if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */ { /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */ mp_twolimb_t num = ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS) | r_ptr[j + b_len - 1]; q_star = num / b_msd; c1 = num % b_msd; } else { /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */ q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */ /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) {<= beta !}. If yes, jump directly to the subtraction loop. (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */ if (r_ptr[j + b_len] > b_msd || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd) /* r[j+n] >= b[n-1]+1 or r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a carry. */ goto subtract; } /* q_star = q*, c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, 0, decrease it by b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2 this can happen only twice. */ if (c3 > c2) { q_star = q_star - 1; /* q* := q* - 1 */ if (c3 - c2 > b_msdd) q_star = q_star - 1; /* q* := q* - 1 */ } } if (q_star > 0) subtract: { /* Subtract r := r - b * q* * beta^j. */ mp_limb_t cr; { const mp_limb_t *sourceptr = b_ptr; mp_limb_t *destptr = r_ptr + j; mp_twolimb_t carry = 0; size_t count; for (count = b_len; count > 0; count--) { /* Here 0 <= carry <= q*. */ carry = carry + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++ + (mp_limb_t) ~(*destptr); /* Here 0 <= carry <= beta*q* + beta-1. */ *destptr++ = ~(mp_limb_t) carry; carry = carry >> GMP_LIMB_BITS; /* <= q* */ } cr = (mp_limb_t) carry; } /* Subtract cr from r_ptr[j + b_len], then forget about r_ptr[j + b_len]. */ if (cr > r_ptr[j + b_len]) { /* Subtraction gave a carry. */ q_star = q_star - 1; /* q* := q* - 1 */ /* Add b back. */ { const mp_limb_t *sourceptr = b_ptr; mp_limb_t *destptr = r_ptr + j; mp_limb_t carry = 0; size_t count; for (count = b_len; count > 0; count--) { mp_limb_t source1 = *sourceptr++; mp_limb_t source2 = *destptr; *destptr++ = source1 + source2 + carry; carry = (carry ? source1 >= (mp_limb_t) ~source2 : source1 > (mp_limb_t) ~source2); } } /* Forget about the carry and about r[j+n]. */ } } /* q* is determined. Store it as q[j]. */ q_ptr[j] = q_star; if (j == 0) break; j--; } } r_len = b_len; /* Normalise q. */ if (q_ptr[q_len - 1] == 0) q_len--; # if 0 /* Not needed here, since we need r only to compare it with b/2, and b is shifted left by s bits. */ /* Shift r right by s bits. */ if (s > 0) { mp_limb_t ptr = r_ptr + r_len; mp_twolimb_t accu = 0; size_t count; for (count = r_len; count > 0; count--) { accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS; accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s); *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS); } } # endif /* Normalise r. */ while (r_len > 0 && r_ptr[r_len - 1] == 0) r_len--; } /* Compare r << 1 with b. */ if (r_len > b_len) goto increment_q; { size_t i; for (i = b_len;;) { mp_limb_t r_i = (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0) | (i < r_len ? r_ptr[i] << 1 : 0); mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0); if (r_i > b_i) goto increment_q; if (r_i < b_i) goto keep_q; if (i == 0) break; i--; } } if (q_len > 0 && ((q_ptr[0] & 1) != 0)) /* q is odd. */ increment_q: { size_t i; for (i = 0; i < q_len; i++) if (++(q_ptr[i]) != 0) goto keep_q; q_ptr[q_len++] = 1; } keep_q: if (tmp_roomptr != NULL) free (tmp_roomptr); q->limbs = q_ptr; q->nlimbs = q_len; return roomptr; } /* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal representation. Destroys the contents of a. Return the allocated memory - containing the decimal digits in low-to-high order, terminated with a NUL character - in case of success, NULL in case of memory allocation failure. */ static char * convert_to_decimal (mpn_t a, size_t extra_zeroes) { mp_limb_t *a_ptr = a.limbs; size_t a_len = a.nlimbs; /* 0.03345 is slightly larger than log(2)/(9*log(10)). */ size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1); char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes)); if (c_ptr != NULL) { char *d_ptr = c_ptr; for (; extra_zeroes > 0; extra_zeroes--) *d_ptr++ = '0'; while (a_len > 0) { /* Divide a by 10^9, in-place. */ mp_limb_t remainder = 0; mp_limb_t *ptr = a_ptr + a_len; size_t count; for (count = a_len; count > 0; count--) { mp_twolimb_t num = ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr; *ptr = num / 1000000000; remainder = num % 1000000000; } /* Store the remainder as 9 decimal digits. */ for (count = 9; count > 0; count--) { *d_ptr++ = '0' + (remainder % 10); remainder = remainder / 10; } /* Normalize a. */ if (a_ptr[a_len - 1] == 0) a_len--; } /* Remove leading zeroes. */ while (d_ptr > c_ptr && d_ptr[-1] == '0') d_ptr--; /* But keep at least one zero. */ if (d_ptr == c_ptr) *d_ptr++ = '0'; /* Terminate the string. */ *d_ptr = '\0'; } return c_ptr; } # if NEED_PRINTF_LONG_DOUBLE /* Assuming x is finite and >= 0: write x as x = 2^e * m, where m is a bignum. Return the allocated memory in case of success, NULL in case of memory allocation failure. */ static void * decode_long_double (long double x, int *ep, mpn_t *mp) { mpn_t m; int exp; long double y; size_t i; /* Allocate memory for result. */ m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); if (m.limbs == NULL) return NULL; /* Split into exponential part and mantissa. */ y = frexpl (x, &exp); if (!(y >= 0.0L && y < 1.0L)) abort (); /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * 2^LDBL_MANT_BIT), and the latter is an integer. */ /* Convert the mantissa (y * 2^LDBL_MANT_BIT) to a sequence of limbs. I'm not sure whether it's safe to cast a 'long double' value between 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only 'long double' values between 0 and 2^16 (to 'unsigned int' or 'int', doesn't matter). */ # if (LDBL_MANT_BIT % GMP_LIMB_BITS) != 0 # if (LDBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2 { mp_limb_t hi, lo; y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % (GMP_LIMB_BITS / 2)); hi = (int) y; y -= hi; if (!(y >= 0.0L && y < 1.0L)) abort (); y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); lo = (int) y; y -= lo; if (!(y >= 0.0L && y < 1.0L)) abort (); m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; } # else { mp_limb_t d; y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % GMP_LIMB_BITS); d = (int) y; y -= d; if (!(y >= 0.0L && y < 1.0L)) abort (); m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d; } # endif # endif for (i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) { mp_limb_t hi, lo; y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); hi = (int) y; y -= hi; if (!(y >= 0.0L && y < 1.0L)) abort (); y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); lo = (int) y; y -= lo; if (!(y >= 0.0L && y < 1.0L)) abort (); m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; } # if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess precision. */ if (!(y == 0.0L)) abort (); # endif /* Normalise. */ while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) m.nlimbs--; *mp = m; *ep = exp - LDBL_MANT_BIT; return m.limbs; } # endif # if NEED_PRINTF_DOUBLE /* Assuming x is finite and >= 0: write x as x = 2^e * m, where m is a bignum. Return the allocated memory in case of success, NULL in case of memory allocation failure. */ static void * decode_double (double x, int *ep, mpn_t *mp) { mpn_t m; int exp; double y; size_t i; /* Allocate memory for result. */ m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); if (m.limbs == NULL) return NULL; /* Split into exponential part and mantissa. */ y = frexp (x, &exp); if (!(y >= 0.0 && y < 1.0)) abort (); /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * 2^DBL_MANT_BIT), and the latter is an integer. */ /* Convert the mantissa (y * 2^DBL_MANT_BIT) to a sequence of limbs. I'm not sure whether it's safe to cast a 'double' value between 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only 'double' values between 0 and 2^16 (to 'unsigned int' or 'int', doesn't matter). */ # if (DBL_MANT_BIT % GMP_LIMB_BITS) != 0 # if (DBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2 { mp_limb_t hi, lo; y *= (mp_limb_t) 1 << (DBL_MANT_BIT % (GMP_LIMB_BITS / 2)); hi = (int) y; y -= hi; if (!(y >= 0.0 && y < 1.0)) abort (); y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); lo = (int) y; y -= lo; if (!(y >= 0.0 && y < 1.0)) abort (); m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; } # else { mp_limb_t d; y *= (mp_limb_t) 1 << (DBL_MANT_BIT % GMP_LIMB_BITS); d = (int) y; y -= d; if (!(y >= 0.0 && y < 1.0)) abort (); m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d; } # endif # endif for (i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) { mp_limb_t hi, lo; y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); hi = (int) y; y -= hi; if (!(y >= 0.0 && y < 1.0)) abort (); y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); lo = (int) y; y -= lo; if (!(y >= 0.0 && y < 1.0)) abort (); m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; } if (!(y == 0.0)) abort (); /* Normalise. */ while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) m.nlimbs--; *mp = m; *ep = exp - DBL_MANT_BIT; return m.limbs; } # endif /* Assuming x = 2^e * m is finite and >= 0, and n is an integer: Returns the decimal representation of round (x * 10^n). Return the allocated memory - containing the decimal digits in low-to-high order, terminated with a NUL character - in case of success, NULL in case of memory allocation failure. */ static char * scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) { int s; size_t extra_zeroes; unsigned int abs_n; unsigned int abs_s; mp_limb_t *pow5_ptr; size_t pow5_len; unsigned int s_limbs; unsigned int s_bits; mpn_t pow5; mpn_t z; void *z_memory; char *digits; if (memory == NULL) return NULL; /* x = 2^e * m, hence y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m) = round (2^s * 5^n * m). */ s = e + n; extra_zeroes = 0; /* Factor out a common power of 10 if possible. */ if (s > 0 && n > 0) { extra_zeroes = (s < n ? s : n); s -= extra_zeroes; n -= extra_zeroes; } /* Here y = round (2^s * 5^n * m) * 10^extra_zeroes. Before converting to decimal, we need to compute z = round (2^s * 5^n * m). */ /* Compute 5^|n|, possibly shifted by |s| bits if n and s have the same sign. 2.322 is slightly larger than log(5)/log(2). */ abs_n = (n >= 0 ? n : -n); abs_s = (s >= 0 ? s : -s); pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1 + abs_s / GMP_LIMB_BITS + 1) * sizeof (mp_limb_t)); if (pow5_ptr == NULL) { free (memory); return NULL; } /* Initialize with 1. */ pow5_ptr[0] = 1; pow5_len = 1; /* Multiply with 5^|n|. */ if (abs_n > 0) { static mp_limb_t const small_pow5[13 + 1] = { 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125 }; unsigned int n13; for (n13 = 0; n13 <= abs_n; n13 += 13) { mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13]; size_t j; mp_twolimb_t carry = 0; for (j = 0; j < pow5_len; j++) { mp_limb_t digit2 = pow5_ptr[j]; carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; pow5_ptr[j] = (mp_limb_t) carry; carry = carry >> GMP_LIMB_BITS; } if (carry > 0) pow5_ptr[pow5_len++] = (mp_limb_t) carry; } } s_limbs = abs_s / GMP_LIMB_BITS; s_bits = abs_s % GMP_LIMB_BITS; if (n >= 0 ? s >= 0 : s <= 0) { /* Multiply with 2^|s|. */ if (s_bits > 0) { mp_limb_t *ptr = pow5_ptr; mp_twolimb_t accu = 0; size_t count; for (count = pow5_len; count > 0; count--) { accu += (mp_twolimb_t) *ptr << s_bits; *ptr++ = (mp_limb_t) accu; accu = accu >> GMP_LIMB_BITS; } if (accu > 0) { *ptr = (mp_limb_t) accu; pow5_len++; } } if (s_limbs > 0) { size_t count; for (count = pow5_len; count > 0;) { count--; pow5_ptr[s_limbs + count] = pow5_ptr[count]; } for (count = s_limbs; count > 0;) { count--; pow5_ptr[count] = 0; } pow5_len += s_limbs; } pow5.limbs = pow5_ptr; pow5.nlimbs = pow5_len; if (n >= 0) { /* Multiply m with pow5. No division needed. */ z_memory = multiply (m, pow5, &z); } else { /* Divide m by pow5 and round. */ z_memory = divide (m, pow5, &z); } } else { pow5.limbs = pow5_ptr; pow5.nlimbs = pow5_len; if (n >= 0) { /* n >= 0, s < 0. Multiply m with pow5, then divide by 2^|s|. */ mpn_t numerator; mpn_t denominator; void *tmp_memory; tmp_memory = multiply (m, pow5, &numerator); if (tmp_memory == NULL) { free (pow5_ptr); free (memory); return NULL; } /* Construct 2^|s|. */ { mp_limb_t *ptr = pow5_ptr + pow5_len; size_t i; for (i = 0; i < s_limbs; i++) ptr[i] = 0; ptr[s_limbs] = (mp_limb_t) 1 << s_bits; denominator.limbs = ptr; denominator.nlimbs = s_limbs + 1; } z_memory = divide (numerator, denominator, &z); free (tmp_memory); } else { /* n < 0, s > 0. Multiply m with 2^s, then divide by pow5. */ mpn_t numerator; mp_limb_t *num_ptr; num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1) * sizeof (mp_limb_t)); if (num_ptr == NULL) { free (pow5_ptr); free (memory); return NULL; } { mp_limb_t *destptr = num_ptr; { size_t i; for (i = 0; i < s_limbs; i++) *destptr++ = 0; } if (s_bits > 0) { const mp_limb_t *sourceptr = m.limbs; mp_twolimb_t accu = 0; size_t count; for (count = m.nlimbs; count > 0; count--) { accu += (mp_twolimb_t) *sourceptr++ << s_bits; *destptr++ = (mp_limb_t) accu; accu = accu >> GMP_LIMB_BITS; } if (accu > 0) *destptr++ = (mp_limb_t) accu; } else { const mp_limb_t *sourceptr = m.limbs; size_t count; for (count = m.nlimbs; count > 0; count--) *destptr++ = *sourceptr++; } numerator.limbs = num_ptr; numerator.nlimbs = destptr - num_ptr; } z_memory = divide (numerator, pow5, &z); free (num_ptr); } } free (pow5_ptr); free (memory); /* Here y = round (x * 10^n) = z * 10^extra_zeroes. */ if (z_memory == NULL) return NULL; digits = convert_to_decimal (z, extra_zeroes); free (z_memory); return digits; } # if NEED_PRINTF_LONG_DOUBLE /* Assuming x is finite and >= 0, and n is an integer: Returns the decimal representation of round (x * 10^n). Return the allocated memory - containing the decimal digits in low-to-high order, terminated with a NUL character - in case of success, NULL in case of memory allocation failure. */ static char * scale10_round_decimal_long_double (long double x, int n) { int e IF_LINT(= 0); mpn_t m; void *memory = decode_long_double (x, &e, &m); return scale10_round_decimal_decoded (e, m, memory, n); } # endif # if NEED_PRINTF_DOUBLE /* Assuming x is finite and >= 0, and n is an integer: Returns the decimal representation of round (x * 10^n). Return the allocated memory - containing the decimal digits in low-to-high order, terminated with a NUL character - in case of success, NULL in case of memory allocation failure. */ static char * scale10_round_decimal_double (double x, int n) { int e IF_LINT(= 0); mpn_t m; void *memory = decode_double (x, &e, &m); return scale10_round_decimal_decoded (e, m, memory, n); } # endif # if NEED_PRINTF_LONG_DOUBLE /* Assuming x is finite and > 0: Return an approximation for n with 10^n <= x < 10^(n+1). The approximation is usually the right n, but may be off by 1 sometimes. */ static int floorlog10l (long double x) { int exp; long double y; double z; double l; /* Split into exponential part and mantissa. */ y = frexpl (x, &exp); if (!(y >= 0.0L && y < 1.0L)) abort (); if (y == 0.0L) return INT_MIN; if (y < 0.5L) { while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) { y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); exp -= GMP_LIMB_BITS; } if (y < (1.0L / (1 << 16))) { y *= 1.0L * (1 << 16); exp -= 16; } if (y < (1.0L / (1 << 8))) { y *= 1.0L * (1 << 8); exp -= 8; } if (y < (1.0L / (1 << 4))) { y *= 1.0L * (1 << 4); exp -= 4; } if (y < (1.0L / (1 << 2))) { y *= 1.0L * (1 << 2); exp -= 2; } if (y < (1.0L / (1 << 1))) { y *= 1.0L * (1 << 1); exp -= 1; } } if (!(y >= 0.5L && y < 1.0L)) abort (); /* Compute an approximation for l = log2(x) = exp + log2(y). */ l = exp; z = y; if (z < 0.70710678118654752444) { z *= 1.4142135623730950488; l -= 0.5; } if (z < 0.8408964152537145431) { z *= 1.1892071150027210667; l -= 0.25; } if (z < 0.91700404320467123175) { z *= 1.0905077326652576592; l -= 0.125; } if (z < 0.9576032806985736469) { z *= 1.0442737824274138403; l -= 0.0625; } /* Now 0.95 <= z <= 1.01. */ z = 1 - z; /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...) Four terms are enough to get an approximation with error < 10^-7. */ l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); /* Finally multiply with log(2)/log(10), yields an approximation for log10(x). */ l *= 0.30102999566398119523; /* Round down to the next integer. */ return (int) l + (l < 0 ? -1 : 0); } # endif # if NEED_PRINTF_DOUBLE /* Assuming x is finite and > 0: Return an approximation for n with 10^n <= x < 10^(n+1). The approximation is usually the right n, but may be off by 1 sometimes. */ static int floorlog10 (double x) { int exp; double y; double z; double l; /* Split into exponential part and mantissa. */ y = frexp (x, &exp); if (!(y >= 0.0 && y < 1.0)) abort (); if (y == 0.0) return INT_MIN; if (y < 0.5) { while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) { y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); exp -= GMP_LIMB_BITS; } if (y < (1.0 / (1 << 16))) { y *= 1.0 * (1 << 16); exp -= 16; } if (y < (1.0 / (1 << 8))) { y *= 1.0 * (1 << 8); exp -= 8; } if (y < (1.0 / (1 << 4))) { y *= 1.0 * (1 << 4); exp -= 4; } if (y < (1.0 / (1 << 2))) { y *= 1.0 * (1 << 2); exp -= 2; } if (y < (1.0 / (1 << 1))) { y *= 1.0 * (1 << 1); exp -= 1; } } if (!(y >= 0.5 && y < 1.0)) abort (); /* Compute an approximation for l = log2(x) = exp + log2(y). */ l = exp; z = y; if (z < 0.70710678118654752444) { z *= 1.4142135623730950488; l -= 0.5; } if (z < 0.8408964152537145431) { z *= 1.1892071150027210667; l -= 0.25; } if (z < 0.91700404320467123175) { z *= 1.0905077326652576592; l -= 0.125; } if (z < 0.9576032806985736469) { z *= 1.0442737824274138403; l -= 0.0625; } /* Now 0.95 <= z <= 1.01. */ z = 1 - z; /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...) Four terms are enough to get an approximation with error < 10^-7. */ l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); /* Finally multiply with log(2)/log(10), yields an approximation for log10(x). */ l *= 0.30102999566398119523; /* Round down to the next integer. */ return (int) l + (l < 0 ? -1 : 0); } # endif /* Tests whether a string of digits consists of exactly PRECISION zeroes and a single '1' digit. */ static int is_borderline (const char *digits, size_t precision) { for (; precision > 0; precision--, digits++) if (*digits != '0') return 0; if (*digits != '1') return 0; digits++; return *digits == '\0'; } #endif #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 /* Use a different function name, to make it possible that the 'wchar_t' parametrization and the 'char' parametrization get compiled in the same translation unit. */ # if WIDE_CHAR_VERSION # define MAX_ROOM_NEEDED wmax_room_needed # else # define MAX_ROOM_NEEDED max_room_needed # endif /* Returns the number of TCHAR_T units needed as temporary space for the result of sprintf or SNPRINTF of a single conversion directive. */ static size_t MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, arg_type type, int flags, size_t width, int has_precision, size_t precision, int pad_ourselves) { size_t tmp_length; switch (conversion) { case 'd': case 'i': case 'u': # if HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.30103 /* binary -> decimal */ ) + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.30103 /* binary -> decimal */ ) + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.30103 /* binary -> decimal */ ) + 1; /* turn floor into ceil */ if (tmp_length < precision) tmp_length = precision; /* Multiply by 2, as an estimate for FLAG_GROUP. */ tmp_length = xsum (tmp_length, tmp_length); /* Add 1, to account for a leading sign. */ tmp_length = xsum (tmp_length, 1); break; case 'o': # if HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.333334 /* binary -> octal */ ) + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.333334 /* binary -> octal */ ) + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.333334 /* binary -> octal */ ) + 1; /* turn floor into ceil */ if (tmp_length < precision) tmp_length = precision; /* Add 1, to account for a leading sign. */ tmp_length = xsum (tmp_length, 1); break; case 'x': case 'X': # if HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) + 1; /* turn floor into ceil */ if (tmp_length < precision) tmp_length = precision; /* Add 2, to account for a leading sign or alternate form. */ tmp_length = xsum (tmp_length, 2); break; case 'f': case 'F': if (type == TYPE_LONGDOUBLE) tmp_length = (unsigned int) (LDBL_MAX_EXP * 0.30103 /* binary -> decimal */ * 2 /* estimate for FLAG_GROUP */ ) + 1 /* turn floor into ceil */ + 10; /* sign, decimal point etc. */ else tmp_length = (unsigned int) (DBL_MAX_EXP * 0.30103 /* binary -> decimal */ * 2 /* estimate for FLAG_GROUP */ ) + 1 /* turn floor into ceil */ + 10; /* sign, decimal point etc. */ tmp_length = xsum (tmp_length, precision); break; case 'e': case 'E': case 'g': case 'G': tmp_length = 12; /* sign, decimal point, exponent etc. */ tmp_length = xsum (tmp_length, precision); break; case 'a': case 'A': if (type == TYPE_LONGDOUBLE) tmp_length = (unsigned int) (LDBL_DIG * 0.831 /* decimal -> hexadecimal */ ) + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (DBL_DIG * 0.831 /* decimal -> hexadecimal */ ) + 1; /* turn floor into ceil */ if (tmp_length < precision) tmp_length = precision; /* Account for sign, decimal point etc. */ tmp_length = xsum (tmp_length, 12); break; case 'c': # if HAVE_WINT_T && !WIDE_CHAR_VERSION if (type == TYPE_WIDE_CHAR) tmp_length = MB_CUR_MAX; else # endif tmp_length = 1; break; case 's': # if HAVE_WCHAR_T if (type == TYPE_WIDE_STRING) { # if WIDE_CHAR_VERSION /* ISO C says about %ls in fwprintf: "If the precision is not specified or is greater than the size of the array, the array shall contain a null wide character." So if there is a precision, we must not use wcslen. */ const wchar_t *arg = ap->arg[arg_index].a.a_wide_string; if (has_precision) tmp_length = local_wcsnlen (arg, precision); else tmp_length = local_wcslen (arg); # else /* ISO C says about %ls in fprintf: "If a precision is specified, no more than that many bytes are written (including shift sequences, if any), and the array shall contain a null wide character if, to equal the multibyte character sequence length given by the precision, the function would need to access a wide character one past the end of the array." So if there is a precision, we must not use wcslen. */ /* This case has already been handled separately in VASNPRINTF. */ abort (); # endif } else # endif { # if WIDE_CHAR_VERSION /* ISO C says about %s in fwprintf: "If the precision is not specified or is greater than the size of the converted array, the converted array shall contain a null wide character." So if there is a precision, we must not use strlen. */ /* This case has already been handled separately in VASNPRINTF. */ abort (); # else /* ISO C says about %s in fprintf: "If the precision is not specified or greater than the size of the array, the array shall contain a null character." So if there is a precision, we must not use strlen. */ const char *arg = ap->arg[arg_index].a.a_string; if (has_precision) tmp_length = local_strnlen (arg, precision); else tmp_length = strlen (arg); # endif } break; case 'p': tmp_length = (unsigned int) (sizeof (void *) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) + 1 /* turn floor into ceil */ + 2; /* account for leading 0x */ break; default: abort (); } if (!pad_ourselves) { # if ENABLE_UNISTDIO /* Padding considers the number of characters, therefore the number of elements after padding may be > max (tmp_length, width) but is certainly <= tmp_length + width. */ tmp_length = xsum (tmp_length, width); # else /* Padding considers the number of elements, says POSIX. */ if (tmp_length < width) tmp_length = width; # endif } tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ return tmp_length; } #endif DCHAR_T * VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const FCHAR_T *format, va_list args) { DIRECTIVES d; arguments a; if (PRINTF_PARSE (format, &d, &a) < 0) /* errno is already set. */ return NULL; #define CLEANUP() \ if (d.dir != d.direct_alloc_dir) \ free (d.dir); \ if (a.arg != a.direct_alloc_arg) \ free (a.arg); if (PRINTF_FETCHARGS (args, &a) < 0) { CLEANUP (); errno = EINVAL; return NULL; } { size_t buf_neededlength; TCHAR_T *buf; TCHAR_T *buf_malloced; const FCHAR_T *cp; size_t i; DIRECTIVE *dp; /* Output string accumulator. */ DCHAR_T *result; size_t allocated; size_t length; /* Allocate a small buffer that will hold a directive passed to sprintf or snprintf. */ buf_neededlength = xsum4 (7, d.max_width_length, d.max_precision_length, 6); #if HAVE_ALLOCA if (buf_neededlength < 4000 / sizeof (TCHAR_T)) { buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T)); buf_malloced = NULL; } else #endif { size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T)); if (size_overflow_p (buf_memsize)) goto out_of_memory_1; buf = (TCHAR_T *) malloc (buf_memsize); if (buf == NULL) goto out_of_memory_1; buf_malloced = buf; } if (resultbuf != NULL) { result = resultbuf; allocated = *lengthp; } else { result = NULL; allocated = 0; } length = 0; /* Invariants: result is either == resultbuf or == NULL or malloc-allocated. If length > 0, then result != NULL. */ /* Ensures that allocated >= needed. Aborts through a jump to out_of_memory if needed is SIZE_MAX or otherwise too big. */ #define ENSURE_ALLOCATION(needed) \ if ((needed) > allocated) \ { \ size_t memory_size; \ DCHAR_T *memory; \ \ allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \ if ((needed) > allocated) \ allocated = (needed); \ memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ if (size_overflow_p (memory_size)) \ goto out_of_memory; \ if (result == resultbuf || result == NULL) \ memory = (DCHAR_T *) malloc (memory_size); \ else \ memory = (DCHAR_T *) realloc (result, memory_size); \ if (memory == NULL) \ goto out_of_memory; \ if (result == resultbuf && length > 0) \ DCHAR_CPY (memory, result, length); \ result = memory; \ } for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++) { if (cp != dp->dir_start) { size_t n = dp->dir_start - cp; size_t augmented_length = xsum (length, n); ENSURE_ALLOCATION (augmented_length); /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we need that the format string contains only ASCII characters if FCHAR_T and DCHAR_T are not the same type. */ if (sizeof (FCHAR_T) == sizeof (DCHAR_T)) { DCHAR_CPY (result + length, (const DCHAR_T *) cp, n); length = augmented_length; } else { do result[length++] = *cp++; while (--n > 0); } } if (i == d.count) break; /* Execute a single directive. */ if (dp->conversion == '%') { size_t augmented_length; if (!(dp->arg_index == ARG_NONE)) abort (); augmented_length = xsum (length, 1); ENSURE_ALLOCATION (augmented_length); result[length] = '%'; length = augmented_length; } else { if (!(dp->arg_index != ARG_NONE)) abort (); if (dp->conversion == 'n') { switch (a.arg[dp->arg_index].type) { case TYPE_COUNT_SCHAR_POINTER: *a.arg[dp->arg_index].a.a_count_schar_pointer = length; break; case TYPE_COUNT_SHORT_POINTER: *a.arg[dp->arg_index].a.a_count_short_pointer = length; break; case TYPE_COUNT_INT_POINTER: *a.arg[dp->arg_index].a.a_count_int_pointer = length; break; case TYPE_COUNT_LONGINT_POINTER: *a.arg[dp->arg_index].a.a_count_longint_pointer = length; break; #if HAVE_LONG_LONG_INT case TYPE_COUNT_LONGLONGINT_POINTER: *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; break; #endif default: abort (); } } #if ENABLE_UNISTDIO /* The unistdio extensions. */ else if (dp->conversion == 'U') { arg_type type = a.arg[dp->arg_index].type; int flags = dp->flags; int has_width; size_t width; int has_precision; size_t precision; has_width = 0; width = 0; if (dp->width_start != dp->width_end) { if (dp->width_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; width = -width; } } else { const FCHAR_T *digitp = dp->width_start; do width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } has_width = 1; } has_precision = 0; precision = 0; if (dp->precision_start != dp->precision_end) { if (dp->precision_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->precision_arg_index].a.a_int; /* "A negative precision is taken as if the precision were omitted." */ if (arg >= 0) { precision = arg; has_precision = 1; } } else { const FCHAR_T *digitp = dp->precision_start + 1; precision = 0; while (digitp != dp->precision_end) precision = xsum (xtimes (precision, 10), *digitp++ - '0'); has_precision = 1; } } switch (type) { case TYPE_U8_STRING: { const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string; const uint8_t *arg_end; size_t characters; if (has_precision) { /* Use only PRECISION characters, from the left. */ arg_end = arg; characters = 0; for (; precision > 0; precision--) { int count = u8_strmblen (arg_end); if (count == 0) break; if (count < 0) { if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end += count; characters++; } } else if (has_width) { /* Use the entire string, and count the number of characters. */ arg_end = arg; characters = 0; for (;;) { int count = u8_strmblen (arg_end); if (count == 0) break; if (count < 0) { if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end += count; characters++; } } else { /* Use the entire string. */ arg_end = arg + u8_strlen (arg); /* The number of characters doesn't matter. */ characters = 0; } if (characters < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } # if DCHAR_IS_UINT8_T { size_t n = arg_end - arg; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_CPY (result + length, arg, n); length += n; } # else { /* Convert. */ DCHAR_T *converted = result + length; size_t converted_len = allocated - length; # if DCHAR_IS_TCHAR /* Convert from UTF-8 to locale encoding. */ converted = u8_conv_to_encoding (locale_charset (), iconveh_question_mark, arg, arg_end - arg, NULL, converted, &converted_len); # else /* Convert from UTF-8 to UTF-16/UTF-32. */ converted = U8_TO_DCHAR (arg, arg_end - arg, converted, &converted_len); # endif if (converted == NULL) { int saved_errno = errno; if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = saved_errno; return NULL; } if (converted != result + length) { ENSURE_ALLOCATION (xsum (length, converted_len)); DCHAR_CPY (result + length, converted, converted_len); free (converted); } length += converted_len; } # endif if (characters < width && (dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } } break; case TYPE_U16_STRING: { const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string; const uint16_t *arg_end; size_t characters; if (has_precision) { /* Use only PRECISION characters, from the left. */ arg_end = arg; characters = 0; for (; precision > 0; precision--) { int count = u16_strmblen (arg_end); if (count == 0) break; if (count < 0) { if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end += count; characters++; } } else if (has_width) { /* Use the entire string, and count the number of characters. */ arg_end = arg; characters = 0; for (;;) { int count = u16_strmblen (arg_end); if (count == 0) break; if (count < 0) { if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end += count; characters++; } } else { /* Use the entire string. */ arg_end = arg + u16_strlen (arg); /* The number of characters doesn't matter. */ characters = 0; } if (characters < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } # if DCHAR_IS_UINT16_T { size_t n = arg_end - arg; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_CPY (result + length, arg, n); length += n; } # else { /* Convert. */ DCHAR_T *converted = result + length; size_t converted_len = allocated - length; # if DCHAR_IS_TCHAR /* Convert from UTF-16 to locale encoding. */ converted = u16_conv_to_encoding (locale_charset (), iconveh_question_mark, arg, arg_end - arg, NULL, converted, &converted_len); # else /* Convert from UTF-16 to UTF-8/UTF-32. */ converted = U16_TO_DCHAR (arg, arg_end - arg, converted, &converted_len); # endif if (converted == NULL) { int saved_errno = errno; if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = saved_errno; return NULL; } if (converted != result + length) { ENSURE_ALLOCATION (xsum (length, converted_len)); DCHAR_CPY (result + length, converted, converted_len); free (converted); } length += converted_len; } # endif if (characters < width && (dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } } break; case TYPE_U32_STRING: { const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string; const uint32_t *arg_end; size_t characters; if (has_precision) { /* Use only PRECISION characters, from the left. */ arg_end = arg; characters = 0; for (; precision > 0; precision--) { int count = u32_strmblen (arg_end); if (count == 0) break; if (count < 0) { if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end += count; characters++; } } else if (has_width) { /* Use the entire string, and count the number of characters. */ arg_end = arg; characters = 0; for (;;) { int count = u32_strmblen (arg_end); if (count == 0) break; if (count < 0) { if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end += count; characters++; } } else { /* Use the entire string. */ arg_end = arg + u32_strlen (arg); /* The number of characters doesn't matter. */ characters = 0; } if (characters < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } # if DCHAR_IS_UINT32_T { size_t n = arg_end - arg; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_CPY (result + length, arg, n); length += n; } # else { /* Convert. */ DCHAR_T *converted = result + length; size_t converted_len = allocated - length; # if DCHAR_IS_TCHAR /* Convert from UTF-32 to locale encoding. */ converted = u32_conv_to_encoding (locale_charset (), iconveh_question_mark, arg, arg_end - arg, NULL, converted, &converted_len); # else /* Convert from UTF-32 to UTF-8/UTF-16. */ converted = U32_TO_DCHAR (arg, arg_end - arg, converted, &converted_len); # endif if (converted == NULL) { int saved_errno = errno; if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = saved_errno; return NULL; } if (converted != result + length) { ENSURE_ALLOCATION (xsum (length, converted_len)); DCHAR_CPY (result + length, converted, converted_len); free (converted); } length += converted_len; } # endif if (characters < width && (dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } } break; default: abort (); } } #endif #if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T else if (dp->conversion == 's' # if WIDE_CHAR_VERSION && a.arg[dp->arg_index].type != TYPE_WIDE_STRING # else && a.arg[dp->arg_index].type == TYPE_WIDE_STRING # endif ) { /* The normal handling of the 's' directive below requires allocating a temporary buffer. The determination of its length (tmp_length), in the case when a precision is specified, below requires a conversion between a char[] string and a wchar_t[] wide string. It could be done, but we have no guarantee that the implementation of sprintf will use the exactly same algorithm. Without this guarantee, it is possible to have buffer overrun bugs. In order to avoid such bugs, we implement the entire processing of the 's' directive ourselves. */ int flags = dp->flags; int has_width; size_t width; int has_precision; size_t precision; has_width = 0; width = 0; if (dp->width_start != dp->width_end) { if (dp->width_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; width = -width; } } else { const FCHAR_T *digitp = dp->width_start; do width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } has_width = 1; } has_precision = 0; precision = 6; if (dp->precision_start != dp->precision_end) { if (dp->precision_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->precision_arg_index].a.a_int; /* "A negative precision is taken as if the precision were omitted." */ if (arg >= 0) { precision = arg; has_precision = 1; } } else { const FCHAR_T *digitp = dp->precision_start + 1; precision = 0; while (digitp != dp->precision_end) precision = xsum (xtimes (precision, 10), *digitp++ - '0'); has_precision = 1; } } # if WIDE_CHAR_VERSION /* %s in vasnwprintf. See the specification of fwprintf. */ { const char *arg = a.arg[dp->arg_index].a.a_string; const char *arg_end; size_t characters; if (has_precision) { /* Use only as many bytes as needed to produce PRECISION wide characters, from the left. */ # if HAVE_MBRTOWC mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif arg_end = arg; characters = 0; for (; precision > 0; precision--) { int count; # if HAVE_MBRTOWC count = mbrlen (arg_end, MB_CUR_MAX, &state); # else count = mblen (arg_end, MB_CUR_MAX); # endif if (count == 0) /* Found the terminating NUL. */ break; if (count < 0) { /* Invalid or incomplete multibyte character. */ if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end += count; characters++; } } else if (has_width) { /* Use the entire string, and count the number of wide characters. */ # if HAVE_MBRTOWC mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif arg_end = arg; characters = 0; for (;;) { int count; # if HAVE_MBRTOWC count = mbrlen (arg_end, MB_CUR_MAX, &state); # else count = mblen (arg_end, MB_CUR_MAX); # endif if (count == 0) /* Found the terminating NUL. */ break; if (count < 0) { /* Invalid or incomplete multibyte character. */ if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end += count; characters++; } } else { /* Use the entire string. */ arg_end = arg + strlen (arg); /* The number of characters doesn't matter. */ characters = 0; } if (characters < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } if (has_precision || has_width) { /* We know the number of wide characters in advance. */ size_t remaining; # if HAVE_MBRTOWC mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif ENSURE_ALLOCATION (xsum (length, characters)); for (remaining = characters; remaining > 0; remaining--) { wchar_t wc; int count; # if HAVE_MBRTOWC count = mbrtowc (&wc, arg, arg_end - arg, &state); # else count = mbtowc (&wc, arg, arg_end - arg); # endif if (count <= 0) /* mbrtowc not consistent with mbrlen, or mbtowc not consistent with mblen. */ abort (); result[length++] = wc; arg += count; } if (!(arg == arg_end)) abort (); } else { # if HAVE_MBRTOWC mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif while (arg < arg_end) { wchar_t wc; int count; # if HAVE_MBRTOWC count = mbrtowc (&wc, arg, arg_end - arg, &state); # else count = mbtowc (&wc, arg, arg_end - arg); # endif if (count <= 0) /* mbrtowc not consistent with mbrlen, or mbtowc not consistent with mblen. */ abort (); ENSURE_ALLOCATION (xsum (length, 1)); result[length++] = wc; arg += count; } } if (characters < width && (dp->flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } } # else /* %ls in vasnprintf. See the specification of fprintf. */ { const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; const wchar_t *arg_end; size_t characters; # if !DCHAR_IS_TCHAR /* This code assumes that TCHAR_T is 'char'. */ verify (sizeof (TCHAR_T) == 1); TCHAR_T *tmpsrc; DCHAR_T *tmpdst; size_t tmpdst_len; # endif size_t w; if (has_precision) { /* Use only as many wide characters as needed to produce at most PRECISION bytes, from the left. */ # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif arg_end = arg; characters = 0; while (precision > 0) { char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ int count; if (*arg_end == 0) /* Found the terminating null wide character. */ break; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t count = wcrtomb (cbuf, *arg_end, &state); # else count = wctomb (cbuf, *arg_end); # endif if (count < 0) { /* Cannot convert. */ if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } if (precision < count) break; arg_end++; characters += count; precision -= count; } } # if DCHAR_IS_TCHAR else if (has_width) # else else # endif { /* Use the entire string, and count the number of bytes. */ # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif arg_end = arg; characters = 0; for (;;) { char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ int count; if (*arg_end == 0) /* Found the terminating null wide character. */ break; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t count = wcrtomb (cbuf, *arg_end, &state); # else count = wctomb (cbuf, *arg_end); # endif if (count < 0) { /* Cannot convert. */ if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } arg_end++; characters += count; } } # if DCHAR_IS_TCHAR else { /* Use the entire string. */ arg_end = arg + local_wcslen (arg); /* The number of bytes doesn't matter. */ characters = 0; } # endif # if !DCHAR_IS_TCHAR /* Convert the string into a piece of temporary memory. */ tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T)); if (tmpsrc == NULL) goto out_of_memory; { TCHAR_T *tmpptr = tmpsrc; size_t remaining; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif for (remaining = characters; remaining > 0; ) { char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ int count; if (*arg == 0) abort (); # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t count = wcrtomb (cbuf, *arg, &state); # else count = wctomb (cbuf, *arg); # endif if (count <= 0) /* Inconsistency. */ abort (); memcpy (tmpptr, cbuf, count); tmpptr += count; arg++; remaining -= count; } if (!(arg == arg_end)) abort (); } /* Convert from TCHAR_T[] to DCHAR_T[]. */ tmpdst = DCHAR_CONV_FROM_ENCODING (locale_charset (), iconveh_question_mark, tmpsrc, characters, NULL, NULL, &tmpdst_len); if (tmpdst == NULL) { int saved_errno = errno; free (tmpsrc); if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = saved_errno; return NULL; } free (tmpsrc); # endif if (has_width) { # if ENABLE_UNISTDIO /* Outside POSIX, it's preferable to compare the width against the number of _characters_ of the converted value. */ w = DCHAR_MBSNLEN (result + length, characters); # else /* The width is compared against the number of _bytes_ of the converted value, says POSIX. */ w = characters; # endif } else /* w doesn't matter. */ w = 0; if (w < width && !(dp->flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } # if DCHAR_IS_TCHAR if (has_precision || has_width) { /* We know the number of bytes in advance. */ size_t remaining; # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif ENSURE_ALLOCATION (xsum (length, characters)); for (remaining = characters; remaining > 0; ) { char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ int count; if (*arg == 0) abort (); # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t count = wcrtomb (cbuf, *arg, &state); # else count = wctomb (cbuf, *arg); # endif if (count <= 0) /* Inconsistency. */ abort (); memcpy (result + length, cbuf, count); length += count; arg++; remaining -= count; } if (!(arg == arg_end)) abort (); } else { # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); # endif while (arg < arg_end) { char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ int count; if (*arg == 0) abort (); # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t count = wcrtomb (cbuf, *arg, &state); # else count = wctomb (cbuf, *arg); # endif if (count <= 0) { /* Cannot convert. */ if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EILSEQ; return NULL; } ENSURE_ALLOCATION (xsum (length, count)); memcpy (result + length, cbuf, count); length += count; arg++; } } # else ENSURE_ALLOCATION (xsum (length, tmpdst_len)); DCHAR_CPY (result + length, tmpdst, tmpdst_len); free (tmpdst); length += tmpdst_len; # endif if (w < width && (dp->flags & FLAG_LEFT)) { size_t n = width - w; ENSURE_ALLOCATION (xsum (length, n)); DCHAR_SET (result + length, ' ', n); length += n; } } # endif } #endif #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL else if ((dp->conversion == 'a' || dp->conversion == 'A') # if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) && (0 # if NEED_PRINTF_DOUBLE || a.arg[dp->arg_index].type == TYPE_DOUBLE # endif # if NEED_PRINTF_LONG_DOUBLE || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE # endif ) # endif ) { arg_type type = a.arg[dp->arg_index].type; int flags = dp->flags; size_t width; int has_precision; size_t precision; size_t tmp_length; size_t count; DCHAR_T tmpbuf[700]; DCHAR_T *tmp; DCHAR_T *pad_ptr; DCHAR_T *p; width = 0; if (dp->width_start != dp->width_end) { if (dp->width_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; width = -width; } } else { const FCHAR_T *digitp = dp->width_start; do width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } } has_precision = 0; precision = 0; if (dp->precision_start != dp->precision_end) { if (dp->precision_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->precision_arg_index].a.a_int; /* "A negative precision is taken as if the precision were omitted." */ if (arg >= 0) { precision = arg; has_precision = 1; } } else { const FCHAR_T *digitp = dp->precision_start + 1; precision = 0; while (digitp != dp->precision_end) precision = xsum (xtimes (precision, 10), *digitp++ - '0'); has_precision = 1; } } /* Allocate a temporary buffer of sufficient size. */ if (type == TYPE_LONGDOUBLE) tmp_length = (unsigned int) ((LDBL_DIG + 1) * 0.831 /* decimal -> hexadecimal */ ) + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) ((DBL_DIG + 1) * 0.831 /* decimal -> hexadecimal */ ) + 1; /* turn floor into ceil */ if (tmp_length < precision) tmp_length = precision; /* Account for sign, decimal point etc. */ tmp_length = xsum (tmp_length, 12); if (tmp_length < width) tmp_length = width; tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) tmp = tmpbuf; else { size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); if (size_overflow_p (tmp_memsize)) /* Overflow, would lead to out of memory. */ goto out_of_memory; tmp = (DCHAR_T *) malloc (tmp_memsize); if (tmp == NULL) /* Out of memory. */ goto out_of_memory; } pad_ptr = NULL; p = tmp; if (type == TYPE_LONGDOUBLE) { # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE long double arg = a.arg[dp->arg_index].a.a_longdouble; if (isnanl (arg)) { if (dp->conversion == 'A') { *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; } else { *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; } } else { int sign = 0; DECL_LONG_DOUBLE_ROUNDING BEGIN_LONG_DOUBLE_ROUNDING (); if (signbit (arg)) /* arg < 0.0L or negative zero */ { sign = -1; arg = -arg; } if (sign < 0) *p++ = '-'; else if (flags & FLAG_SHOWSIGN) *p++ = '+'; else if (flags & FLAG_SPACE) *p++ = ' '; if (arg > 0.0L && arg + arg == arg) { if (dp->conversion == 'A') { *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; } else { *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; } } else { int exponent; long double mantissa; if (arg > 0.0L) mantissa = printf_frexpl (arg, &exponent); else { exponent = 0; mantissa = 0.0L; } if (has_precision && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1) { /* Round the mantissa. */ long double tail = mantissa; size_t q; for (q = precision; ; q--) { int digit = (int) tail; tail -= digit; if (q == 0) { if (digit & 1 ? tail >= 0.5L : tail > 0.5L) tail = 1 - tail; else tail = - tail; break; } tail *= 16.0L; } if (tail != 0.0L) for (q = precision; q > 0; q--) tail *= 0.0625L; mantissa += tail; } *p++ = '0'; *p++ = dp->conversion - 'A' + 'X'; pad_ptr = p; { int digit; digit = (int) mantissa; mantissa -= digit; *p++ = '0' + digit; if ((flags & FLAG_ALT) || mantissa > 0.0L || precision > 0) { *p++ = decimal_point_char (); /* This loop terminates because we assume that FLT_RADIX is a power of 2. */ while (mantissa > 0.0L) { mantissa *= 16.0L; digit = (int) mantissa; mantissa -= digit; *p++ = digit + (digit < 10 ? '0' : dp->conversion - 10); if (precision > 0) precision--; } while (precision > 0) { *p++ = '0'; precision--; } } } *p++ = dp->conversion - 'A' + 'P'; # if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = { '%', '+', 'd', '\0' }; SNPRINTF (p, 6 + 1, decimal_format, exponent); } while (*p != '\0') p++; # else if (sizeof (DCHAR_T) == 1) { sprintf ((char *) p, "%+d", exponent); while (*p != '\0') p++; } else { char expbuf[6 + 1]; const char *ep; sprintf (expbuf, "%+d", exponent); for (ep = expbuf; (*p = *ep) != '\0'; ep++) p++; } # endif } END_LONG_DOUBLE_ROUNDING (); } # else abort (); # endif } else { # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE double arg = a.arg[dp->arg_index].a.a_double; if (isnand (arg)) { if (dp->conversion == 'A') { *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; } else { *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; } } else { int sign = 0; if (signbit (arg)) /* arg < 0.0 or negative zero */ { sign = -1; arg = -arg; } if (sign < 0) *p++ = '-'; else if (flags & FLAG_SHOWSIGN) *p++ = '+'; else if (flags & FLAG_SPACE) *p++ = ' '; if (arg > 0.0 && arg + arg == arg) { if (dp->conversion == 'A') { *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; } else { *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; } } else { int exponent; double mantissa; if (arg > 0.0) mantissa = printf_frexp (arg, &exponent); else { exponent = 0; mantissa = 0.0; } if (has_precision && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1) { /* Round the mantissa. */ double tail = mantissa; size_t q; for (q = precision; ; q--) { int digit = (int) tail; tail -= digit; if (q == 0) { if (digit & 1 ? tail >= 0.5 : tail > 0.5) tail = 1 - tail; else tail = - tail; break; } tail *= 16.0; } if (tail != 0.0) for (q = precision; q > 0; q--) tail *= 0.0625; mantissa += tail; } *p++ = '0'; *p++ = dp->conversion - 'A' + 'X'; pad_ptr = p; { int digit; digit = (int) mantissa; mantissa -= digit; *p++ = '0' + digit; if ((flags & FLAG_ALT) || mantissa > 0.0 || precision > 0) { *p++ = decimal_point_char (); /* This loop terminates because we assume that FLT_RADIX is a power of 2. */ while (mantissa > 0.0) { mantissa *= 16.0; digit = (int) mantissa; mantissa -= digit; *p++ = digit + (digit < 10 ? '0' : dp->conversion - 10); if (precision > 0) precision--; } while (precision > 0) { *p++ = '0'; precision--; } } } *p++ = dp->conversion - 'A' + 'P'; # if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = { '%', '+', 'd', '\0' }; SNPRINTF (p, 6 + 1, decimal_format, exponent); } while (*p != '\0') p++; # else if (sizeof (DCHAR_T) == 1) { sprintf ((char *) p, "%+d", exponent); while (*p != '\0') p++; } else { char expbuf[6 + 1]; const char *ep; sprintf (expbuf, "%+d", exponent); for (ep = expbuf; (*p = *ep) != '\0'; ep++) p++; } # endif } } # else abort (); # endif } /* The generated string now extends from tmp to p, with the zero padding insertion point being at pad_ptr. */ count = p - tmp; if (count < width) { size_t pad = width - count; DCHAR_T *end = p + pad; if (flags & FLAG_LEFT) { /* Pad with spaces on the right. */ for (; pad > 0; pad--) *p++ = ' '; } else if ((flags & FLAG_ZERO) && pad_ptr != NULL) { /* Pad with zeroes. */ DCHAR_T *q = end; while (p > pad_ptr) *--q = *--p; for (; pad > 0; pad--) *p++ = '0'; } else { /* Pad with spaces on the left. */ DCHAR_T *q = end; while (p > tmp) *--q = *--p; for (; pad > 0; pad--) *p++ = ' '; } p = end; } count = p - tmp; if (count >= tmp_length) /* tmp_length was incorrectly calculated - fix the code above! */ abort (); /* Make room for the result. */ if (count >= allocated - length) { size_t n = xsum (length, count); ENSURE_ALLOCATION (n); } /* Append the result. */ memcpy (result + length, tmp, count * sizeof (DCHAR_T)); if (tmp != tmpbuf) free (tmp); length += count; } #endif #if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL else if ((dp->conversion == 'f' || dp->conversion == 'F' || dp->conversion == 'e' || dp->conversion == 'E' || dp->conversion == 'g' || dp->conversion == 'G' || dp->conversion == 'a' || dp->conversion == 'A') && (0 # if NEED_PRINTF_DOUBLE || a.arg[dp->arg_index].type == TYPE_DOUBLE # elif NEED_PRINTF_INFINITE_DOUBLE || (a.arg[dp->arg_index].type == TYPE_DOUBLE /* The systems (mingw) which produce wrong output for Inf, -Inf, and NaN also do so for -0.0. Therefore we treat this case here as well. */ && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double)) # endif # if NEED_PRINTF_LONG_DOUBLE || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE # elif NEED_PRINTF_INFINITE_LONG_DOUBLE || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE /* Some systems produce wrong output for Inf, -Inf, and NaN. Some systems in this category (IRIX 5.3) also do so for -0.0. Therefore we treat this case here as well. */ && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble)) # endif )) { # if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) arg_type type = a.arg[dp->arg_index].type; # endif int flags = dp->flags; size_t width; size_t count; int has_precision; size_t precision; size_t tmp_length; DCHAR_T tmpbuf[700]; DCHAR_T *tmp; DCHAR_T *pad_ptr; DCHAR_T *p; width = 0; if (dp->width_start != dp->width_end) { if (dp->width_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; width = -width; } } else { const FCHAR_T *digitp = dp->width_start; do width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } } has_precision = 0; precision = 0; if (dp->precision_start != dp->precision_end) { if (dp->precision_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->precision_arg_index].a.a_int; /* "A negative precision is taken as if the precision were omitted." */ if (arg >= 0) { precision = arg; has_precision = 1; } } else { const FCHAR_T *digitp = dp->precision_start + 1; precision = 0; while (digitp != dp->precision_end) precision = xsum (xtimes (precision, 10), *digitp++ - '0'); has_precision = 1; } } /* POSIX specifies the default precision to be 6 for %f, %F, %e, %E, but not for %g, %G. Implementations appear to use the same default precision also for %g, %G. But for %a, %A, the default precision is 0. */ if (!has_precision) if (!(dp->conversion == 'a' || dp->conversion == 'A')) precision = 6; /* Allocate a temporary buffer of sufficient size. */ # if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1); # elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0); # elif NEED_PRINTF_LONG_DOUBLE tmp_length = LDBL_DIG + 1; # elif NEED_PRINTF_DOUBLE tmp_length = DBL_DIG + 1; # else tmp_length = 0; # endif if (tmp_length < precision) tmp_length = precision; # if NEED_PRINTF_LONG_DOUBLE # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE if (type == TYPE_LONGDOUBLE) # endif if (dp->conversion == 'f' || dp->conversion == 'F') { long double arg = a.arg[dp->arg_index].a.a_longdouble; if (!(isnanl (arg) || arg + arg == arg)) { /* arg is finite and nonzero. */ int exponent = floorlog10l (arg < 0 ? -arg : arg); if (exponent >= 0 && tmp_length < exponent + precision) tmp_length = exponent + precision; } } # endif # if NEED_PRINTF_DOUBLE # if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE if (type == TYPE_DOUBLE) # endif if (dp->conversion == 'f' || dp->conversion == 'F') { double arg = a.arg[dp->arg_index].a.a_double; if (!(isnand (arg) || arg + arg == arg)) { /* arg is finite and nonzero. */ int exponent = floorlog10 (arg < 0 ? -arg : arg); if (exponent >= 0 && tmp_length < exponent + precision) tmp_length = exponent + precision; } } # endif /* Account for sign, decimal point etc. */ tmp_length = xsum (tmp_length, 12); if (tmp_length < width) tmp_length = width; tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) tmp = tmpbuf; else { size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); if (size_overflow_p (tmp_memsize)) /* Overflow, would lead to out of memory. */ goto out_of_memory; tmp = (DCHAR_T *) malloc (tmp_memsize); if (tmp == NULL) /* Out of memory. */ goto out_of_memory; } pad_ptr = NULL; p = tmp; # if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE if (type == TYPE_LONGDOUBLE) # endif { long double arg = a.arg[dp->arg_index].a.a_longdouble; if (isnanl (arg)) { if (dp->conversion >= 'A' && dp->conversion <= 'Z') { *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; } else { *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; } } else { int sign = 0; DECL_LONG_DOUBLE_ROUNDING BEGIN_LONG_DOUBLE_ROUNDING (); if (signbit (arg)) /* arg < 0.0L or negative zero */ { sign = -1; arg = -arg; } if (sign < 0) *p++ = '-'; else if (flags & FLAG_SHOWSIGN) *p++ = '+'; else if (flags & FLAG_SPACE) *p++ = ' '; if (arg > 0.0L && arg + arg == arg) { if (dp->conversion >= 'A' && dp->conversion <= 'Z') { *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; } else { *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; } } else { # if NEED_PRINTF_LONG_DOUBLE pad_ptr = p; if (dp->conversion == 'f' || dp->conversion == 'F') { char *digits; size_t ndigits; digits = scale10_round_decimal_long_double (arg, precision); if (digits == NULL) { END_LONG_DOUBLE_ROUNDING (); goto out_of_memory; } ndigits = strlen (digits); if (ndigits > precision) do { --ndigits; *p++ = digits[ndigits]; } while (ndigits > precision); else *p++ = '0'; /* Here ndigits <= precision. */ if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > ndigits; precision--) *p++ = '0'; while (ndigits > 0) { --ndigits; *p++ = digits[ndigits]; } } free (digits); } else if (dp->conversion == 'e' || dp->conversion == 'E') { int exponent; if (arg == 0.0L) { exponent = 0; *p++ = '0'; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > 0; precision--) *p++ = '0'; } } else { /* arg > 0.0L. */ int adjusted; char *digits; size_t ndigits; exponent = floorlog10l (arg); adjusted = 0; for (;;) { digits = scale10_round_decimal_long_double (arg, (int)precision - exponent); if (digits == NULL) { END_LONG_DOUBLE_ROUNDING (); goto out_of_memory; } ndigits = strlen (digits); if (ndigits == precision + 1) break; if (ndigits < precision || ndigits > precision + 2) /* The exponent was not guessed precisely enough. */ abort (); if (adjusted) /* None of two values of exponent is the right one. Prevent an endless loop. */ abort (); free (digits); if (ndigits == precision) exponent -= 1; else exponent += 1; adjusted = 1; } /* Here ndigits = precision+1. */ if (is_borderline (digits, precision)) { /* Maybe the exponent guess was too high and a smaller exponent can be reached by turning a 10...0 into 9...9x. */ char *digits2 = scale10_round_decimal_long_double (arg, (int)precision - exponent + 1); if (digits2 == NULL) { free (digits); END_LONG_DOUBLE_ROUNDING (); goto out_of_memory; } if (strlen (digits2) == precision + 1) { free (digits); digits = digits2; exponent -= 1; } else free (digits2); } /* Here ndigits = precision+1. */ *p++ = digits[--ndigits]; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); while (ndigits > 0) { --ndigits; *p++ = digits[ndigits]; } } free (digits); } *p++ = dp->conversion; /* 'e' or 'E' */ # if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = { '%', '+', '.', '2', 'd', '\0' }; SNPRINTF (p, 6 + 1, decimal_format, exponent); } while (*p != '\0') p++; # else if (sizeof (DCHAR_T) == 1) { sprintf ((char *) p, "%+.2d", exponent); while (*p != '\0') p++; } else { char expbuf[6 + 1]; const char *ep; sprintf (expbuf, "%+.2d", exponent); for (ep = expbuf; (*p = *ep) != '\0'; ep++) p++; } # endif } else if (dp->conversion == 'g' || dp->conversion == 'G') { if (precision == 0) precision = 1; /* precision >= 1. */ if (arg == 0.0L) /* The exponent is 0, >= -4, < precision. Use fixed-point notation. */ { size_t ndigits = precision; /* Number of trailing zeroes that have to be dropped. */ size_t nzeroes = (flags & FLAG_ALT ? 0 : precision - 1); --ndigits; *p++ = '0'; if ((flags & FLAG_ALT) || ndigits > nzeroes) { *p++ = decimal_point_char (); while (ndigits > nzeroes) { --ndigits; *p++ = '0'; } } } else { /* arg > 0.0L. */ int exponent; int adjusted; char *digits; size_t ndigits; size_t nzeroes; exponent = floorlog10l (arg); adjusted = 0; for (;;) { digits = scale10_round_decimal_long_double (arg, (int)(precision - 1) - exponent); if (digits == NULL) { END_LONG_DOUBLE_ROUNDING (); goto out_of_memory; } ndigits = strlen (digits); if (ndigits == precision) break; if (ndigits < precision - 1 || ndigits > precision + 1) /* The exponent was not guessed precisely enough. */ abort (); if (adjusted) /* None of two values of exponent is the right one. Prevent an endless loop. */ abort (); free (digits); if (ndigits < precision) exponent -= 1; else exponent += 1; adjusted = 1; } /* Here ndigits = precision. */ if (is_borderline (digits, precision - 1)) { /* Maybe the exponent guess was too high and a smaller exponent can be reached by turning a 10...0 into 9...9x. */ char *digits2 = scale10_round_decimal_long_double (arg, (int)(precision - 1) - exponent + 1); if (digits2 == NULL) { free (digits); END_LONG_DOUBLE_ROUNDING (); goto out_of_memory; } if (strlen (digits2) == precision) { free (digits); digits = digits2; exponent -= 1; } else free (digits2); } /* Here ndigits = precision. */ /* Determine the number of trailing zeroes that have to be dropped. */ nzeroes = 0; if ((flags & FLAG_ALT) == 0) while (nzeroes < ndigits && digits[nzeroes] == '0') nzeroes++; /* The exponent is now determined. */ if (exponent >= -4 && exponent < (long)precision) { /* Fixed-point notation: max(exponent,0)+1 digits, then the decimal point, then the remaining digits without trailing zeroes. */ if (exponent >= 0) { size_t ecount = exponent + 1; /* Note: count <= precision = ndigits. */ for (; ecount > 0; ecount--) *p++ = digits[--ndigits]; if ((flags & FLAG_ALT) || ndigits > nzeroes) { *p++ = decimal_point_char (); while (ndigits > nzeroes) { --ndigits; *p++ = digits[ndigits]; } } } else { size_t ecount = -exponent - 1; *p++ = '0'; *p++ = decimal_point_char (); for (; ecount > 0; ecount--) *p++ = '0'; while (ndigits > nzeroes) { --ndigits; *p++ = digits[ndigits]; } } } else { /* Exponential notation. */ *p++ = digits[--ndigits]; if ((flags & FLAG_ALT) || ndigits > nzeroes) { *p++ = decimal_point_char (); while (ndigits > nzeroes) { --ndigits; *p++ = digits[ndigits]; } } *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ # if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = { '%', '+', '.', '2', 'd', '\0' }; SNPRINTF (p, 6 + 1, decimal_format, exponent); } while (*p != '\0') p++; # else if (sizeof (DCHAR_T) == 1) { sprintf ((char *) p, "%+.2d", exponent); while (*p != '\0') p++; } else { char expbuf[6 + 1]; const char *ep; sprintf (expbuf, "%+.2d", exponent); for (ep = expbuf; (*p = *ep) != '\0'; ep++) p++; } # endif } free (digits); } } else abort (); # else /* arg is finite. */ if (!(arg == 0.0L)) abort (); pad_ptr = p; if (dp->conversion == 'f' || dp->conversion == 'F') { *p++ = '0'; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > 0; precision--) *p++ = '0'; } } else if (dp->conversion == 'e' || dp->conversion == 'E') { *p++ = '0'; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > 0; precision--) *p++ = '0'; } *p++ = dp->conversion; /* 'e' or 'E' */ *p++ = '+'; *p++ = '0'; *p++ = '0'; } else if (dp->conversion == 'g' || dp->conversion == 'G') { *p++ = '0'; if (flags & FLAG_ALT) { size_t ndigits = (precision > 0 ? precision - 1 : 0); *p++ = decimal_point_char (); for (; ndigits > 0; --ndigits) *p++ = '0'; } } else if (dp->conversion == 'a' || dp->conversion == 'A') { *p++ = '0'; *p++ = dp->conversion - 'A' + 'X'; pad_ptr = p; *p++ = '0'; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > 0; precision--) *p++ = '0'; } *p++ = dp->conversion - 'A' + 'P'; *p++ = '+'; *p++ = '0'; } else abort (); # endif } END_LONG_DOUBLE_ROUNDING (); } } # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE else # endif # endif # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE { double arg = a.arg[dp->arg_index].a.a_double; if (isnand (arg)) { if (dp->conversion >= 'A' && dp->conversion <= 'Z') { *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; } else { *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; } } else { int sign = 0; if (signbit (arg)) /* arg < 0.0 or negative zero */ { sign = -1; arg = -arg; } if (sign < 0) *p++ = '-'; else if (flags & FLAG_SHOWSIGN) *p++ = '+'; else if (flags & FLAG_SPACE) *p++ = ' '; if (arg > 0.0 && arg + arg == arg) { if (dp->conversion >= 'A' && dp->conversion <= 'Z') { *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; } else { *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; } } else { # if NEED_PRINTF_DOUBLE pad_ptr = p; if (dp->conversion == 'f' || dp->conversion == 'F') { char *digits; size_t ndigits; digits = scale10_round_decimal_double (arg, precision); if (digits == NULL) goto out_of_memory; ndigits = strlen (digits); if (ndigits > precision) do { --ndigits; *p++ = digits[ndigits]; } while (ndigits > precision); else *p++ = '0'; /* Here ndigits <= precision. */ if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > ndigits; precision--) *p++ = '0'; while (ndigits > 0) { --ndigits; *p++ = digits[ndigits]; } } free (digits); } else if (dp->conversion == 'e' || dp->conversion == 'E') { int exponent; if (arg == 0.0) { exponent = 0; *p++ = '0'; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > 0; precision--) *p++ = '0'; } } else { /* arg > 0.0. */ int adjusted; char *digits; size_t ndigits; exponent = floorlog10 (arg); adjusted = 0; for (;;) { digits = scale10_round_decimal_double (arg, (int)precision - exponent); if (digits == NULL) goto out_of_memory; ndigits = strlen (digits); if (ndigits == precision + 1) break; if (ndigits < precision || ndigits > precision + 2) /* The exponent was not guessed precisely enough. */ abort (); if (adjusted) /* None of two values of exponent is the right one. Prevent an endless loop. */ abort (); free (digits); if (ndigits == precision) exponent -= 1; else exponent += 1; adjusted = 1; } /* Here ndigits = precision+1. */ if (is_borderline (digits, precision)) { /* Maybe the exponent guess was too high and a smaller exponent can be reached by turning a 10...0 into 9...9x. */ char *digits2 = scale10_round_decimal_double (arg, (int)precision - exponent + 1); if (digits2 == NULL) { free (digits); goto out_of_memory; } if (strlen (digits2) == precision + 1) { free (digits); digits = digits2; exponent -= 1; } else free (digits2); } /* Here ndigits = precision+1. */ *p++ = digits[--ndigits]; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); while (ndigits > 0) { --ndigits; *p++ = digits[ndigits]; } } free (digits); } *p++ = dp->conversion; /* 'e' or 'E' */ # if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = /* Produce the same number of exponent digits as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ { '%', '+', '.', '3', 'd', '\0' }; # else { '%', '+', '.', '2', 'd', '\0' }; # endif SNPRINTF (p, 6 + 1, decimal_format, exponent); } while (*p != '\0') p++; # else { static const char decimal_format[] = /* Produce the same number of exponent digits as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ "%+.3d"; # else "%+.2d"; # endif if (sizeof (DCHAR_T) == 1) { sprintf ((char *) p, decimal_format, exponent); while (*p != '\0') p++; } else { char expbuf[6 + 1]; const char *ep; sprintf (expbuf, decimal_format, exponent); for (ep = expbuf; (*p = *ep) != '\0'; ep++) p++; } } # endif } else if (dp->conversion == 'g' || dp->conversion == 'G') { if (precision == 0) precision = 1; /* precision >= 1. */ if (arg == 0.0) /* The exponent is 0, >= -4, < precision. Use fixed-point notation. */ { size_t ndigits = precision; /* Number of trailing zeroes that have to be dropped. */ size_t nzeroes = (flags & FLAG_ALT ? 0 : precision - 1); --ndigits; *p++ = '0'; if ((flags & FLAG_ALT) || ndigits > nzeroes) { *p++ = decimal_point_char (); while (ndigits > nzeroes) { --ndigits; *p++ = '0'; } } } else { /* arg > 0.0. */ int exponent; int adjusted; char *digits; size_t ndigits; size_t nzeroes; exponent = floorlog10 (arg); adjusted = 0; for (;;) { digits = scale10_round_decimal_double (arg, (int)(precision - 1) - exponent); if (digits == NULL) goto out_of_memory; ndigits = strlen (digits); if (ndigits == precision) break; if (ndigits < precision - 1 || ndigits > precision + 1) /* The exponent was not guessed precisely enough. */ abort (); if (adjusted) /* None of two values of exponent is the right one. Prevent an endless loop. */ abort (); free (digits); if (ndigits < precision) exponent -= 1; else exponent += 1; adjusted = 1; } /* Here ndigits = precision. */ if (is_borderline (digits, precision - 1)) { /* Maybe the exponent guess was too high and a smaller exponent can be reached by turning a 10...0 into 9...9x. */ char *digits2 = scale10_round_decimal_double (arg, (int)(precision - 1) - exponent + 1); if (digits2 == NULL) { free (digits); goto out_of_memory; } if (strlen (digits2) == precision) { free (digits); digits = digits2; exponent -= 1; } else free (digits2); } /* Here ndigits = precision. */ /* Determine the number of trailing zeroes that have to be dropped. */ nzeroes = 0; if ((flags & FLAG_ALT) == 0) while (nzeroes < ndigits && digits[nzeroes] == '0') nzeroes++; /* The exponent is now determined. */ if (exponent >= -4 && exponent < (long)precision) { /* Fixed-point notation: max(exponent,0)+1 digits, then the decimal point, then the remaining digits without trailing zeroes. */ if (exponent >= 0) { size_t ecount = exponent + 1; /* Note: ecount <= precision = ndigits. */ for (; ecount > 0; ecount--) *p++ = digits[--ndigits]; if ((flags & FLAG_ALT) || ndigits > nzeroes) { *p++ = decimal_point_char (); while (ndigits > nzeroes) { --ndigits; *p++ = digits[ndigits]; } } } else { size_t ecount = -exponent - 1; *p++ = '0'; *p++ = decimal_point_char (); for (; ecount > 0; ecount--) *p++ = '0'; while (ndigits > nzeroes) { --ndigits; *p++ = digits[ndigits]; } } } else { /* Exponential notation. */ *p++ = digits[--ndigits]; if ((flags & FLAG_ALT) || ndigits > nzeroes) { *p++ = decimal_point_char (); while (ndigits > nzeroes) { --ndigits; *p++ = digits[ndigits]; } } *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ # if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = /* Produce the same number of exponent digits as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ { '%', '+', '.', '3', 'd', '\0' }; # else { '%', '+', '.', '2', 'd', '\0' }; # endif SNPRINTF (p, 6 + 1, decimal_format, exponent); } while (*p != '\0') p++; # else { static const char decimal_format[] = /* Produce the same number of exponent digits as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ "%+.3d"; # else "%+.2d"; # endif if (sizeof (DCHAR_T) == 1) { sprintf ((char *) p, decimal_format, exponent); while (*p != '\0') p++; } else { char expbuf[6 + 1]; const char *ep; sprintf (expbuf, decimal_format, exponent); for (ep = expbuf; (*p = *ep) != '\0'; ep++) p++; } } # endif } free (digits); } } else abort (); # else /* arg is finite. */ if (!(arg == 0.0)) abort (); pad_ptr = p; if (dp->conversion == 'f' || dp->conversion == 'F') { *p++ = '0'; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > 0; precision--) *p++ = '0'; } } else if (dp->conversion == 'e' || dp->conversion == 'E') { *p++ = '0'; if ((flags & FLAG_ALT) || precision > 0) { *p++ = decimal_point_char (); for (; precision > 0; precision--) *p++ = '0'; } *p++ = dp->conversion; /* 'e' or 'E' */ *p++ = '+'; /* Produce the same number of exponent digits as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ *p++ = '0'; # endif *p++ = '0'; *p++ = '0'; } else if (dp->conversion == 'g' || dp->conversion == 'G') { *p++ = '0'; if (flags & FLAG_ALT) { size_t ndigits = (precision > 0 ? precision - 1 : 0); *p++ = decimal_point_char (); for (; ndigits > 0; --ndigits) *p++ = '0'; } } else abort (); # endif } } } # endif /* The generated string now extends from tmp to p, with the zero padding insertion point being at pad_ptr. */ count = p - tmp; if (count < width) { size_t pad = width - count; DCHAR_T *end = p + pad; if (flags & FLAG_LEFT) { /* Pad with spaces on the right. */ for (; pad > 0; pad--) *p++ = ' '; } else if ((flags & FLAG_ZERO) && pad_ptr != NULL) { /* Pad with zeroes. */ DCHAR_T *q = end; while (p > pad_ptr) *--q = *--p; for (; pad > 0; pad--) *p++ = '0'; } else { /* Pad with spaces on the left. */ DCHAR_T *q = end; while (p > tmp) *--q = *--p; for (; pad > 0; pad--) *p++ = ' '; } p = end; } count = p - tmp; if (count >= tmp_length) /* tmp_length was incorrectly calculated - fix the code above! */ abort (); /* Make room for the result. */ if (count >= allocated - length) { size_t n = xsum (length, count); ENSURE_ALLOCATION (n); } /* Append the result. */ memcpy (result + length, tmp, count * sizeof (DCHAR_T)); if (tmp != tmpbuf) free (tmp); length += count; } #endif else { arg_type type = a.arg[dp->arg_index].type; int flags = dp->flags; #if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION int has_width; #endif #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION size_t width; #endif #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION int has_precision; size_t precision; #endif #if NEED_PRINTF_UNBOUNDED_PRECISION int prec_ourselves; #else # define prec_ourselves 0 #endif #if NEED_PRINTF_FLAG_LEFTADJUST # define pad_ourselves 1 #elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION int pad_ourselves; #else # define pad_ourselves 0 #endif TCHAR_T *fbp; unsigned int prefix_count; int prefixes[2] IF_LINT (= { 0 }); int orig_errno; #if !USE_SNPRINTF size_t tmp_length; TCHAR_T tmpbuf[700]; TCHAR_T *tmp; #endif #if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION has_width = 0; #endif #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION width = 0; if (dp->width_start != dp->width_end) { if (dp->width_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->width_arg_index].a.a_int; width = arg; if (arg < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ flags |= FLAG_LEFT; width = -width; } } else { const FCHAR_T *digitp = dp->width_start; do width = xsum (xtimes (width, 10), *digitp++ - '0'); while (digitp != dp->width_end); } #if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION has_width = 1; #endif } #endif #if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION has_precision = 0; precision = 6; if (dp->precision_start != dp->precision_end) { if (dp->precision_arg_index != ARG_NONE) { int arg; if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) abort (); arg = a.arg[dp->precision_arg_index].a.a_int; /* "A negative precision is taken as if the precision were omitted." */ if (arg >= 0) { precision = arg; has_precision = 1; } } else { const FCHAR_T *digitp = dp->precision_start + 1; precision = 0; while (digitp != dp->precision_end) precision = xsum (xtimes (precision, 10), *digitp++ - '0'); has_precision = 1; } } #endif /* Decide whether to handle the precision ourselves. */ #if NEED_PRINTF_UNBOUNDED_PRECISION switch (dp->conversion) { case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': prec_ourselves = has_precision && (precision > 0); break; default: prec_ourselves = 0; break; } #endif /* Decide whether to perform the padding ourselves. */ #if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) switch (dp->conversion) { # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need to perform the padding after this conversion. Functions with unistdio extensions perform the padding based on character count rather than element count. */ case 'c': case 's': # endif # if NEED_PRINTF_FLAG_ZERO case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': case 'a': case 'A': # endif pad_ourselves = 1; break; default: pad_ourselves = prec_ourselves; break; } #endif #if !USE_SNPRINTF /* Allocate a temporary buffer of sufficient size for calling sprintf. */ tmp_length = MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type, flags, width, has_precision, precision, pad_ourselves); if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) tmp = tmpbuf; else { size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T)); if (size_overflow_p (tmp_memsize)) /* Overflow, would lead to out of memory. */ goto out_of_memory; tmp = (TCHAR_T *) malloc (tmp_memsize); if (tmp == NULL) /* Out of memory. */ goto out_of_memory; } #endif /* Construct the format string for calling snprintf or sprintf. */ fbp = buf; *fbp++ = '%'; #if NEED_PRINTF_FLAG_GROUPING /* The underlying implementation doesn't support the ' flag. Produce no grouping characters in this case; this is acceptable because the grouping is locale dependent. */ #else if (flags & FLAG_GROUP) *fbp++ = '\''; #endif if (flags & FLAG_LEFT) *fbp++ = '-'; if (flags & FLAG_SHOWSIGN) *fbp++ = '+'; if (flags & FLAG_SPACE) *fbp++ = ' '; if (flags & FLAG_ALT) *fbp++ = '#'; #if __GLIBC__ >= 2 && !defined __UCLIBC__ if (flags & FLAG_LOCALIZED) *fbp++ = 'I'; #endif if (!pad_ourselves) { if (flags & FLAG_ZERO) *fbp++ = '0'; if (dp->width_start != dp->width_end) { size_t n = dp->width_end - dp->width_start; /* The width specification is known to consist only of standard ASCII characters. */ if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) { memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T)); fbp += n; } else { const FCHAR_T *mp = dp->width_start; do *fbp++ = *mp++; while (--n > 0); } } } if (!prec_ourselves) { if (dp->precision_start != dp->precision_end) { size_t n = dp->precision_end - dp->precision_start; /* The precision specification is known to consist only of standard ASCII characters. */ if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) { memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T)); fbp += n; } else { const FCHAR_T *mp = dp->precision_start; do *fbp++ = *mp++; while (--n > 0); } } } switch (type) { #if HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: case TYPE_ULONGLONGINT: # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ *fbp++ = 'I'; *fbp++ = '6'; *fbp++ = '4'; break; # else *fbp++ = 'l'; /*FALLTHROUGH*/ # endif #endif case TYPE_LONGINT: case TYPE_ULONGINT: #if HAVE_WINT_T case TYPE_WIDE_CHAR: #endif #if HAVE_WCHAR_T case TYPE_WIDE_STRING: #endif *fbp++ = 'l'; break; case TYPE_LONGDOUBLE: *fbp++ = 'L'; break; default: break; } #if NEED_PRINTF_DIRECTIVE_F if (dp->conversion == 'F') *fbp = 'f'; else #endif *fbp = dp->conversion; #if USE_SNPRINTF # if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) fbp[1] = '%'; fbp[2] = 'n'; fbp[3] = '\0'; # else /* On glibc2 systems from glibc >= 2.3 - probably also older ones - we know that snprintf's return value conforms to ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and gl_SNPRINTF_TRUNCATION_C99 pass. Therefore we can avoid using %n in this situation. On glibc2 systems from 2004-10-18 or newer, the use of %n in format strings in writable memory may crash the program (if compiled with _FORTIFY_SOURCE=2), so we should avoid it in this situation. */ /* On native Windows systems (such as mingw), we can avoid using %n because: - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, snprintf does not write more than the specified number of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes '4', '5', '6' into buf, not '4', '5', '\0'.) - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf allows us to recognize the case of an insufficient buffer size: it returns -1 in this case. On native Windows systems (such as mingw) where the OS is Windows Vista, the use of %n in format strings by default crashes the program. See and So we should avoid %n in this situation. */ fbp[1] = '\0'; # endif #else fbp[1] = '\0'; #endif /* Construct the arguments for calling snprintf or sprintf. */ prefix_count = 0; if (!pad_ourselves && dp->width_arg_index != ARG_NONE) { if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) abort (); prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int; } if (!prec_ourselves && dp->precision_arg_index != ARG_NONE) { if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) abort (); prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int; } #if USE_SNPRINTF /* The SNPRINTF result is appended after result[0..length]. The latter is an array of DCHAR_T; SNPRINTF appends an array of TCHAR_T to it. This is possible because sizeof (TCHAR_T) divides sizeof (DCHAR_T) and alignof (TCHAR_T) <= alignof (DCHAR_T). */ # define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T)) /* Ensure that maxlen below will be >= 2. Needed on BeOS, where an snprintf() with maxlen==1 acts like sprintf(). */ ENSURE_ALLOCATION (xsum (length, (2 + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR)); /* Prepare checking whether snprintf returns the count via %n. */ *(TCHAR_T *) (result + length) = '\0'; #endif orig_errno = errno; for (;;) { int count = -1; #if USE_SNPRINTF int retcount = 0; size_t maxlen = allocated - length; /* SNPRINTF can fail if its second argument is > INT_MAX. */ if (maxlen > INT_MAX / TCHARS_PER_DCHAR) maxlen = INT_MAX / TCHARS_PER_DCHAR; maxlen = maxlen * TCHARS_PER_DCHAR; # define SNPRINTF_BUF(arg) \ switch (prefix_count) \ { \ case 0: \ retcount = SNPRINTF ((TCHAR_T *) (result + length), \ maxlen, buf, \ arg, &count); \ break; \ case 1: \ retcount = SNPRINTF ((TCHAR_T *) (result + length), \ maxlen, buf, \ prefixes[0], arg, &count); \ break; \ case 2: \ retcount = SNPRINTF ((TCHAR_T *) (result + length), \ maxlen, buf, \ prefixes[0], prefixes[1], arg, \ &count); \ break; \ default: \ abort (); \ } #else # define SNPRINTF_BUF(arg) \ switch (prefix_count) \ { \ case 0: \ count = sprintf (tmp, buf, arg); \ break; \ case 1: \ count = sprintf (tmp, buf, prefixes[0], arg); \ break; \ case 2: \ count = sprintf (tmp, buf, prefixes[0], prefixes[1],\ arg); \ break; \ default: \ abort (); \ } #endif errno = 0; switch (type) { case TYPE_SCHAR: { int arg = a.arg[dp->arg_index].a.a_schar; SNPRINTF_BUF (arg); } break; case TYPE_UCHAR: { unsigned int arg = a.arg[dp->arg_index].a.a_uchar; SNPRINTF_BUF (arg); } break; case TYPE_SHORT: { int arg = a.arg[dp->arg_index].a.a_short; SNPRINTF_BUF (arg); } break; case TYPE_USHORT: { unsigned int arg = a.arg[dp->arg_index].a.a_ushort; SNPRINTF_BUF (arg); } break; case TYPE_INT: { int arg = a.arg[dp->arg_index].a.a_int; SNPRINTF_BUF (arg); } break; case TYPE_UINT: { unsigned int arg = a.arg[dp->arg_index].a.a_uint; SNPRINTF_BUF (arg); } break; case TYPE_LONGINT: { long int arg = a.arg[dp->arg_index].a.a_longint; SNPRINTF_BUF (arg); } break; case TYPE_ULONGINT: { unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint; SNPRINTF_BUF (arg); } break; #if HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: { long long int arg = a.arg[dp->arg_index].a.a_longlongint; SNPRINTF_BUF (arg); } break; case TYPE_ULONGLONGINT: { unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint; SNPRINTF_BUF (arg); } break; #endif case TYPE_DOUBLE: { double arg = a.arg[dp->arg_index].a.a_double; SNPRINTF_BUF (arg); } break; case TYPE_LONGDOUBLE: { long double arg = a.arg[dp->arg_index].a.a_longdouble; SNPRINTF_BUF (arg); } break; case TYPE_CHAR: { int arg = a.arg[dp->arg_index].a.a_char; SNPRINTF_BUF (arg); } break; #if HAVE_WINT_T case TYPE_WIDE_CHAR: { wint_t arg = a.arg[dp->arg_index].a.a_wide_char; SNPRINTF_BUF (arg); } break; #endif case TYPE_STRING: { const char *arg = a.arg[dp->arg_index].a.a_string; SNPRINTF_BUF (arg); } break; #if HAVE_WCHAR_T case TYPE_WIDE_STRING: { const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; SNPRINTF_BUF (arg); } break; #endif case TYPE_POINTER: { void *arg = a.arg[dp->arg_index].a.a_pointer; SNPRINTF_BUF (arg); } break; default: abort (); } #if USE_SNPRINTF /* Portability: Not all implementations of snprintf() are ISO C 99 compliant. Determine the number of bytes that snprintf() has produced or would have produced. */ if (count >= 0) { /* Verify that snprintf() has NUL-terminated its result. */ if (count < maxlen && ((TCHAR_T *) (result + length)) [count] != '\0') abort (); /* Portability hack. */ if (retcount > count) count = retcount; } else { /* snprintf() doesn't understand the '%n' directive. */ if (fbp[1] != '\0') { /* Don't use the '%n' directive; instead, look at the snprintf() return value. */ fbp[1] = '\0'; continue; } else { /* Look at the snprintf() return value. */ if (retcount < 0) { # if !HAVE_SNPRINTF_RETVAL_C99 /* HP-UX 10.20 snprintf() is doubly deficient: It doesn't understand the '%n' directive, *and* it returns -1 (rather than the length that would have been required) when the buffer is too small. But a failure at this point can also come from other reasons than a too small buffer, such as an invalid wide string argument to the %ls directive, or possibly an invalid floating-point argument. */ size_t tmp_length = MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type, flags, width, has_precision, precision, pad_ourselves); if (maxlen < tmp_length) { /* Make more room. But try to do through this reallocation only once. */ size_t bigger_need = xsum (length, xsum (tmp_length, TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR); /* And always grow proportionally. (There may be several arguments, each needing a little more room than the previous one.) */ size_t bigger_need2 = xsum (xtimes (allocated, 2), 12); if (bigger_need < bigger_need2) bigger_need = bigger_need2; ENSURE_ALLOCATION (bigger_need); continue; } # endif } else count = retcount; } } #endif /* Attempt to handle failure. */ if (count < 0) { /* SNPRINTF or sprintf failed. Save and use the errno that it has set, if any. */ int saved_errno = errno; if (saved_errno == 0) { if (dp->conversion == 'c' || dp->conversion == 's') saved_errno = EILSEQ; else saved_errno = EINVAL; } if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = saved_errno; return NULL; } #if USE_SNPRINTF /* Handle overflow of the allocated buffer. If such an overflow occurs, a C99 compliant snprintf() returns a count >= maxlen. However, a non-compliant snprintf() function returns only count = maxlen - 1. To cover both cases, test whether count >= maxlen - 1. */ if ((unsigned int) count + 1 >= maxlen) { /* If maxlen already has attained its allowed maximum, allocating more memory will not increase maxlen. Instead of looping, bail out. */ if (maxlen == INT_MAX / TCHARS_PER_DCHAR) goto overflow; else { /* Need at least (count + 1) * sizeof (TCHAR_T) bytes. (The +1 is for the trailing NUL.) But ask for (count + 2) * sizeof (TCHAR_T) bytes, so that in the next round, we likely get maxlen > (unsigned int) count + 1 and so we don't get here again. And allocate proportionally, to avoid looping eternally if snprintf() reports a too small count. */ size_t n = xmax (xsum (length, ((unsigned int) count + 2 + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR), xtimes (allocated, 2)); ENSURE_ALLOCATION (n); continue; } } #endif #if NEED_PRINTF_UNBOUNDED_PRECISION if (prec_ourselves) { /* Handle the precision. */ TCHAR_T *prec_ptr = # if USE_SNPRINTF (TCHAR_T *) (result + length); # else tmp; # endif size_t prefix_count; size_t move; prefix_count = 0; /* Put the additional zeroes after the sign. */ if (count >= 1 && (*prec_ptr == '-' || *prec_ptr == '+' || *prec_ptr == ' ')) prefix_count = 1; /* Put the additional zeroes after the 0x prefix if (flags & FLAG_ALT) || (dp->conversion == 'p'). */ else if (count >= 2 && prec_ptr[0] == '0' && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X')) prefix_count = 2; move = count - prefix_count; if (precision > move) { /* Insert zeroes. */ size_t insert = precision - move; TCHAR_T *prec_end; # if USE_SNPRINTF size_t n = xsum (length, (count + insert + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR); length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; ENSURE_ALLOCATION (n); length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; prec_ptr = (TCHAR_T *) (result + length); # endif prec_end = prec_ptr + count; prec_ptr += prefix_count; while (prec_end > prec_ptr) { prec_end--; prec_end[insert] = prec_end[0]; } prec_end += insert; do *--prec_end = '0'; while (prec_end > prec_ptr); count += insert; } } #endif #if !USE_SNPRINTF if (count >= tmp_length) /* tmp_length was incorrectly calculated - fix the code above! */ abort (); #endif #if !DCHAR_IS_TCHAR /* Convert from TCHAR_T[] to DCHAR_T[]. */ if (dp->conversion == 'c' || dp->conversion == 's') { /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING TYPE_WIDE_STRING. The result string is not certainly ASCII. */ const TCHAR_T *tmpsrc; DCHAR_T *tmpdst; size_t tmpdst_len; /* This code assumes that TCHAR_T is 'char'. */ verify (sizeof (TCHAR_T) == 1); # if USE_SNPRINTF tmpsrc = (TCHAR_T *) (result + length); # else tmpsrc = tmp; # endif tmpdst = DCHAR_CONV_FROM_ENCODING (locale_charset (), iconveh_question_mark, tmpsrc, count, NULL, NULL, &tmpdst_len); if (tmpdst == NULL) { int saved_errno = errno; if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = saved_errno; return NULL; } ENSURE_ALLOCATION (xsum (length, tmpdst_len)); DCHAR_CPY (result + length, tmpdst, tmpdst_len); free (tmpdst); count = tmpdst_len; } else { /* The result string is ASCII. Simple 1:1 conversion. */ # if USE_SNPRINTF /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a no-op conversion, in-place on the array starting at (result + length). */ if (sizeof (DCHAR_T) != sizeof (TCHAR_T)) # endif { const TCHAR_T *tmpsrc; DCHAR_T *tmpdst; size_t n; # if USE_SNPRINTF if (result == resultbuf) { tmpsrc = (TCHAR_T *) (result + length); /* ENSURE_ALLOCATION will not move tmpsrc (because it's part of resultbuf). */ ENSURE_ALLOCATION (xsum (length, count)); } else { /* ENSURE_ALLOCATION will move the array (because it uses realloc(). */ ENSURE_ALLOCATION (xsum (length, count)); tmpsrc = (TCHAR_T *) (result + length); } # else tmpsrc = tmp; ENSURE_ALLOCATION (xsum (length, count)); # endif tmpdst = result + length; /* Copy backwards, because of overlapping. */ tmpsrc += count; tmpdst += count; for (n = count; n > 0; n--) *--tmpdst = *--tmpsrc; } } #endif #if DCHAR_IS_TCHAR && !USE_SNPRINTF /* Make room for the result. */ if (count > allocated - length) { /* Need at least count elements. But allocate proportionally. */ size_t n = xmax (xsum (length, count), xtimes (allocated, 2)); ENSURE_ALLOCATION (n); } #endif /* Here count <= allocated - length. */ /* Perform padding. */ #if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION if (pad_ourselves && has_width) { size_t w; # if ENABLE_UNISTDIO /* Outside POSIX, it's preferable to compare the width against the number of _characters_ of the converted value. */ w = DCHAR_MBSNLEN (result + length, count); # else /* The width is compared against the number of _bytes_ of the converted value, says POSIX. */ w = count; # endif if (w < width) { size_t pad = width - w; /* Make room for the result. */ if (xsum (count, pad) > allocated - length) { /* Need at least count + pad elements. But allocate proportionally. */ size_t n = xmax (xsum3 (length, count, pad), xtimes (allocated, 2)); # if USE_SNPRINTF length += count; ENSURE_ALLOCATION (n); length -= count; # else ENSURE_ALLOCATION (n); # endif } /* Here count + pad <= allocated - length. */ { # if !DCHAR_IS_TCHAR || USE_SNPRINTF DCHAR_T * const rp = result + length; # else DCHAR_T * const rp = tmp; # endif DCHAR_T *p = rp + count; DCHAR_T *end = p + pad; DCHAR_T *pad_ptr; # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO if (dp->conversion == 'c' || dp->conversion == 's') /* No zero-padding for string directives. */ pad_ptr = NULL; else # endif { pad_ptr = (*rp == '-' ? rp + 1 : rp); /* No zero-padding of "inf" and "nan". */ if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z') || (*pad_ptr >= 'a' && *pad_ptr <= 'z')) pad_ptr = NULL; } /* The generated string now extends from rp to p, with the zero padding insertion point being at pad_ptr. */ count = count + pad; /* = end - rp */ if (flags & FLAG_LEFT) { /* Pad with spaces on the right. */ for (; pad > 0; pad--) *p++ = ' '; } else if ((flags & FLAG_ZERO) && pad_ptr != NULL) { /* Pad with zeroes. */ DCHAR_T *q = end; while (p > pad_ptr) *--q = *--p; for (; pad > 0; pad--) *p++ = '0'; } else { /* Pad with spaces on the left. */ DCHAR_T *q = end; while (p > rp) *--q = *--p; for (; pad > 0; pad--) *p++ = ' '; } } } } #endif /* Here still count <= allocated - length. */ #if !DCHAR_IS_TCHAR || USE_SNPRINTF /* The snprintf() result did fit. */ #else /* Append the sprintf() result. */ memcpy (result + length, tmp, count * sizeof (DCHAR_T)); #endif #if !USE_SNPRINTF if (tmp != tmpbuf) free (tmp); #endif #if NEED_PRINTF_DIRECTIVE_F if (dp->conversion == 'F') { /* Convert the %f result to upper case for %F. */ DCHAR_T *rp = result + length; size_t rc; for (rc = count; rc > 0; rc--, rp++) if (*rp >= 'a' && *rp <= 'z') *rp = *rp - 'a' + 'A'; } #endif length += count; break; } errno = orig_errno; #undef pad_ourselves #undef prec_ourselves } } } /* Add the final NUL. */ ENSURE_ALLOCATION (xsum (length, 1)); result[length] = '\0'; if (result != resultbuf && length + 1 < allocated) { /* Shrink the allocated memory if possible. */ DCHAR_T *memory; memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T)); if (memory != NULL) result = memory; } if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); *lengthp = length; /* Note that we can produce a big string of a length > INT_MAX. POSIX says that snprintf() fails with errno = EOVERFLOW in this case, but that's only because snprintf() returns an 'int'. This function does not have this limitation. */ return result; #if USE_SNPRINTF overflow: if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); errno = EOVERFLOW; return NULL; #endif out_of_memory: if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); out_of_memory_1: CLEANUP (); errno = ENOMEM; return NULL; } } #undef MAX_ROOM_NEEDED #undef TCHARS_PER_DCHAR #undef SNPRINTF #undef USE_SNPRINTF #undef DCHAR_SET #undef DCHAR_CPY #undef PRINTF_PARSE #undef DIRECTIVES #undef DIRECTIVE #undef DCHAR_IS_TCHAR #undef TCHAR_T #undef DCHAR_T #undef FCHAR_T #undef VASNPRINTF lftp-4.6.3a/lib/mbsrtowcs.c0000644000015000007670000000175612466374011012525 00000000000000/* Convert string to wide string. Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. 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 . */ #include /* Specification. */ #include #include #include #include #include "strnlen1.h" extern mbstate_t _gl_mbsrtowcs_state; #include "mbsrtowcs-impl.h" lftp-4.6.3a/lib/signbitl.c0000644000015000007670000000414212466374012012306 00000000000000/* signbit() macro: Determine the sign bit of a floating-point number. Copyright (C) 2007, 2009-2015 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 . */ #include /* Specification. */ #include #include #include "isnanl-nolibm.h" #include "float+.h" #ifdef gl_signbitl_OPTIMIZED_MACRO # undef gl_signbitl #endif int gl_signbitl (long double arg) { #if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT /* The use of a union to extract the bits of the representation of a 'long double' is safe in practice, despite of the "aliasing rules" of C99, because the GCC docs say "Even with '-fstrict-aliasing', type-punning is allowed, provided the memory is accessed through the union type." and similarly for other compilers. */ # define NWORDS \ ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) union { long double value; unsigned int word[NWORDS]; } m; m.value = arg; return (m.word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; #elif HAVE_COPYSIGNL_IN_LIBC return copysignl (1.0L, arg) < 0; #else /* This does not do the right thing for NaN, but this is irrelevant for most use cases. */ if (isnanl (arg)) return 0; if (arg < 0.0L) return 1; else if (arg == 0.0L) { /* Distinguish 0.0L and -0.0L. */ static long double plus_zero = 0.0L; long double arg_mem = arg; return (memcmp (&plus_zero, &arg_mem, SIZEOF_LDBL) != 0); } else return 0; #endif } lftp-4.6.3a/lib/wcrtomb.c0000644000015000007670000000271512466374012012154 00000000000000/* Convert wide character to multibyte character. Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. 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 . */ #include /* Specification. */ #include #include #include size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps) { /* This implementation of wcrtomb on top of wctomb() supports only stateless encodings. ps must be in the initial state. */ if (ps != NULL && !mbsinit (ps)) { errno = EINVAL; return (size_t)(-1); } if (s == NULL) /* We know the NUL wide character corresponds to the NUL character. */ return 1; else { int ret = wctomb (s, wc); if (ret >= 0) return ret; else { errno = EILSEQ; return (size_t)(-1); } } } lftp-4.6.3a/lib/iconv_open-aix.gperf0000644000015000007670000000172412122621312014260 00000000000000struct mapping { int standard_name; const char vendor_name[10 + 1]; }; %struct-type %language=ANSI-C %define slot-name standard_name %define hash-function-name mapping_hash %define lookup-function-name mapping_lookup %readonly-tables %global-table %define word-array-name mappings %pic %% # On AIX 5.1, look in /usr/lib/nls/loc/uconvTable. ISO-8859-1, "ISO8859-1" ISO-8859-2, "ISO8859-2" ISO-8859-3, "ISO8859-3" ISO-8859-4, "ISO8859-4" ISO-8859-5, "ISO8859-5" ISO-8859-6, "ISO8859-6" ISO-8859-7, "ISO8859-7" ISO-8859-8, "ISO8859-8" ISO-8859-9, "ISO8859-9" ISO-8859-15, "ISO8859-15" CP437, "IBM-437" CP850, "IBM-850" CP852, "IBM-852" CP856, "IBM-856" CP857, "IBM-857" CP861, "IBM-861" CP865, "IBM-865" CP869, "IBM-869" ISO-8859-13, "IBM-921" CP922, "IBM-922" CP932, "IBM-932" CP943, "IBM-943" CP1046, "IBM-1046" CP1124, "IBM-1124" CP1125, "IBM-1125" CP1129, "IBM-1129" CP1252, "IBM-1252" GB2312, "IBM-eucCN" EUC-JP, "IBM-eucJP" EUC-KR, "IBM-eucKR" EUC-TW, "IBM-eucTW" BIG5, "big5" lftp-4.6.3a/lib/mbtowc.c0000644000015000007670000000164612466374011011773 00000000000000/* Convert multibyte character to wide character. Copyright (C) 2011-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2011. 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 . */ #include #include #include #include #include #include "mbtowc-impl.h" lftp-4.6.3a/lib/time_r.c0000644000015000007670000000227312466374012011755 00000000000000/* Reentrant time functions like localtime_r. Copyright (C) 2003, 2006-2007, 2010-2015 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 . */ /* Written by Paul Eggert. */ #include #include static struct tm * copy_tm_result (struct tm *dest, struct tm const *src) { if (! src) return 0; *dest = *src; return dest; } struct tm * gmtime_r (time_t const * restrict t, struct tm * restrict tp) { return copy_tm_result (tp, gmtime (t)); } struct tm * localtime_r (time_t const * restrict t, struct tm * restrict tp) { return copy_tm_result (tp, localtime (t)); } lftp-4.6.3a/lib/iconv_open-hpux.h0000644000015000007670000002750512122621410013613 00000000000000/* ANSI-C code produced by gperf version 3.0.4 */ /* Command-line: gperf -m 10 ./iconv_open-hpux.gperf */ /* Computed positions: -k'4,$' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "./iconv_open-hpux.gperf" struct mapping { int standard_name; const char vendor_name[9 + 1]; }; #define TOTAL_KEYWORDS 44 #define MIN_WORD_LENGTH 4 #define MAX_WORD_LENGTH 11 #define MIN_HASH_VALUE 6 #define MAX_HASH_VALUE 49 /* maximum key range = 44, duplicates = 0 */ #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static unsigned int mapping_hash (register const char *str, register unsigned int len) { static const unsigned char asso_values[] = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 1, 2, 24, 43, 5, 10, 0, 13, 32, 3, 19, 18, 50, 50, 50, 50, 50, 50, 50, 50, 50, 5, 50, 50, 50, 50, 14, 5, 0, 50, 50, 0, 27, 50, 12, 14, 50, 50, 0, 5, 2, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 }; return len + asso_values[(unsigned char)str[3]+4] + asso_values[(unsigned char)str[len - 1]]; } struct stringpool_t { char stringpool_str6[sizeof("CP1256")]; char stringpool_str7[sizeof("CP1250")]; char stringpool_str8[sizeof("CP1251")]; char stringpool_str9[sizeof("CP850")]; char stringpool_str10[sizeof("TIS-620")]; char stringpool_str11[sizeof("CP1254")]; char stringpool_str12[sizeof("ISO-8859-6")]; char stringpool_str13[sizeof("EUC-TW")]; char stringpool_str14[sizeof("ISO-8859-1")]; char stringpool_str15[sizeof("ISO-8859-9")]; char stringpool_str16[sizeof("CP1255")]; char stringpool_str17[sizeof("BIG5")]; char stringpool_str18[sizeof("CP855")]; char stringpool_str19[sizeof("CP1257")]; char stringpool_str20[sizeof("EUC-KR")]; char stringpool_str21[sizeof("CP857")]; char stringpool_str22[sizeof("ISO-8859-5")]; char stringpool_str23[sizeof("ISO-8859-15")]; char stringpool_str24[sizeof("CP866")]; char stringpool_str25[sizeof("ISO-8859-7")]; char stringpool_str26[sizeof("CP861")]; char stringpool_str27[sizeof("CP869")]; char stringpool_str28[sizeof("CP874")]; char stringpool_str29[sizeof("CP864")]; char stringpool_str30[sizeof("CP1252")]; char stringpool_str31[sizeof("CP437")]; char stringpool_str32[sizeof("CP852")]; char stringpool_str33[sizeof("CP775")]; char stringpool_str34[sizeof("CP865")]; char stringpool_str35[sizeof("EUC-JP")]; char stringpool_str36[sizeof("ISO-8859-2")]; char stringpool_str37[sizeof("SHIFT_JIS")]; char stringpool_str38[sizeof("CP1258")]; char stringpool_str39[sizeof("UTF-8")]; char stringpool_str40[sizeof("HP-KANA8")]; char stringpool_str41[sizeof("HP-ROMAN8")]; char stringpool_str42[sizeof("HP-HEBREW8")]; char stringpool_str43[sizeof("GB2312")]; char stringpool_str44[sizeof("ISO-8859-8")]; char stringpool_str45[sizeof("HP-TURKISH8")]; char stringpool_str46[sizeof("HP-GREEK8")]; char stringpool_str47[sizeof("HP-ARABIC8")]; char stringpool_str48[sizeof("CP862")]; char stringpool_str49[sizeof("CP1253")]; }; static const struct stringpool_t stringpool_contents = { "CP1256", "CP1250", "CP1251", "CP850", "TIS-620", "CP1254", "ISO-8859-6", "EUC-TW", "ISO-8859-1", "ISO-8859-9", "CP1255", "BIG5", "CP855", "CP1257", "EUC-KR", "CP857", "ISO-8859-5", "ISO-8859-15", "CP866", "ISO-8859-7", "CP861", "CP869", "CP874", "CP864", "CP1252", "CP437", "CP852", "CP775", "CP865", "EUC-JP", "ISO-8859-2", "SHIFT_JIS", "CP1258", "UTF-8", "HP-KANA8", "HP-ROMAN8", "HP-HEBREW8", "GB2312", "ISO-8859-8", "HP-TURKISH8", "HP-GREEK8", "HP-ARABIC8", "CP862", "CP1253" }; #define stringpool ((const char *) &stringpool_contents) static const struct mapping mappings[] = { {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, #line 40 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str6, "cp1256"}, #line 34 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str7, "cp1250"}, #line 35 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str8, "cp1251"}, #line 23 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str9, "cp850"}, #line 49 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str10, "tis620"}, #line 38 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str11, "cp1254"}, #line 16 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str12, "iso88596"}, #line 53 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str13, "eucTW"}, #line 13 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str14, "iso88591"}, #line 19 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, "iso88599"}, #line 39 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str16, "cp1255"}, #line 54 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str17, "big5"}, #line 25 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, "cp855"}, #line 41 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str19, "cp1257"}, #line 52 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str20, "eucKR"}, #line 26 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str21, "cp857"}, #line 15 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str22, "iso88595"}, #line 20 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str23, "iso885915"}, #line 31 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str24, "cp866"}, #line 17 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str25, "iso88597"}, #line 27 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str26, "cp861"}, #line 32 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str27, "cp869"}, #line 33 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str28, "cp874"}, #line 29 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str29, "cp864"}, #line 36 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str30, "cp1252"}, #line 21 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str31, "cp437"}, #line 24 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str32, "cp852"}, #line 22 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str33, "cp775"}, #line 30 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str34, "cp865"}, #line 51 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str35, "eucJP"}, #line 14 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str36, "iso88592"}, #line 55 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str37, "sjis"}, #line 42 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str38, "cp1258"}, #line 56 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str39, "utf8"}, #line 48 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str40, "kana8"}, #line 43 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str41, "roman8"}, #line 46 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str42, "hebrew8"}, #line 50 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str43, "hp15CN"}, #line 18 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str44, "iso88598"}, #line 47 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str45, "turkish8"}, #line 45 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str46, "greek8"}, #line 44 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str47, "arabic8"}, #line 28 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str48, "cp862"}, #line 37 "./iconv_open-hpux.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str49, "cp1253"} }; #ifdef __GNUC__ __inline #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ __attribute__ ((__gnu_inline__)) #endif #endif const struct mapping * mapping_lookup (register const char *str, register unsigned int len) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { register int key = mapping_hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) { register int o = mappings[key].standard_name; if (o >= 0) { register const char *s = o + stringpool; if (*str == *s && !strcmp (str + 1, s + 1)) return &mappings[key]; } } } return 0; } lftp-4.6.3a/lib/chown.c0000644000015000007670000001042112466374011011605 00000000000000/* provide consistent interface to chown for systems that don't interpret an ID of -1 as meaning "don't change the corresponding ID". Copyright (C) 1997, 2004-2007, 2009-2015 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 . */ /* written by Jim Meyering */ #include /* Specification. */ #include #include #include #include #include #include #if !HAVE_CHOWN /* Simple stub that always fails with ENOSYS, for mingw. */ int chown (const char *file _GL_UNUSED, uid_t uid _GL_UNUSED, gid_t gid _GL_UNUSED) { errno = ENOSYS; return -1; } #else /* HAVE_CHOWN */ /* Below we refer to the system's chown(). */ # undef chown /* Provide a more-closely POSIX-conforming version of chown on systems with one or both of the following problems: - chown doesn't treat an ID of -1 as meaning "don't change the corresponding ID". - chown doesn't dereference symlinks. */ int rpl_chown (const char *file, uid_t uid, gid_t gid) { struct stat st; bool stat_valid = false; int result; # if CHOWN_CHANGE_TIME_BUG if (gid != (gid_t) -1 || uid != (uid_t) -1) { if (stat (file, &st)) return -1; stat_valid = true; } # endif # if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE if (gid == (gid_t) -1 || uid == (uid_t) -1) { /* Stat file to get id(s) that should remain unchanged. */ if (!stat_valid && stat (file, &st)) return -1; if (gid == (gid_t) -1) gid = st.st_gid; if (uid == (uid_t) -1) uid = st.st_uid; } # endif # if CHOWN_MODIFIES_SYMLINK { /* Handle the case in which the system-supplied chown function does *not* follow symlinks. Instead, it changes permissions on the symlink itself. To work around that, we open the file (but this can fail due to lack of read or write permission) and use fchown on the resulting descriptor. */ int open_flags = O_NONBLOCK | O_NOCTTY; int fd = open (file, O_RDONLY | open_flags); if (0 <= fd || (errno == EACCES && 0 <= (fd = open (file, O_WRONLY | open_flags)))) { int saved_errno; bool fchown_socket_failure; result = fchown (fd, uid, gid); saved_errno = errno; /* POSIX says fchown can fail with errno == EINVAL on sockets and pipes, so fall back on chown in that case. */ fchown_socket_failure = (result != 0 && saved_errno == EINVAL && fstat (fd, &st) == 0 && (S_ISFIFO (st.st_mode) || S_ISSOCK (st.st_mode))); close (fd); if (! fchown_socket_failure) { errno = saved_errno; return result; } } else if (errno != EACCES) return -1; } # endif # if CHOWN_TRAILING_SLASH_BUG if (!stat_valid) { size_t len = strlen (file); if (len && file[len - 1] == '/' && stat (file, &st)) return -1; } # endif result = chown (file, uid, gid); # if CHOWN_CHANGE_TIME_BUG if (result == 0 && stat_valid && (uid == st.st_uid || uid == (uid_t) -1) && (gid == st.st_gid || gid == (gid_t) -1)) { /* No change in ownership, but at least one argument was not -1, so we are required to update ctime. Since chown succeeded, we assume that chmod will do likewise. Fortunately, on all known systems where a 'no-op' chown skips the ctime update, a 'no-op' chmod still does the trick. */ result = chmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)); } # endif return result; } #endif /* HAVE_CHOWN */ lftp-4.6.3a/lib/open.c0000644000015000007670000001375512466374011011445 00000000000000/* Open a descriptor to a file. Copyright (C) 2007-2015 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 . */ /* Written by Bruno Haible , 2007. */ /* If the user's config.h happens to include , let it include only the system's here, so that orig_open doesn't recurse to rpl_open. */ #define __need_system_fcntl_h #include /* Get the original definition of open. It might be defined as a macro. */ #include #include #undef __need_system_fcntl_h static int orig_open (const char *filename, int flags, mode_t mode) { return open (filename, flags, mode); } /* Specification. */ /* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ #include "fcntl.h" #include #include #include #include #include #include #ifndef REPLACE_OPEN_DIRECTORY # define REPLACE_OPEN_DIRECTORY 0 #endif int open (const char *filename, int flags, ...) { mode_t mode; int fd; mode = 0; if (flags & O_CREAT) { va_list arg; va_start (arg, flags); /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 creates crashing code when 'mode_t' is smaller than 'int'. */ mode = va_arg (arg, PROMOTED_MODE_T); va_end (arg); } #if GNULIB_defined_O_NONBLOCK /* The only known platform that lacks O_NONBLOCK is mingw, but it also lacks named pipes and Unix sockets, which are the only two file types that require non-blocking handling in open(). Therefore, it is safe to ignore O_NONBLOCK here. It is handy that mingw also lacks openat(), so that is also covered here. */ flags &= ~O_NONBLOCK; #endif #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ if (strcmp (filename, "/dev/null") == 0) filename = "NUL"; #endif #if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR is specified, then fail. Rationale: POSIX says that "A pathname that contains at least one non-slash character and that ends with one or more trailing slashes shall be resolved as if a single dot character ( '.' ) were appended to the pathname." and "The special filename dot shall refer to the directory specified by its predecessor." If the named file already exists as a directory, then - if O_CREAT is specified, open() must fail because of the semantics of O_CREAT, - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX says that it fails with errno = EISDIR in this case. If the named file does not exist or does not name a directory, then - if O_CREAT is specified, open() must fail since open() cannot create directories, - if O_WRONLY or O_RDWR is specified, open() must fail because the file does not contain a '.' directory. */ if (flags & (O_CREAT | O_WRONLY | O_RDWR)) { size_t len = strlen (filename); if (len > 0 && filename[len - 1] == '/') { errno = EISDIR; return -1; } } #endif fd = orig_open (filename, flags, mode); #if REPLACE_FCHDIR /* Implementing fchdir and fdopendir requires the ability to open a directory file descriptor. If open doesn't support that (as on mingw), we use a dummy file that behaves the same as directories on Linux (ie. always reports EOF on attempts to read()), and override fstat() in fchdir.c to hide the fact that we have a dummy. */ if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES && ((flags & O_ACCMODE) == O_RDONLY || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH))) { struct stat statbuf; if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) { /* Maximum recursion depth of 1. */ fd = open ("/dev/null", flags, mode); if (0 <= fd) fd = _gl_register_fd (fd, filename); } else errno = EACCES; } #endif #if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and fd does not refer to a directory, then fail. Rationale: POSIX says that "A pathname that contains at least one non-slash character and that ends with one or more trailing slashes shall be resolved as if a single dot character ( '.' ) were appended to the pathname." and "The special filename dot shall refer to the directory specified by its predecessor." If the named file without the slash is not a directory, open() must fail with ENOTDIR. */ if (fd >= 0) { /* We know len is positive, since open did not fail with ENOENT. */ size_t len = strlen (filename); if (filename[len - 1] == '/') { struct stat statbuf; if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) { close (fd); errno = ENOTDIR; return -1; } } } #endif #if REPLACE_FCHDIR if (!REPLACE_OPEN_DIRECTORY && 0 <= fd) fd = _gl_register_fd (fd, filename); #endif return fd; } lftp-4.6.3a/lib/getopt1.c0000644000015000007670000001055212466374011012057 00000000000000/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2015 Free Software Foundation, Inc. This file is part of 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 . */ #ifdef _LIBC # include #else # include # include "getopt.h" #endif #include "getopt_int.h" #include /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif #ifndef NULL #define NULL 0 #endif int getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, opt_index, 0, 0); } int _getopt_long_r (int argc, char **argv, const char *options, const struct option *long_options, int *opt_index, struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, 0, d, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (int argc, char *__getopt_argv_const *argv, const char *options, const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, opt_index, 1, 0); } int _getopt_long_only_r (int argc, char **argv, const char *options, const struct option *long_options, int *opt_index, struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, 1, d, 0); } #ifdef TEST #include int main (int argc, char **argv) { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static const struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == -1) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value '%s'\n", optarg); break; case 'd': printf ("option d with value '%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ lftp-4.6.3a/lib/glob-libc.h0000644000015000007670000001753312466374011012341 00000000000000/* Copyright (C) 1991-1992, 1995-1998, 2000-2001, 2004-2007, 2009-2015 Free Software Foundation, Inc. This file is part of 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 . */ #ifndef _GLOB_H #define _GLOB_H 1 #ifndef __GLOB_GNULIB # include #endif /* GCC 2.95 and later have "__restrict"; C99 compilers have "restrict", and "configure" may have defined "restrict". Other compilers use __restrict, __restrict__, and _Restrict, and 'configure' might #define 'restrict' to those words, so pick a different name. */ #ifndef _Restrict_ # if 199901L <= __STDC_VERSION__ # define _Restrict_ restrict # elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__) # define _Restrict_ __restrict # else # define _Restrict_ # endif #endif __BEGIN_DECLS /* We need 'size_t' for the following definitions. */ #ifndef __size_t # if defined __GNUC__ && __GNUC__ >= 2 typedef __SIZE_TYPE__ __size_t; # ifdef __USE_XOPEN typedef __SIZE_TYPE__ size_t; # endif # else # include # ifndef __size_t # define __size_t size_t # endif # endif #else /* The GNU CC stddef.h version defines __size_t as empty. We need a real definition. */ # undef __size_t # define __size_t size_t #endif /* Bits set in the FLAGS argument to 'glob'. */ #define GLOB_ERR (1 << 0)/* Return on read errors. */ #define GLOB_MARK (1 << 1)/* Append a slash to each name. */ #define GLOB_NOSORT (1 << 2)/* Don't sort the names. */ #define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */ #define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */ #define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */ #define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */ #define GLOB_PERIOD (1 << 7)/* Leading '.' can be matched by metachars. */ #if !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU # define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */ # define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */ # define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */ # define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */ # define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */ # define GLOB_ONLYDIR (1 << 13)/* Match only directories. */ # define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error if the user name is not available. */ # define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \ GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \ GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK) #else # define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \ GLOB_PERIOD) #endif /* Error returns from 'glob'. */ #define GLOB_NOSPACE 1 /* Ran out of memory. */ #define GLOB_ABORTED 2 /* Read error. */ #define GLOB_NOMATCH 3 /* No matches found. */ #define GLOB_NOSYS 4 /* Not implemented. */ #ifdef __USE_GNU /* Previous versions of this file defined GLOB_ABEND instead of GLOB_ABORTED. Provide a compatibility definition here. */ # define GLOB_ABEND GLOB_ABORTED #endif /* Structure describing a globbing run. */ #ifdef __USE_GNU struct stat; #endif typedef struct { __size_t gl_pathc; /* Count of paths matched by the pattern. */ char **gl_pathv; /* List of matched pathnames. */ __size_t gl_offs; /* Slots to reserve in 'gl_pathv'. */ int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */ /* If the GLOB_ALTDIRFUNC flag is set, the following functions are used instead of the normal file access functions. */ void (*gl_closedir) (void *); #ifdef __USE_GNU struct dirent *(*gl_readdir) (void *); #else void *(*gl_readdir) (void *); #endif void *(*gl_opendir) (const char *); #ifdef __USE_GNU int (*gl_lstat) (const char *_Restrict_, struct stat *_Restrict_); int (*gl_stat) (const char *_Restrict_, struct stat *_Restrict_); #else int (*gl_lstat) (const char *_Restrict_, void *_Restrict_); int (*gl_stat) (const char *_Restrict_, void *_Restrict_); #endif } glob_t; #if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB # ifdef __USE_GNU struct stat64; # endif typedef struct { __size_t gl_pathc; char **gl_pathv; __size_t gl_offs; int gl_flags; /* If the GLOB_ALTDIRFUNC flag is set, the following functions are used instead of the normal file access functions. */ void (*gl_closedir) (void *); # ifdef __USE_GNU struct dirent64 *(*gl_readdir) (void *); # else void *(*gl_readdir) (void *); # endif void *(*gl_opendir) (const char *); # ifdef __USE_GNU int (*gl_lstat) (const char *_Restrict_, struct stat64 *_Restrict_); int (*gl_stat) (const char *_Restrict_, struct stat64 *_Restrict_); # else int (*gl_lstat) (const char *_Restrict_, void *_Restrict_); int (*gl_stat) (const char *_Restrict_, void *_Restrict_); # endif } glob64_t; #endif #if __USE_FILE_OFFSET64 && __GNUC__ < 2 && !defined __GLOB_GNULIB # define glob glob64 # define globfree globfree64 #endif /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. If a directory cannot be opened or read and ERRFUNC is not nil, it is called with the pathname that caused the error, and the 'errno' value from the failing call; if it returns non-zero 'glob' returns GLOB_ABEND; if it returns zero, the error is ignored. If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned. Otherwise, 'glob' returns zero. */ #if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 || defined __GLOB_GNULIB extern int glob (const char *_Restrict_ __pattern, int __flags, int (*__errfunc) (const char *, int), glob_t *_Restrict_ __pglob) __THROW _GL_ARG_NONNULL ((1, 4)); /* Free storage allocated in PGLOB by a previous 'glob' call. */ extern void globfree (glob_t *__pglob) __THROW _GL_ARG_NONNULL ((1)); #else extern int __REDIRECT_NTH (glob, (const char *_Restrict_ __pattern, int __flags, int (*__errfunc) (const char *, int), glob_t *_Restrict_ __pglob), glob64); extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64); #endif #if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB extern int glob64 (const char *_Restrict_ __pattern, int __flags, int (*__errfunc) (const char *, int), glob64_t *_Restrict_ __pglob) __THROW _GL_ARG_NONNULL ((1, 4)); extern void globfree64 (glob64_t *__pglob) __THROW _GL_ARG_NONNULL ((1)); #endif #ifdef __USE_GNU /* Return nonzero if PATTERN contains any metacharacters. Metacharacters can be quoted with backslashes if QUOTE is nonzero. This function is not part of the interface specified by POSIX.2 but several programs want to use it. */ extern int glob_pattern_p (const char *__pattern, int __quote) __THROW _GL_ARG_NONNULL ((1)); #endif __END_DECLS #endif /* glob.h */ lftp-4.6.3a/lib/fnmatch.c0000644000015000007670000002622612466374011012121 00000000000000/* Copyright (C) 1991-1993, 1996-2007, 2009-2015 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 . */ #ifndef _LIBC # include #endif /* Enable GNU extensions in fnmatch.h. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif #if ! defined __builtin_expect && __GNUC__ < 3 # define __builtin_expect(expr, expected) (expr) #endif #include #include #include #include #include #include #include #include #include #define WIDE_CHAR_SUPPORT \ (HAVE_WCTYPE_H && HAVE_BTOWC && HAVE_ISWCTYPE \ && HAVE_WMEMCHR && (HAVE_WMEMCPY || HAVE_WMEMPCPY)) /* For platform which support the ISO C amendment 1 functionality we support user defined character classes. */ #if defined _LIBC || WIDE_CHAR_SUPPORT # include # include #endif /* We need some of the locale data (the collation sequence information) but there is no interface to get this information in general. Therefore we support a correct implementation only in glibc. */ #ifdef _LIBC # include "../locale/localeinfo.h" # include "../locale/elem-hash.h" # include "../locale/coll-lookup.h" # include # define CONCAT(a,b) __CONCAT(a,b) # define mbsrtowcs __mbsrtowcs # define fnmatch __fnmatch extern int fnmatch (const char *pattern, const char *string, int flags); #endif #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif /* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */ #define NO_LEADING_PERIOD(flags) \ ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD)) /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself, and have not detected a bug in the library. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand 'configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU # if ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK)) # define isblank(c) ((c) == ' ' || (c) == '\t') # endif # define STREQ(s1, s2) (strcmp (s1, s2) == 0) # if defined _LIBC || WIDE_CHAR_SUPPORT /* The GNU C library provides support for user-defined character classes and the functions from ISO C amendment 1. */ # ifdef CHARCLASS_NAME_MAX # define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX # else /* This shouldn't happen but some implementation might still have this problem. Use a reasonable default value. */ # define CHAR_CLASS_MAX_LENGTH 256 # endif # ifdef _LIBC # define IS_CHAR_CLASS(string) __wctype (string) # else # define IS_CHAR_CLASS(string) wctype (string) # endif # ifdef _LIBC # define ISWCTYPE(WC, WT) __iswctype (WC, WT) # else # define ISWCTYPE(WC, WT) iswctype (WC, WT) # endif # if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC /* In this case we are implementing the multibyte character handling. */ # define HANDLE_MULTIBYTE 1 # endif # else # define CHAR_CLASS_MAX_LENGTH 6 /* Namely, 'xdigit'. */ # define IS_CHAR_CLASS(string) \ (STREQ (string, "alpha") || STREQ (string, "upper") \ || STREQ (string, "lower") || STREQ (string, "digit") \ || STREQ (string, "alnum") || STREQ (string, "xdigit") \ || STREQ (string, "space") || STREQ (string, "print") \ || STREQ (string, "punct") || STREQ (string, "graph") \ || STREQ (string, "cntrl") || STREQ (string, "blank")) # endif /* Avoid depending on library functions or files whose names are inconsistent. */ /* Global variable. */ static int posixly_correct; # ifndef internal_function /* Inside GNU libc we mark some function in a special way. In other environments simply ignore the marking. */ # define internal_function # endif /* Note that this evaluates C many times. */ # define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c)) # define CHAR char # define UCHAR unsigned char # define INT int # define FCT internal_fnmatch # define EXT ext_match # define END end_pattern # define L_(CS) CS # ifdef _LIBC # define BTOWC(C) __btowc (C) # else # define BTOWC(C) btowc (C) # endif # define STRLEN(S) strlen (S) # define STRCAT(D, S) strcat (D, S) # ifdef _LIBC # define MEMPCPY(D, S, N) __mempcpy (D, S, N) # else # if HAVE_MEMPCPY # define MEMPCPY(D, S, N) mempcpy (D, S, N) # else # define MEMPCPY(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) # endif # endif # define MEMCHR(S, C, N) memchr (S, C, N) # include "fnmatch_loop.c" # if HANDLE_MULTIBYTE # define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c)) # define CHAR wchar_t # define UCHAR wint_t # define INT wint_t # define FCT internal_fnwmatch # define EXT ext_wmatch # define END end_wpattern # define L_(CS) L##CS # define BTOWC(C) (C) # ifdef _LIBC # define STRLEN(S) __wcslen (S) # define STRCAT(D, S) __wcscat (D, S) # define MEMPCPY(D, S, N) __wmempcpy (D, S, N) # else # define STRLEN(S) wcslen (S) # define STRCAT(D, S) wcscat (D, S) # if HAVE_WMEMPCPY # define MEMPCPY(D, S, N) wmempcpy (D, S, N) # else # define MEMPCPY(D, S, N) (wmemcpy (D, S, N) + (N)) # endif # endif # define MEMCHR(S, C, N) wmemchr (S, C, N) # define WIDE_CHAR_VERSION 1 # undef IS_CHAR_CLASS /* We have to convert the wide character string in a multibyte string. But we know that the character class names consist of alphanumeric characters from the portable character set, and since the wide character encoding for a member of the portable character set is the same code point as its single-byte encoding, we can use a simplified method to convert the string to a multibyte character string. */ static wctype_t is_char_class (const wchar_t *wcs) { char s[CHAR_CLASS_MAX_LENGTH + 1]; char *cp = s; do { /* Test for a printable character from the portable character set. */ # ifdef _LIBC if (*wcs < 0x20 || *wcs > 0x7e || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60) return (wctype_t) 0; # else switch (*wcs) { case L' ': case L'!': case L'"': case L'#': case L'%': case L'&': case L'\'': case L'(': case L')': case L'*': case L'+': case L',': case L'-': case L'.': case L'/': case L'0': case L'1': case L'2': case L'3': case L'4': case L'5': case L'6': case L'7': case L'8': case L'9': case L':': case L';': case L'<': case L'=': case L'>': case L'?': case L'A': case L'B': case L'C': case L'D': case L'E': case L'F': case L'G': case L'H': case L'I': case L'J': case L'K': case L'L': case L'M': case L'N': case L'O': case L'P': case L'Q': case L'R': case L'S': case L'T': case L'U': case L'V': case L'W': case L'X': case L'Y': case L'Z': case L'[': case L'\\': case L']': case L'^': case L'_': case L'a': case L'b': case L'c': case L'd': case L'e': case L'f': case L'g': case L'h': case L'i': case L'j': case L'k': case L'l': case L'm': case L'n': case L'o': case L'p': case L'q': case L'r': case L's': case L't': case L'u': case L'v': case L'w': case L'x': case L'y': case L'z': case L'{': case L'|': case L'}': case L'~': break; default: return (wctype_t) 0; } # endif /* Avoid overrunning the buffer. */ if (cp == s + CHAR_CLASS_MAX_LENGTH) return (wctype_t) 0; *cp++ = (char) *wcs++; } while (*wcs != L'\0'); *cp = '\0'; # ifdef _LIBC return __wctype (s); # else return wctype (s); # endif } # define IS_CHAR_CLASS(string) is_char_class (string) # include "fnmatch_loop.c" # endif int fnmatch (const char *pattern, const char *string, int flags) { # if HANDLE_MULTIBYTE # define ALLOCA_LIMIT 2000 if (__builtin_expect (MB_CUR_MAX, 1) != 1) { mbstate_t ps; size_t patsize; size_t strsize; size_t totsize; wchar_t *wpattern; wchar_t *wstring; int res; /* Calculate the size needed to convert the strings to wide characters. */ memset (&ps, '\0', sizeof (ps)); patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1; if (__builtin_expect (patsize != 0, 1)) { assert (mbsinit (&ps)); strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1; if (__builtin_expect (strsize != 0, 1)) { assert (mbsinit (&ps)); totsize = patsize + strsize; if (__builtin_expect (! (patsize <= totsize && totsize <= SIZE_MAX / sizeof (wchar_t)), 0)) { errno = ENOMEM; return -1; } /* Allocate room for the wide characters. */ if (__builtin_expect (totsize < ALLOCA_LIMIT, 1)) wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t)); else { wpattern = malloc (totsize * sizeof (wchar_t)); if (__builtin_expect (! wpattern, 0)) { errno = ENOMEM; return -1; } } wstring = wpattern + patsize; /* Convert the strings into wide characters. */ mbsrtowcs (wpattern, &pattern, patsize, &ps); assert (mbsinit (&ps)); mbsrtowcs (wstring, &string, strsize, &ps); res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1, flags & FNM_PERIOD, flags); if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0)) free (wpattern); return res; } } } # endif /* HANDLE_MULTIBYTE */ return internal_fnmatch (pattern, string, string + strlen (string), flags & FNM_PERIOD, flags); } # ifdef _LIBC # undef fnmatch versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3); # if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3) strong_alias (__fnmatch, __fnmatch_old) compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0); # endif libc_hidden_ver (__fnmatch, fnmatch) # endif #endif /* _LIBC or not __GNU_LIBRARY__. */ lftp-4.6.3a/lib/fd-hook.c0000644000015000007670000000701212466374011012020 00000000000000/* Hook for making making file descriptor functions close(), ioctl() extensible. Copyright (C) 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2009. 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 . */ #include /* Specification. */ #include "fd-hook.h" #include /* Currently, this entire code is only needed for the handling of sockets on native Windows platforms. */ #if WINDOWS_SOCKETS /* The first and last link in the doubly linked list. Initially the list is empty. */ static struct fd_hook anchor = { &anchor, &anchor, NULL, NULL }; int execute_close_hooks (const struct fd_hook *remaining_list, gl_close_fn primary, int fd) { if (remaining_list == &anchor) /* End of list reached. */ return primary (fd); else return remaining_list->private_close_fn (remaining_list->private_next, primary, fd); } int execute_all_close_hooks (gl_close_fn primary, int fd) { return execute_close_hooks (anchor.private_next, primary, fd); } int execute_ioctl_hooks (const struct fd_hook *remaining_list, gl_ioctl_fn primary, int fd, int request, void *arg) { if (remaining_list == &anchor) /* End of list reached. */ return primary (fd, request, arg); else return remaining_list->private_ioctl_fn (remaining_list->private_next, primary, fd, request, arg); } int execute_all_ioctl_hooks (gl_ioctl_fn primary, int fd, int request, void *arg) { return execute_ioctl_hooks (anchor.private_next, primary, fd, request, arg); } void register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook, struct fd_hook *link) { if (close_hook == NULL) close_hook = execute_close_hooks; if (ioctl_hook == NULL) ioctl_hook = execute_ioctl_hooks; if (link->private_next == NULL && link->private_prev == NULL) { /* Add the link to the doubly linked list. */ link->private_next = anchor.private_next; link->private_prev = &anchor; link->private_close_fn = close_hook; link->private_ioctl_fn = ioctl_hook; anchor.private_next->private_prev = link; anchor.private_next = link; } else { /* The link is already in use. */ if (link->private_close_fn != close_hook || link->private_ioctl_fn != ioctl_hook) abort (); } } void unregister_fd_hook (struct fd_hook *link) { struct fd_hook *next = link->private_next; struct fd_hook *prev = link->private_prev; if (next != NULL && prev != NULL) { /* The link is in use. Remove it from the doubly linked list. */ prev->private_next = next; next->private_prev = prev; /* Clear the link, to mark it unused. */ link->private_next = NULL; link->private_prev = NULL; link->private_close_fn = NULL; link->private_ioctl_fn = NULL; } } #endif lftp-4.6.3a/lib/ref-del.sin0000644000015000007670000000167512466374011012367 00000000000000# Remove this package from a list of references stored in a text file. # # Copyright (C) 2000, 2009-2015 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 . # # Written by Bruno Haible . # /^# Packages using this file: / { s/# Packages using this file:// s/ @PACKAGE@ / / s/^/# Packages using this file:/ } lftp-4.6.3a/lib/printf-parse.c0000644000015000007670000005317112466374011013112 00000000000000/* Formatted output to strings. Copyright (C) 1999-2000, 2002-2003, 2006-2015 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 . */ /* This file can be parametrized with the following macros: CHAR_T The element type of the format string. CHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters in the format string are ASCII. DIRECTIVE Structure denoting a format directive. Depends on CHAR_T. DIRECTIVES Structure denoting the set of format directives of a format string. Depends on CHAR_T. PRINTF_PARSE Function that parses a format string. Depends on CHAR_T. STATIC Set to 'static' to declare the function static. ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. */ #ifndef PRINTF_PARSE # include #endif /* Specification. */ #ifndef PRINTF_PARSE # include "printf-parse.h" #endif /* Default parameters. */ #ifndef PRINTF_PARSE # define PRINTF_PARSE printf_parse # define CHAR_T char # define DIRECTIVE char_directive # define DIRECTIVES char_directives #endif /* Get size_t, NULL. */ #include /* Get intmax_t. */ #if defined IN_LIBINTL || defined IN_LIBASPRINTF # if HAVE_STDINT_H_WITH_UINTMAX # include # endif # if HAVE_INTTYPES_H_WITH_UINTMAX # include # endif #else # include #endif /* malloc(), realloc(), free(). */ #include /* memcpy(). */ #include /* errno. */ #include /* Checked size_t computations. */ #include "xsize.h" #if CHAR_T_ONLY_ASCII /* c_isascii(). */ # include "c-ctype.h" #endif #ifdef STATIC STATIC #endif int PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) { const CHAR_T *cp = format; /* pointer into format */ size_t arg_posn = 0; /* number of regular arguments consumed */ size_t d_allocated; /* allocated elements of d->dir */ size_t a_allocated; /* allocated elements of a->arg */ size_t max_width_length = 0; size_t max_precision_length = 0; d->count = 0; d_allocated = N_DIRECT_ALLOC_DIRECTIVES; d->dir = d->direct_alloc_dir; a->count = 0; a_allocated = N_DIRECT_ALLOC_ARGUMENTS; a->arg = a->direct_alloc_arg; #define REGISTER_ARG(_index_,_type_) \ { \ size_t n = (_index_); \ if (n >= a_allocated) \ { \ size_t memory_size; \ argument *memory; \ \ a_allocated = xtimes (a_allocated, 2); \ if (a_allocated <= n) \ a_allocated = xsum (n, 1); \ memory_size = xtimes (a_allocated, sizeof (argument)); \ if (size_overflow_p (memory_size)) \ /* Overflow, would lead to out of memory. */ \ goto out_of_memory; \ memory = (argument *) (a->arg != a->direct_alloc_arg \ ? realloc (a->arg, memory_size) \ : malloc (memory_size)); \ if (memory == NULL) \ /* Out of memory. */ \ goto out_of_memory; \ if (a->arg == a->direct_alloc_arg) \ memcpy (memory, a->arg, a->count * sizeof (argument)); \ a->arg = memory; \ } \ while (a->count <= n) \ a->arg[a->count++].type = TYPE_NONE; \ if (a->arg[n].type == TYPE_NONE) \ a->arg[n].type = (_type_); \ else if (a->arg[n].type != (_type_)) \ /* Ambiguous type for positional argument. */ \ goto error; \ } while (*cp != '\0') { CHAR_T c = *cp++; if (c == '%') { size_t arg_index = ARG_NONE; DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ /* Initialize the next directive. */ dp->dir_start = cp - 1; dp->flags = 0; dp->width_start = NULL; dp->width_end = NULL; dp->width_arg_index = ARG_NONE; dp->precision_start = NULL; dp->precision_end = NULL; dp->precision_arg_index = ARG_NONE; dp->arg_index = ARG_NONE; /* Test for positional argument. */ if (*cp >= '0' && *cp <= '9') { const CHAR_T *np; for (np = cp; *np >= '0' && *np <= '9'; np++) ; if (*np == '$') { size_t n = 0; for (np = cp; *np >= '0' && *np <= '9'; np++) n = xsum (xtimes (n, 10), *np - '0'); if (n == 0) /* Positional argument 0. */ goto error; if (size_overflow_p (n)) /* n too large, would lead to out of memory later. */ goto error; arg_index = n - 1; cp = np + 1; } } /* Read the flags. */ for (;;) { if (*cp == '\'') { dp->flags |= FLAG_GROUP; cp++; } else if (*cp == '-') { dp->flags |= FLAG_LEFT; cp++; } else if (*cp == '+') { dp->flags |= FLAG_SHOWSIGN; cp++; } else if (*cp == ' ') { dp->flags |= FLAG_SPACE; cp++; } else if (*cp == '#') { dp->flags |= FLAG_ALT; cp++; } else if (*cp == '0') { dp->flags |= FLAG_ZERO; cp++; } #if __GLIBC__ >= 2 && !defined __UCLIBC__ else if (*cp == 'I') { dp->flags |= FLAG_LOCALIZED; cp++; } #endif else break; } /* Parse the field width. */ if (*cp == '*') { dp->width_start = cp; cp++; dp->width_end = cp; if (max_width_length < 1) max_width_length = 1; /* Test for positional argument. */ if (*cp >= '0' && *cp <= '9') { const CHAR_T *np; for (np = cp; *np >= '0' && *np <= '9'; np++) ; if (*np == '$') { size_t n = 0; for (np = cp; *np >= '0' && *np <= '9'; np++) n = xsum (xtimes (n, 10), *np - '0'); if (n == 0) /* Positional argument 0. */ goto error; if (size_overflow_p (n)) /* n too large, would lead to out of memory later. */ goto error; dp->width_arg_index = n - 1; cp = np + 1; } } if (dp->width_arg_index == ARG_NONE) { dp->width_arg_index = arg_posn++; if (dp->width_arg_index == ARG_NONE) /* arg_posn wrapped around. */ goto error; } REGISTER_ARG (dp->width_arg_index, TYPE_INT); } else if (*cp >= '0' && *cp <= '9') { size_t width_length; dp->width_start = cp; for (; *cp >= '0' && *cp <= '9'; cp++) ; dp->width_end = cp; width_length = dp->width_end - dp->width_start; if (max_width_length < width_length) max_width_length = width_length; } /* Parse the precision. */ if (*cp == '.') { cp++; if (*cp == '*') { dp->precision_start = cp - 1; cp++; dp->precision_end = cp; if (max_precision_length < 2) max_precision_length = 2; /* Test for positional argument. */ if (*cp >= '0' && *cp <= '9') { const CHAR_T *np; for (np = cp; *np >= '0' && *np <= '9'; np++) ; if (*np == '$') { size_t n = 0; for (np = cp; *np >= '0' && *np <= '9'; np++) n = xsum (xtimes (n, 10), *np - '0'); if (n == 0) /* Positional argument 0. */ goto error; if (size_overflow_p (n)) /* n too large, would lead to out of memory later. */ goto error; dp->precision_arg_index = n - 1; cp = np + 1; } } if (dp->precision_arg_index == ARG_NONE) { dp->precision_arg_index = arg_posn++; if (dp->precision_arg_index == ARG_NONE) /* arg_posn wrapped around. */ goto error; } REGISTER_ARG (dp->precision_arg_index, TYPE_INT); } else { size_t precision_length; dp->precision_start = cp - 1; for (; *cp >= '0' && *cp <= '9'; cp++) ; dp->precision_end = cp; precision_length = dp->precision_end - dp->precision_start; if (max_precision_length < precision_length) max_precision_length = precision_length; } } { arg_type type; /* Parse argument type/size specifiers. */ { int flags = 0; for (;;) { if (*cp == 'h') { flags |= (1 << (flags & 1)); cp++; } else if (*cp == 'L') { flags |= 4; cp++; } else if (*cp == 'l') { flags += 8; cp++; } else if (*cp == 'j') { if (sizeof (intmax_t) > sizeof (long)) { /* intmax_t = long long */ flags += 16; } else if (sizeof (intmax_t) > sizeof (int)) { /* intmax_t = long */ flags += 8; } cp++; } else if (*cp == 'z' || *cp == 'Z') { /* 'z' is standardized in ISO C 99, but glibc uses 'Z' because the warning facility in gcc-2.95.2 understands only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ if (sizeof (size_t) > sizeof (long)) { /* size_t = long long */ flags += 16; } else if (sizeof (size_t) > sizeof (int)) { /* size_t = long */ flags += 8; } cp++; } else if (*cp == 't') { if (sizeof (ptrdiff_t) > sizeof (long)) { /* ptrdiff_t = long long */ flags += 16; } else if (sizeof (ptrdiff_t) > sizeof (int)) { /* ptrdiff_t = long */ flags += 8; } cp++; } #if defined __APPLE__ && defined __MACH__ /* On Mac OS X 10.3, PRIdMAX is defined as "qd". We cannot change it to "lld" because PRIdMAX must also be understood by the system's printf routines. */ else if (*cp == 'q') { if (64 / 8 > sizeof (long)) { /* int64_t = long long */ flags += 16; } else { /* int64_t = long */ flags += 8; } cp++; } #endif #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* On native Windows, PRIdMAX is defined as "I64d". We cannot change it to "lld" because PRIdMAX must also be understood by the system's printf routines. */ else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') { if (64 / 8 > sizeof (long)) { /* __int64 = long long */ flags += 16; } else { /* __int64 = long */ flags += 8; } cp += 3; } #endif else break; } /* Read the conversion character. */ c = *cp++; switch (c) { case 'd': case 'i': #if HAVE_LONG_LONG_INT /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_LONGLONGINT; else #endif /* If 'long long' exists and is the same as 'long', we parse "lld" into TYPE_LONGINT. */ if (flags >= 8) type = TYPE_LONGINT; else if (flags & 2) type = TYPE_SCHAR; else if (flags & 1) type = TYPE_SHORT; else type = TYPE_INT; break; case 'o': case 'u': case 'x': case 'X': #if HAVE_LONG_LONG_INT /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_ULONGLONGINT; else #endif /* If 'unsigned long long' exists and is the same as 'unsigned long', we parse "llu" into TYPE_ULONGINT. */ if (flags >= 8) type = TYPE_ULONGINT; else if (flags & 2) type = TYPE_UCHAR; else if (flags & 1) type = TYPE_USHORT; else type = TYPE_UINT; break; case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': case 'a': case 'A': if (flags >= 16 || (flags & 4)) type = TYPE_LONGDOUBLE; else type = TYPE_DOUBLE; break; case 'c': if (flags >= 8) #if HAVE_WINT_T type = TYPE_WIDE_CHAR; #else goto error; #endif else type = TYPE_CHAR; break; #if HAVE_WINT_T case 'C': type = TYPE_WIDE_CHAR; c = 'c'; break; #endif case 's': if (flags >= 8) #if HAVE_WCHAR_T type = TYPE_WIDE_STRING; #else goto error; #endif else type = TYPE_STRING; break; #if HAVE_WCHAR_T case 'S': type = TYPE_WIDE_STRING; c = 's'; break; #endif case 'p': type = TYPE_POINTER; break; case 'n': #if HAVE_LONG_LONG_INT /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_COUNT_LONGLONGINT_POINTER; else #endif /* If 'long long' exists and is the same as 'long', we parse "lln" into TYPE_COUNT_LONGINT_POINTER. */ if (flags >= 8) type = TYPE_COUNT_LONGINT_POINTER; else if (flags & 2) type = TYPE_COUNT_SCHAR_POINTER; else if (flags & 1) type = TYPE_COUNT_SHORT_POINTER; else type = TYPE_COUNT_INT_POINTER; break; #if ENABLE_UNISTDIO /* The unistdio extensions. */ case 'U': if (flags >= 16) type = TYPE_U32_STRING; else if (flags >= 8) type = TYPE_U16_STRING; else type = TYPE_U8_STRING; break; #endif case '%': type = TYPE_NONE; break; default: /* Unknown conversion character. */ goto error; } } if (type != TYPE_NONE) { dp->arg_index = arg_index; if (dp->arg_index == ARG_NONE) { dp->arg_index = arg_posn++; if (dp->arg_index == ARG_NONE) /* arg_posn wrapped around. */ goto error; } REGISTER_ARG (dp->arg_index, type); } dp->conversion = c; dp->dir_end = cp; } d->count++; if (d->count >= d_allocated) { size_t memory_size; DIRECTIVE *memory; d_allocated = xtimes (d_allocated, 2); memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); if (size_overflow_p (memory_size)) /* Overflow, would lead to out of memory. */ goto out_of_memory; memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir ? realloc (d->dir, memory_size) : malloc (memory_size)); if (memory == NULL) /* Out of memory. */ goto out_of_memory; if (d->dir == d->direct_alloc_dir) memcpy (memory, d->dir, d->count * sizeof (DIRECTIVE)); d->dir = memory; } } #if CHAR_T_ONLY_ASCII else if (!c_isascii (c)) { /* Non-ASCII character. Not supported. */ goto error; } #endif } d->dir[d->count].dir_start = cp; d->max_width_length = max_width_length; d->max_precision_length = max_precision_length; return 0; error: if (a->arg != a->direct_alloc_arg) free (a->arg); if (d->dir != d->direct_alloc_dir) free (d->dir); errno = EINVAL; return -1; out_of_memory: if (a->arg != a->direct_alloc_arg) free (a->arg); if (d->dir != d->direct_alloc_dir) free (d->dir); errno = ENOMEM; return -1; } #undef PRINTF_PARSE #undef DIRECTIVES #undef DIRECTIVE #undef CHAR_T_ONLY_ASCII #undef CHAR_T lftp-4.6.3a/lib/asnprintf.c0000644000015000007670000000204612466374011012477 00000000000000/* Formatted output to strings. Copyright (C) 1999, 2002, 2006, 2009-2015 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 . */ #include /* Specification. */ #include "vasnprintf.h" #include char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) { va_list args; char *result; va_start (args, format); result = vasnprintf (resultbuf, lengthp, format, args); va_end (args); return result; } lftp-4.6.3a/lib/dosname.h0000644000015000007670000000373312466374011012132 00000000000000/* File names on MS-DOS/Windows systems. Copyright (C) 2000-2001, 2004-2006, 2009-2015 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 . From Paul Eggert and Jim Meyering. */ #ifndef _DOSNAME_H #define _DOSNAME_H #if (defined _WIN32 || defined __WIN32__ || \ defined __MSDOS__ || defined __CYGWIN__ || \ defined __EMX__ || defined __DJGPP__) /* This internal macro assumes ASCII, but all hosts that support drive letters use ASCII. */ # define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \ <= 'z' - 'a') # define FILE_SYSTEM_PREFIX_LEN(Filename) \ (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) # ifndef __CYGWIN__ # define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1 # endif # define ISSLASH(C) ((C) == '/' || (C) == '\\') #else # define FILE_SYSTEM_PREFIX_LEN(Filename) 0 # define ISSLASH(C) ((C) == '/') #endif #ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE # define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 #endif #if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) # else # define IS_ABSOLUTE_FILE_NAME(F) \ (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0) #endif #define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) #endif /* DOSNAME_H_ */ lftp-4.6.3a/lib/iconv_open-osf.h0000644000015000007670000002550512122621410013414 00000000000000/* ANSI-C code produced by gperf version 3.0.4 */ /* Command-line: gperf -m 10 ./iconv_open-osf.gperf */ /* Computed positions: -k'4,$' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "./iconv_open-osf.gperf" struct mapping { int standard_name; const char vendor_name[10 + 1]; }; #define TOTAL_KEYWORDS 38 #define MIN_WORD_LENGTH 4 #define MAX_WORD_LENGTH 11 #define MIN_HASH_VALUE 6 #define MAX_HASH_VALUE 47 /* maximum key range = 42, duplicates = 0 */ #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static unsigned int mapping_hash (register const char *str, register unsigned int len) { static const unsigned char asso_values[] = { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 2, 29, 24, 34, 31, 0, 15, 14, 10, 13, 2, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 7, 48, 48, 48, 48, 48, 48, 11, 48, 2, 7, 48, 48, 48, 1, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 }; return len + asso_values[(unsigned char)str[3]+3] + asso_values[(unsigned char)str[len - 1]]; } struct stringpool_t { char stringpool_str6[sizeof("CP1255")]; char stringpool_str7[sizeof("CP775")]; char stringpool_str8[sizeof("CP1250")]; char stringpool_str9[sizeof("EUC-TW")]; char stringpool_str10[sizeof("EUC-KR")]; char stringpool_str11[sizeof("TIS-620")]; char stringpool_str12[sizeof("ISO-8859-5")]; char stringpool_str13[sizeof("ISO-8859-15")]; char stringpool_str14[sizeof("BIG5")]; char stringpool_str15[sizeof("CP855")]; char stringpool_str16[sizeof("CP1258")]; char stringpool_str17[sizeof("CP850")]; char stringpool_str18[sizeof("CP865")]; char stringpool_str19[sizeof("EUC-JP")]; char stringpool_str20[sizeof("CP1257")]; char stringpool_str21[sizeof("CP1256")]; char stringpool_str22[sizeof("ISO-8859-8")]; char stringpool_str23[sizeof("SHIFT_JIS")]; char stringpool_str25[sizeof("ISO-8859-9")]; char stringpool_str26[sizeof("ISO-8859-7")]; char stringpool_str27[sizeof("ISO-8859-6")]; char stringpool_str29[sizeof("CP857")]; char stringpool_str30[sizeof("CP1252")]; char stringpool_str31[sizeof("CP869")]; char stringpool_str32[sizeof("CP949")]; char stringpool_str33[sizeof("CP866")]; char stringpool_str34[sizeof("CP437")]; char stringpool_str35[sizeof("CP1251")]; char stringpool_str36[sizeof("ISO-8859-2")]; char stringpool_str37[sizeof("CP1254")]; char stringpool_str38[sizeof("CP874")]; char stringpool_str39[sizeof("CP852")]; char stringpool_str40[sizeof("CP1253")]; char stringpool_str41[sizeof("ISO-8859-1")]; char stringpool_str42[sizeof("CP862")]; char stringpool_str43[sizeof("ISO-8859-4")]; char stringpool_str46[sizeof("ISO-8859-3")]; char stringpool_str47[sizeof("CP861")]; }; static const struct stringpool_t stringpool_contents = { "CP1255", "CP775", "CP1250", "EUC-TW", "EUC-KR", "TIS-620", "ISO-8859-5", "ISO-8859-15", "BIG5", "CP855", "CP1258", "CP850", "CP865", "EUC-JP", "CP1257", "CP1256", "ISO-8859-8", "SHIFT_JIS", "ISO-8859-9", "ISO-8859-7", "ISO-8859-6", "CP857", "CP1252", "CP869", "CP949", "CP866", "CP437", "CP1251", "ISO-8859-2", "CP1254", "CP874", "CP852", "CP1253", "ISO-8859-1", "CP862", "ISO-8859-4", "ISO-8859-3", "CP861" }; #define stringpool ((const char *) &stringpool_contents) static const struct mapping mappings[] = { {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, #line 41 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str6, "cp1255"}, #line 24 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str7, "cp775"}, #line 36 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str8, "cp1250"}, #line 47 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str9, "eucTW"}, #line 46 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str10, "eucKR"}, #line 50 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str11, "TACTIS"}, #line 17 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str12, "ISO8859-5"}, #line 22 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str13, "ISO8859-15"}, #line 48 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str14, "big5"}, #line 27 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, "cp855"}, #line 44 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str16, "cp1258"}, #line 25 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str17, "cp850"}, #line 31 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, "cp865"}, #line 45 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str19, "eucJP"}, #line 43 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str20, "cp1257"}, #line 42 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str21, "cp1256"}, #line 20 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str22, "ISO8859-8"}, #line 49 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str23, "SJIS"}, {-1}, #line 21 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str25, "ISO8859-9"}, #line 19 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str26, "ISO8859-7"}, #line 18 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str27, "ISO8859-6"}, {-1}, #line 28 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str29, "cp857"}, #line 38 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str30, "cp1252"}, #line 33 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str31, "cp869"}, #line 35 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str32, "KSC5601"}, #line 32 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str33, "cp866"}, #line 23 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str34, "cp437"}, #line 37 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str35, "cp1251"}, #line 14 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str36, "ISO8859-2"}, #line 40 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str37, "cp1254"}, #line 34 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str38, "cp874"}, #line 26 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str39, "cp852"}, #line 39 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str40, "cp1253"}, #line 13 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str41, "ISO8859-1"}, #line 30 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str42, "cp862"}, #line 16 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str43, "ISO8859-4"}, {-1}, {-1}, #line 15 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str46, "ISO8859-3"}, #line 29 "./iconv_open-osf.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str47, "cp861"} }; #ifdef __GNUC__ __inline #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ __attribute__ ((__gnu_inline__)) #endif #endif const struct mapping * mapping_lookup (register const char *str, register unsigned int len) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { register int key = mapping_hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) { register int o = mappings[key].standard_name; if (o >= 0) { register const char *s = o + stringpool; if (*str == *s && !strcmp (str + 1, s + 1)) return &mappings[key]; } } } return 0; } lftp-4.6.3a/lib/locale.in.h0000644000015000007670000001600212466374011012341 00000000000000/* A POSIX . Copyright (C) 2007-2015 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 . */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #ifdef _GL_ALREADY_INCLUDING_LOCALE_H /* Special invocation conventions to handle Solaris header files (through Solaris 10) when combined with gettext's libintl.h. */ #@INCLUDE_NEXT@ @NEXT_LOCALE_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_LOCALE_H #define _GL_ALREADY_INCLUDING_LOCALE_H /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_LOCALE_H@ #undef _GL_ALREADY_INCLUDING_LOCALE_H #ifndef _@GUARD_PREFIX@_LOCALE_H #define _@GUARD_PREFIX@_LOCALE_H /* NetBSD 5.0 mis-defines NULL. */ #include /* Mac OS X 10.5 defines the locale_t type in . */ #if @HAVE_XLOCALE_H@ # include #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. */ /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. On systems that don't define it, use the same value as GNU libintl. */ #if !defined LC_MESSAGES # define LC_MESSAGES 1729 #endif /* Bionic libc's 'struct lconv' is just a dummy. */ #if @REPLACE_STRUCT_LCONV@ # define lconv rpl_lconv struct lconv { /* All 'char *' are actually 'const char *'. */ /* Members that depend on the LC_NUMERIC category of the locale. See */ /* Symbol used as decimal point. */ char *decimal_point; /* Symbol used to separate groups of digits to the left of the decimal point. */ char *thousands_sep; /* Definition of the size of groups of digits to the left of the decimal point. */ char *grouping; /* Members that depend on the LC_MONETARY category of the locale. See */ /* Symbol used as decimal point. */ char *mon_decimal_point; /* Symbol used to separate groups of digits to the left of the decimal point. */ char *mon_thousands_sep; /* Definition of the size of groups of digits to the left of the decimal point. */ char *mon_grouping; /* Sign used to indicate a value >= 0. */ char *positive_sign; /* Sign used to indicate a value < 0. */ char *negative_sign; /* For formatting local currency. */ /* Currency symbol (3 characters) followed by separator (1 character). */ char *currency_symbol; /* Number of digits after the decimal point. */ char frac_digits; /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it comes after the number. */ char p_cs_precedes; /* For values >= 0: Position of the sign. */ char p_sign_posn; /* For values >= 0: Placement of spaces between currency symbol, sign, and number. */ char p_sep_by_space; /* For values < 0: 1 if the currency symbol precedes the number, 0 if it comes after the number. */ char n_cs_precedes; /* For values < 0: Position of the sign. */ char n_sign_posn; /* For values < 0: Placement of spaces between currency symbol, sign, and number. */ char n_sep_by_space; /* For formatting international currency. */ /* Currency symbol (3 characters) followed by separator (1 character). */ char *int_curr_symbol; /* Number of digits after the decimal point. */ char int_frac_digits; /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it comes after the number. */ char int_p_cs_precedes; /* For values >= 0: Position of the sign. */ char int_p_sign_posn; /* For values >= 0: Placement of spaces between currency symbol, sign, and number. */ char int_p_sep_by_space; /* For values < 0: 1 if the currency symbol precedes the number, 0 if it comes after the number. */ char int_n_cs_precedes; /* For values < 0: Position of the sign. */ char int_n_sign_posn; /* For values < 0: Placement of spaces between currency symbol, sign, and number. */ char int_n_sep_by_space; }; #endif #if @GNULIB_LOCALECONV@ # if @REPLACE_LOCALECONV@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef localeconv # define localeconv rpl_localeconv # endif _GL_FUNCDECL_RPL (localeconv, struct lconv *, (void)); _GL_CXXALIAS_RPL (localeconv, struct lconv *, (void)); # else _GL_CXXALIAS_SYS (localeconv, struct lconv *, (void)); # endif _GL_CXXALIASWARN (localeconv); #elif @REPLACE_STRUCT_LCONV@ # undef localeconv # define localeconv localeconv_used_without_requesting_gnulib_module_localeconv #elif defined GNULIB_POSIXCHECK # undef localeconv # if HAVE_RAW_DECL_LOCALECONV _GL_WARN_ON_USE (localeconv, "localeconv returns too few information on some platforms - " "use gnulib module localeconv for portability"); # endif #endif #if @GNULIB_SETLOCALE@ # if @REPLACE_SETLOCALE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef setlocale # define setlocale rpl_setlocale # define GNULIB_defined_setlocale 1 # endif _GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale)); _GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale)); # else _GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale)); # endif _GL_CXXALIASWARN (setlocale); #elif defined GNULIB_POSIXCHECK # undef setlocale # if HAVE_RAW_DECL_SETLOCALE _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - " "use gnulib module setlocale for portability"); # endif #endif #if @GNULIB_DUPLOCALE@ # if @REPLACE_DUPLOCALE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef duplocale # define duplocale rpl_duplocale # endif _GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); # else # if @HAVE_DUPLOCALE@ _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale)); # endif # endif # if @HAVE_DUPLOCALE@ _GL_CXXALIASWARN (duplocale); # endif #elif defined GNULIB_POSIXCHECK # undef duplocale # if HAVE_RAW_DECL_DUPLOCALE _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - " "use gnulib module duplocale for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_LOCALE_H */ #endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */ #endif /* _@GUARD_PREFIX@_LOCALE_H */ lftp-4.6.3a/lib/assure.h0000644000015000007670000000225612466374011012005 00000000000000/* Run-time assert-like macros. Copyright (C) 2014-2015 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 . */ /* Written by Paul Eggert. */ #ifndef _GL_ASSURE_H #define _GL_ASSURE_H #include /* Check E's value at runtime, and report an error and abort if not. However, do nothng if NDEBUG is defined. Unlike standard 'assert', this macro always compiles E even when NDEBUG is defined, so as to catch typos and avoid some GCC warnings. */ #ifdef NDEBUG # define assure(E) ((void) (0 && (E))) #else # define assure(E) assert (E) #endif #endif lftp-4.6.3a/lib/mbtowc-impl.h0000644000015000007670000000262612466374011012736 00000000000000/* Convert multibyte character to wide character. Copyright (C) 2011-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2011. 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 . */ /* We don't need a static internal state, because the encoding is not state dependent, and when mbrtowc returns (size_t)(-2). we throw the result away. */ int mbtowc (wchar_t *pwc, const char *s, size_t n) { if (s == NULL) return 0; else { mbstate_t state; wchar_t wc; size_t result; memset (&state, 0, sizeof (mbstate_t)); result = mbrtowc (&wc, s, n, &state); if (result == (size_t)-1 || result == (size_t)-2) { errno = EILSEQ; return -1; } if (pwc != NULL) *pwc = wc; return (wc == 0 ? 0 : result); } } lftp-4.6.3a/lib/mbswidth.h0000644000015000007670000000417612466374011012327 00000000000000/* Determine the number of screen columns needed for a string. Copyright (C) 2000-2004, 2007, 2009-2015 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 . */ #include /* Avoid a clash of our mbswidth() with a function of the same name defined in UnixWare 7.1.1 . We need this #include before the #define below. However, we don't want to #include on all platforms because - Tru64 with Desktop Toolkit C has a bug: must be included before . - BSD/OS 4.1 has a bug: and must be included before . */ #if HAVE_DECL_MBSWIDTH_IN_WCHAR_H # include #endif #ifdef __cplusplus extern "C" { #endif /* Optional flags to influence mbswidth/mbsnwidth behavior. */ /* If this bit is set, return -1 upon finding an invalid or incomplete character. Otherwise, assume invalid characters have width 1. */ #define MBSW_REJECT_INVALID 1 /* If this bit is set, return -1 upon finding a non-printable character. Otherwise, assume unprintable characters have width 0 if they are control characters and 1 otherwise. */ #define MBSW_REJECT_UNPRINTABLE 2 /* Returns the number of screen columns needed for STRING. */ #define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */ extern int mbswidth (const char *string, int flags); /* Returns the number of screen columns needed for the NBYTES bytes starting at BUF. */ extern int mbsnwidth (const char *buf, size_t nbytes, int flags); #ifdef __cplusplus } #endif lftp-4.6.3a/lib/wcwidth.c0000644000015000007670000000276612466374012012156 00000000000000/* Determine the number of screen columns needed for a character. Copyright (C) 2006-2007, 2010-2015 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 . */ #include /* Specification. */ #include /* Get iswprint. */ #include #include "localcharset.h" #include "streq.h" #include "uniwidth.h" int wcwidth (wchar_t wc) #undef wcwidth { /* In UTF-8 locales, use a Unicode aware width function. */ const char *encoding = locale_charset (); if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0 ,0)) { /* We assume that in a UTF-8 locale, a wide character is the same as a Unicode character. */ return uc_width1 (wc); } else { /* Otherwise, fall back to the system's wcwidth function. */ #if HAVE_WCWIDTH return wcwidth (wc); #else return wc == 0 ? 0 : iswprint (wc) ? 1 : -1; #endif } } lftp-4.6.3a/lib/sys_types.in.h0000644000015000007670000000330212466374012013144 00000000000000/* Provide a more complete sys/types.h. Copyright (C) 2011-2015 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 . */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #ifndef _@GUARD_PREFIX@_SYS_TYPES_H /* The include_next requires a split double-inclusion guard. */ # define _GL_INCLUDING_SYS_TYPES_H #@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ # undef _GL_INCLUDING_SYS_TYPES_H #ifndef _@GUARD_PREFIX@_SYS_TYPES_H #define _@GUARD_PREFIX@_SYS_TYPES_H /* Override off_t if Large File Support is requested on native Windows. */ #if @WINDOWS_64_BIT_OFF_T@ /* Same as int64_t in . */ # if defined _MSC_VER # define off_t __int64 # else # define off_t long long int # endif /* Indicator, for gnulib internal purposes. */ # define _GL_WINDOWS_64_BIT_OFF_T 1 #endif /* MSVC 9 defines size_t in , not in . */ /* But avoid namespace pollution on glibc systems. */ #if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \ && ! defined __GLIBC__ # include #endif #endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ #endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ lftp-4.6.3a/lib/mempcpy.c0000644000015000007670000000200212466374011012135 00000000000000/* Copy memory area and return pointer after last written byte. Copyright (C) 2003, 2007, 2009-2015 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 . */ #include /* Specification. */ #include /* Copy N bytes of SRC to DEST, return pointer to bytes after the last written byte. */ void * mempcpy (void *dest, const void *src, size_t n) { return (char *) memcpy (dest, src, n) + n; } lftp-4.6.3a/lib/msvc-inval.h0000644000015000007670000002113512466374011012557 00000000000000/* Invalid parameter handler for MSVC runtime libraries. Copyright (C) 2011-2015 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 . */ #ifndef _MSVC_INVAL_H #define _MSVC_INVAL_H /* With MSVC runtime libraries with the "invalid parameter handler" concept, functions like fprintf(), dup2(), or close() crash when the caller passes an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF) instead. This file defines macros that turn such an invalid parameter notification into a non-local exit. An error code can then be produced at the target of this exit. You can thus write code like TRY_MSVC_INVAL { } CATCH_MSVC_INVAL { } DONE_MSVC_INVAL; This entire block expands to a single statement. The handling of invalid parameters can be done in three ways: * The default way, which is reasonable for programs (not libraries): AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [DEFAULT_HANDLING]) * The way for libraries that make "hairy" calls (like close(-1), or fclose(fp) where fileno(fp) is closed, or simply getdtablesize()): AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [HAIRY_LIBRARY_HANDLING]) * The way for libraries that make no "hairy" calls: AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING]) */ #define DEFAULT_HANDLING 0 #define HAIRY_LIBRARY_HANDLING 1 #define SANE_LIBRARY_HANDLING 2 #if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING) /* A native Windows platform with the "invalid parameter handler" concept, and either DEFAULT_HANDLING or HAIRY_LIBRARY_HANDLING. */ # if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING /* Default handling. */ # ifdef __cplusplus extern "C" { # endif /* Ensure that the invalid parameter handler in installed that just returns. Because we assume no other part of the program installs a different invalid parameter handler, this solution is multithread-safe. */ extern void gl_msvc_inval_ensure_handler (void); # ifdef __cplusplus } # endif # define TRY_MSVC_INVAL \ do \ { \ gl_msvc_inval_ensure_handler (); \ if (1) # define CATCH_MSVC_INVAL \ else # define DONE_MSVC_INVAL \ } \ while (0) # else /* Handling for hairy libraries. */ # include /* Gnulib can define its own status codes, as described in the page "Raising Software Exceptions" on microsoft.com . Our status codes are composed of - 0xE0000000, mandatory for all user-defined status codes, - 0x474E550, a API identifier ("GNU"), - 0, 1, 2, ..., used to distinguish different status codes from the same API. */ # define STATUS_GNULIB_INVALID_PARAMETER (0xE0000000 + 0x474E550 + 0) # if defined _MSC_VER /* A compiler that supports __try/__except, as described in the page "try-except statement" on microsoft.com . With __try/__except, we can use the multithread-safe exception handling. */ # ifdef __cplusplus extern "C" { # endif /* Ensure that the invalid parameter handler in installed that raises a software exception with code STATUS_GNULIB_INVALID_PARAMETER. Because we assume no other part of the program installs a different invalid parameter handler, this solution is multithread-safe. */ extern void gl_msvc_inval_ensure_handler (void); # ifdef __cplusplus } # endif # define TRY_MSVC_INVAL \ do \ { \ gl_msvc_inval_ensure_handler (); \ __try # define CATCH_MSVC_INVAL \ __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \ ? EXCEPTION_EXECUTE_HANDLER \ : EXCEPTION_CONTINUE_SEARCH) # define DONE_MSVC_INVAL \ } \ while (0) # else /* Any compiler. We can only use setjmp/longjmp. */ # include # ifdef __cplusplus extern "C" { # endif struct gl_msvc_inval_per_thread { /* The restart that will resume execution at the code between CATCH_MSVC_INVAL and DONE_MSVC_INVAL. It is enabled only between TRY_MSVC_INVAL and CATCH_MSVC_INVAL. */ jmp_buf restart; /* Tells whether the contents of restart is valid. */ int restart_valid; }; /* Ensure that the invalid parameter handler in installed that passes control to the gl_msvc_inval_restart if it is valid, or raises a software exception with code STATUS_GNULIB_INVALID_PARAMETER otherwise. Because we assume no other part of the program installs a different invalid parameter handler, this solution is multithread-safe. */ extern void gl_msvc_inval_ensure_handler (void); /* Return a pointer to the per-thread data for the current thread. */ extern struct gl_msvc_inval_per_thread *gl_msvc_inval_current (void); # ifdef __cplusplus } # endif # define TRY_MSVC_INVAL \ do \ { \ struct gl_msvc_inval_per_thread *msvc_inval_current; \ gl_msvc_inval_ensure_handler (); \ msvc_inval_current = gl_msvc_inval_current (); \ /* First, initialize gl_msvc_inval_restart. */ \ if (setjmp (msvc_inval_current->restart) == 0) \ { \ /* Then, mark it as valid. */ \ msvc_inval_current->restart_valid = 1; # define CATCH_MSVC_INVAL \ /* Execution completed. \ Mark gl_msvc_inval_restart as invalid. */ \ msvc_inval_current->restart_valid = 0; \ } \ else \ { \ /* Execution triggered an invalid parameter notification. \ Mark gl_msvc_inval_restart as invalid. */ \ msvc_inval_current->restart_valid = 0; # define DONE_MSVC_INVAL \ } \ } \ while (0) # endif # endif #else /* A platform that does not need to the invalid parameter handler, or when SANE_LIBRARY_HANDLING is desired. */ /* The braces here avoid GCC warnings like "warning: suggest explicit braces to avoid ambiguous 'else'". */ # define TRY_MSVC_INVAL \ do \ { \ if (1) # define CATCH_MSVC_INVAL \ else # define DONE_MSVC_INVAL \ } \ while (0) #endif #endif /* _MSVC_INVAL_H */ lftp-4.6.3a/lib/fcntl.c0000644000015000007670000002376712466374011011616 00000000000000/* Provide file descriptor control. Copyright (C) 2009-2015 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 . */ /* Written by Eric Blake . */ #include /* Specification. */ #include #include #include #include #include #if !HAVE_FCNTL # define rpl_fcntl fcntl #endif #undef fcntl #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include /* Get _get_osfhandle. */ # include "msvc-nothrow.h" /* Upper bound on getdtablesize(). See lib/getdtablesize.c. */ # define OPEN_MAX_MAX 0x10000 /* Duplicate OLDFD into the first available slot of at least NEWFD, which must be positive, with FLAGS determining whether the duplicate will be inheritable. */ static int dupfd (int oldfd, int newfd, int flags) { /* Mingw has no way to create an arbitrary fd. Iterate until all file descriptors less than newfd are filled up. */ HANDLE curr_process = GetCurrentProcess (); HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd); unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT]; unsigned int fds_to_close_bound = 0; int result; BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE; int mode; if (newfd < 0 || getdtablesize () <= newfd) { errno = EINVAL; return -1; } if (old_handle == INVALID_HANDLE_VALUE || (mode = setmode (oldfd, O_BINARY)) == -1) { /* oldfd is not open, or is an unassigned standard file descriptor. */ errno = EBADF; return -1; } setmode (oldfd, mode); flags |= mode; for (;;) { HANDLE new_handle; int duplicated_fd; unsigned int index; if (!DuplicateHandle (curr_process, /* SourceProcessHandle */ old_handle, /* SourceHandle */ curr_process, /* TargetProcessHandle */ (PHANDLE) &new_handle, /* TargetHandle */ (DWORD) 0, /* DesiredAccess */ inherit, /* InheritHandle */ DUPLICATE_SAME_ACCESS)) /* Options */ { switch (GetLastError ()) { case ERROR_TOO_MANY_OPEN_FILES: errno = EMFILE; break; case ERROR_INVALID_HANDLE: case ERROR_INVALID_TARGET_HANDLE: case ERROR_DIRECT_ACCESS_HANDLE: errno = EBADF; break; case ERROR_INVALID_PARAMETER: case ERROR_INVALID_FUNCTION: case ERROR_INVALID_ACCESS: errno = EINVAL; break; default: errno = EACCES; break; } result = -1; break; } duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags); if (duplicated_fd < 0) { CloseHandle (new_handle); result = -1; break; } if (newfd <= duplicated_fd) { result = duplicated_fd; break; } /* Set the bit duplicated_fd in fds_to_close[]. */ index = (unsigned int) duplicated_fd / CHAR_BIT; if (fds_to_close_bound <= index) { if (sizeof fds_to_close <= index) /* Need to increase OPEN_MAX_MAX. */ abort (); memset (fds_to_close + fds_to_close_bound, '\0', index + 1 - fds_to_close_bound); fds_to_close_bound = index + 1; } fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT); } /* Close the previous fds that turned out to be too small. */ { int saved_errno = errno; unsigned int duplicated_fd; for (duplicated_fd = 0; duplicated_fd < fds_to_close_bound * CHAR_BIT; duplicated_fd++) if ((fds_to_close[duplicated_fd / CHAR_BIT] >> (duplicated_fd % CHAR_BIT)) & 1) close (duplicated_fd); errno = saved_errno; } # if REPLACE_FCHDIR if (0 <= result) result = _gl_register_dup (oldfd, result); # endif return result; } #endif /* W32 */ /* Perform the specified ACTION on the file descriptor FD, possibly using the argument ARG further described below. This replacement handles the following actions, and forwards all others on to the native fcntl. An unrecognized ACTION returns -1 with errno set to EINVAL. F_DUPFD - duplicate FD, with int ARG being the minimum target fd. If successful, return the duplicate, which will be inheritable; otherwise return -1 and set errno. F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum target fd. If successful, return the duplicate, which will not be inheritable; otherwise return -1 and set errno. F_GETFD - ARG need not be present. If successful, return a non-negative value containing the descriptor flags of FD (only FD_CLOEXEC is portable, but other flags may be present); otherwise return -1 and set errno. */ int rpl_fcntl (int fd, int action, /* arg */...) { va_list arg; int result = -1; va_start (arg, action); switch (action) { #if !HAVE_FCNTL case F_DUPFD: { int target = va_arg (arg, int); result = dupfd (fd, target, 0); break; } #elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR case F_DUPFD: { int target = va_arg (arg, int); /* Detect invalid target; needed for cygwin 1.5.x. */ if (target < 0 || getdtablesize () <= target) errno = EINVAL; else { /* Haiku alpha 2 loses fd flags on original. */ int flags = fcntl (fd, F_GETFD); if (flags < 0) { result = -1; break; } result = fcntl (fd, action, target); if (0 <= result && fcntl (fd, F_SETFD, flags) == -1) { int saved_errno = errno; close (result); result = -1; errno = saved_errno; } # if REPLACE_FCHDIR if (0 <= result) result = _gl_register_dup (fd, result); # endif } break; } /* F_DUPFD */ #endif /* FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR */ case F_DUPFD_CLOEXEC: { int target = va_arg (arg, int); #if !HAVE_FCNTL result = dupfd (fd, target, O_CLOEXEC); break; #else /* HAVE_FCNTL */ /* Try the system call first, if the headers claim it exists (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we may be running with a glibc that has the macro but with an older kernel that does not support it. Cache the information on whether the system call really works, but avoid caching failure if the corresponding F_DUPFD fails for any reason. 0 = unknown, 1 = yes, -1 = no. */ static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0; if (0 <= have_dupfd_cloexec) { result = fcntl (fd, action, target); if (0 <= result || errno != EINVAL) { have_dupfd_cloexec = 1; # if REPLACE_FCHDIR if (0 <= result) result = _gl_register_dup (fd, result); # endif } else { result = rpl_fcntl (fd, F_DUPFD, target); if (result < 0) break; have_dupfd_cloexec = -1; } } else result = rpl_fcntl (fd, F_DUPFD, target); if (0 <= result && have_dupfd_cloexec == -1) { int flags = fcntl (result, F_GETFD); if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1) { int saved_errno = errno; close (result); errno = saved_errno; result = -1; } } break; #endif /* HAVE_FCNTL */ } /* F_DUPFD_CLOEXEC */ #if !HAVE_FCNTL case F_GETFD: { # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ HANDLE handle = (HANDLE) _get_osfhandle (fd); DWORD flags; if (handle == INVALID_HANDLE_VALUE || GetHandleInformation (handle, &flags) == 0) errno = EBADF; else result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC; # else /* !W32 */ /* Use dup2 to reject invalid file descriptors. No way to access this information, so punt. */ if (0 <= dup2 (fd, fd)) result = 0; # endif /* !W32 */ break; } /* F_GETFD */ #endif /* !HAVE_FCNTL */ /* Implementing F_SETFD on mingw is not trivial - there is no API for changing the O_NOINHERIT bit on an fd, and merely changing the HANDLE_FLAG_INHERIT bit on the underlying handle can lead to odd state. It may be possible by duplicating the handle, using _open_osfhandle with the right flags, then using dup2 to move the duplicate onto the original, but that is not supported for now. */ default: { #if HAVE_FCNTL void *p = va_arg (arg, void *); result = fcntl (fd, action, p); #else errno = EINVAL; #endif break; } } va_end (arg); return result; } lftp-4.6.3a/lib/ref-add.sin0000644000015000007670000000175212466374011012347 00000000000000# Add this package to a list of references stored in a text file. # # Copyright (C) 2000, 2009-2015 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 . # # Written by Bruno Haible . # /^# Packages using this file: / { s/# Packages using this file:// ta :a s/ @PACKAGE@ / @PACKAGE@ / tb s/ $/ @PACKAGE@ / :b s/^/# Packages using this file:/ } lftp-4.6.3a/lib/vasnprintf.h0000644000015000007670000000560012466374012012672 00000000000000/* vsprintf with automatic memory allocation. Copyright (C) 2002-2004, 2007-2015 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 . */ #ifndef _VASNPRINTF_H #define _VASNPRINTF_H /* Get va_list. */ #include /* Get size_t. */ #include /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) #else # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif #ifdef __cplusplus extern "C" { #endif /* Write formatted output to a string dynamically allocated with malloc(). You can pass a preallocated buffer for the result in RESULTBUF and its size in *LENGTHP; otherwise you pass RESULTBUF = NULL. If successful, return the address of the string (this may be = RESULTBUF if no dynamic memory allocation was necessary) and set *LENGTHP to the number of resulting bytes, excluding the trailing NUL. Upon error, set errno and return NULL. When dynamic memory allocation occurs, the preallocated buffer is left alone (with possibly modified contents). This makes it possible to use a statically allocated or stack-allocated buffer, like this: char buf[100]; size_t len = sizeof (buf); char *output = vasnprintf (buf, &len, format, args); if (output == NULL) ... error handling ...; else { ... use the output string ...; if (output != buf) free (output); } */ #if REPLACE_VASNPRINTF # define asnprintf rpl_asnprintf # define vasnprintf rpl_vasnprintf #endif extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0)); #ifdef __cplusplus } #endif #endif /* _VASNPRINTF_H */ lftp-4.6.3a/lib/alloca.c0000644000015000007670000003445412122621311011721 00000000000000/* alloca.c -- allocate automatically reclaimed memory (Mostly) portable public-domain implementation -- D A Gwyn This implementation of the PWB library alloca function, which is used to allocate space off the run-time stack so that it is automatically reclaimed upon procedure exit, was inspired by discussions with J. Q. Johnson of Cornell. J.Otto Tennant contributed the Cray support. There are some preprocessor constants that can be defined when compiling for your specific system, for improved efficiency; however, the defaults should be okay. The general concept of this implementation is to keep track of all alloca-allocated blocks, and reclaim any that are found to be deeper in the stack than the current invocation. This heuristic does not reclaim storage as soon as it becomes invalid, but it will do so eventually. As a special case, alloca(0) reclaims storage without allocating any. It is a good idea to use alloca(0) in your main control loop, etc. to force garbage collection. */ #include #include #include #include #ifdef emacs # include "lisp.h" # include "blockinput.h" # ifdef EMACS_FREE # undef free # define free EMACS_FREE # endif #else # define memory_full() abort () #endif /* If compiling with GCC 2, this file's not needed. */ #if !defined (__GNUC__) || __GNUC__ < 2 /* If someone has defined alloca as a macro, there must be some other way alloca is supposed to work. */ # ifndef alloca # ifdef emacs # ifdef static /* actually, only want this if static is defined as "" -- this is for usg, in which emacs must undefine static in order to make unexec workable */ # ifndef STACK_DIRECTION you lose -- must know STACK_DIRECTION at compile-time /* Using #error here is not wise since this file should work for old and obscure compilers. */ # endif /* STACK_DIRECTION undefined */ # endif /* static */ # endif /* emacs */ /* If your stack is a linked list of frames, you have to provide an "address metric" ADDRESS_FUNCTION macro. */ # if defined (CRAY) && defined (CRAY_STACKSEG_END) long i00afunc (); # define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) # else # define ADDRESS_FUNCTION(arg) &(arg) # endif /* Define STACK_DIRECTION if you know the direction of stack growth for your system; otherwise it will be automatically deduced at run-time. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ # ifndef STACK_DIRECTION # define STACK_DIRECTION 0 /* Direction unknown. */ # endif # if STACK_DIRECTION != 0 # define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ # else /* STACK_DIRECTION == 0; need run-time code. */ static int stack_dir; /* 1 or -1 once known. */ # define STACK_DIR stack_dir static int find_stack_direction (int *addr, int depth) { int dir, dummy = 0; if (! addr) addr = &dummy; *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; dir = depth ? find_stack_direction (addr, depth - 1) : 0; return dir + dummy; } # endif /* STACK_DIRECTION == 0 */ /* An "alloca header" is used to: (a) chain together all alloca'ed blocks; (b) keep track of stack depth. It is very important that sizeof(header) agree with malloc alignment chunk size. The following default should work okay. */ # ifndef ALIGN_SIZE # define ALIGN_SIZE sizeof(double) # endif typedef union hdr { char align[ALIGN_SIZE]; /* To force sizeof(header). */ struct { union hdr *next; /* For chaining headers. */ char *deep; /* For stack depth measure. */ } h; } header; static header *last_alloca_header = NULL; /* -> last alloca header. */ /* Return a pointer to at least SIZE bytes of storage, which will be automatically reclaimed upon exit from the procedure that called alloca. Originally, this space was supposed to be taken from the current stack frame of the caller, but that method cannot be made to work for some implementations of C, for example under Gould's UTX/32. */ void * alloca (size_t size) { auto char probe; /* Probes stack depth: */ register char *depth = ADDRESS_FUNCTION (probe); # if STACK_DIRECTION == 0 if (STACK_DIR == 0) /* Unknown growth direction. */ STACK_DIR = find_stack_direction (NULL, (size & 1) + 20); # endif /* Reclaim garbage, defined as all alloca'd storage that was allocated from deeper in the stack than currently. */ { register header *hp; /* Traverses linked list. */ # ifdef emacs BLOCK_INPUT; # endif for (hp = last_alloca_header; hp != NULL;) if ((STACK_DIR > 0 && hp->h.deep > depth) || (STACK_DIR < 0 && hp->h.deep < depth)) { register header *np = hp->h.next; free (hp); /* Collect garbage. */ hp = np; /* -> next header. */ } else break; /* Rest are not deeper. */ last_alloca_header = hp; /* -> last valid storage. */ # ifdef emacs UNBLOCK_INPUT; # endif } if (size == 0) return NULL; /* No allocation required. */ /* Allocate combined header + user data storage. */ { /* Address of header. */ register header *new; size_t combined_size = sizeof (header) + size; if (combined_size < sizeof (header)) memory_full (); new = malloc (combined_size); if (! new) memory_full (); new->h.next = last_alloca_header; new->h.deep = depth; last_alloca_header = new; /* User storage begins just after header. */ return (void *) (new + 1); } } # if defined (CRAY) && defined (CRAY_STACKSEG_END) # ifdef DEBUG_I00AFUNC # include # endif # ifndef CRAY_STACK # define CRAY_STACK # ifndef CRAY2 /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ struct stack_control_header { long shgrow:32; /* Number of times stack has grown. */ long shaseg:32; /* Size of increments to stack. */ long shhwm:32; /* High water mark of stack. */ long shsize:32; /* Current size of stack (all segments). */ }; /* The stack segment linkage control information occurs at the high-address end of a stack segment. (The stack grows from low addresses to high addresses.) The initial part of the stack segment linkage control information is 0200 (octal) words. This provides for register storage for the routine which overflows the stack. */ struct stack_segment_linkage { long ss[0200]; /* 0200 overflow words. */ long sssize:32; /* Number of words in this segment. */ long ssbase:32; /* Offset to stack base. */ long:32; long sspseg:32; /* Offset to linkage control of previous segment of stack. */ long:32; long sstcpt:32; /* Pointer to task common address block. */ long sscsnm; /* Private control structure number for microtasking. */ long ssusr1; /* Reserved for user. */ long ssusr2; /* Reserved for user. */ long sstpid; /* Process ID for pid based multi-tasking. */ long ssgvup; /* Pointer to multitasking thread giveup. */ long sscray[7]; /* Reserved for Cray Research. */ long ssa0; long ssa1; long ssa2; long ssa3; long ssa4; long ssa5; long ssa6; long ssa7; long sss0; long sss1; long sss2; long sss3; long sss4; long sss5; long sss6; long sss7; }; # else /* CRAY2 */ /* The following structure defines the vector of words returned by the STKSTAT library routine. */ struct stk_stat { long now; /* Current total stack size. */ long maxc; /* Amount of contiguous space which would be required to satisfy the maximum stack demand to date. */ long high_water; /* Stack high-water mark. */ long overflows; /* Number of stack overflow ($STKOFEN) calls. */ long hits; /* Number of internal buffer hits. */ long extends; /* Number of block extensions. */ long stko_mallocs; /* Block allocations by $STKOFEN. */ long underflows; /* Number of stack underflow calls ($STKRETN). */ long stko_free; /* Number of deallocations by $STKRETN. */ long stkm_free; /* Number of deallocations by $STKMRET. */ long segments; /* Current number of stack segments. */ long maxs; /* Maximum number of stack segments so far. */ long pad_size; /* Stack pad size. */ long current_address; /* Current stack segment address. */ long current_size; /* Current stack segment size. This number is actually corrupted by STKSTAT to include the fifteen word trailer area. */ long initial_address; /* Address of initial segment. */ long initial_size; /* Size of initial segment. */ }; /* The following structure describes the data structure which trails any stack segment. I think that the description in 'asdef' is out of date. I only describe the parts that I am sure about. */ struct stk_trailer { long this_address; /* Address of this block. */ long this_size; /* Size of this block (does not include this trailer). */ long unknown2; long unknown3; long link; /* Address of trailer block of previous segment. */ long unknown5; long unknown6; long unknown7; long unknown8; long unknown9; long unknown10; long unknown11; long unknown12; long unknown13; long unknown14; }; # endif /* CRAY2 */ # endif /* not CRAY_STACK */ # ifdef CRAY2 /* Determine a "stack measure" for an arbitrary ADDRESS. I doubt that "lint" will like this much. */ static long i00afunc (long *address) { struct stk_stat status; struct stk_trailer *trailer; long *block, size; long result = 0; /* We want to iterate through all of the segments. The first step is to get the stack status structure. We could do this more quickly and more directly, perhaps, by referencing the $LM00 common block, but I know that this works. */ STKSTAT (&status); /* Set up the iteration. */ trailer = (struct stk_trailer *) (status.current_address + status.current_size - 15); /* There must be at least one stack segment. Therefore it is a fatal error if "trailer" is null. */ if (trailer == 0) abort (); /* Discard segments that do not contain our argument address. */ while (trailer != 0) { block = (long *) trailer->this_address; size = trailer->this_size; if (block == 0 || size == 0) abort (); trailer = (struct stk_trailer *) trailer->link; if ((block <= address) && (address < (block + size))) break; } /* Set the result to the offset in this segment and add the sizes of all predecessor segments. */ result = address - block; if (trailer == 0) { return result; } do { if (trailer->this_size <= 0) abort (); result += trailer->this_size; trailer = (struct stk_trailer *) trailer->link; } while (trailer != 0); /* We are done. Note that if you present a bogus address (one not in any segment), you will get a different number back, formed from subtracting the address of the first block. This is probably not what you want. */ return (result); } # else /* not CRAY2 */ /* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. Determine the number of the cell within the stack, given the address of the cell. The purpose of this routine is to linearize, in some sense, stack addresses for alloca. */ static long i00afunc (long address) { long stkl = 0; long size, pseg, this_segment, stack; long result = 0; struct stack_segment_linkage *ssptr; /* Register B67 contains the address of the end of the current stack segment. If you (as a subprogram) store your registers on the stack and find that you are past the contents of B67, you have overflowed the segment. B67 also points to the stack segment linkage control area, which is what we are really interested in. */ stkl = CRAY_STACKSEG_END (); ssptr = (struct stack_segment_linkage *) stkl; /* If one subtracts 'size' from the end of the segment, one has the address of the first word of the segment. If this is not the first segment, 'pseg' will be nonzero. */ pseg = ssptr->sspseg; size = ssptr->sssize; this_segment = stkl - size; /* It is possible that calling this routine itself caused a stack overflow. Discard stack segments which do not contain the target address. */ while (!(this_segment <= address && address <= stkl)) { # ifdef DEBUG_I00AFUNC fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); # endif if (pseg == 0) break; stkl = stkl - pseg; ssptr = (struct stack_segment_linkage *) stkl; size = ssptr->sssize; pseg = ssptr->sspseg; this_segment = stkl - size; } result = address - this_segment; /* If you subtract pseg from the current end of the stack, you get the address of the previous stack segment's end. This seems a little convoluted to me, but I'll bet you save a cycle somewhere. */ while (pseg != 0) { # ifdef DEBUG_I00AFUNC fprintf (stderr, "%011o %011o\n", pseg, size); # endif stkl = stkl - pseg; ssptr = (struct stack_segment_linkage *) stkl; size = ssptr->sssize; pseg = ssptr->sspseg; result += size; } return (result); } # endif /* not CRAY2 */ # endif /* CRAY */ # endif /* no alloca */ #endif /* not GCC 2 */ lftp-4.6.3a/lib/lstat.c0000644000015000007670000000667412466374011011635 00000000000000/* Work around a bug of lstat on some systems Copyright (C) 1997-2006, 2008-2015 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 . */ /* written by Jim Meyering */ /* If the user's config.h happens to include , let it include only the system's here, so that orig_lstat doesn't recurse to rpl_lstat. */ #define __need_system_sys_stat_h #include #if !HAVE_LSTAT /* On systems that lack symlinks, our replacement already defined lstat as stat, so there is nothing further to do other than avoid an empty file. */ typedef int dummy; #else /* HAVE_LSTAT */ /* Get the original definition of lstat. It might be defined as a macro. */ # include # include # undef __need_system_sys_stat_h static int orig_lstat (const char *filename, struct stat *buf) { return lstat (filename, buf); } /* Specification. */ /* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ # include "sys/stat.h" # include # include /* lstat works differently on Linux and Solaris systems. POSIX (see "pathname resolution" in the glossary) requires that programs like 'ls' take into consideration the fact that FILE has a trailing slash when FILE is a symbolic link. On Linux and Solaris 10 systems, the lstat function already has the desired semantics (in treating 'lstat ("symlink/", sbuf)' just like 'lstat ("symlink/.", sbuf)', but on Solaris 9 and earlier it does not. If FILE has a trailing slash and specifies a symbolic link, then use stat() to get more info on the referent of FILE. If the referent is a non-directory, then set errno to ENOTDIR and return -1. Otherwise, return stat's result. */ int rpl_lstat (const char *file, struct stat *sbuf) { size_t len; int lstat_result = orig_lstat (file, sbuf); if (lstat_result != 0) return lstat_result; /* This replacement file can blindly check against '/' rather than using the ISSLASH macro, because all platforms with '\\' either lack symlinks (mingw) or have working lstat (cygwin) and thus do not compile this file. 0 len should have already been filtered out above, with a failure return of ENOENT. */ len = strlen (file); if (file[len - 1] != '/' || S_ISDIR (sbuf->st_mode)) return 0; /* At this point, a trailing slash is only permitted on symlink-to-dir; but it should have found information on the directory, not the symlink. Call stat() to get info about the link's referent. Our replacement stat guarantees valid results, even if the symlink is not pointing to a directory. */ if (!S_ISLNK (sbuf->st_mode)) { errno = ENOTDIR; return -1; } return stat (file, sbuf); } #endif /* HAVE_LSTAT */ lftp-4.6.3a/lib/regcomp.c0000644000015000007670000033532012466374011012133 00000000000000/* Extended regular expression matching and search library. Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . The GNU C Library 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. The GNU C Library 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 the GNU C Library; if not, see . */ static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, size_t length, reg_syntax_t syntax); static void re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, char *fastmap); static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); #ifdef RE_ENABLE_I18N static void free_charset (re_charset_t *cset); #endif /* RE_ENABLE_I18N */ static void free_workarea_compile (regex_t *preg); static reg_errcode_t create_initial_state (re_dfa_t *dfa); #ifdef RE_ENABLE_I18N static void optimize_utf8 (re_dfa_t *dfa); #endif static reg_errcode_t analyze (regex_t *preg); static reg_errcode_t preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), void *extra); static reg_errcode_t postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), void *extra); static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node); static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node); static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node); static reg_errcode_t calc_first (void *extra, bin_tree_t *node); static reg_errcode_t calc_next (void *extra, bin_tree_t *node); static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node); static Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint); static Idx search_duplicated_node (const re_dfa_t *dfa, Idx org_node, unsigned int constraint); static reg_errcode_t calc_eclosure (re_dfa_t *dfa); static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root); static reg_errcode_t calc_inveclosure (re_dfa_t *dfa); static Idx fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax); static int peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) internal_function; static bin_tree_t *parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, reg_errcode_t *err); static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, reg_syntax_t syntax, Idx nest, reg_errcode_t *err); static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, reg_syntax_t syntax, Idx nest, reg_errcode_t *err); static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, reg_syntax_t syntax, Idx nest, reg_errcode_t *err); static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, reg_syntax_t syntax, Idx nest, reg_errcode_t *err); static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err); static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err); static reg_errcode_t parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, re_token_t *token, int token_len, re_dfa_t *dfa, reg_syntax_t syntax, bool accept_hyphen); static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp, re_token_t *token); #ifdef RE_ENABLE_I18N static reg_errcode_t build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, Idx *equiv_class_alloc, const unsigned char *name); static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, re_charset_t *mbcset, Idx *char_class_alloc, const char *class_name, reg_syntax_t syntax); #else /* not RE_ENABLE_I18N */ static reg_errcode_t build_equiv_class (bitset_t sbcset, const unsigned char *name); static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, const char *class_name, reg_syntax_t syntax); #endif /* not RE_ENABLE_I18N */ static bin_tree_t *build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, const char *class_name, const char *extra, bool non_match, reg_errcode_t *err); static bin_tree_t *create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, re_token_type_t type); static bin_tree_t *create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, const re_token_t *token); static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa); static void free_token (re_token_t *node); static reg_errcode_t free_tree (void *extra, bin_tree_t *node); static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node); /* This table gives an error message for each of the error codes listed in regex.h. Obviously the order here has to be same as there. POSIX doesn't require that we do anything for REG_NOERROR, but why not be nice? */ static const char __re_error_msgid[] = { #define REG_NOERROR_IDX 0 gettext_noop ("Success") /* REG_NOERROR */ "\0" #define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success") gettext_noop ("No match") /* REG_NOMATCH */ "\0" #define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match") gettext_noop ("Invalid regular expression") /* REG_BADPAT */ "\0" #define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression") gettext_noop ("Invalid collation character") /* REG_ECOLLATE */ "\0" #define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character") gettext_noop ("Invalid character class name") /* REG_ECTYPE */ "\0" #define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name") gettext_noop ("Trailing backslash") /* REG_EESCAPE */ "\0" #define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash") gettext_noop ("Invalid back reference") /* REG_ESUBREG */ "\0" #define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference") gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */ "\0" #define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^") gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */ "\0" #define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(") gettext_noop ("Unmatched \\{") /* REG_EBRACE */ "\0" #define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{") gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */ "\0" #define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}") gettext_noop ("Invalid range end") /* REG_ERANGE */ "\0" #define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end") gettext_noop ("Memory exhausted") /* REG_ESPACE */ "\0" #define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted") gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */ "\0" #define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression") gettext_noop ("Premature end of regular expression") /* REG_EEND */ "\0" #define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression") gettext_noop ("Regular expression too big") /* REG_ESIZE */ "\0" #define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big") gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */ }; static const size_t __re_error_msgid_idx[] = { REG_NOERROR_IDX, REG_NOMATCH_IDX, REG_BADPAT_IDX, REG_ECOLLATE_IDX, REG_ECTYPE_IDX, REG_EESCAPE_IDX, REG_ESUBREG_IDX, REG_EBRACK_IDX, REG_EPAREN_IDX, REG_EBRACE_IDX, REG_BADBR_IDX, REG_ERANGE_IDX, REG_ESPACE_IDX, REG_BADRPT_IDX, REG_EEND_IDX, REG_ESIZE_IDX, REG_ERPAREN_IDX }; /* Entry points for GNU code. */ /* re_compile_pattern is the GNU regular expression compiler: it compiles PATTERN (of length LENGTH) and puts the result in BUFP. Returns 0 if the pattern was valid, otherwise an error string. Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields are set in BUFP on entry. */ #ifdef _LIBC const char * re_compile_pattern (pattern, length, bufp) const char *pattern; size_t length; struct re_pattern_buffer *bufp; #else /* size_t might promote */ const char * re_compile_pattern (const char *pattern, size_t length, struct re_pattern_buffer *bufp) #endif { reg_errcode_t ret; /* And GNU code determines whether or not to get register information by passing null for the REGS argument to re_match, etc., not by setting no_sub, unless RE_NO_SUB is set. */ bufp->no_sub = !!(re_syntax_options & RE_NO_SUB); /* Match anchors at newline. */ bufp->newline_anchor = 1; ret = re_compile_internal (bufp, pattern, length, re_syntax_options); if (!ret) return NULL; return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); } #ifdef _LIBC weak_alias (__re_compile_pattern, re_compile_pattern) #endif /* Set by 're_set_syntax' to the current regexp syntax to recognize. Can also be assigned to arbitrarily: each pattern buffer stores its own syntax, so it can be changed between regex compilations. */ /* This has no initializer because initialized variables in Emacs become read-only after dumping. */ reg_syntax_t re_syntax_options; /* Specify the precise syntax of regexps for compilation. This provides for compatibility for various utilities which historically have different, incompatible syntaxes. The argument SYNTAX is a bit mask comprised of the various bits defined in regex.h. We return the old syntax. */ reg_syntax_t re_set_syntax (syntax) reg_syntax_t syntax; { reg_syntax_t ret = re_syntax_options; re_syntax_options = syntax; return ret; } #ifdef _LIBC weak_alias (__re_set_syntax, re_set_syntax) #endif int re_compile_fastmap (bufp) struct re_pattern_buffer *bufp; { re_dfa_t *dfa = bufp->buffer; char *fastmap = bufp->fastmap; memset (fastmap, '\0', sizeof (char) * SBC_MAX); re_compile_fastmap_iter (bufp, dfa->init_state, fastmap); if (dfa->init_state != dfa->init_state_word) re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap); if (dfa->init_state != dfa->init_state_nl) re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap); if (dfa->init_state != dfa->init_state_begbuf) re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap); bufp->fastmap_accurate = 1; return 0; } #ifdef _LIBC weak_alias (__re_compile_fastmap, re_compile_fastmap) #endif static inline void __attribute__ ((always_inline)) re_set_fastmap (char *fastmap, bool icase, int ch) { fastmap[ch] = 1; if (icase) fastmap[tolower (ch)] = 1; } /* Helper function for re_compile_fastmap. Compile fastmap for the initial_state INIT_STATE. */ static void re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, char *fastmap) { re_dfa_t *dfa = bufp->buffer; Idx node_cnt; bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE)); for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) { Idx node = init_state->nodes.elems[node_cnt]; re_token_type_t type = dfa->nodes[node].type; if (type == CHARACTER) { re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c); #ifdef RE_ENABLE_I18N if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) { unsigned char buf[MB_LEN_MAX]; unsigned char *p; wchar_t wc; mbstate_t state; p = buf; *p++ = dfa->nodes[node].opr.c; while (++node < dfa->nodes_len && dfa->nodes[node].type == CHARACTER && dfa->nodes[node].mb_partial) *p++ = dfa->nodes[node].opr.c; memset (&state, '\0', sizeof (state)); if (__mbrtowc (&wc, (const char *) buf, p - buf, &state) == p - buf && (__wcrtomb ((char *) buf, towlower (wc), &state) != (size_t) -1)) re_set_fastmap (fastmap, false, buf[0]); } #endif } else if (type == SIMPLE_BRACKET) { int i, ch; for (i = 0, ch = 0; i < BITSET_WORDS; ++i) { int j; bitset_word_t w = dfa->nodes[node].opr.sbcset[i]; for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) if (w & ((bitset_word_t) 1 << j)) re_set_fastmap (fastmap, icase, ch); } } #ifdef RE_ENABLE_I18N else if (type == COMPLEX_BRACKET) { re_charset_t *cset = dfa->nodes[node].opr.mbcset; Idx i; # ifdef _LIBC /* See if we have to try all bytes which start multiple collation elements. e.g. In da_DK, we want to catch 'a' since "aa" is a valid collation element, and don't catch 'b' since 'b' is the only collation element which starts from 'b' (and it is caught by SIMPLE_BRACKET). */ if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0 && (cset->ncoll_syms || cset->nranges)) { const int32_t *table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); for (i = 0; i < SBC_MAX; ++i) if (table[i] < 0) re_set_fastmap (fastmap, icase, i); } # endif /* _LIBC */ /* See if we have to start the match at all multibyte characters, i.e. where we would not find an invalid sequence. This only applies to multibyte character sets; for single byte character sets, the SIMPLE_BRACKET again suffices. */ if (dfa->mb_cur_max > 1 && (cset->nchar_classes || cset->non_match || cset->nranges # ifdef _LIBC || cset->nequiv_classes # endif /* _LIBC */ )) { unsigned char c = 0; do { mbstate_t mbs; memset (&mbs, 0, sizeof (mbs)); if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2) re_set_fastmap (fastmap, false, (int) c); } while (++c != 0); } else { /* ... Else catch all bytes which can start the mbchars. */ for (i = 0; i < cset->nmbchars; ++i) { char buf[256]; mbstate_t state; memset (&state, '\0', sizeof (state)); if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1) re_set_fastmap (fastmap, icase, *(unsigned char *) buf); if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) { if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state) != (size_t) -1) re_set_fastmap (fastmap, false, *(unsigned char *) buf); } } } } #endif /* RE_ENABLE_I18N */ else if (type == OP_PERIOD #ifdef RE_ENABLE_I18N || type == OP_UTF8_PERIOD #endif /* RE_ENABLE_I18N */ || type == END_OF_RE) { memset (fastmap, '\1', sizeof (char) * SBC_MAX); if (type == END_OF_RE) bufp->can_be_null = 1; return; } } } /* Entry point for POSIX code. */ /* regcomp takes a regular expression as a string and compiles it. PREG is a regex_t *. We do not expect any fields to be initialized, since POSIX says we shouldn't. Thus, we set 'buffer' to the compiled pattern; 'used' to the length of the compiled pattern; 'syntax' to RE_SYNTAX_POSIX_EXTENDED if the REG_EXTENDED bit in CFLAGS is set; otherwise, to RE_SYNTAX_POSIX_BASIC; 'newline_anchor' to REG_NEWLINE being set in CFLAGS; 'fastmap' to an allocated space for the fastmap; 'fastmap_accurate' to zero; 're_nsub' to the number of subexpressions in PATTERN. PATTERN is the address of the pattern string. CFLAGS is a series of bits which affect compilation. If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we use POSIX basic syntax. If REG_NEWLINE is set, then . and [^...] don't match newline. Also, regexec will try a match beginning after every newline. If REG_ICASE is set, then we considers upper- and lowercase versions of letters to be equivalent when matching. If REG_NOSUB is set, then when PREG is passed to regexec, that routine will report only success or failure, and nothing about the registers. It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for the return codes and their meanings.) */ int regcomp (preg, pattern, cflags) regex_t *_Restrict_ preg; const char *_Restrict_ pattern; int cflags; { reg_errcode_t ret; reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC); preg->buffer = NULL; preg->allocated = 0; preg->used = 0; /* Try to allocate space for the fastmap. */ preg->fastmap = re_malloc (char, SBC_MAX); if (BE (preg->fastmap == NULL, 0)) return REG_ESPACE; syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; /* If REG_NEWLINE is set, newlines are treated differently. */ if (cflags & REG_NEWLINE) { /* REG_NEWLINE implies neither . nor [^...] match newline. */ syntax &= ~RE_DOT_NEWLINE; syntax |= RE_HAT_LISTS_NOT_NEWLINE; /* It also changes the matching behavior. */ preg->newline_anchor = 1; } else preg->newline_anchor = 0; preg->no_sub = !!(cflags & REG_NOSUB); preg->translate = NULL; ret = re_compile_internal (preg, pattern, strlen (pattern), syntax); /* POSIX doesn't distinguish between an unmatched open-group and an unmatched close-group: both are REG_EPAREN. */ if (ret == REG_ERPAREN) ret = REG_EPAREN; /* We have already checked preg->fastmap != NULL. */ if (BE (ret == REG_NOERROR, 1)) /* Compute the fastmap now, since regexec cannot modify the pattern buffer. This function never fails in this implementation. */ (void) re_compile_fastmap (preg); else { /* Some error occurred while compiling the expression. */ re_free (preg->fastmap); preg->fastmap = NULL; } return (int) ret; } #ifdef _LIBC weak_alias (__regcomp, regcomp) #endif /* Returns a message corresponding to an error code, ERRCODE, returned from either regcomp or regexec. We don't use PREG here. */ #ifdef _LIBC size_t regerror (errcode, preg, errbuf, errbuf_size) int errcode; const regex_t *_Restrict_ preg; char *_Restrict_ errbuf; size_t errbuf_size; #else /* size_t might promote */ size_t regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf, size_t errbuf_size) #endif { const char *msg; size_t msg_size; if (BE (errcode < 0 || errcode >= (int) (sizeof (__re_error_msgid_idx) / sizeof (__re_error_msgid_idx[0])), 0)) /* Only error codes returned by the rest of the code should be passed to this routine. If we are given anything else, or if other regex code generates an invalid error code, then the program has a bug. Dump core so we can fix it. */ abort (); msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); msg_size = strlen (msg) + 1; /* Includes the null. */ if (BE (errbuf_size != 0, 1)) { size_t cpy_size = msg_size; if (BE (msg_size > errbuf_size, 0)) { cpy_size = errbuf_size - 1; errbuf[cpy_size] = '\0'; } memcpy (errbuf, msg, cpy_size); } return msg_size; } #ifdef _LIBC weak_alias (__regerror, regerror) #endif #ifdef RE_ENABLE_I18N /* This static array is used for the map to single-byte characters when UTF-8 is used. Otherwise we would allocate memory just to initialize it the same all the time. UTF-8 is the preferred encoding so this is a worthwhile optimization. */ static const bitset_t utf8_sb_map = { /* Set the first 128 bits. */ # if defined __GNUC__ && !defined __STRICT_ANSI__ [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX # else # if 4 * BITSET_WORD_BITS < ASCII_CHARS # error "bitset_word_t is narrower than 32 bits" # elif 3 * BITSET_WORD_BITS < ASCII_CHARS BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, # elif 2 * BITSET_WORD_BITS < ASCII_CHARS BITSET_WORD_MAX, BITSET_WORD_MAX, # elif 1 * BITSET_WORD_BITS < ASCII_CHARS BITSET_WORD_MAX, # endif (BITSET_WORD_MAX >> (SBC_MAX % BITSET_WORD_BITS == 0 ? 0 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS)) # endif }; #endif static void free_dfa_content (re_dfa_t *dfa) { Idx i, j; if (dfa->nodes) for (i = 0; i < dfa->nodes_len; ++i) free_token (dfa->nodes + i); re_free (dfa->nexts); for (i = 0; i < dfa->nodes_len; ++i) { if (dfa->eclosures != NULL) re_node_set_free (dfa->eclosures + i); if (dfa->inveclosures != NULL) re_node_set_free (dfa->inveclosures + i); if (dfa->edests != NULL) re_node_set_free (dfa->edests + i); } re_free (dfa->edests); re_free (dfa->eclosures); re_free (dfa->inveclosures); re_free (dfa->nodes); if (dfa->state_table) for (i = 0; i <= dfa->state_hash_mask; ++i) { struct re_state_table_entry *entry = dfa->state_table + i; for (j = 0; j < entry->num; ++j) { re_dfastate_t *state = entry->array[j]; free_state (state); } re_free (entry->array); } re_free (dfa->state_table); #ifdef RE_ENABLE_I18N if (dfa->sb_char != utf8_sb_map) re_free (dfa->sb_char); #endif re_free (dfa->subexp_map); #ifdef DEBUG re_free (dfa->re_str); #endif re_free (dfa); } /* Free dynamically allocated space used by PREG. */ void regfree (preg) regex_t *preg; { re_dfa_t *dfa = preg->buffer; if (BE (dfa != NULL, 1)) { lock_fini (dfa->lock); free_dfa_content (dfa); } preg->buffer = NULL; preg->allocated = 0; re_free (preg->fastmap); preg->fastmap = NULL; re_free (preg->translate); preg->translate = NULL; } #ifdef _LIBC weak_alias (__regfree, regfree) #endif /* Entry points compatible with 4.2 BSD regex library. We don't define them unless specifically requested. */ #if defined _REGEX_RE_COMP || defined _LIBC /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; char * # ifdef _LIBC /* Make these definitions weak in libc, so POSIX programs can redefine these names if they don't use our functions, and still use regcomp/regexec above without link errors. */ weak_function # endif re_comp (s) const char *s; { reg_errcode_t ret; char *fastmap; if (!s) { if (!re_comp_buf.buffer) return gettext ("No previous regular expression"); return 0; } if (re_comp_buf.buffer) { fastmap = re_comp_buf.fastmap; re_comp_buf.fastmap = NULL; __regfree (&re_comp_buf); memset (&re_comp_buf, '\0', sizeof (re_comp_buf)); re_comp_buf.fastmap = fastmap; } if (re_comp_buf.fastmap == NULL) { re_comp_buf.fastmap = (char *) malloc (SBC_MAX); if (re_comp_buf.fastmap == NULL) return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) REG_ESPACE]); } /* Since 're_exec' always passes NULL for the 'regs' argument, we don't need to initialize the pattern buffer fields which affect it. */ /* Match anchors at newlines. */ re_comp_buf.newline_anchor = 1; ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options); if (!ret) return NULL; /* Yes, we're discarding 'const' here if !HAVE_LIBINTL. */ return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); } #ifdef _LIBC libc_freeres_fn (free_mem) { __regfree (&re_comp_buf); } #endif #endif /* _REGEX_RE_COMP */ /* Internal entry point. Compile the regular expression PATTERN, whose length is LENGTH. SYNTAX indicate regular expression's syntax. */ static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, size_t length, reg_syntax_t syntax) { reg_errcode_t err = REG_NOERROR; re_dfa_t *dfa; re_string_t regexp; /* Initialize the pattern buffer. */ preg->fastmap_accurate = 0; preg->syntax = syntax; preg->not_bol = preg->not_eol = 0; preg->used = 0; preg->re_nsub = 0; preg->can_be_null = 0; preg->regs_allocated = REGS_UNALLOCATED; /* Initialize the dfa. */ dfa = preg->buffer; if (BE (preg->allocated < sizeof (re_dfa_t), 0)) { /* If zero allocated, but buffer is non-null, try to realloc enough space. This loses if buffer's address is bogus, but that is the user's responsibility. If ->buffer is NULL this is a simple allocation. */ dfa = re_realloc (preg->buffer, re_dfa_t, 1); if (dfa == NULL) return REG_ESPACE; preg->allocated = sizeof (re_dfa_t); preg->buffer = dfa; } preg->used = sizeof (re_dfa_t); err = init_dfa (dfa, length); if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0)) err = REG_ESPACE; if (BE (err != REG_NOERROR, 0)) { free_dfa_content (dfa); preg->buffer = NULL; preg->allocated = 0; return err; } #ifdef DEBUG /* Note: length+1 will not overflow since it is checked in init_dfa. */ dfa->re_str = re_malloc (char, length + 1); strncpy (dfa->re_str, pattern, length + 1); #endif err = re_string_construct (®exp, pattern, length, preg->translate, (syntax & RE_ICASE) != 0, dfa); if (BE (err != REG_NOERROR, 0)) { re_compile_internal_free_return: free_workarea_compile (preg); re_string_destruct (®exp); lock_fini (dfa->lock); free_dfa_content (dfa); preg->buffer = NULL; preg->allocated = 0; return err; } /* Parse the regular expression, and build a structure tree. */ preg->re_nsub = 0; dfa->str_tree = parse (®exp, preg, syntax, &err); if (BE (dfa->str_tree == NULL, 0)) goto re_compile_internal_free_return; /* Analyze the tree and create the nfa. */ err = analyze (preg); if (BE (err != REG_NOERROR, 0)) goto re_compile_internal_free_return; #ifdef RE_ENABLE_I18N /* If possible, do searching in single byte encoding to speed things up. */ if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL) optimize_utf8 (dfa); #endif /* Then create the initial state of the dfa. */ err = create_initial_state (dfa); /* Release work areas. */ free_workarea_compile (preg); re_string_destruct (®exp); if (BE (err != REG_NOERROR, 0)) { lock_fini (dfa->lock); free_dfa_content (dfa); preg->buffer = NULL; preg->allocated = 0; } return err; } /* Initialize DFA. We use the length of the regular expression PAT_LEN as the initial length of some arrays. */ static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len) { __re_size_t table_size; #ifndef _LIBC const char *codeset_name; #endif #ifdef RE_ENABLE_I18N size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); #else size_t max_i18n_object_size = 0; #endif size_t max_object_size = MAX (sizeof (struct re_state_table_entry), MAX (sizeof (re_token_t), MAX (sizeof (re_node_set), MAX (sizeof (regmatch_t), max_i18n_object_size)))); memset (dfa, '\0', sizeof (re_dfa_t)); /* Force allocation of str_tree_storage the first time. */ dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; /* Avoid overflows. The extra "/ 2" is for the table_size doubling calculation below, and for similar doubling calculations elsewhere. And it's <= rather than <, because some of the doubling calculations add 1 afterwards. */ if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 <= pat_len, 0)) return REG_ESPACE; dfa->nodes_alloc = pat_len + 1; dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc); /* table_size = 2 ^ ceil(log pat_len) */ for (table_size = 1; ; table_size <<= 1) if (table_size > pat_len) break; dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); dfa->state_hash_mask = table_size - 1; dfa->mb_cur_max = MB_CUR_MAX; #ifdef _LIBC if (dfa->mb_cur_max == 6 && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0) dfa->is_utf8 = 1; dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII) != 0); #else codeset_name = nl_langinfo (CODESET); if ((codeset_name[0] == 'U' || codeset_name[0] == 'u') && (codeset_name[1] == 'T' || codeset_name[1] == 't') && (codeset_name[2] == 'F' || codeset_name[2] == 'f') && strcmp (codeset_name + 3 + (codeset_name[3] == '-'), "8") == 0) dfa->is_utf8 = 1; /* We check exhaustively in the loop below if this charset is a superset of ASCII. */ dfa->map_notascii = 0; #endif #ifdef RE_ENABLE_I18N if (dfa->mb_cur_max > 1) { if (dfa->is_utf8) dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map; else { int i, j, ch; dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); if (BE (dfa->sb_char == NULL, 0)) return REG_ESPACE; /* Set the bits corresponding to single byte chars. */ for (i = 0, ch = 0; i < BITSET_WORDS; ++i) for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) { wint_t wch = __btowc (ch); if (wch != WEOF) dfa->sb_char[i] |= (bitset_word_t) 1 << j; # ifndef _LIBC if (isascii (ch) && wch != ch) dfa->map_notascii = 1; # endif } } } #endif if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0)) return REG_ESPACE; return REG_NOERROR; } /* Initialize WORD_CHAR table, which indicate which character is "word". In this case "word" means that it is the word construction character used by some operators like "\<", "\>", etc. */ static void internal_function init_word_char (re_dfa_t *dfa) { int i = 0; int j; int ch = 0; dfa->word_ops_used = 1; if (BE (dfa->map_notascii == 0, 1)) { bitset_word_t bits0 = 0x00000000; bitset_word_t bits1 = 0x03ff0000; bitset_word_t bits2 = 0x87fffffe; bitset_word_t bits3 = 0x07fffffe; if (BITSET_WORD_BITS == 64) { dfa->word_char[0] = bits1 << 31 << 1 | bits0; dfa->word_char[1] = bits3 << 31 << 1 | bits2; i = 2; } else if (BITSET_WORD_BITS == 32) { dfa->word_char[0] = bits0; dfa->word_char[1] = bits1; dfa->word_char[2] = bits2; dfa->word_char[3] = bits3; i = 4; } else goto general_case; ch = 128; if (BE (dfa->is_utf8, 1)) { memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); return; } } general_case: for (; i < BITSET_WORDS; ++i) for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) if (isalnum (ch) || ch == '_') dfa->word_char[i] |= (bitset_word_t) 1 << j; } /* Free the work area which are only used while compiling. */ static void free_workarea_compile (regex_t *preg) { re_dfa_t *dfa = preg->buffer; bin_tree_storage_t *storage, *next; for (storage = dfa->str_tree_storage; storage; storage = next) { next = storage->next; re_free (storage); } dfa->str_tree_storage = NULL; dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; dfa->str_tree = NULL; re_free (dfa->org_indices); dfa->org_indices = NULL; } /* Create initial states for all contexts. */ static reg_errcode_t create_initial_state (re_dfa_t *dfa) { Idx first, i; reg_errcode_t err; re_node_set init_nodes; /* Initial states have the epsilon closure of the node which is the first node of the regular expression. */ first = dfa->str_tree->first->node_idx; dfa->init_node = first; err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); if (BE (err != REG_NOERROR, 0)) return err; /* The back-references which are in initial states can epsilon transit, since in this case all of the subexpressions can be null. Then we add epsilon closures of the nodes which are the next nodes of the back-references. */ if (dfa->nbackref > 0) for (i = 0; i < init_nodes.nelem; ++i) { Idx node_idx = init_nodes.elems[i]; re_token_type_t type = dfa->nodes[node_idx].type; Idx clexp_idx; if (type != OP_BACK_REF) continue; for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx) { re_token_t *clexp_node; clexp_node = dfa->nodes + init_nodes.elems[clexp_idx]; if (clexp_node->type == OP_CLOSE_SUBEXP && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx) break; } if (clexp_idx == init_nodes.nelem) continue; if (type == OP_BACK_REF) { Idx dest_idx = dfa->edests[node_idx].elems[0]; if (!re_node_set_contains (&init_nodes, dest_idx)) { reg_errcode_t merge_err = re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx); if (merge_err != REG_NOERROR) return merge_err; i = 0; } } } /* It must be the first time to invoke acquire_state. */ dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); /* We don't check ERR here, since the initial state must not be NULL. */ if (BE (dfa->init_state == NULL, 0)) return err; if (dfa->init_state->has_constraint) { dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes, CONTEXT_WORD); dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes, CONTEXT_NEWLINE); dfa->init_state_begbuf = re_acquire_state_context (&err, dfa, &init_nodes, CONTEXT_NEWLINE | CONTEXT_BEGBUF); if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL || dfa->init_state_begbuf == NULL, 0)) return err; } else dfa->init_state_word = dfa->init_state_nl = dfa->init_state_begbuf = dfa->init_state; re_node_set_free (&init_nodes); return REG_NOERROR; } #ifdef RE_ENABLE_I18N /* If it is possible to do searching in single byte encoding instead of UTF-8 to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change DFA nodes where needed. */ static void optimize_utf8 (re_dfa_t *dfa) { Idx node; int i; bool mb_chars = false; bool has_period = false; for (node = 0; node < dfa->nodes_len; ++node) switch (dfa->nodes[node].type) { case CHARACTER: if (dfa->nodes[node].opr.c >= ASCII_CHARS) mb_chars = true; break; case ANCHOR: switch (dfa->nodes[node].opr.ctx_type) { case LINE_FIRST: case LINE_LAST: case BUF_FIRST: case BUF_LAST: break; default: /* Word anchors etc. cannot be handled. It's okay to test opr.ctx_type since constraints (for all DFA nodes) are created by ORing one or more opr.ctx_type values. */ return; } break; case OP_PERIOD: has_period = true; break; case OP_BACK_REF: case OP_ALT: case END_OF_RE: case OP_DUP_ASTERISK: case OP_OPEN_SUBEXP: case OP_CLOSE_SUBEXP: break; case COMPLEX_BRACKET: return; case SIMPLE_BRACKET: /* Just double check. */ { int rshift = (ASCII_CHARS % BITSET_WORD_BITS == 0 ? 0 : BITSET_WORD_BITS - ASCII_CHARS % BITSET_WORD_BITS); for (i = ASCII_CHARS / BITSET_WORD_BITS; i < BITSET_WORDS; ++i) { if (dfa->nodes[node].opr.sbcset[i] >> rshift != 0) return; rshift = 0; } } break; default: abort (); } if (mb_chars || has_period) for (node = 0; node < dfa->nodes_len; ++node) { if (dfa->nodes[node].type == CHARACTER && dfa->nodes[node].opr.c >= ASCII_CHARS) dfa->nodes[node].mb_partial = 0; else if (dfa->nodes[node].type == OP_PERIOD) dfa->nodes[node].type = OP_UTF8_PERIOD; } /* The search can be in single byte locale. */ dfa->mb_cur_max = 1; dfa->is_utf8 = 0; dfa->has_mb_node = dfa->nbackref > 0 || has_period; } #endif /* Analyze the structure tree, and calculate "first", "next", "edest", "eclosure", and "inveclosure". */ static reg_errcode_t analyze (regex_t *preg) { re_dfa_t *dfa = preg->buffer; reg_errcode_t ret; /* Allocate arrays. */ dfa->nexts = re_malloc (Idx, dfa->nodes_alloc); dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc); dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL || dfa->eclosures == NULL, 0)) return REG_ESPACE; dfa->subexp_map = re_malloc (Idx, preg->re_nsub); if (dfa->subexp_map != NULL) { Idx i; for (i = 0; i < preg->re_nsub; i++) dfa->subexp_map[i] = i; preorder (dfa->str_tree, optimize_subexps, dfa); for (i = 0; i < preg->re_nsub; i++) if (dfa->subexp_map[i] != i) break; if (i == preg->re_nsub) { free (dfa->subexp_map); dfa->subexp_map = NULL; } } ret = postorder (dfa->str_tree, lower_subexps, preg); if (BE (ret != REG_NOERROR, 0)) return ret; ret = postorder (dfa->str_tree, calc_first, dfa); if (BE (ret != REG_NOERROR, 0)) return ret; preorder (dfa->str_tree, calc_next, dfa); ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); if (BE (ret != REG_NOERROR, 0)) return ret; ret = calc_eclosure (dfa); if (BE (ret != REG_NOERROR, 0)) return ret; /* We only need this during the prune_impossible_nodes pass in regexec.c; skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */ if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match) || dfa->nbackref) { dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); if (BE (dfa->inveclosures == NULL, 0)) return REG_ESPACE; ret = calc_inveclosure (dfa); } return ret; } /* Our parse trees are very unbalanced, so we cannot use a stack to implement parse tree visits. Instead, we use parent pointers and some hairy code in these two functions. */ static reg_errcode_t postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), void *extra) { bin_tree_t *node, *prev; for (node = root; ; ) { /* Descend down the tree, preferably to the left (or to the right if that's the only child). */ while (node->left || node->right) if (node->left) node = node->left; else node = node->right; do { reg_errcode_t err = fn (extra, node); if (BE (err != REG_NOERROR, 0)) return err; if (node->parent == NULL) return REG_NOERROR; prev = node; node = node->parent; } /* Go up while we have a node that is reached from the right. */ while (node->right == prev || node->right == NULL); node = node->right; } } static reg_errcode_t preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), void *extra) { bin_tree_t *node; for (node = root; ; ) { reg_errcode_t err = fn (extra, node); if (BE (err != REG_NOERROR, 0)) return err; /* Go to the left node, or up and to the right. */ if (node->left) node = node->left; else { bin_tree_t *prev = NULL; while (node->right == prev || node->right == NULL) { prev = node; node = node->parent; if (!node) return REG_NOERROR; } node = node->right; } } } /* Optimization pass: if a SUBEXP is entirely contained, strip it and tell re_search_internal to map the inner one's opr.idx to this one's. Adjust backreferences as well. Requires a preorder visit. */ static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node) { re_dfa_t *dfa = (re_dfa_t *) extra; if (node->token.type == OP_BACK_REF && dfa->subexp_map) { int idx = node->token.opr.idx; node->token.opr.idx = dfa->subexp_map[idx]; dfa->used_bkref_map |= 1 << node->token.opr.idx; } else if (node->token.type == SUBEXP && node->left && node->left->token.type == SUBEXP) { Idx other_idx = node->left->token.opr.idx; node->left = node->left->left; if (node->left) node->left->parent = node; dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; if (other_idx < BITSET_WORD_BITS) dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx); } return REG_NOERROR; } /* Lowering pass: Turn each SUBEXP node into the appropriate concatenation of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */ static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node) { regex_t *preg = (regex_t *) extra; reg_errcode_t err = REG_NOERROR; if (node->left && node->left->token.type == SUBEXP) { node->left = lower_subexp (&err, preg, node->left); if (node->left) node->left->parent = node; } if (node->right && node->right->token.type == SUBEXP) { node->right = lower_subexp (&err, preg, node->right); if (node->right) node->right->parent = node; } return err; } static bin_tree_t * lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node) { re_dfa_t *dfa = preg->buffer; bin_tree_t *body = node->left; bin_tree_t *op, *cls, *tree1, *tree; if (preg->no_sub /* We do not optimize empty subexpressions, because otherwise we may have bad CONCAT nodes with NULL children. This is obviously not very common, so we do not lose much. An example that triggers this case is the sed "script" /\(\)/x. */ && node->left != NULL && (node->token.opr.idx >= BITSET_WORD_BITS || !(dfa->used_bkref_map & ((bitset_word_t) 1 << node->token.opr.idx)))) return node->left; /* Convert the SUBEXP node to the concatenation of an OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP. */ op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP); cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; tree = create_tree (dfa, op, tree1, CONCAT); if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0)) { *err = REG_ESPACE; return NULL; } op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx; op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp; return tree; } /* Pass 1 in building the NFA: compute FIRST and create unlinked automaton nodes. Requires a postorder visit. */ static reg_errcode_t calc_first (void *extra, bin_tree_t *node) { re_dfa_t *dfa = (re_dfa_t *) extra; if (node->token.type == CONCAT) { node->first = node->left->first; node->node_idx = node->left->node_idx; } else { node->first = node; node->node_idx = re_dfa_add_node (dfa, node->token); if (BE (node->node_idx == REG_MISSING, 0)) return REG_ESPACE; if (node->token.type == ANCHOR) dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; } return REG_NOERROR; } /* Pass 2: compute NEXT on the tree. Preorder visit. */ static reg_errcode_t calc_next (void *extra, bin_tree_t *node) { switch (node->token.type) { case OP_DUP_ASTERISK: node->left->next = node; break; case CONCAT: node->left->next = node->right->first; node->right->next = node->next; break; default: if (node->left) node->left->next = node->next; if (node->right) node->right->next = node->next; break; } return REG_NOERROR; } /* Pass 3: link all DFA nodes to their NEXT node (any order will do). */ static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node) { re_dfa_t *dfa = (re_dfa_t *) extra; Idx idx = node->node_idx; reg_errcode_t err = REG_NOERROR; switch (node->token.type) { case CONCAT: break; case END_OF_RE: assert (node->next == NULL); break; case OP_DUP_ASTERISK: case OP_ALT: { Idx left, right; dfa->has_plural_match = 1; if (node->left != NULL) left = node->left->first->node_idx; else left = node->next->node_idx; if (node->right != NULL) right = node->right->first->node_idx; else right = node->next->node_idx; assert (REG_VALID_INDEX (left)); assert (REG_VALID_INDEX (right)); err = re_node_set_init_2 (dfa->edests + idx, left, right); } break; case ANCHOR: case OP_OPEN_SUBEXP: case OP_CLOSE_SUBEXP: err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx); break; case OP_BACK_REF: dfa->nexts[idx] = node->next->node_idx; if (node->token.type == OP_BACK_REF) err = re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]); break; default: assert (!IS_EPSILON_NODE (node->token.type)); dfa->nexts[idx] = node->next->node_idx; break; } return err; } /* Duplicate the epsilon closure of the node ROOT_NODE. Note that duplicated nodes have constraint INIT_CONSTRAINT in addition to their own constraint. */ static reg_errcode_t internal_function duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, Idx root_node, unsigned int init_constraint) { Idx org_node, clone_node; bool ok; unsigned int constraint = init_constraint; for (org_node = top_org_node, clone_node = top_clone_node;;) { Idx org_dest, clone_dest; if (dfa->nodes[org_node].type == OP_BACK_REF) { /* If the back reference epsilon-transit, its destination must also have the constraint. Then duplicate the epsilon closure of the destination of the back reference, and store it in edests of the back reference. */ org_dest = dfa->nexts[org_node]; re_node_set_empty (dfa->edests + clone_node); clone_dest = duplicate_node (dfa, org_dest, constraint); if (BE (clone_dest == REG_MISSING, 0)) return REG_ESPACE; dfa->nexts[clone_node] = dfa->nexts[org_node]; ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (! ok, 0)) return REG_ESPACE; } else if (dfa->edests[org_node].nelem == 0) { /* In case of the node can't epsilon-transit, don't duplicate the destination and store the original destination as the destination of the node. */ dfa->nexts[clone_node] = dfa->nexts[org_node]; break; } else if (dfa->edests[org_node].nelem == 1) { /* In case of the node can epsilon-transit, and it has only one destination. */ org_dest = dfa->edests[org_node].elems[0]; re_node_set_empty (dfa->edests + clone_node); /* If the node is root_node itself, it means the epsilon closure has a loop. Then tie it to the destination of the root_node. */ if (org_node == root_node && clone_node != org_node) { ok = re_node_set_insert (dfa->edests + clone_node, org_dest); if (BE (! ok, 0)) return REG_ESPACE; break; } /* In case the node has another constraint, append it. */ constraint |= dfa->nodes[org_node].constraint; clone_dest = duplicate_node (dfa, org_dest, constraint); if (BE (clone_dest == REG_MISSING, 0)) return REG_ESPACE; ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (! ok, 0)) return REG_ESPACE; } else /* dfa->edests[org_node].nelem == 2 */ { /* In case of the node can epsilon-transit, and it has two destinations. In the bin_tree_t and DFA, that's '|' and '*'. */ org_dest = dfa->edests[org_node].elems[0]; re_node_set_empty (dfa->edests + clone_node); /* Search for a duplicated node which satisfies the constraint. */ clone_dest = search_duplicated_node (dfa, org_dest, constraint); if (clone_dest == REG_MISSING) { /* There is no such duplicated node, create a new one. */ reg_errcode_t err; clone_dest = duplicate_node (dfa, org_dest, constraint); if (BE (clone_dest == REG_MISSING, 0)) return REG_ESPACE; ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (! ok, 0)) return REG_ESPACE; err = duplicate_node_closure (dfa, org_dest, clone_dest, root_node, constraint); if (BE (err != REG_NOERROR, 0)) return err; } else { /* There is a duplicated node which satisfies the constraint, use it to avoid infinite loop. */ ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (! ok, 0)) return REG_ESPACE; } org_dest = dfa->edests[org_node].elems[1]; clone_dest = duplicate_node (dfa, org_dest, constraint); if (BE (clone_dest == REG_MISSING, 0)) return REG_ESPACE; ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (! ok, 0)) return REG_ESPACE; } org_node = org_dest; clone_node = clone_dest; } return REG_NOERROR; } /* Search for a node which is duplicated from the node ORG_NODE, and satisfies the constraint CONSTRAINT. */ static Idx search_duplicated_node (const re_dfa_t *dfa, Idx org_node, unsigned int constraint) { Idx idx; for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx) { if (org_node == dfa->org_indices[idx] && constraint == dfa->nodes[idx].constraint) return idx; /* Found. */ } return REG_MISSING; /* Not found. */ } /* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. Return the index of the new node, or REG_MISSING if insufficient storage is available. */ static Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint) { Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); if (BE (dup_idx != REG_MISSING, 1)) { dfa->nodes[dup_idx].constraint = constraint; dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; dfa->nodes[dup_idx].duplicated = 1; /* Store the index of the original node. */ dfa->org_indices[dup_idx] = org_idx; } return dup_idx; } static reg_errcode_t calc_inveclosure (re_dfa_t *dfa) { Idx src, idx; bool ok; for (idx = 0; idx < dfa->nodes_len; ++idx) re_node_set_init_empty (dfa->inveclosures + idx); for (src = 0; src < dfa->nodes_len; ++src) { Idx *elems = dfa->eclosures[src].elems; for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) { ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); if (BE (! ok, 0)) return REG_ESPACE; } } return REG_NOERROR; } /* Calculate "eclosure" for all the node in DFA. */ static reg_errcode_t calc_eclosure (re_dfa_t *dfa) { Idx node_idx; bool incomplete; #ifdef DEBUG assert (dfa->nodes_len > 0); #endif incomplete = false; /* For each nodes, calculate epsilon closure. */ for (node_idx = 0; ; ++node_idx) { reg_errcode_t err; re_node_set eclosure_elem; if (node_idx == dfa->nodes_len) { if (!incomplete) break; incomplete = false; node_idx = 0; } #ifdef DEBUG assert (dfa->eclosures[node_idx].nelem != REG_MISSING); #endif /* If we have already calculated, skip it. */ if (dfa->eclosures[node_idx].nelem != 0) continue; /* Calculate epsilon closure of 'node_idx'. */ err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); if (BE (err != REG_NOERROR, 0)) return err; if (dfa->eclosures[node_idx].nelem == 0) { incomplete = true; re_node_set_free (&eclosure_elem); } } return REG_NOERROR; } /* Calculate epsilon closure of NODE. */ static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) { reg_errcode_t err; Idx i; re_node_set eclosure; bool ok; bool incomplete = false; err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); if (BE (err != REG_NOERROR, 0)) return err; /* This indicates that we are calculating this node now. We reference this value to avoid infinite loop. */ dfa->eclosures[node].nelem = REG_MISSING; /* If the current node has constraints, duplicate all nodes since they must inherit the constraints. */ if (dfa->nodes[node].constraint && dfa->edests[node].nelem && !dfa->nodes[dfa->edests[node].elems[0]].duplicated) { err = duplicate_node_closure (dfa, node, node, node, dfa->nodes[node].constraint); if (BE (err != REG_NOERROR, 0)) return err; } /* Expand each epsilon destination nodes. */ if (IS_EPSILON_NODE(dfa->nodes[node].type)) for (i = 0; i < dfa->edests[node].nelem; ++i) { re_node_set eclosure_elem; Idx edest = dfa->edests[node].elems[i]; /* If calculating the epsilon closure of 'edest' is in progress, return intermediate result. */ if (dfa->eclosures[edest].nelem == REG_MISSING) { incomplete = true; continue; } /* If we haven't calculated the epsilon closure of 'edest' yet, calculate now. Otherwise use calculated epsilon closure. */ if (dfa->eclosures[edest].nelem == 0) { err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); if (BE (err != REG_NOERROR, 0)) return err; } else eclosure_elem = dfa->eclosures[edest]; /* Merge the epsilon closure of 'edest'. */ err = re_node_set_merge (&eclosure, &eclosure_elem); if (BE (err != REG_NOERROR, 0)) return err; /* If the epsilon closure of 'edest' is incomplete, the epsilon closure of this node is also incomplete. */ if (dfa->eclosures[edest].nelem == 0) { incomplete = true; re_node_set_free (&eclosure_elem); } } /* An epsilon closure includes itself. */ ok = re_node_set_insert (&eclosure, node); if (BE (! ok, 0)) return REG_ESPACE; if (incomplete && !root) dfa->eclosures[node].nelem = 0; else dfa->eclosures[node] = eclosure; *new_set = eclosure; return REG_NOERROR; } /* Functions for token which are used in the parser. */ /* Fetch a token from INPUT. We must not use this function inside bracket expressions. */ static void internal_function fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax) { re_string_skip_bytes (input, peek_token (result, input, syntax)); } /* Peek a token from INPUT, and return the length of the token. We must not use this function inside bracket expressions. */ static int internal_function peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) { unsigned char c; if (re_string_eoi (input)) { token->type = END_OF_RE; return 0; } c = re_string_peek_byte (input, 0); token->opr.c = c; token->word_char = 0; #ifdef RE_ENABLE_I18N token->mb_partial = 0; if (input->mb_cur_max > 1 && !re_string_first_byte (input, re_string_cur_idx (input))) { token->type = CHARACTER; token->mb_partial = 1; return 1; } #endif if (c == '\\') { unsigned char c2; if (re_string_cur_idx (input) + 1 >= re_string_length (input)) { token->type = BACK_SLASH; return 1; } c2 = re_string_peek_byte_case (input, 1); token->opr.c = c2; token->type = CHARACTER; #ifdef RE_ENABLE_I18N if (input->mb_cur_max > 1) { wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input) + 1); token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; } else #endif token->word_char = IS_WORD_CHAR (c2) != 0; switch (c2) { case '|': if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR)) token->type = OP_ALT; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (!(syntax & RE_NO_BK_REFS)) { token->type = OP_BACK_REF; token->opr.idx = c2 - '1'; } break; case '<': if (!(syntax & RE_NO_GNU_OPS)) { token->type = ANCHOR; token->opr.ctx_type = WORD_FIRST; } break; case '>': if (!(syntax & RE_NO_GNU_OPS)) { token->type = ANCHOR; token->opr.ctx_type = WORD_LAST; } break; case 'b': if (!(syntax & RE_NO_GNU_OPS)) { token->type = ANCHOR; token->opr.ctx_type = WORD_DELIM; } break; case 'B': if (!(syntax & RE_NO_GNU_OPS)) { token->type = ANCHOR; token->opr.ctx_type = NOT_WORD_DELIM; } break; case 'w': if (!(syntax & RE_NO_GNU_OPS)) token->type = OP_WORD; break; case 'W': if (!(syntax & RE_NO_GNU_OPS)) token->type = OP_NOTWORD; break; case 's': if (!(syntax & RE_NO_GNU_OPS)) token->type = OP_SPACE; break; case 'S': if (!(syntax & RE_NO_GNU_OPS)) token->type = OP_NOTSPACE; break; case '`': if (!(syntax & RE_NO_GNU_OPS)) { token->type = ANCHOR; token->opr.ctx_type = BUF_FIRST; } break; case '\'': if (!(syntax & RE_NO_GNU_OPS)) { token->type = ANCHOR; token->opr.ctx_type = BUF_LAST; } break; case '(': if (!(syntax & RE_NO_BK_PARENS)) token->type = OP_OPEN_SUBEXP; break; case ')': if (!(syntax & RE_NO_BK_PARENS)) token->type = OP_CLOSE_SUBEXP; break; case '+': if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) token->type = OP_DUP_PLUS; break; case '?': if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) token->type = OP_DUP_QUESTION; break; case '{': if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) token->type = OP_OPEN_DUP_NUM; break; case '}': if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) token->type = OP_CLOSE_DUP_NUM; break; default: break; } return 2; } token->type = CHARACTER; #ifdef RE_ENABLE_I18N if (input->mb_cur_max > 1) { wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input)); token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; } else #endif token->word_char = IS_WORD_CHAR (token->opr.c); switch (c) { case '\n': if (syntax & RE_NEWLINE_ALT) token->type = OP_ALT; break; case '|': if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR)) token->type = OP_ALT; break; case '*': token->type = OP_DUP_ASTERISK; break; case '+': if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) token->type = OP_DUP_PLUS; break; case '?': if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) token->type = OP_DUP_QUESTION; break; case '{': if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) token->type = OP_OPEN_DUP_NUM; break; case '}': if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) token->type = OP_CLOSE_DUP_NUM; break; case '(': if (syntax & RE_NO_BK_PARENS) token->type = OP_OPEN_SUBEXP; break; case ')': if (syntax & RE_NO_BK_PARENS) token->type = OP_CLOSE_SUBEXP; break; case '[': token->type = OP_OPEN_BRACKET; break; case '.': token->type = OP_PERIOD; break; case '^': if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && re_string_cur_idx (input) != 0) { char prev = re_string_peek_byte (input, -1); if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') break; } token->type = ANCHOR; token->opr.ctx_type = LINE_FIRST; break; case '$': if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && re_string_cur_idx (input) + 1 != re_string_length (input)) { re_token_t next; re_string_skip_bytes (input, 1); peek_token (&next, input, syntax); re_string_skip_bytes (input, -1); if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP) break; } token->type = ANCHOR; token->opr.ctx_type = LINE_LAST; break; default: break; } return 1; } /* Peek a token from INPUT, and return the length of the token. We must not use this function out of bracket expressions. */ static int internal_function peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) { unsigned char c; if (re_string_eoi (input)) { token->type = END_OF_RE; return 0; } c = re_string_peek_byte (input, 0); token->opr.c = c; #ifdef RE_ENABLE_I18N if (input->mb_cur_max > 1 && !re_string_first_byte (input, re_string_cur_idx (input))) { token->type = CHARACTER; return 1; } #endif /* RE_ENABLE_I18N */ if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && re_string_cur_idx (input) + 1 < re_string_length (input)) { /* In this case, '\' escape a character. */ unsigned char c2; re_string_skip_bytes (input, 1); c2 = re_string_peek_byte (input, 0); token->opr.c = c2; token->type = CHARACTER; return 1; } if (c == '[') /* '[' is a special char in a bracket exps. */ { unsigned char c2; int token_len; if (re_string_cur_idx (input) + 1 < re_string_length (input)) c2 = re_string_peek_byte (input, 1); else c2 = 0; token->opr.c = c2; token_len = 2; switch (c2) { case '.': token->type = OP_OPEN_COLL_ELEM; break; case '=': token->type = OP_OPEN_EQUIV_CLASS; break; case ':': if (syntax & RE_CHAR_CLASSES) { token->type = OP_OPEN_CHAR_CLASS; break; } /* else fall through. */ default: token->type = CHARACTER; token->opr.c = c; token_len = 1; break; } return token_len; } switch (c) { case '-': token->type = OP_CHARSET_RANGE; break; case ']': token->type = OP_CLOSE_BRACKET; break; case '^': token->type = OP_NON_MATCH_LIST; break; default: token->type = CHARACTER; } return 1; } /* Functions for parser. */ /* Entry point of the parser. Parse the regular expression REGEXP and return the structure tree. If an error occurs, ERR is set by error code, and return NULL. This function build the following tree, from regular expression : CAT / \ / \ EOR CAT means concatenation. EOR means end of regular expression. */ static bin_tree_t * parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, reg_errcode_t *err) { re_dfa_t *dfa = preg->buffer; bin_tree_t *tree, *eor, *root; re_token_t current_token; dfa->syntax = syntax; fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; eor = create_tree (dfa, NULL, NULL, END_OF_RE); if (tree != NULL) root = create_tree (dfa, tree, eor, CONCAT); else root = eor; if (BE (eor == NULL || root == NULL, 0)) { *err = REG_ESPACE; return NULL; } return root; } /* This function build the following tree, from regular expression |: ALT / \ / \ ALT means alternative, which represents the operator '|'. */ static bin_tree_t * parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, reg_syntax_t syntax, Idx nest, reg_errcode_t *err) { re_dfa_t *dfa = preg->buffer; bin_tree_t *tree, *branch = NULL; tree = parse_branch (regexp, preg, token, syntax, nest, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; while (token->type == OP_ALT) { fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); if (token->type != OP_ALT && token->type != END_OF_RE && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) { branch = parse_branch (regexp, preg, token, syntax, nest, err); if (BE (*err != REG_NOERROR && branch == NULL, 0)) { if (tree != NULL) postorder (tree, free_tree, NULL); return NULL; } } else branch = NULL; tree = create_tree (dfa, tree, branch, OP_ALT); if (BE (tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } } return tree; } /* This function build the following tree, from regular expression : CAT / \ / \ CAT means concatenation. */ static bin_tree_t * parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, reg_syntax_t syntax, Idx nest, reg_errcode_t *err) { bin_tree_t *tree, *expr; re_dfa_t *dfa = preg->buffer; tree = parse_expression (regexp, preg, token, syntax, nest, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; while (token->type != OP_ALT && token->type != END_OF_RE && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) { expr = parse_expression (regexp, preg, token, syntax, nest, err); if (BE (*err != REG_NOERROR && expr == NULL, 0)) { if (tree != NULL) postorder (tree, free_tree, NULL); return NULL; } if (tree != NULL && expr != NULL) { bin_tree_t *newtree = create_tree (dfa, tree, expr, CONCAT); if (newtree == NULL) { postorder (expr, free_tree, NULL); postorder (tree, free_tree, NULL); *err = REG_ESPACE; return NULL; } tree = newtree; } else if (tree == NULL) tree = expr; /* Otherwise expr == NULL, we don't need to create new tree. */ } return tree; } /* This function build the following tree, from regular expression a*: * | a */ static bin_tree_t * parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, reg_syntax_t syntax, Idx nest, reg_errcode_t *err) { re_dfa_t *dfa = preg->buffer; bin_tree_t *tree; switch (token->type) { case CHARACTER: tree = create_token_tree (dfa, NULL, NULL, token); if (BE (tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } #ifdef RE_ENABLE_I18N if (dfa->mb_cur_max > 1) { while (!re_string_eoi (regexp) && !re_string_first_byte (regexp, re_string_cur_idx (regexp))) { bin_tree_t *mbc_remain; fetch_token (token, regexp, syntax); mbc_remain = create_token_tree (dfa, NULL, NULL, token); tree = create_tree (dfa, tree, mbc_remain, CONCAT); if (BE (mbc_remain == NULL || tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } } } #endif break; case OP_OPEN_SUBEXP: tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; break; case OP_OPEN_BRACKET: tree = parse_bracket_exp (regexp, dfa, token, syntax, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; break; case OP_BACK_REF: if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) { *err = REG_ESUBREG; return NULL; } dfa->used_bkref_map |= 1 << token->opr.idx; tree = create_token_tree (dfa, NULL, NULL, token); if (BE (tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } ++dfa->nbackref; dfa->has_mb_node = 1; break; case OP_OPEN_DUP_NUM: if (syntax & RE_CONTEXT_INVALID_DUP) { *err = REG_BADRPT; return NULL; } /* FALLTHROUGH */ case OP_DUP_ASTERISK: case OP_DUP_PLUS: case OP_DUP_QUESTION: if (syntax & RE_CONTEXT_INVALID_OPS) { *err = REG_BADRPT; return NULL; } else if (syntax & RE_CONTEXT_INDEP_OPS) { fetch_token (token, regexp, syntax); return parse_expression (regexp, preg, token, syntax, nest, err); } /* else fall through */ case OP_CLOSE_SUBEXP: if ((token->type == OP_CLOSE_SUBEXP) && !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) { *err = REG_ERPAREN; return NULL; } /* else fall through */ case OP_CLOSE_DUP_NUM: /* We treat it as a normal character. */ /* Then we can these characters as normal characters. */ token->type = CHARACTER; /* mb_partial and word_char bits should be initialized already by peek_token. */ tree = create_token_tree (dfa, NULL, NULL, token); if (BE (tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } break; case ANCHOR: if ((token->opr.ctx_type & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST)) && dfa->word_ops_used == 0) init_word_char (dfa); if (token->opr.ctx_type == WORD_DELIM || token->opr.ctx_type == NOT_WORD_DELIM) { bin_tree_t *tree_first, *tree_last; if (token->opr.ctx_type == WORD_DELIM) { token->opr.ctx_type = WORD_FIRST; tree_first = create_token_tree (dfa, NULL, NULL, token); token->opr.ctx_type = WORD_LAST; } else { token->opr.ctx_type = INSIDE_WORD; tree_first = create_token_tree (dfa, NULL, NULL, token); token->opr.ctx_type = INSIDE_NOTWORD; } tree_last = create_token_tree (dfa, NULL, NULL, token); tree = create_tree (dfa, tree_first, tree_last, OP_ALT); if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } } else { tree = create_token_tree (dfa, NULL, NULL, token); if (BE (tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } } /* We must return here, since ANCHORs can't be followed by repetition operators. eg. RE"^*" is invalid or "", it must not be "". */ fetch_token (token, regexp, syntax); return tree; case OP_PERIOD: tree = create_token_tree (dfa, NULL, NULL, token); if (BE (tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } if (dfa->mb_cur_max > 1) dfa->has_mb_node = 1; break; case OP_WORD: case OP_NOTWORD: tree = build_charclass_op (dfa, regexp->trans, "alnum", "_", token->type == OP_NOTWORD, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; break; case OP_SPACE: case OP_NOTSPACE: tree = build_charclass_op (dfa, regexp->trans, "space", "", token->type == OP_NOTSPACE, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; break; case OP_ALT: case END_OF_RE: return NULL; case BACK_SLASH: *err = REG_EESCAPE; return NULL; default: /* Must not happen? */ #ifdef DEBUG assert (0); #endif return NULL; } fetch_token (token, regexp, syntax); while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) { bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token, syntax, err); if (BE (*err != REG_NOERROR && dup_tree == NULL, 0)) { if (tree != NULL) postorder (tree, free_tree, NULL); return NULL; } tree = dup_tree; /* In BRE consecutive duplications are not allowed. */ if ((syntax & RE_CONTEXT_INVALID_DUP) && (token->type == OP_DUP_ASTERISK || token->type == OP_OPEN_DUP_NUM)) { if (tree != NULL) postorder (tree, free_tree, NULL); *err = REG_BADRPT; return NULL; } } return tree; } /* This function build the following tree, from regular expression (): SUBEXP | */ static bin_tree_t * parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, reg_syntax_t syntax, Idx nest, reg_errcode_t *err) { re_dfa_t *dfa = preg->buffer; bin_tree_t *tree; size_t cur_nsub; cur_nsub = preg->re_nsub++; fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); /* The subexpression may be a null string. */ if (token->type == OP_CLOSE_SUBEXP) tree = NULL; else { tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) { if (tree != NULL) postorder (tree, free_tree, NULL); *err = REG_EPAREN; } if (BE (*err != REG_NOERROR, 0)) return NULL; } if (cur_nsub <= '9' - '1') dfa->completed_bkref_map |= 1 << cur_nsub; tree = create_tree (dfa, tree, NULL, SUBEXP); if (BE (tree == NULL, 0)) { *err = REG_ESPACE; return NULL; } tree->token.opr.idx = cur_nsub; return tree; } /* This function parse repetition operators like "*", "+", "{1,3}" etc. */ static bin_tree_t * parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err) { bin_tree_t *tree = NULL, *old_tree = NULL; Idx i, start, end, start_idx = re_string_cur_idx (regexp); re_token_t start_token = *token; if (token->type == OP_OPEN_DUP_NUM) { end = 0; start = fetch_number (regexp, token, syntax); if (start == REG_MISSING) { if (token->type == CHARACTER && token->opr.c == ',') start = 0; /* We treat "{,m}" as "{0,m}". */ else { *err = REG_BADBR; /* {} is invalid. */ return NULL; } } if (BE (start != REG_ERROR, 1)) { /* We treat "{n}" as "{n,n}". */ end = ((token->type == OP_CLOSE_DUP_NUM) ? start : ((token->type == CHARACTER && token->opr.c == ',') ? fetch_number (regexp, token, syntax) : REG_ERROR)); } if (BE (start == REG_ERROR || end == REG_ERROR, 0)) { /* Invalid sequence. */ if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0)) { if (token->type == END_OF_RE) *err = REG_EBRACE; else *err = REG_BADBR; return NULL; } /* If the syntax bit is set, rollback. */ re_string_set_index (regexp, start_idx); *token = start_token; token->type = CHARACTER; /* mb_partial and word_char bits should be already initialized by peek_token. */ return elem; } if (BE ((end != REG_MISSING && start > end) || token->type != OP_CLOSE_DUP_NUM, 0)) { /* First number greater than second. */ *err = REG_BADBR; return NULL; } if (BE (RE_DUP_MAX < (end == REG_MISSING ? start : end), 0)) { *err = REG_ESIZE; return NULL; } } else { start = (token->type == OP_DUP_PLUS) ? 1 : 0; end = (token->type == OP_DUP_QUESTION) ? 1 : REG_MISSING; } fetch_token (token, regexp, syntax); if (BE (elem == NULL, 0)) return NULL; if (BE (start == 0 && end == 0, 0)) { postorder (elem, free_tree, NULL); return NULL; } /* Extract "{n,m}" to "...{0,}". */ if (BE (start > 0, 0)) { tree = elem; for (i = 2; i <= start; ++i) { elem = duplicate_tree (elem, dfa); tree = create_tree (dfa, tree, elem, CONCAT); if (BE (elem == NULL || tree == NULL, 0)) goto parse_dup_op_espace; } if (start == end) return tree; /* Duplicate ELEM before it is marked optional. */ elem = duplicate_tree (elem, dfa); if (BE (elem == NULL, 0)) goto parse_dup_op_espace; old_tree = tree; } else old_tree = NULL; if (elem->token.type == SUBEXP) { uintptr_t subidx = elem->token.opr.idx; postorder (elem, mark_opt_subexp, (void *) subidx); } tree = create_tree (dfa, elem, NULL, (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT)); if (BE (tree == NULL, 0)) goto parse_dup_op_espace; /* From gnulib's "intprops.h": True if the arithmetic type T is signed. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* This loop is actually executed only when end != REG_MISSING, to rewrite {0,n} as ((...?)?)?... We have already created the start+1-th copy. */ if (TYPE_SIGNED (Idx) || end != REG_MISSING) for (i = start + 2; i <= end; ++i) { elem = duplicate_tree (elem, dfa); tree = create_tree (dfa, tree, elem, CONCAT); if (BE (elem == NULL || tree == NULL, 0)) goto parse_dup_op_espace; tree = create_tree (dfa, tree, NULL, OP_ALT); if (BE (tree == NULL, 0)) goto parse_dup_op_espace; } if (old_tree) tree = create_tree (dfa, old_tree, tree, CONCAT); return tree; parse_dup_op_espace: *err = REG_ESPACE; return NULL; } /* Size of the names for collating symbol/equivalence_class/character_class. I'm not sure, but maybe enough. */ #define BRACKET_NAME_BUF_SIZE 32 #ifndef _LIBC /* Local function for parse_bracket_exp only used in case of NOT _LIBC. Build the range expression which starts from START_ELEM, and ends at END_ELEM. The result are written to MBCSET and SBCSET. RANGE_ALLOC is the allocated size of mbcset->range_starts, and mbcset->range_ends, is a pointer argument since we may update it. */ static reg_errcode_t internal_function # ifdef RE_ENABLE_I18N build_range_exp (const reg_syntax_t syntax, bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc, const bracket_elem_t *start_elem, const bracket_elem_t *end_elem) # else /* not RE_ENABLE_I18N */ build_range_exp (const reg_syntax_t syntax, bitset_t sbcset, const bracket_elem_t *start_elem, const bracket_elem_t *end_elem) # endif /* not RE_ENABLE_I18N */ { unsigned int start_ch, end_ch; /* Equivalence Classes and Character Classes can't be a range start/end. */ if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, 0)) return REG_ERANGE; /* We can handle no multi character collating elements without libc support. */ if (BE ((start_elem->type == COLL_SYM && strlen ((char *) start_elem->opr.name) > 1) || (end_elem->type == COLL_SYM && strlen ((char *) end_elem->opr.name) > 1), 0)) return REG_ECOLLATE; # ifdef RE_ENABLE_I18N { wchar_t wc; wint_t start_wc; wint_t end_wc; start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] : 0)); end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] : 0)); start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) ? __btowc (start_ch) : start_elem->opr.wch); end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) ? __btowc (end_ch) : end_elem->opr.wch); if (start_wc == WEOF || end_wc == WEOF) return REG_ECOLLATE; else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0)) return REG_ERANGE; /* Got valid collation sequence values, add them as a new entry. However, for !_LIBC we have no collation elements: if the character set is single byte, the single byte character set that we build below suffices. parse_bracket_exp passes no MBCSET if dfa->mb_cur_max == 1. */ if (mbcset) { /* Check the space of the arrays. */ if (BE (*range_alloc == mbcset->nranges, 0)) { /* There is not enough space, need realloc. */ wchar_t *new_array_start, *new_array_end; Idx new_nranges; /* +1 in case of mbcset->nranges is 0. */ new_nranges = 2 * mbcset->nranges + 1; /* Use realloc since mbcset->range_starts and mbcset->range_ends are NULL if *range_alloc == 0. */ new_array_start = re_realloc (mbcset->range_starts, wchar_t, new_nranges); new_array_end = re_realloc (mbcset->range_ends, wchar_t, new_nranges); if (BE (new_array_start == NULL || new_array_end == NULL, 0)) return REG_ESPACE; mbcset->range_starts = new_array_start; mbcset->range_ends = new_array_end; *range_alloc = new_nranges; } mbcset->range_starts[mbcset->nranges] = start_wc; mbcset->range_ends[mbcset->nranges++] = end_wc; } /* Build the table for single byte characters. */ for (wc = 0; wc < SBC_MAX; ++wc) { if (start_wc <= wc && wc <= end_wc) bitset_set (sbcset, wc); } } # else /* not RE_ENABLE_I18N */ { unsigned int ch; start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] : 0)); end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] : 0)); if (start_ch > end_ch) return REG_ERANGE; /* Build the table for single byte characters. */ for (ch = 0; ch < SBC_MAX; ++ch) if (start_ch <= ch && ch <= end_ch) bitset_set (sbcset, ch); } # endif /* not RE_ENABLE_I18N */ return REG_NOERROR; } #endif /* not _LIBC */ #ifndef _LIBC /* Helper function for parse_bracket_exp only used in case of NOT _LIBC.. Build the collating element which is represented by NAME. The result are written to MBCSET and SBCSET. COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a pointer argument since we may update it. */ static reg_errcode_t internal_function # ifdef RE_ENABLE_I18N build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, Idx *coll_sym_alloc, const unsigned char *name) # else /* not RE_ENABLE_I18N */ build_collating_symbol (bitset_t sbcset, const unsigned char *name) # endif /* not RE_ENABLE_I18N */ { size_t name_len = strlen ((const char *) name); if (BE (name_len != 1, 0)) return REG_ECOLLATE; else { bitset_set (sbcset, name[0]); return REG_NOERROR; } } #endif /* not _LIBC */ /* This function parse bracket expression like "[abc]", "[a-c]", "[[.a-a.]]" etc. */ static bin_tree_t * parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err) { #ifdef _LIBC const unsigned char *collseqmb; const char *collseqwc; uint32_t nrules; int32_t table_size; const int32_t *symb_table; const unsigned char *extra; /* Local function for parse_bracket_exp used in _LIBC environment. Seek the collating symbol entry corresponding to NAME. Return the index of the symbol in the SYMB_TABLE, or -1 if not found. */ auto inline int32_t __attribute__ ((always_inline)) seek_collating_symbol_entry (const unsigned char *name, size_t name_len) { int32_t elem; for (elem = 0; elem < table_size; elem++) if (symb_table[2 * elem] != 0) { int32_t idx = symb_table[2 * elem + 1]; /* Skip the name of collating element name. */ idx += 1 + extra[idx]; if (/* Compare the length of the name. */ name_len == extra[idx] /* Compare the name. */ && memcmp (name, &extra[idx + 1], name_len) == 0) /* Yep, this is the entry. */ return elem; } return -1; } /* Local function for parse_bracket_exp used in _LIBC environment. Look up the collation sequence value of BR_ELEM. Return the value if succeeded, UINT_MAX otherwise. */ auto inline unsigned int __attribute__ ((always_inline)) lookup_collation_sequence_value (bracket_elem_t *br_elem) { if (br_elem->type == SB_CHAR) { /* if (MB_CUR_MAX == 1) */ if (nrules == 0) return collseqmb[br_elem->opr.ch]; else { wint_t wc = __btowc (br_elem->opr.ch); return __collseq_table_lookup (collseqwc, wc); } } else if (br_elem->type == MB_CHAR) { if (nrules != 0) return __collseq_table_lookup (collseqwc, br_elem->opr.wch); } else if (br_elem->type == COLL_SYM) { size_t sym_name_len = strlen ((char *) br_elem->opr.name); if (nrules != 0) { int32_t elem, idx; elem = seek_collating_symbol_entry (br_elem->opr.name, sym_name_len); if (elem != -1) { /* We found the entry. */ idx = symb_table[2 * elem + 1]; /* Skip the name of collating element name. */ idx += 1 + extra[idx]; /* Skip the byte sequence of the collating element. */ idx += 1 + extra[idx]; /* Adjust for the alignment. */ idx = (idx + 3) & ~3; /* Skip the multibyte collation sequence value. */ idx += sizeof (unsigned int); /* Skip the wide char sequence of the collating element. */ idx += sizeof (unsigned int) * (1 + *(unsigned int *) (extra + idx)); /* Return the collation sequence value. */ return *(unsigned int *) (extra + idx); } else if (sym_name_len == 1) { /* No valid character. Match it as a single byte character. */ return collseqmb[br_elem->opr.name[0]]; } } else if (sym_name_len == 1) return collseqmb[br_elem->opr.name[0]]; } return UINT_MAX; } /* Local function for parse_bracket_exp used in _LIBC environment. Build the range expression which starts from START_ELEM, and ends at END_ELEM. The result are written to MBCSET and SBCSET. RANGE_ALLOC is the allocated size of mbcset->range_starts, and mbcset->range_ends, is a pointer argument since we may update it. */ auto inline reg_errcode_t __attribute__ ((always_inline)) build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc, bracket_elem_t *start_elem, bracket_elem_t *end_elem) { unsigned int ch; uint32_t start_collseq; uint32_t end_collseq; /* Equivalence Classes and Character Classes can't be a range start/end. */ if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, 0)) return REG_ERANGE; /* FIXME: Implement rational ranges here, too. */ start_collseq = lookup_collation_sequence_value (start_elem); end_collseq = lookup_collation_sequence_value (end_elem); /* Check start/end collation sequence values. */ if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) return REG_ECOLLATE; if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) return REG_ERANGE; /* Got valid collation sequence values, add them as a new entry. However, if we have no collation elements, and the character set is single byte, the single byte character set that we build below suffices. */ if (nrules > 0 || dfa->mb_cur_max > 1) { /* Check the space of the arrays. */ if (BE (*range_alloc == mbcset->nranges, 0)) { /* There is not enough space, need realloc. */ uint32_t *new_array_start; uint32_t *new_array_end; Idx new_nranges; /* +1 in case of mbcset->nranges is 0. */ new_nranges = 2 * mbcset->nranges + 1; new_array_start = re_realloc (mbcset->range_starts, uint32_t, new_nranges); new_array_end = re_realloc (mbcset->range_ends, uint32_t, new_nranges); if (BE (new_array_start == NULL || new_array_end == NULL, 0)) return REG_ESPACE; mbcset->range_starts = new_array_start; mbcset->range_ends = new_array_end; *range_alloc = new_nranges; } mbcset->range_starts[mbcset->nranges] = start_collseq; mbcset->range_ends[mbcset->nranges++] = end_collseq; } /* Build the table for single byte characters. */ for (ch = 0; ch < SBC_MAX; ch++) { uint32_t ch_collseq; /* if (MB_CUR_MAX == 1) */ if (nrules == 0) ch_collseq = collseqmb[ch]; else ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch)); if (start_collseq <= ch_collseq && ch_collseq <= end_collseq) bitset_set (sbcset, ch); } return REG_NOERROR; } /* Local function for parse_bracket_exp used in _LIBC environment. Build the collating element which is represented by NAME. The result are written to MBCSET and SBCSET. COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a pointer argument since we may update it. */ auto inline reg_errcode_t __attribute__ ((always_inline)) build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, Idx *coll_sym_alloc, const unsigned char *name) { int32_t elem, idx; size_t name_len = strlen ((const char *) name); if (nrules != 0) { elem = seek_collating_symbol_entry (name, name_len); if (elem != -1) { /* We found the entry. */ idx = symb_table[2 * elem + 1]; /* Skip the name of collating element name. */ idx += 1 + extra[idx]; } else if (name_len == 1) { /* No valid character, treat it as a normal character. */ bitset_set (sbcset, name[0]); return REG_NOERROR; } else return REG_ECOLLATE; /* Got valid collation sequence, add it as a new entry. */ /* Check the space of the arrays. */ if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0)) { /* Not enough, realloc it. */ /* +1 in case of mbcset->ncoll_syms is 0. */ Idx new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1; /* Use realloc since mbcset->coll_syms is NULL if *alloc == 0. */ int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t, new_coll_sym_alloc); if (BE (new_coll_syms == NULL, 0)) return REG_ESPACE; mbcset->coll_syms = new_coll_syms; *coll_sym_alloc = new_coll_sym_alloc; } mbcset->coll_syms[mbcset->ncoll_syms++] = idx; return REG_NOERROR; } else { if (BE (name_len != 1, 0)) return REG_ECOLLATE; else { bitset_set (sbcset, name[0]); return REG_NOERROR; } } } #endif re_token_t br_token; re_bitset_ptr_t sbcset; #ifdef RE_ENABLE_I18N re_charset_t *mbcset; Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0; Idx equiv_class_alloc = 0, char_class_alloc = 0; #endif /* not RE_ENABLE_I18N */ bool non_match = false; bin_tree_t *work_tree; int token_len; bool first_round = true; #ifdef _LIBC collseqmb = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); if (nrules) { /* if (MB_CUR_MAX > 1) */ collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB); extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); } #endif sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); #ifdef RE_ENABLE_I18N mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); #endif /* RE_ENABLE_I18N */ #ifdef RE_ENABLE_I18N if (BE (sbcset == NULL || mbcset == NULL, 0)) #else if (BE (sbcset == NULL, 0)) #endif /* RE_ENABLE_I18N */ { re_free (sbcset); #ifdef RE_ENABLE_I18N re_free (mbcset); #endif *err = REG_ESPACE; return NULL; } token_len = peek_token_bracket (token, regexp, syntax); if (BE (token->type == END_OF_RE, 0)) { *err = REG_BADPAT; goto parse_bracket_exp_free_return; } if (token->type == OP_NON_MATCH_LIST) { #ifdef RE_ENABLE_I18N mbcset->non_match = 1; #endif /* not RE_ENABLE_I18N */ non_match = true; if (syntax & RE_HAT_LISTS_NOT_NEWLINE) bitset_set (sbcset, '\n'); re_string_skip_bytes (regexp, token_len); /* Skip a token. */ token_len = peek_token_bracket (token, regexp, syntax); if (BE (token->type == END_OF_RE, 0)) { *err = REG_BADPAT; goto parse_bracket_exp_free_return; } } /* We treat the first ']' as a normal character. */ if (token->type == OP_CLOSE_BRACKET) token->type = CHARACTER; while (1) { bracket_elem_t start_elem, end_elem; unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE]; unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE]; reg_errcode_t ret; int token_len2 = 0; bool is_range_exp = false; re_token_t token2; start_elem.opr.name = start_name_buf; ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, syntax, first_round); if (BE (ret != REG_NOERROR, 0)) { *err = ret; goto parse_bracket_exp_free_return; } first_round = false; /* Get information about the next token. We need it in any case. */ token_len = peek_token_bracket (token, regexp, syntax); /* Do not check for ranges if we know they are not allowed. */ if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) { if (BE (token->type == END_OF_RE, 0)) { *err = REG_EBRACK; goto parse_bracket_exp_free_return; } if (token->type == OP_CHARSET_RANGE) { re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ token_len2 = peek_token_bracket (&token2, regexp, syntax); if (BE (token2.type == END_OF_RE, 0)) { *err = REG_EBRACK; goto parse_bracket_exp_free_return; } if (token2.type == OP_CLOSE_BRACKET) { /* We treat the last '-' as a normal character. */ re_string_skip_bytes (regexp, -token_len); token->type = CHARACTER; } else is_range_exp = true; } } if (is_range_exp == true) { end_elem.opr.name = end_name_buf; ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, dfa, syntax, true); if (BE (ret != REG_NOERROR, 0)) { *err = ret; goto parse_bracket_exp_free_return; } token_len = peek_token_bracket (token, regexp, syntax); #ifdef _LIBC *err = build_range_exp (sbcset, mbcset, &range_alloc, &start_elem, &end_elem); #else # ifdef RE_ENABLE_I18N *err = build_range_exp (syntax, sbcset, dfa->mb_cur_max > 1 ? mbcset : NULL, &range_alloc, &start_elem, &end_elem); # else *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem); # endif #endif /* RE_ENABLE_I18N */ if (BE (*err != REG_NOERROR, 0)) goto parse_bracket_exp_free_return; } else { switch (start_elem.type) { case SB_CHAR: bitset_set (sbcset, start_elem.opr.ch); break; #ifdef RE_ENABLE_I18N case MB_CHAR: /* Check whether the array has enough space. */ if (BE (mbchar_alloc == mbcset->nmbchars, 0)) { wchar_t *new_mbchars; /* Not enough, realloc it. */ /* +1 in case of mbcset->nmbchars is 0. */ mbchar_alloc = 2 * mbcset->nmbchars + 1; /* Use realloc since array is NULL if *alloc == 0. */ new_mbchars = re_realloc (mbcset->mbchars, wchar_t, mbchar_alloc); if (BE (new_mbchars == NULL, 0)) goto parse_bracket_exp_espace; mbcset->mbchars = new_mbchars; } mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch; break; #endif /* RE_ENABLE_I18N */ case EQUIV_CLASS: *err = build_equiv_class (sbcset, #ifdef RE_ENABLE_I18N mbcset, &equiv_class_alloc, #endif /* RE_ENABLE_I18N */ start_elem.opr.name); if (BE (*err != REG_NOERROR, 0)) goto parse_bracket_exp_free_return; break; case COLL_SYM: *err = build_collating_symbol (sbcset, #ifdef RE_ENABLE_I18N mbcset, &coll_sym_alloc, #endif /* RE_ENABLE_I18N */ start_elem.opr.name); if (BE (*err != REG_NOERROR, 0)) goto parse_bracket_exp_free_return; break; case CHAR_CLASS: *err = build_charclass (regexp->trans, sbcset, #ifdef RE_ENABLE_I18N mbcset, &char_class_alloc, #endif /* RE_ENABLE_I18N */ (const char *) start_elem.opr.name, syntax); if (BE (*err != REG_NOERROR, 0)) goto parse_bracket_exp_free_return; break; default: assert (0); break; } } if (BE (token->type == END_OF_RE, 0)) { *err = REG_EBRACK; goto parse_bracket_exp_free_return; } if (token->type == OP_CLOSE_BRACKET) break; } re_string_skip_bytes (regexp, token_len); /* Skip a token. */ /* If it is non-matching list. */ if (non_match) bitset_not (sbcset); #ifdef RE_ENABLE_I18N /* Ensure only single byte characters are set. */ if (dfa->mb_cur_max > 1) bitset_mask (sbcset, dfa->sb_char); if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes || mbcset->non_match))) { bin_tree_t *mbc_tree; int sbc_idx; /* Build a tree for complex bracket. */ dfa->has_mb_node = 1; br_token.type = COMPLEX_BRACKET; br_token.opr.mbcset = mbcset; mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); if (BE (mbc_tree == NULL, 0)) goto parse_bracket_exp_espace; for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) if (sbcset[sbc_idx]) break; /* If there are no bits set in sbcset, there is no point of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */ if (sbc_idx < BITSET_WORDS) { /* Build a tree for simple bracket. */ br_token.type = SIMPLE_BRACKET; br_token.opr.sbcset = sbcset; work_tree = create_token_tree (dfa, NULL, NULL, &br_token); if (BE (work_tree == NULL, 0)) goto parse_bracket_exp_espace; /* Then join them by ALT node. */ work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); if (BE (work_tree == NULL, 0)) goto parse_bracket_exp_espace; } else { re_free (sbcset); work_tree = mbc_tree; } } else #endif /* not RE_ENABLE_I18N */ { #ifdef RE_ENABLE_I18N free_charset (mbcset); #endif /* Build a tree for simple bracket. */ br_token.type = SIMPLE_BRACKET; br_token.opr.sbcset = sbcset; work_tree = create_token_tree (dfa, NULL, NULL, &br_token); if (BE (work_tree == NULL, 0)) goto parse_bracket_exp_espace; } return work_tree; parse_bracket_exp_espace: *err = REG_ESPACE; parse_bracket_exp_free_return: re_free (sbcset); #ifdef RE_ENABLE_I18N free_charset (mbcset); #endif /* RE_ENABLE_I18N */ return NULL; } /* Parse an element in the bracket expression. */ static reg_errcode_t parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, re_token_t *token, int token_len, re_dfa_t *dfa, reg_syntax_t syntax, bool accept_hyphen) { #ifdef RE_ENABLE_I18N int cur_char_size; cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp)); if (cur_char_size > 1) { elem->type = MB_CHAR; elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp)); re_string_skip_bytes (regexp, cur_char_size); return REG_NOERROR; } #endif /* RE_ENABLE_I18N */ re_string_skip_bytes (regexp, token_len); /* Skip a token. */ if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS || token->type == OP_OPEN_EQUIV_CLASS) return parse_bracket_symbol (elem, regexp, token); if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) { /* A '-' must only appear as anything but a range indicator before the closing bracket. Everything else is an error. */ re_token_t token2; (void) peek_token_bracket (&token2, regexp, syntax); if (token2.type != OP_CLOSE_BRACKET) /* The actual error value is not standardized since this whole case is undefined. But ERANGE makes good sense. */ return REG_ERANGE; } elem->type = SB_CHAR; elem->opr.ch = token->opr.c; return REG_NOERROR; } /* Parse a bracket symbol in the bracket expression. Bracket symbols are such as [::], [..], and [==]. */ static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp, re_token_t *token) { unsigned char ch, delim = token->opr.c; int i = 0; if (re_string_eoi(regexp)) return REG_EBRACK; for (;; ++i) { if (i >= BRACKET_NAME_BUF_SIZE) return REG_EBRACK; if (token->type == OP_OPEN_CHAR_CLASS) ch = re_string_fetch_byte_case (regexp); else ch = re_string_fetch_byte (regexp); if (re_string_eoi(regexp)) return REG_EBRACK; if (ch == delim && re_string_peek_byte (regexp, 0) == ']') break; elem->opr.name[i] = ch; } re_string_skip_bytes (regexp, 1); elem->opr.name[i] = '\0'; switch (token->type) { case OP_OPEN_COLL_ELEM: elem->type = COLL_SYM; break; case OP_OPEN_EQUIV_CLASS: elem->type = EQUIV_CLASS; break; case OP_OPEN_CHAR_CLASS: elem->type = CHAR_CLASS; break; default: break; } return REG_NOERROR; } /* Helper function for parse_bracket_exp. Build the equivalence class which is represented by NAME. The result are written to MBCSET and SBCSET. EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes, is a pointer argument since we may update it. */ static reg_errcode_t #ifdef RE_ENABLE_I18N build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, Idx *equiv_class_alloc, const unsigned char *name) #else /* not RE_ENABLE_I18N */ build_equiv_class (bitset_t sbcset, const unsigned char *name) #endif /* not RE_ENABLE_I18N */ { #ifdef _LIBC uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); if (nrules != 0) { const int32_t *table, *indirect; const unsigned char *weights, *extra, *cp; unsigned char char_buf[2]; int32_t idx1, idx2; unsigned int ch; size_t len; /* This #include defines a local function! */ # include /* Calculate the index for equivalence class. */ cp = name; table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); idx1 = findidx (&cp, -1); if (BE (idx1 == 0 || *cp != '\0', 0)) /* This isn't a valid character. */ return REG_ECOLLATE; /* Build single byte matching table for this equivalence class. */ len = weights[idx1 & 0xffffff]; for (ch = 0; ch < SBC_MAX; ++ch) { char_buf[0] = ch; cp = char_buf; idx2 = findidx (&cp, 1); /* idx2 = table[ch]; */ if (idx2 == 0) /* This isn't a valid character. */ continue; /* Compare only if the length matches and the collation rule index is the same. */ if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)) { int cnt = 0; while (cnt <= len && weights[(idx1 & 0xffffff) + 1 + cnt] == weights[(idx2 & 0xffffff) + 1 + cnt]) ++cnt; if (cnt > len) bitset_set (sbcset, ch); } } /* Check whether the array has enough space. */ if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0)) { /* Not enough, realloc it. */ /* +1 in case of mbcset->nequiv_classes is 0. */ Idx new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1; /* Use realloc since the array is NULL if *alloc == 0. */ int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, int32_t, new_equiv_class_alloc); if (BE (new_equiv_classes == NULL, 0)) return REG_ESPACE; mbcset->equiv_classes = new_equiv_classes; *equiv_class_alloc = new_equiv_class_alloc; } mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1; } else #endif /* _LIBC */ { if (BE (strlen ((const char *) name) != 1, 0)) return REG_ECOLLATE; bitset_set (sbcset, *name); } return REG_NOERROR; } /* Helper function for parse_bracket_exp. Build the character class which is represented by NAME. The result are written to MBCSET and SBCSET. CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes, is a pointer argument since we may update it. */ static reg_errcode_t #ifdef RE_ENABLE_I18N build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, re_charset_t *mbcset, Idx *char_class_alloc, const char *class_name, reg_syntax_t syntax) #else /* not RE_ENABLE_I18N */ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, const char *class_name, reg_syntax_t syntax) #endif /* not RE_ENABLE_I18N */ { int i; const char *name = class_name; /* In case of REG_ICASE "upper" and "lower" match the both of upper and lower cases. */ if ((syntax & RE_ICASE) && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0)) name = "alpha"; #ifdef RE_ENABLE_I18N /* Check the space of the arrays. */ if (BE (*char_class_alloc == mbcset->nchar_classes, 0)) { /* Not enough, realloc it. */ /* +1 in case of mbcset->nchar_classes is 0. */ Idx new_char_class_alloc = 2 * mbcset->nchar_classes + 1; /* Use realloc since array is NULL if *alloc == 0. */ wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, new_char_class_alloc); if (BE (new_char_classes == NULL, 0)) return REG_ESPACE; mbcset->char_classes = new_char_classes; *char_class_alloc = new_char_class_alloc; } mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name); #endif /* RE_ENABLE_I18N */ #define BUILD_CHARCLASS_LOOP(ctype_func) \ do { \ if (BE (trans != NULL, 0)) \ { \ for (i = 0; i < SBC_MAX; ++i) \ if (ctype_func (i)) \ bitset_set (sbcset, trans[i]); \ } \ else \ { \ for (i = 0; i < SBC_MAX; ++i) \ if (ctype_func (i)) \ bitset_set (sbcset, i); \ } \ } while (0) if (strcmp (name, "alnum") == 0) BUILD_CHARCLASS_LOOP (isalnum); else if (strcmp (name, "cntrl") == 0) BUILD_CHARCLASS_LOOP (iscntrl); else if (strcmp (name, "lower") == 0) BUILD_CHARCLASS_LOOP (islower); else if (strcmp (name, "space") == 0) BUILD_CHARCLASS_LOOP (isspace); else if (strcmp (name, "alpha") == 0) BUILD_CHARCLASS_LOOP (isalpha); else if (strcmp (name, "digit") == 0) BUILD_CHARCLASS_LOOP (isdigit); else if (strcmp (name, "print") == 0) BUILD_CHARCLASS_LOOP (isprint); else if (strcmp (name, "upper") == 0) BUILD_CHARCLASS_LOOP (isupper); else if (strcmp (name, "blank") == 0) BUILD_CHARCLASS_LOOP (isblank); else if (strcmp (name, "graph") == 0) BUILD_CHARCLASS_LOOP (isgraph); else if (strcmp (name, "punct") == 0) BUILD_CHARCLASS_LOOP (ispunct); else if (strcmp (name, "xdigit") == 0) BUILD_CHARCLASS_LOOP (isxdigit); else return REG_ECTYPE; return REG_NOERROR; } static bin_tree_t * build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, const char *class_name, const char *extra, bool non_match, reg_errcode_t *err) { re_bitset_ptr_t sbcset; #ifdef RE_ENABLE_I18N re_charset_t *mbcset; Idx alloc = 0; #endif /* not RE_ENABLE_I18N */ reg_errcode_t ret; re_token_t br_token; bin_tree_t *tree; sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); #ifdef RE_ENABLE_I18N mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); #endif /* RE_ENABLE_I18N */ #ifdef RE_ENABLE_I18N if (BE (sbcset == NULL || mbcset == NULL, 0)) #else /* not RE_ENABLE_I18N */ if (BE (sbcset == NULL, 0)) #endif /* not RE_ENABLE_I18N */ { *err = REG_ESPACE; return NULL; } if (non_match) { #ifdef RE_ENABLE_I18N mbcset->non_match = 1; #endif /* not RE_ENABLE_I18N */ } /* We don't care the syntax in this case. */ ret = build_charclass (trans, sbcset, #ifdef RE_ENABLE_I18N mbcset, &alloc, #endif /* RE_ENABLE_I18N */ class_name, 0); if (BE (ret != REG_NOERROR, 0)) { re_free (sbcset); #ifdef RE_ENABLE_I18N free_charset (mbcset); #endif /* RE_ENABLE_I18N */ *err = ret; return NULL; } /* \w match '_' also. */ for (; *extra; extra++) bitset_set (sbcset, *extra); /* If it is non-matching list. */ if (non_match) bitset_not (sbcset); #ifdef RE_ENABLE_I18N /* Ensure only single byte characters are set. */ if (dfa->mb_cur_max > 1) bitset_mask (sbcset, dfa->sb_char); #endif /* Build a tree for simple bracket. */ br_token.type = SIMPLE_BRACKET; br_token.opr.sbcset = sbcset; tree = create_token_tree (dfa, NULL, NULL, &br_token); if (BE (tree == NULL, 0)) goto build_word_op_espace; #ifdef RE_ENABLE_I18N if (dfa->mb_cur_max > 1) { bin_tree_t *mbc_tree; /* Build a tree for complex bracket. */ br_token.type = COMPLEX_BRACKET; br_token.opr.mbcset = mbcset; dfa->has_mb_node = 1; mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); if (BE (mbc_tree == NULL, 0)) goto build_word_op_espace; /* Then join them by ALT node. */ tree = create_tree (dfa, tree, mbc_tree, OP_ALT); if (BE (mbc_tree != NULL, 1)) return tree; } else { free_charset (mbcset); return tree; } #else /* not RE_ENABLE_I18N */ return tree; #endif /* not RE_ENABLE_I18N */ build_word_op_espace: re_free (sbcset); #ifdef RE_ENABLE_I18N free_charset (mbcset); #endif /* RE_ENABLE_I18N */ *err = REG_ESPACE; return NULL; } /* This is intended for the expressions like "a{1,3}". Fetch a number from 'input', and return the number. Return REG_MISSING if the number field is empty like "{,1}". Return RE_DUP_MAX + 1 if the number field is too large. Return REG_ERROR if an error occurred. */ static Idx fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) { Idx num = REG_MISSING; unsigned char c; while (1) { fetch_token (token, input, syntax); c = token->opr.c; if (BE (token->type == END_OF_RE, 0)) return REG_ERROR; if (token->type == OP_CLOSE_DUP_NUM || c == ',') break; num = ((token->type != CHARACTER || c < '0' || '9' < c || num == REG_ERROR) ? REG_ERROR : num == REG_MISSING ? c - '0' : MIN (RE_DUP_MAX + 1, num * 10 + c - '0')); } return num; } #ifdef RE_ENABLE_I18N static void free_charset (re_charset_t *cset) { re_free (cset->mbchars); # ifdef _LIBC re_free (cset->coll_syms); re_free (cset->equiv_classes); re_free (cset->range_starts); re_free (cset->range_ends); # endif re_free (cset->char_classes); re_free (cset); } #endif /* RE_ENABLE_I18N */ /* Functions for binary tree operation. */ /* Create a tree node. */ static bin_tree_t * create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, re_token_type_t type) { re_token_t t; t.type = type; return create_token_tree (dfa, left, right, &t); } static bin_tree_t * create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, const re_token_t *token) { bin_tree_t *tree; if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0)) { bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); if (storage == NULL) return NULL; storage->next = dfa->str_tree_storage; dfa->str_tree_storage = storage; dfa->str_tree_storage_idx = 0; } tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++]; tree->parent = NULL; tree->left = left; tree->right = right; tree->token = *token; tree->token.duplicated = 0; tree->token.opt_subexp = 0; tree->first = NULL; tree->next = NULL; tree->node_idx = REG_MISSING; if (left != NULL) left->parent = tree; if (right != NULL) right->parent = tree; return tree; } /* Mark the tree SRC as an optional subexpression. To be called from preorder or postorder. */ static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node) { Idx idx = (uintptr_t) extra; if (node->token.type == SUBEXP && node->token.opr.idx == idx) node->token.opt_subexp = 1; return REG_NOERROR; } /* Free the allocated memory inside NODE. */ static void free_token (re_token_t *node) { #ifdef RE_ENABLE_I18N if (node->type == COMPLEX_BRACKET && node->duplicated == 0) free_charset (node->opr.mbcset); else #endif /* RE_ENABLE_I18N */ if (node->type == SIMPLE_BRACKET && node->duplicated == 0) re_free (node->opr.sbcset); } /* Worker function for tree walking. Free the allocated memory inside NODE and its children. */ static reg_errcode_t free_tree (void *extra, bin_tree_t *node) { free_token (&node->token); return REG_NOERROR; } /* Duplicate the node SRC, and return new node. This is a preorder visit similar to the one implemented by the generic visitor, but we need more infrastructure to maintain two parallel trees --- so, it's easier to duplicate. */ static bin_tree_t * duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa) { const bin_tree_t *node; bin_tree_t *dup_root; bin_tree_t **p_new = &dup_root, *dup_node = root->parent; for (node = root; ; ) { /* Create a new tree and link it back to the current parent. */ *p_new = create_token_tree (dfa, NULL, NULL, &node->token); if (*p_new == NULL) return NULL; (*p_new)->parent = dup_node; (*p_new)->token.duplicated = 1; dup_node = *p_new; /* Go to the left node, or up and to the right. */ if (node->left) { node = node->left; p_new = &dup_node->left; } else { const bin_tree_t *prev = NULL; while (node->right == prev || node->right == NULL) { prev = node; node = node->parent; dup_node = dup_node->parent; if (!node) return dup_root; } node = node->right; p_new = &dup_node->right; } } } lftp-4.6.3a/lib/strncasecmp.c0000644000015000007670000000355712466374012013026 00000000000000/* strncasecmp.c -- case insensitive string comparator Copyright (C) 1998-1999, 2005-2007, 2009-2015 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 . */ #include /* Specification. */ #include #include #include #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); } lftp-4.6.3a/lib/wctype-h.c0000644000015000007670000000023312122621313012214 00000000000000/* Normally this would be wctype.c, but that name's already taken. */ #include #define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE #include "wctype.h" lftp-4.6.3a/lib/strcasecmp.c0000644000015000007670000000342712466374012012644 00000000000000/* Case-insensitive string comparison function. Copyright (C) 1998-1999, 2005-2007, 2009-2015 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 . */ #include /* Specification. */ #include #include #include #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); } lftp-4.6.3a/lib/localcharset.c0000644000015000007670000005264412466374011013150 00000000000000/* Determine a canonical name for the current locale's character encoding. Copyright (C) 2000-2006, 2008-2015 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 . */ /* Written by Bruno Haible . */ #include /* Specification. */ #include "localcharset.h" #include #include #include #include #include #if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET # define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */ #endif #if defined _WIN32 || defined __WIN32__ # define WINDOWS_NATIVE # include #endif #if defined __EMX__ /* Assume EMX program runs on OS/2, even if compiled under DOS. */ # ifndef OS2 # define OS2 # endif #endif #if !defined WINDOWS_NATIVE # include # if HAVE_LANGINFO_CODESET # include # else # if 0 /* see comment below */ # include # endif # endif # ifdef __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include # endif #elif defined WINDOWS_NATIVE # define WIN32_LEAN_AND_MEAN # include #endif #if defined OS2 # define INCL_DOS # include #endif /* For MB_CUR_MAX_L */ #if defined DARWIN7 # include #endif #if ENABLE_RELOCATABLE # include "relocatable.h" #else # define relocate(pathname) (pathname) #endif /* Get LIBDIR. */ #ifndef LIBDIR # include "configmake.h" #endif /* Define O_NOFOLLOW to 0 on platforms where it does not exist. */ #ifndef O_NOFOLLOW # define O_NOFOLLOW 0 #endif #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Native Windows, Cygwin, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') #endif #ifndef DIRECTORY_SEPARATOR # define DIRECTORY_SEPARATOR '/' #endif #ifndef ISSLASH # define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) #endif #if HAVE_DECL_GETC_UNLOCKED # undef getc # define getc getc_unlocked #endif /* The following static variable is declared 'volatile' to avoid a possible multithread problem in the function get_charset_aliases. If we are running in a threaded environment, and if two threads initialize 'charset_aliases' simultaneously, both will produce the same value, and everything will be ok if the two assignments to 'charset_aliases' are atomic. But I don't know what will happen if the two assignments mix. */ #if __STDC__ != 1 # define volatile /* empty */ #endif /* Pointer to the ordered array of charset aliases read. Format of a single alias is: ALIAS '\0' CANONICAL '\0' */ static const char ** volatile charset_aliases; /* Aliases count, -1 until charset aliases are read. */ static int volatile charset_aliases_count = -1; /* fallback charset name, "*" entry from aliases */ static const char * volatile charset_fallback; static int charset_alias_cmp(const void *a,const void *b) { return strcmp (*(const char**)a, *(const char**)b); } /* Reads the contents of the charset.alias file. */ static void get_charset_aliases (void) { const char *cp; const char **cps = 0; int cnt = 0; const char *fb = 0; const char *aliases; if (charset_aliases_count < 0) { #if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__ || defined OS2) const char *dir; const char *base = "charset.alias"; char *file_name; /* Make it possible to override the charset.alias location. This is necessary for running the testsuite before "make install". */ dir = getenv ("CHARSETALIASDIR"); if (dir == NULL || dir[0] == '\0') dir = relocate (LIBDIR); /* Concatenate dir and base into freshly allocated file_name. */ { size_t dir_len = strlen (dir); size_t base_len = strlen (base); int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); file_name = (char *) malloc (dir_len + add_slash + base_len + 1); if (file_name != NULL) { memcpy (file_name, dir, dir_len); if (add_slash) file_name[dir_len] = DIRECTORY_SEPARATOR; memcpy (file_name + dir_len + add_slash, base, base_len + 1); } } if (file_name == NULL) /* Out of memory. Treat the file as empty. */ cp = ""; else { int fd; /* Open the file. Reject symbolic links on platforms that support O_NOFOLLOW. This is a security feature. Without it, an attacker could retrieve parts of the contents (namely, the tail of the first line that starts with "* ") of an arbitrary file by placing a symbolic link to that file under the name "charset.alias" in some writable directory and defining the environment variable CHARSETALIASDIR to point to that directory. */ fd = open (file_name, O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0)); if (fd < 0) /* File not found. Treat it as empty. */ cp = ""; else { FILE *fp; fp = fdopen (fd, "r"); if (fp == NULL) { /* Out of memory. Treat the file as empty. */ close (fd); cp = ""; } else { /* Parse the file's contents. */ char *res_ptr = NULL; size_t res_size = 0; for (;;) { int c; char buf1[50+1]; char buf2[50+1]; size_t l1, l2; char *old_res_ptr; c = getc (fp); if (c == EOF) break; if (c == '\n' || c == ' ' || c == '\t') continue; if (c == '#') { /* Skip comment, to end of line. */ do c = getc (fp); while (!(c == EOF || c == '\n')); if (c == EOF) break; continue; } ungetc (c, fp); if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) break; l1 = strlen (buf1); l2 = strlen (buf2); old_res_ptr = res_ptr; if (res_size == 0) { res_size = l1 + 1 + l2 + 1; res_ptr = (char *) malloc (res_size + 1); } else { res_size += l1 + 1 + l2 + 1; res_ptr = (char *) realloc (res_ptr, res_size + 1); } if (res_ptr == NULL) { /* Out of memory. */ res_size = 0; free (old_res_ptr); break; } strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); strcpy (res_ptr + res_size - (l2 + 1), buf2); } fclose (fp); if (res_size == 0) cp = ""; else { *(res_ptr + res_size) = '\0'; cp = res_ptr; } } } free (file_name); } #else # if defined DARWIN7 /* To avoid the trouble of installing a file that is shared by many GNU packages -- many packaging systems have problems with this --, simply inline the aliases here. */ cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" "ISO8859-2" "\0" "ISO-8859-2" "\0" "ISO8859-4" "\0" "ISO-8859-4" "\0" "ISO8859-5" "\0" "ISO-8859-5" "\0" "ISO8859-7" "\0" "ISO-8859-7" "\0" "ISO8859-9" "\0" "ISO-8859-9" "\0" "ISO8859-13" "\0" "ISO-8859-13" "\0" "ISO8859-15" "\0" "ISO-8859-15" "\0" "KOI8-R" "\0" "KOI8-R" "\0" "KOI8-U" "\0" "KOI8-U" "\0" "CP866" "\0" "CP866" "\0" "CP949" "\0" "CP949" "\0" "CP1131" "\0" "CP1131" "\0" "CP1251" "\0" "CP1251" "\0" "eucCN" "\0" "GB2312" "\0" "GB2312" "\0" "GB2312" "\0" "eucJP" "\0" "EUC-JP" "\0" "eucKR" "\0" "EUC-KR" "\0" "Big5" "\0" "BIG5" "\0" "Big5HKSCS" "\0" "BIG5-HKSCS" "\0" "GBK" "\0" "GBK" "\0" "GB18030" "\0" "GB18030" "\0" "SJIS" "\0" "SHIFT_JIS" "\0" "ARMSCII-8" "\0" "ARMSCII-8" "\0" "PT154" "\0" "PT154" "\0" /*"ISCII-DEV" "\0" "?" "\0"*/ "*" "\0" "UTF-8" "\0"; # endif # if defined VMS /* To avoid the troubles of an extra file charset.alias_vms in the sources of many GNU packages, simply inline the aliases here. */ /* The list of encodings is taken from the OpenVMS 7.3-1 documentation "Compaq C Run-Time Library Reference Manual for OpenVMS systems" section 10.7 "Handling Different Character Sets". */ cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" "ISO8859-2" "\0" "ISO-8859-2" "\0" "ISO8859-5" "\0" "ISO-8859-5" "\0" "ISO8859-7" "\0" "ISO-8859-7" "\0" "ISO8859-8" "\0" "ISO-8859-8" "\0" "ISO8859-9" "\0" "ISO-8859-9" "\0" /* Japanese */ "eucJP" "\0" "EUC-JP" "\0" "SJIS" "\0" "SHIFT_JIS" "\0" "DECKANJI" "\0" "DEC-KANJI" "\0" "SDECKANJI" "\0" "EUC-JP" "\0" /* Chinese */ "eucTW" "\0" "EUC-TW" "\0" "DECHANYU" "\0" "DEC-HANYU" "\0" "DECHANZI" "\0" "GB2312" "\0" /* Korean */ "DECKOREAN" "\0" "EUC-KR" "\0"; # endif # if defined WINDOWS_NATIVE || defined __CYGWIN__ /* To avoid the troubles of installing a separate file in the same directory as the DLL and of retrieving the DLL's directory at runtime, simply inline the aliases here. */ cp = "CP936" "\0" "GBK" "\0" "CP1361" "\0" "JOHAB" "\0" "CP20127" "\0" "ASCII" "\0" "CP20866" "\0" "KOI8-R" "\0" "CP20936" "\0" "GB2312" "\0" "CP21866" "\0" "KOI8-RU" "\0" "CP28591" "\0" "ISO-8859-1" "\0" "CP28592" "\0" "ISO-8859-2" "\0" "CP28593" "\0" "ISO-8859-3" "\0" "CP28594" "\0" "ISO-8859-4" "\0" "CP28595" "\0" "ISO-8859-5" "\0" "CP28596" "\0" "ISO-8859-6" "\0" "CP28597" "\0" "ISO-8859-7" "\0" "CP28598" "\0" "ISO-8859-8" "\0" "CP28599" "\0" "ISO-8859-9" "\0" "CP28605" "\0" "ISO-8859-15" "\0" "CP38598" "\0" "ISO-8859-8" "\0" "CP51932" "\0" "EUC-JP" "\0" "CP51936" "\0" "GB2312" "\0" "CP51949" "\0" "EUC-KR" "\0" "CP51950" "\0" "EUC-TW" "\0" "CP54936" "\0" "GB18030" "\0" "CP65001" "\0" "UTF-8" "\0"; # endif # if defined OS2 /* To avoid the troubles of installing a separate file in the same directory as the DLL and of retrieving the DLL's directory at runtime, simply inline the aliases here. */ /* The list of encodings is taken from "List of OS/2 Codepages" by Alex Taylor: . See also "IBM Globalization - Code page identifiers": . */ cp = "CP813" "\0" "ISO-8859-7" "\0" "CP878" "\0" "KOI8-R" "\0" "CP819" "\0" "ISO-8859-1" "\0" "CP912" "\0" "ISO-8859-2" "\0" "CP913" "\0" "ISO-8859-3" "\0" "CP914" "\0" "ISO-8859-4" "\0" "CP915" "\0" "ISO-8859-5" "\0" "CP916" "\0" "ISO-8859-8" "\0" "CP920" "\0" "ISO-8859-9" "\0" "CP921" "\0" "ISO-8859-13" "\0" "CP923" "\0" "ISO-8859-15" "\0" "CP954" "\0" "EUC-JP" "\0" "CP964" "\0" "EUC-TW" "\0" "CP970" "\0" "EUC-KR" "\0" "CP1089" "\0" "ISO-8859-6" "\0" "CP1208" "\0" "UTF-8" "\0" "CP1381" "\0" "GB2312" "\0" "CP1386" "\0" "GBK" "\0" "CP3372" "\0" "EUC-JP" "\0"; # endif #endif /* build ordered array of aliases and also find fallback */ cnt = 0; for (aliases = cp; *aliases != '\0'; aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) { if (aliases[0] == '*' && aliases[1] == '\0') fb = aliases + strlen (aliases) + 1; else cnt ++; } if (cnt > 0) { cps = (const char **) malloc (cnt * sizeof(*cps)); if (cps == NULL) { /* out of memory */ charset_aliases_count = 0; return; } cnt = 0; for (aliases = cp; *aliases != '\0'; aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) { if (!(aliases[0] == '*' && aliases[1] == '\0')) cps[cnt++] = aliases; } qsort (cps, cnt, sizeof(*cps), charset_alias_cmp); } charset_aliases = cps; charset_fallback = fb; charset_aliases_count = cnt; } } /* Replace codeset name using the alias table. The result must not be freed; it is statically allocated. */ static const char * resolve_alias (const char *codeset) { const char **alias_ptr = 0; get_charset_aliases (); if (charset_aliases_count > 0) alias_ptr = bsearch (&codeset, charset_aliases, charset_aliases_count, sizeof(codeset), charset_alias_cmp); if (alias_ptr != NULL) return *alias_ptr + strlen (*alias_ptr) + 1; if (charset_fallback != NULL) return charset_fallback; return codeset; } /* Determine the current locale's character encoding, and canonicalize it into one of the canonical names listed in config.charset. The result must not be freed; it is statically allocated. If the canonical name cannot be determined, the result is a non-canonical name. */ #ifdef STATIC STATIC #endif const char * locale_charset (void) { const char *codeset; #if !(defined WINDOWS_NATIVE || defined OS2) # if HAVE_LANGINFO_CODESET /* Most systems support nl_langinfo (CODESET) nowadays. */ codeset = nl_langinfo (CODESET); # ifdef __CYGWIN__ /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always returns "US-ASCII". Return the suffix of the locale name from the environment variables (if present) or the codepage as a number. */ if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) { const char *locale; static char buf[2 + 10 + 1]; locale = getenv ("LC_ALL"); if (locale == NULL || locale[0] == '\0') { locale = getenv ("LC_CTYPE"); if (locale == NULL || locale[0] == '\0') locale = getenv ("LANG"); } if (locale != NULL && locale[0] != '\0') { /* If the locale name contains an encoding after the dot, return it. */ const char *dot = strchr (locale, '.'); if (dot != NULL) { const char *modifier; dot++; /* Look for the possible @... trailer and remove it, if any. */ modifier = strchr (dot, '@'); if (modifier == NULL) return dot; if (modifier - dot < sizeof (buf)) { memcpy (buf, dot, modifier - dot); buf [modifier - dot] = '\0'; return buf; } } } /* The Windows API has a function returning the locale's codepage as a number: GetACP(). This encoding is used by Cygwin, unless the user has set the environment variable CYGWIN=codepage:oem (which very few people do). Output directed to console windows needs to be converted (to GetOEMCP() if the console is using a raster font, or to GetConsoleOutputCP() if it is using a TrueType font). Cygwin does this conversion transparently (see winsup/cygwin/fhandler_console.cc), converting to GetConsoleOutputCP(). This leads to correct results, except when SetConsoleOutputCP has been called and a raster font is in use. */ sprintf (buf, "CP%u", GetACP ()); codeset = buf; } # endif # else /* On old systems which lack it, use setlocale or getenv. */ const char *locale = NULL; /* But most old systems don't have a complete set of locales. Some (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't use setlocale here; it would return "C" when it doesn't support the locale name the user has set. */ # if 0 locale = setlocale (LC_CTYPE, NULL); # endif if (locale == NULL || locale[0] == '\0') { locale = getenv ("LC_ALL"); if (locale == NULL || locale[0] == '\0') { locale = getenv ("LC_CTYPE"); if (locale == NULL || locale[0] == '\0') locale = getenv ("LANG"); } } /* On some old systems, one used to set locale = "iso8859_1". On others, you set it to "language_COUNTRY.charset". In any case, we resolve it through the charset.alias file. */ codeset = locale; # endif #elif defined WINDOWS_NATIVE static char buf[2 + 10 + 1]; /* The Windows API has a function returning the locale's codepage as a number, but the value doesn't change according to what the 'setlocale' call specified. So we use it as a last resort, in case the string returned by 'setlocale' doesn't specify the codepage. */ char *current_locale = setlocale (LC_ALL, NULL); char *pdot; /* If they set different locales for different categories, 'setlocale' will return a semi-colon separated list of locale values. To make sure we use the correct one, we choose LC_CTYPE. */ if (strchr (current_locale, ';')) current_locale = setlocale (LC_CTYPE, NULL); pdot = strrchr (current_locale, '.'); if (pdot) sprintf (buf, "CP%s", pdot + 1); else { /* The Windows API has a function returning the locale's codepage as a number: GetACP(). When the output goes to a console window, it needs to be provided in GetOEMCP() encoding if the console is using a raster font, or in GetConsoleOutputCP() encoding if it is using a TrueType font. But in GUI programs and for output sent to files and pipes, GetACP() encoding is the best bet. */ sprintf (buf, "CP%u", GetACP ()); } codeset = buf; #elif defined OS2 const char *locale; static char buf[2 + 10 + 1]; ULONG cp[3]; ULONG cplen; codeset = NULL; /* Allow user to override the codeset, as set in the operating system, with standard language environment variables. */ locale = getenv ("LC_ALL"); if (locale == NULL || locale[0] == '\0') { locale = getenv ("LC_CTYPE"); if (locale == NULL || locale[0] == '\0') locale = getenv ("LANG"); } if (locale != NULL && locale[0] != '\0') { /* If the locale name contains an encoding after the dot, return it. */ const char *dot = strchr (locale, '.'); if (dot != NULL) { const char *modifier; dot++; /* Look for the possible @... trailer and remove it, if any. */ modifier = strchr (dot, '@'); if (modifier == NULL) return dot; if (modifier - dot < sizeof (buf)) { memcpy (buf, dot, modifier - dot); buf [modifier - dot] = '\0'; return buf; } } /* For the POSIX locale, don't use the system's codepage. */ if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0) codeset = ""; } if (codeset == NULL) { /* OS/2 has a function returning the locale's codepage as a number. */ if (DosQueryCp (sizeof (cp), cp, &cplen)) codeset = ""; else { sprintf (buf, "CP%u", cp[0]); codeset = buf; } } #endif if (codeset == NULL) /* The canonical name cannot be determined. */ codeset = ""; codeset = resolve_alias (codeset); /* Don't return an empty string. GNU libc and GNU libiconv interpret the empty string as denoting "the locale's character encoding", thus GNU libiconv would call this function a second time. */ if (codeset[0] == '\0') codeset = "ASCII"; #ifdef DARWIN7 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" (the default codeset) does not work when MB_CUR_MAX is 1. */ if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1) codeset = "ASCII"; #endif return codeset; } lftp-4.6.3a/lib/cloexec.c0000644000015000007670000000442712466374011012122 00000000000000/* closexec.c - set or clear the close-on-exec descriptor flag Copyright (C) 1991, 2004-2006, 2009-2015 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 . The code is taken from glibc/manual/llio.texi */ #include #include "cloexec.h" #include #include #include /* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true, or clear the flag if VALUE is false. Return 0 on success, or -1 on error with 'errno' set. Note that on MingW, this function does NOT protect DESC from being inherited into spawned children. Instead, either use dup_cloexec followed by closing the original DESC, or use interfaces such as open or pipe2 that accept flags like O_CLOEXEC to create DESC non-inheritable in the first place. */ int set_cloexec_flag (int desc, bool value) { #ifdef F_SETFD int flags = fcntl (desc, F_GETFD, 0); if (0 <= flags) { int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC); if (flags == newflags || fcntl (desc, F_SETFD, newflags) != -1) return 0; } return -1; #else /* !F_SETFD */ /* Use dup2 to reject invalid file descriptors; the cloexec flag will be unaffected. */ if (desc < 0) { errno = EBADF; return -1; } if (dup2 (desc, desc) < 0) /* errno is EBADF here. */ return -1; /* There is nothing we can do on this kind of platform. Punt. */ return 0; #endif /* !F_SETFD */ } /* Duplicates a file handle FD, while marking the copy to be closed prior to exec or spawn. Returns -1 and sets errno if FD could not be duplicated. */ int dup_cloexec (int fd) { return fcntl (fd, F_DUPFD_CLOEXEC, 0); } lftp-4.6.3a/lib/alloca.in.h0000644000015000007670000000372412466374011012344 00000000000000/* Memory allocation on the stack. Copyright (C) 1995, 1999, 2001-2004, 2006-2015 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 . */ /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H means there is a real alloca function. */ #ifndef _GL_ALLOCA_H #define _GL_ALLOCA_H /* alloca (N) returns a pointer to N bytes of memory allocated on the stack, which will last until the function returns. Use of alloca should be avoided: - inside arguments of function calls - undefined behaviour, - in inline functions - the allocation may actually last until the calling function returns, - for huge N (say, N >= 65536) - you never know how large (or small) the stack is, and when the stack cannot fulfill the memory allocation request, the program just crashes. */ #ifndef alloca # ifdef __GNUC__ # define alloca __builtin_alloca # elif defined _AIX # define alloca __alloca # elif defined _MSC_VER # include # define alloca _alloca # elif defined __DECC && defined __VMS # define alloca __ALLOCA # elif defined __TANDEM && defined _TNS_E_TARGET # ifdef __cplusplus extern "C" # endif void *_alloca (unsigned short); # pragma intrinsic (_alloca) # define alloca _alloca # else # include # ifdef __cplusplus extern "C" # endif void *alloca (size_t); # endif #endif #endif /* _GL_ALLOCA_H */ lftp-4.6.3a/lib/stdlib.in.h0000644000015000007670000010243412466374012012371 00000000000000/* A GNU-like . Copyright (C) 1995, 2001-2004, 2006-2015 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 . */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined __need_system_stdlib_h || defined __need_malloc_and_calloc /* Special invocation conventions inside some gnulib header files, and inside some glibc header files, respectively. */ #@INCLUDE_NEXT@ @NEXT_STDLIB_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_STDLIB_H /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STDLIB_H@ #ifndef _@GUARD_PREFIX@_STDLIB_H #define _@GUARD_PREFIX@_STDLIB_H /* NetBSD 5.0 mis-defines NULL. */ #include /* MirBSD 10 defines WEXITSTATUS in , not in . */ #if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS # include #endif /* Solaris declares getloadavg() in . */ #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ # include #endif /* Native Windows platforms declare mktemp() in . */ #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) # include #endif #if @GNULIB_RANDOM_R@ /* OSF/1 5.1 declares 'struct random_data' in , which is included from if _REENTRANT is defined. Include it whenever we need 'struct random_data'. */ # if @HAVE_RANDOM_H@ # include # endif # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@ # include # endif # if !@HAVE_STRUCT_RANDOM_DATA@ /* Define 'struct random_data'. But allow multiple gnulib generated replacements to coexist. */ # if !GNULIB_defined_struct_random_data struct random_data { int32_t *fptr; /* Front pointer. */ int32_t *rptr; /* Rear pointer. */ int32_t *state; /* Array of state values. */ int rand_type; /* Type of random number generator. */ int rand_deg; /* Degree of random number generator. */ int rand_sep; /* Distance between front and rear. */ int32_t *end_ptr; /* Pointer behind state table. */ }; # define GNULIB_defined_struct_random_data 1 # endif # endif #endif #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) /* On Mac OS X 10.3, only declares mkstemp. */ /* On Mac OS X 10.5, only declares mkstemps. */ /* On Cygwin 1.7.1, only declares getsubopt. */ /* But avoid namespace pollution on glibc systems and native Windows. */ # include #endif /* The __attribute__ feature is available in gcc versions 2.5 and later. The attribute __pure__ was added in gcc 2.96. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else # define _GL_ATTRIBUTE_PURE /* empty */ #endif /* The definition of _Noreturn is copied here. */ /* 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. */ /* Some systems do not define EXIT_*, despite otherwise supporting C89. */ #ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 #endif /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere with proper operation of xargs. */ #ifndef EXIT_FAILURE # define EXIT_FAILURE 1 #elif EXIT_FAILURE != 1 # undef EXIT_FAILURE # define EXIT_FAILURE 1 #endif #if @GNULIB__EXIT@ /* Terminate the current process with the given return code, without running the 'atexit' handlers. */ # if !@HAVE__EXIT@ _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); # endif _GL_CXXALIAS_SYS (_Exit, void, (int status)); _GL_CXXALIASWARN (_Exit); #elif defined GNULIB_POSIXCHECK # undef _Exit # if HAVE_RAW_DECL__EXIT _GL_WARN_ON_USE (_Exit, "_Exit is unportable - " "use gnulib module _Exit for portability"); # endif #endif #if @GNULIB_ATOLL@ /* Parse a signed decimal integer. Returns the value of the integer. Errors are not detected. */ # if !@HAVE_ATOLL@ _GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (atoll, long long, (const char *string)); _GL_CXXALIASWARN (atoll); #elif defined GNULIB_POSIXCHECK # undef atoll # if HAVE_RAW_DECL_ATOLL _GL_WARN_ON_USE (atoll, "atoll is unportable - " "use gnulib module atoll for portability"); # endif #endif #if @GNULIB_CALLOC_POSIX@ # if @REPLACE_CALLOC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef calloc # define calloc rpl_calloc # endif _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size)); _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); # else _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); # endif _GL_CXXALIASWARN (calloc); #elif defined GNULIB_POSIXCHECK # undef calloc /* Assume calloc is always declared. */ _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " "use gnulib module calloc-posix for portability"); #endif #if @GNULIB_CANONICALIZE_FILE_NAME@ # if @REPLACE_CANONICALIZE_FILE_NAME@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define canonicalize_file_name rpl_canonicalize_file_name # endif _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); # else # if !@HAVE_CANONICALIZE_FILE_NAME@ _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); # endif _GL_CXXALIASWARN (canonicalize_file_name); #elif defined GNULIB_POSIXCHECK # undef canonicalize_file_name # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME _GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - " "use gnulib module canonicalize-lgpl for portability"); # endif #endif #if @GNULIB_GETLOADAVG@ /* Store max(NELEM,3) load average numbers in LOADAVG[]. The three numbers are the load average of the last 1 minute, the last 5 minutes, and the last 15 minutes, respectively. LOADAVG is an array of NELEM numbers. */ # if !@HAVE_DECL_GETLOADAVG@ _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); _GL_CXXALIASWARN (getloadavg); #elif defined GNULIB_POSIXCHECK # undef getloadavg # if HAVE_RAW_DECL_GETLOADAVG _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " "use gnulib module getloadavg for portability"); # endif #endif #if @GNULIB_GETSUBOPT@ /* Assuming *OPTIONP is a comma separated list of elements of the form "token" or "token=value", getsubopt parses the first of these elements. If the first element refers to a "token" that is member of the given NULL-terminated array of tokens: - It replaces the comma with a NUL byte, updates *OPTIONP to point past the first option and the comma, sets *VALUEP to the value of the element (or NULL if it doesn't contain an "=" sign), - It returns the index of the "token" in the given array of tokens. Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. For more details see the POSIX:2001 specification. http://www.opengroup.org/susv3xsh/getsubopt.html */ # if !@HAVE_GETSUBOPT@ _GL_FUNCDECL_SYS (getsubopt, int, (char **optionp, char *const *tokens, char **valuep) _GL_ARG_NONNULL ((1, 2, 3))); # endif _GL_CXXALIAS_SYS (getsubopt, int, (char **optionp, char *const *tokens, char **valuep)); _GL_CXXALIASWARN (getsubopt); #elif defined GNULIB_POSIXCHECK # undef getsubopt # if HAVE_RAW_DECL_GETSUBOPT _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - " "use gnulib module getsubopt for portability"); # endif #endif #if @GNULIB_GRANTPT@ /* Change the ownership and access permission of the slave side of the pseudo-terminal whose master side is specified by FD. */ # if !@HAVE_GRANTPT@ _GL_FUNCDECL_SYS (grantpt, int, (int fd)); # endif _GL_CXXALIAS_SYS (grantpt, int, (int fd)); _GL_CXXALIASWARN (grantpt); #elif defined GNULIB_POSIXCHECK # undef grantpt # if HAVE_RAW_DECL_GRANTPT _GL_WARN_ON_USE (grantpt, "grantpt is not portable - " "use gnulib module grantpt for portability"); # endif #endif /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not rely on GNU or POSIX semantics for malloc and realloc (for example, by never specifying a zero size), so it does not need malloc or realloc to be redefined. */ #if @GNULIB_MALLOC_POSIX@ # if @REPLACE_MALLOC@ # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ || _GL_USE_STDLIB_ALLOC) # undef malloc # define malloc rpl_malloc # endif _GL_FUNCDECL_RPL (malloc, void *, (size_t size)); _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); # else _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); # endif _GL_CXXALIASWARN (malloc); #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC # undef malloc /* Assume malloc is always declared. */ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " "use gnulib module malloc-posix for portability"); #endif /* Convert a multibyte character to a wide character. */ #if @GNULIB_MBTOWC@ # if @REPLACE_MBTOWC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mbtowc # define mbtowc rpl_mbtowc # endif _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); # else _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); # endif _GL_CXXALIASWARN (mbtowc); #endif #if @GNULIB_MKDTEMP@ /* Create a unique temporary directory from TEMPLATE. The last six characters of TEMPLATE must be "XXXXXX"; they are replaced with a string that makes the directory name unique. Returns TEMPLATE, or a null pointer if it cannot get a unique name. The directory is created mode 700. */ # if !@HAVE_MKDTEMP@ _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); _GL_CXXALIASWARN (mkdtemp); #elif defined GNULIB_POSIXCHECK # undef mkdtemp # if HAVE_RAW_DECL_MKDTEMP _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " "use gnulib module mkdtemp for portability"); # endif #endif #if @GNULIB_MKOSTEMP@ /* Create a unique temporary file from TEMPLATE. The last six characters of TEMPLATE 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 ) 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. */ # if !@HAVE_MKOSTEMP@ _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); _GL_CXXALIASWARN (mkostemp); #elif defined GNULIB_POSIXCHECK # undef mkostemp # if HAVE_RAW_DECL_MKOSTEMP _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " "use gnulib module mkostemp for portability"); # endif #endif #if @GNULIB_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 ) 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. */ # if !@HAVE_MKOSTEMPS@ _GL_FUNCDECL_SYS (mkostemps, int, (char * /*template*/, int /*suffixlen*/, int /*flags*/) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (mkostemps, int, (char * /*template*/, int /*suffixlen*/, int /*flags*/)); _GL_CXXALIASWARN (mkostemps); #elif defined GNULIB_POSIXCHECK # undef mkostemps # if HAVE_RAW_DECL_MKOSTEMPS _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " "use gnulib module mkostemps for portability"); # endif #endif #if @GNULIB_MKSTEMP@ /* Create a unique temporary file from TEMPLATE. The last six characters of TEMPLATE 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. */ # if @REPLACE_MKSTEMP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mkstemp rpl_mkstemp # endif _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); # else # if ! @HAVE_MKSTEMP@ _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); # endif _GL_CXXALIASWARN (mkstemp); #elif defined GNULIB_POSIXCHECK # undef mkstemp # if HAVE_RAW_DECL_MKSTEMP _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " "use gnulib module mkstemp for portability"); # endif #endif #if @GNULIB_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. */ # if !@HAVE_MKSTEMPS@ _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); _GL_CXXALIASWARN (mkstemps); #elif defined GNULIB_POSIXCHECK # undef mkstemps # if HAVE_RAW_DECL_MKSTEMPS _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " "use gnulib module mkstemps for portability"); # endif #endif #if @GNULIB_POSIX_OPENPT@ /* Return an FD open to the master side of a pseudo-terminal. Flags should include O_RDWR, and may also include O_NOCTTY. */ # if !@HAVE_POSIX_OPENPT@ _GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); # endif _GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); _GL_CXXALIASWARN (posix_openpt); #elif defined GNULIB_POSIXCHECK # undef posix_openpt # if HAVE_RAW_DECL_POSIX_OPENPT _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " "use gnulib module posix_openpt for portability"); # endif #endif #if @GNULIB_PTSNAME@ /* Return the pathname of the pseudo-terminal slave associated with the master FD is open on, or NULL on errors. */ # if @REPLACE_PTSNAME@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ptsname # define ptsname rpl_ptsname # endif _GL_FUNCDECL_RPL (ptsname, char *, (int fd)); _GL_CXXALIAS_RPL (ptsname, char *, (int fd)); # else # if !@HAVE_PTSNAME@ _GL_FUNCDECL_SYS (ptsname, char *, (int fd)); # endif _GL_CXXALIAS_SYS (ptsname, char *, (int fd)); # endif _GL_CXXALIASWARN (ptsname); #elif defined GNULIB_POSIXCHECK # undef ptsname # if HAVE_RAW_DECL_PTSNAME _GL_WARN_ON_USE (ptsname, "ptsname is not portable - " "use gnulib module ptsname for portability"); # endif #endif #if @GNULIB_PTSNAME_R@ /* Set the pathname of the pseudo-terminal slave associated with the master FD is open on and return 0, or set errno and return non-zero on errors. */ # if @REPLACE_PTSNAME_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ptsname_r # define ptsname_r rpl_ptsname_r # endif _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); # else # if !@HAVE_PTSNAME_R@ _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); # endif _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); # endif _GL_CXXALIASWARN (ptsname_r); #elif defined GNULIB_POSIXCHECK # undef ptsname_r # if HAVE_RAW_DECL_PTSNAME_R _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - " "use gnulib module ptsname_r for portability"); # endif #endif #if @GNULIB_PUTENV@ # if @REPLACE_PUTENV@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef putenv # define putenv rpl_putenv # endif _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (putenv, int, (char *string)); # else _GL_CXXALIAS_SYS (putenv, int, (char *string)); # endif _GL_CXXALIASWARN (putenv); #endif #if @GNULIB_QSORT_R@ # if @REPLACE_QSORT_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef qsort_r # define qsort_r rpl_qsort_r # endif _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, int (*compare) (void const *, void const *, void *), void *arg) _GL_ARG_NONNULL ((1, 4))); _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, int (*compare) (void const *, void const *, void *), void *arg)); # else _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, int (*compare) (void const *, void const *, void *), void *arg)); # endif _GL_CXXALIASWARN (qsort_r); #endif #if @GNULIB_RANDOM_R@ # if !@HAVE_RANDOM_R@ # ifndef RAND_MAX # define RAND_MAX 2147483647 # endif # endif #endif #if @GNULIB_RANDOM@ # if !@HAVE_RANDOM@ _GL_FUNCDECL_SYS (random, long, (void)); # endif _GL_CXXALIAS_SYS (random, long, (void)); _GL_CXXALIASWARN (random); #elif defined GNULIB_POSIXCHECK # undef random # if HAVE_RAW_DECL_RANDOM _GL_WARN_ON_USE (random, "random is unportable - " "use gnulib module random for portability"); # endif #endif #if @GNULIB_RANDOM@ # if !@HAVE_RANDOM@ _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); # endif _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed)); _GL_CXXALIASWARN (srandom); #elif defined GNULIB_POSIXCHECK # undef srandom # if HAVE_RAW_DECL_SRANDOM _GL_WARN_ON_USE (srandom, "srandom is unportable - " "use gnulib module random for portability"); # endif #endif #if @GNULIB_RANDOM@ # if !@HAVE_RANDOM@ _GL_FUNCDECL_SYS (initstate, char *, (unsigned int seed, char *buf, size_t buf_size) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (initstate, char *, (unsigned int seed, char *buf, size_t buf_size)); _GL_CXXALIASWARN (initstate); #elif defined GNULIB_POSIXCHECK # undef initstate # if HAVE_RAW_DECL_INITSTATE_R _GL_WARN_ON_USE (initstate, "initstate is unportable - " "use gnulib module random for portability"); # endif #endif #if @GNULIB_RANDOM@ # if !@HAVE_RANDOM@ _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state)); _GL_CXXALIASWARN (setstate); #elif defined GNULIB_POSIXCHECK # undef setstate # if HAVE_RAW_DECL_SETSTATE_R _GL_WARN_ON_USE (setstate, "setstate is unportable - " "use gnulib module random for portability"); # endif #endif #if @GNULIB_RANDOM_R@ # if @REPLACE_RANDOM_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef random_r # define random_r rpl_random_r # endif _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result)); # else # if !@HAVE_RANDOM_R@ _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); # endif _GL_CXXALIASWARN (random_r); #elif defined GNULIB_POSIXCHECK # undef random_r # if HAVE_RAW_DECL_RANDOM_R _GL_WARN_ON_USE (random_r, "random_r is unportable - " "use gnulib module random_r for portability"); # endif #endif #if @GNULIB_RANDOM_R@ # if @REPLACE_RANDOM_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef srandom_r # define srandom_r rpl_srandom_r # endif _GL_FUNCDECL_RPL (srandom_r, int, (unsigned int seed, struct random_data *rand_state) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (srandom_r, int, (unsigned int seed, struct random_data *rand_state)); # else # if !@HAVE_RANDOM_R@ _GL_FUNCDECL_SYS (srandom_r, int, (unsigned int seed, struct random_data *rand_state) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (srandom_r, int, (unsigned int seed, struct random_data *rand_state)); # endif _GL_CXXALIASWARN (srandom_r); #elif defined GNULIB_POSIXCHECK # undef srandom_r # if HAVE_RAW_DECL_SRANDOM_R _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " "use gnulib module random_r for portability"); # endif #endif #if @GNULIB_RANDOM_R@ # if @REPLACE_RANDOM_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef initstate_r # define initstate_r rpl_initstate_r # endif _GL_FUNCDECL_RPL (initstate_r, int, (unsigned int seed, char *buf, size_t buf_size, struct random_data *rand_state) _GL_ARG_NONNULL ((2, 4))); _GL_CXXALIAS_RPL (initstate_r, int, (unsigned int seed, char *buf, size_t buf_size, struct random_data *rand_state)); # else # if !@HAVE_RANDOM_R@ _GL_FUNCDECL_SYS (initstate_r, int, (unsigned int seed, char *buf, size_t buf_size, struct random_data *rand_state) _GL_ARG_NONNULL ((2, 4))); # endif _GL_CXXALIAS_SYS (initstate_r, int, (unsigned int seed, char *buf, size_t buf_size, struct random_data *rand_state)); # endif _GL_CXXALIASWARN (initstate_r); #elif defined GNULIB_POSIXCHECK # undef initstate_r # if HAVE_RAW_DECL_INITSTATE_R _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " "use gnulib module random_r for portability"); # endif #endif #if @GNULIB_RANDOM_R@ # if @REPLACE_RANDOM_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef setstate_r # define setstate_r rpl_setstate_r # endif _GL_FUNCDECL_RPL (setstate_r, int, (char *arg_state, struct random_data *rand_state) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (setstate_r, int, (char *arg_state, struct random_data *rand_state)); # else # if !@HAVE_RANDOM_R@ _GL_FUNCDECL_SYS (setstate_r, int, (char *arg_state, struct random_data *rand_state) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (setstate_r, int, (char *arg_state, struct random_data *rand_state)); # endif _GL_CXXALIASWARN (setstate_r); #elif defined GNULIB_POSIXCHECK # undef setstate_r # if HAVE_RAW_DECL_SETSTATE_R _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " "use gnulib module random_r for portability"); # endif #endif #if @GNULIB_REALLOC_POSIX@ # if @REPLACE_REALLOC@ # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ || _GL_USE_STDLIB_ALLOC) # undef realloc # define realloc rpl_realloc # endif _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); # else _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); # endif _GL_CXXALIASWARN (realloc); #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC # undef realloc /* Assume realloc is always declared. */ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " "use gnulib module realloc-posix for portability"); #endif #if @GNULIB_REALPATH@ # if @REPLACE_REALPATH@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define realpath rpl_realpath # endif _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved)); # else # if !@HAVE_REALPATH@ _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved)); # endif _GL_CXXALIASWARN (realpath); #elif defined GNULIB_POSIXCHECK # undef realpath # if HAVE_RAW_DECL_REALPATH _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " "canonicalize or canonicalize-lgpl for portability"); # endif #endif #if @GNULIB_RPMATCH@ /* Test a user response to a question. Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ # if !@HAVE_RPMATCH@ _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); _GL_CXXALIASWARN (rpmatch); #elif defined GNULIB_POSIXCHECK # undef rpmatch # if HAVE_RAW_DECL_RPMATCH _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " "use gnulib module rpmatch for portability"); # endif #endif #if @GNULIB_SECURE_GETENV@ /* Look up NAME in the environment, returning 0 in insecure situations. */ # if !@HAVE_SECURE_GETENV@ _GL_FUNCDECL_SYS (secure_getenv, char *, (char const *name) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name)); _GL_CXXALIASWARN (secure_getenv); #elif defined GNULIB_POSIXCHECK # undef secure_getenv # if HAVE_RAW_DECL_SECURE_GETENV _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - " "use gnulib module secure_getenv for portability"); # endif #endif #if @GNULIB_SETENV@ /* Set NAME to VALUE in the environment. If REPLACE is nonzero, overwrite an existing value. */ # if @REPLACE_SETENV@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef setenv # define setenv rpl_setenv # endif _GL_FUNCDECL_RPL (setenv, int, (const char *name, const char *value, int replace) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (setenv, int, (const char *name, const char *value, int replace)); # else # if !@HAVE_DECL_SETENV@ _GL_FUNCDECL_SYS (setenv, int, (const char *name, const char *value, int replace) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (setenv, int, (const char *name, const char *value, int replace)); # endif # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@) _GL_CXXALIASWARN (setenv); # endif #elif defined GNULIB_POSIXCHECK # undef setenv # if HAVE_RAW_DECL_SETENV _GL_WARN_ON_USE (setenv, "setenv is unportable - " "use gnulib module setenv for portability"); # endif #endif #if @GNULIB_STRTOD@ /* Parse a double from STRING, updating ENDP if appropriate. */ # if @REPLACE_STRTOD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define strtod rpl_strtod # endif _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp)); # else # if !@HAVE_STRTOD@ _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); # endif _GL_CXXALIASWARN (strtod); #elif defined GNULIB_POSIXCHECK # undef strtod # if HAVE_RAW_DECL_STRTOD _GL_WARN_ON_USE (strtod, "strtod is unportable - " "use gnulib module strtod for portability"); # endif #endif #if @GNULIB_STRTOLL@ /* Parse a signed integer whose textual representation starts at STRING. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, it may be decimal or octal (with prefix "0") or hexadecimal (with prefix "0x"). If ENDPTR is not NULL, the address of the first byte after the integer is stored in *ENDPTR. Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set to ERANGE. */ # if !@HAVE_STRTOLL@ _GL_FUNCDECL_SYS (strtoll, long long, (const char *string, char **endptr, int base) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoll, long long, (const char *string, char **endptr, int base)); _GL_CXXALIASWARN (strtoll); #elif defined GNULIB_POSIXCHECK # undef strtoll # if HAVE_RAW_DECL_STRTOLL _GL_WARN_ON_USE (strtoll, "strtoll is unportable - " "use gnulib module strtoll for portability"); # endif #endif #if @GNULIB_STRTOULL@ /* Parse an unsigned integer whose textual representation starts at STRING. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, it may be decimal or octal (with prefix "0") or hexadecimal (with prefix "0x"). If ENDPTR is not NULL, the address of the first byte after the integer is stored in *ENDPTR. Upon overflow, the return value is ULLONG_MAX, and errno is set to ERANGE. */ # if !@HAVE_STRTOULL@ _GL_FUNCDECL_SYS (strtoull, unsigned long long, (const char *string, char **endptr, int base) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoull, unsigned long long, (const char *string, char **endptr, int base)); _GL_CXXALIASWARN (strtoull); #elif defined GNULIB_POSIXCHECK # undef strtoull # if HAVE_RAW_DECL_STRTOULL _GL_WARN_ON_USE (strtoull, "strtoull is unportable - " "use gnulib module strtoull for portability"); # endif #endif #if @GNULIB_UNLOCKPT@ /* Unlock the slave side of the pseudo-terminal whose master side is specified by FD, so that it can be opened. */ # if !@HAVE_UNLOCKPT@ _GL_FUNCDECL_SYS (unlockpt, int, (int fd)); # endif _GL_CXXALIAS_SYS (unlockpt, int, (int fd)); _GL_CXXALIASWARN (unlockpt); #elif defined GNULIB_POSIXCHECK # undef unlockpt # if HAVE_RAW_DECL_UNLOCKPT _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " "use gnulib module unlockpt for portability"); # endif #endif #if @GNULIB_UNSETENV@ /* Remove the variable NAME from the environment. */ # if @REPLACE_UNSETENV@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef unsetenv # define unsetenv rpl_unsetenv # endif _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); # else # if !@HAVE_DECL_UNSETENV@ _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); # endif # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@) _GL_CXXALIASWARN (unsetenv); # endif #elif defined GNULIB_POSIXCHECK # undef unsetenv # if HAVE_RAW_DECL_UNSETENV _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " "use gnulib module unsetenv for portability"); # endif #endif /* Convert a wide character to a multibyte character. */ #if @GNULIB_WCTOMB@ # if @REPLACE_WCTOMB@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef wctomb # define wctomb rpl_wctomb # endif _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc)); _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc)); # else _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); # endif _GL_CXXALIASWARN (wctomb); #endif #endif /* _@GUARD_PREFIX@_STDLIB_H */ #endif /* _@GUARD_PREFIX@_STDLIB_H */ #endif lftp-4.6.3a/lib/strtol.c0000644000015000007670000002566612466374012012040 00000000000000/* Convert string representation of a number into an integer value. Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2015 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. 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 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 . */ #ifdef _LIBC # define USE_NUMBER_GROUPING #else # include #endif #include #include #ifndef __set_errno # define __set_errno(Val) errno = (Val) #endif #include #include #include #include #ifdef USE_NUMBER_GROUPING # include "../locale/localeinfo.h" #endif /* Nonzero if we are defining 'strtoul' or 'strtoull', operating on unsigned integers. */ #ifndef UNSIGNED # define UNSIGNED 0 # define INT LONG int #else # define INT unsigned LONG int #endif /* Determine the name. */ #ifdef USE_IN_EXTENDED_LOCALE_MODEL # if UNSIGNED # ifdef USE_WIDE_CHAR # ifdef QUAD # define strtol __wcstoull_l # else # define strtol __wcstoul_l # endif # else # ifdef QUAD # define strtol __strtoull_l # else # define strtol __strtoul_l # endif # endif # else # ifdef USE_WIDE_CHAR # ifdef QUAD # define strtol __wcstoll_l # else # define strtol __wcstol_l # endif # else # ifdef QUAD # define strtol __strtoll_l # else # define strtol __strtol_l # endif # endif # endif #else # if UNSIGNED # ifdef USE_WIDE_CHAR # ifdef QUAD # define strtol wcstoull # else # define strtol wcstoul # endif # else # ifdef QUAD # define strtol strtoull # else # define strtol strtoul # endif # endif # else # ifdef USE_WIDE_CHAR # ifdef QUAD # define strtol wcstoll # else # define strtol wcstol # endif # else # ifdef QUAD # define strtol strtoll # endif # endif # endif #endif /* If QUAD is defined, we are defining 'strtoll' or 'strtoull', operating on 'long long int's. */ #ifdef QUAD # define LONG long long # define STRTOL_LONG_MIN LLONG_MIN # define STRTOL_LONG_MAX LLONG_MAX # define STRTOL_ULONG_MAX ULLONG_MAX /* The extra casts in the following macros work around compiler bugs, e.g., in Cray C 5.0.3.0. */ /* True if negative values of the signed integer type T use two's complement, ones' complement, or signed magnitude representation, respectively. Much GNU code assumes two's complement, but some people like to be portable to all possible C hosts. */ # define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) # define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) # define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) /* True if the arithmetic type T is signed. */ # define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* The maximum and minimum values for the integer type T. These macros have undefined behavior if T is signed and has padding bits. If this is a problem for you, please let us know how to fix it for your host. */ # define TYPE_MINIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ ? (t) 0 \ : TYPE_SIGNED_MAGNITUDE (t) \ ? ~ (t) 0 \ : ~ TYPE_MAXIMUM (t))) # define TYPE_MAXIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ ? (t) -1 \ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) # ifndef ULLONG_MAX # define ULLONG_MAX TYPE_MAXIMUM (unsigned long long) # endif # ifndef LLONG_MAX # define LLONG_MAX TYPE_MAXIMUM (long long int) # endif # ifndef LLONG_MIN # define LLONG_MIN TYPE_MINIMUM (long long int) # endif # if __GNUC__ == 2 && __GNUC_MINOR__ < 7 /* Work around gcc bug with using this constant. */ static const unsigned long long int maxquad = ULLONG_MAX; # undef STRTOL_ULONG_MAX # define STRTOL_ULONG_MAX maxquad # endif #else # define LONG long # define STRTOL_LONG_MIN LONG_MIN # define STRTOL_LONG_MAX LONG_MAX # define STRTOL_ULONG_MAX ULONG_MAX #endif /* We use this code also for the extended locale handling where the function gets as an additional argument the locale which has to be used. To access the values we have to redefine the _NL_CURRENT macro. */ #ifdef USE_IN_EXTENDED_LOCALE_MODEL # undef _NL_CURRENT # define _NL_CURRENT(category, item) \ (current->values[_NL_ITEM_INDEX (item)].string) # define LOCALE_PARAM , loc # define LOCALE_PARAM_PROTO , __locale_t loc #else # define LOCALE_PARAM # define LOCALE_PARAM_PROTO #endif #ifdef USE_WIDE_CHAR # include # include # define L_(Ch) L##Ch # define UCHAR_TYPE wint_t # define STRING_TYPE wchar_t # ifdef USE_IN_EXTENDED_LOCALE_MODEL # define ISSPACE(Ch) __iswspace_l ((Ch), loc) # define ISALPHA(Ch) __iswalpha_l ((Ch), loc) # define TOUPPER(Ch) __towupper_l ((Ch), loc) # else # define ISSPACE(Ch) iswspace (Ch) # define ISALPHA(Ch) iswalpha (Ch) # define TOUPPER(Ch) towupper (Ch) # endif #else # define L_(Ch) Ch # define UCHAR_TYPE unsigned char # define STRING_TYPE char # ifdef USE_IN_EXTENDED_LOCALE_MODEL # define ISSPACE(Ch) __isspace_l ((Ch), loc) # define ISALPHA(Ch) __isalpha_l ((Ch), loc) # define TOUPPER(Ch) __toupper_l ((Ch), loc) # else # define ISSPACE(Ch) isspace (Ch) # define ISALPHA(Ch) isalpha (Ch) # define TOUPPER(Ch) toupper (Ch) # endif #endif #define INTERNAL(X) INTERNAL1(X) #define INTERNAL1(X) __##X##_internal #define WEAKNAME(X) WEAKNAME1(X) #ifdef USE_NUMBER_GROUPING /* This file defines a function to check for correct grouping. */ # include "grouping.h" #endif /* Convert NPTR to an 'unsigned long int' or 'long int' in base BASE. If BASE is 0 the base is determined by the presence of a leading zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal. If BASE is < 2 or > 36, it is reset to 10. If ENDPTR is not NULL, a pointer to the character after the last one converted is stored in *ENDPTR. */ INT INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base, int group LOCALE_PARAM_PROTO) { int negative; register unsigned LONG int cutoff; register unsigned int cutlim; register unsigned LONG int i; register const STRING_TYPE *s; register UCHAR_TYPE c; const STRING_TYPE *save, *end; int overflow; #ifdef USE_NUMBER_GROUPING # ifdef USE_IN_EXTENDED_LOCALE_MODEL struct locale_data *current = loc->__locales[LC_NUMERIC]; # endif /* The thousands character of the current locale. */ wchar_t thousands = L'\0'; /* The numeric grouping specification of the current locale, in the format described in . */ const char *grouping; if (group) { grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ # if defined _LIBC || defined _HAVE_BTOWC thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)); if (thousands == WEOF) thousands = L'\0'; # endif if (thousands == L'\0') grouping = NULL; } } else grouping = NULL; #endif if (base < 0 || base == 1 || base > 36) { __set_errno (EINVAL); return 0; } save = s = nptr; /* Skip white space. */ while (ISSPACE (*s)) ++s; if (*s == L_('\0')) goto noconv; /* Check for a sign. */ if (*s == L_('-')) { negative = 1; ++s; } else if (*s == L_('+')) { negative = 0; ++s; } else negative = 0; /* Recognize number prefix and if BASE is zero, figure it out ourselves. */ if (*s == L_('0')) { if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X')) { s += 2; base = 16; } else if (base == 0) base = 8; } else if (base == 0) base = 10; /* Save the pointer so we can check later if anything happened. */ save = s; #ifdef USE_NUMBER_GROUPING if (group) { /* Find the end of the digit string and check its grouping. */ end = s; for (c = *end; c != L_('\0'); c = *++end) if ((wchar_t) c != thousands && ((wchar_t) c < L_('0') || (wchar_t) c > L_('9')) && (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base)) break; if (*s == thousands) end = s; else end = correctly_grouped_prefix (s, end, thousands, grouping); } else #endif end = NULL; cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base; cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base; overflow = 0; i = 0; for (c = *s; c != L_('\0'); c = *++s) { if (s == end) break; if (c >= L_('0') && c <= L_('9')) c -= L_('0'); else if (ISALPHA (c)) c = TOUPPER (c) - L_('A') + 10; else break; if ((int) c >= base) break; /* Check for overflow. */ if (i > cutoff || (i == cutoff && c > cutlim)) overflow = 1; else { i *= (unsigned LONG int) base; i += c; } } /* Check if anything actually happened. */ if (s == save) goto noconv; /* Store in ENDPTR the address of one character past the last character we converted. */ if (endptr != NULL) *endptr = (STRING_TYPE *) s; #if !UNSIGNED /* Check for a value that is within the range of 'unsigned LONG int', but outside the range of 'LONG int'. */ if (overflow == 0 && i > (negative ? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1 : (unsigned LONG int) STRTOL_LONG_MAX)) overflow = 1; #endif if (overflow) { __set_errno (ERANGE); #if UNSIGNED return STRTOL_ULONG_MAX; #else return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX; #endif } /* Return the result of the appropriate sign. */ return negative ? -i : i; noconv: /* We must handle a special case here: the base is 0 or 16 and the first two characters are '0' and 'x', but the rest are no hexadecimal digits. This is no error case. We return 0 and ENDPTR points to the 'x'. */ if (endptr != NULL) { if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X') && save[-2] == L_('0')) *endptr = (STRING_TYPE *) &save[-1]; else /* There was no number to convert. */ *endptr = (STRING_TYPE *) nptr; } return 0L; } /* External user entry point. */ INT #ifdef weak_function weak_function #endif strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base LOCALE_PARAM_PROTO) { return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM); } lftp-4.6.3a/lib/fchown-stub.c0000644000015000007670000000046512122621312012721 00000000000000#include #include #include /* A trivial substitute for 'fchown'. DJGPP 2.03 and earlier (and perhaps later) don't have 'fchown', so we pretend no-one has permission for this operation. */ int fchown (int fd, uid_t uid, gid_t gid) { errno = EPERM; return -1; } lftp-4.6.3a/lib/dirfd.c0000644000015000007670000000173512466374011011567 00000000000000/* dirfd.c -- return the file descriptor associated with an open DIR* Copyright (C) 2001, 2006, 2008-2015 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 . */ /* Written by Jim Meyering. */ #include #include #include int dirfd (DIR *dir_p) { int fd = DIR_TO_FD (dir_p); if (fd == -1) errno = ENOTSUP; return fd; } lftp-4.6.3a/lib/iconv_close.c0000644000015000007670000000253112466374011012775 00000000000000/* Character set conversion. Copyright (C) 2007, 2009-2015 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 . */ #include /* Specification. */ #include #include #ifndef uintptr_t # define uintptr_t unsigned long #endif int rpl_iconv_close (iconv_t cd) #undef iconv_close { #if REPLACE_ICONV_UTF switch ((uintptr_t) cd) { case (uintptr_t) _ICONV_UTF8_UTF16BE: case (uintptr_t) _ICONV_UTF8_UTF16LE: case (uintptr_t) _ICONV_UTF8_UTF32BE: case (uintptr_t) _ICONV_UTF8_UTF32LE: case (uintptr_t) _ICONV_UTF16BE_UTF8: case (uintptr_t) _ICONV_UTF16LE_UTF8: case (uintptr_t) _ICONV_UTF32BE_UTF8: case (uintptr_t) _ICONV_UTF32LE_UTF8: return 0; } #endif return iconv_close (cd); } lftp-4.6.3a/lib/stdio.in.h0000644000015000007670000014256212540234037012233 00000000000000/* A GNU-like . Copyright (C) 2004, 2007-2015 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 . */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H /* Special invocation convention: - Inside glibc header files. - On OSF/1 5.1 we have a sequence of nested includes -> -> -> -> -> -> -> . In this situation, the functions are not yet declared, therefore we cannot provide the C++ aliases. */ #@INCLUDE_NEXT@ @NEXT_STDIO_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_STDIO_H #define _GL_ALREADY_INCLUDING_STDIO_H /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STDIO_H@ #undef _GL_ALREADY_INCLUDING_STDIO_H #ifndef _@GUARD_PREFIX@_STDIO_H #define _@GUARD_PREFIX@_STDIO_H /* Get va_list. Needed on many systems, including glibc 2.8. */ #include #include /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 and eglibc 2.11.2. May also define off_t to a 64-bit type on native Windows. */ #include /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) #else # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif /* _GL_ATTRIBUTE_FORMAT_PRINTF indicates to GCC that the function takes a format string and arguments, where the format string directives are the ones standardized by ISO C99 and POSIX. */ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument)) #else # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) #endif /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF, except that it indicates to GCC that the supported format string directives are the ones of the system printf(), rather than the ones standardized by ISO C99 and POSIX. */ #if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU # define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT_PRINTF (formatstring_parameter, first_argument) #else # define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) #endif /* _GL_ATTRIBUTE_FORMAT_SCANF indicates to GCC that the function takes a format string and arguments, where the format string directives are the ones standardized by ISO C99 and POSIX. */ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument)) #else # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) #endif /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF, except that it indicates to GCC that the supported format string directives are the ones of the system scanf(), rather than the ones standardized by ISO C99 and POSIX. */ #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) /* Solaris 10 declares renameat in , not in . */ /* But in any case avoid namespace pollution on glibc systems. */ #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \ && ! defined __GLIBC__ # include #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. */ /* Macros for stringification. */ #define _GL_STDIO_STRINGIZE(token) #token #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) /* When also using extern inline, suppress the use of static inline in standard headers of problematic Apple configurations, as Libc at least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., . Perhaps Apple will fix this some day. */ #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ && defined __GNUC__ && defined __STDC__) # undef putc_unlocked #endif #if @GNULIB_DPRINTF@ # if @REPLACE_DPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define dprintf rpl_dprintf # endif _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); # else # if !@HAVE_DPRINTF@ _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); # endif _GL_CXXALIASWARN (dprintf); #elif defined GNULIB_POSIXCHECK # undef dprintf # if HAVE_RAW_DECL_DPRINTF _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " "use gnulib module dprintf for portability"); # endif #endif #if @GNULIB_FCLOSE@ /* Close STREAM and its underlying file descriptor. */ # if @REPLACE_FCLOSE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define fclose rpl_fclose # endif _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); # endif _GL_CXXALIASWARN (fclose); #elif defined GNULIB_POSIXCHECK # undef fclose /* Assume fclose is always declared. */ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " "use gnulib module fclose for portable POSIX compliance"); #endif #if @GNULIB_FDOPEN@ # if @REPLACE_FDOPEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fdopen # define fdopen rpl_fdopen # endif _GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); # else _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); # endif _GL_CXXALIASWARN (fdopen); #elif defined GNULIB_POSIXCHECK # undef fdopen /* Assume fdopen is always declared. */ _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " "use gnulib module fdopen for portability"); #endif #if @GNULIB_FFLUSH@ /* Flush all pending data on STREAM according to POSIX rules. Both output and seekable input streams are supported. Note! LOSS OF DATA can occur if fflush is applied on an input stream that is _not_seekable_ or on an update stream that is _not_seekable_ and in which the most recent operation was input. Seekability can be tested with lseek(fileno(fp),0,SEEK_CUR). */ # if @REPLACE_FFLUSH@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define fflush rpl_fflush # endif _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); # else _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); # endif _GL_CXXALIASWARN (fflush); #elif defined GNULIB_POSIXCHECK # undef fflush /* Assume fflush is always declared. */ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " "use gnulib module fflush for portable POSIX compliance"); #endif #if @GNULIB_FGETC@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fgetc # define fgetc rpl_fgetc # endif _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); # endif _GL_CXXALIASWARN (fgetc); #endif #if @GNULIB_FGETS@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fgets # define fgets rpl_fgets # endif _GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream) _GL_ARG_NONNULL ((1, 3))); _GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream)); # else _GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream)); # endif _GL_CXXALIASWARN (fgets); #endif #if @GNULIB_FOPEN@ # if @REPLACE_FOPEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fopen # define fopen rpl_fopen # endif _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); # else _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); # endif _GL_CXXALIASWARN (fopen); #elif defined GNULIB_POSIXCHECK # undef fopen /* Assume fopen is always declared. */ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " "use gnulib module fopen for portability"); #endif #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define fprintf rpl_fprintf # endif # define GNULIB_overrides_fprintf 1 # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) _GL_ARG_NONNULL ((1, 2))); # else _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); # else _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); # endif _GL_CXXALIASWARN (fprintf); #endif #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK # if !GNULIB_overrides_fprintf # undef fprintf # endif /* Assume fprintf is always declared. */ _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " "use gnulib module fprintf-posix for portable " "POSIX compliance"); #endif #if @GNULIB_FPURGE@ /* Discard all pending buffered I/O data on STREAM. STREAM must not be wide-character oriented. When discarding pending output, the file position is set back to where it was before the write calls. When discarding pending input, the file position is advanced to match the end of the previously read input. Return 0 if successful. Upon error, return -1 and set errno. */ # if @REPLACE_FPURGE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define fpurge rpl_fpurge # endif _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); # else # if !@HAVE_DECL_FPURGE@ _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); # endif _GL_CXXALIASWARN (fpurge); #elif defined GNULIB_POSIXCHECK # undef fpurge # if HAVE_RAW_DECL_FPURGE _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " "use gnulib module fpurge for portability"); # endif #endif #if @GNULIB_FPUTC@ # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fputc # define fputc rpl_fputc # endif _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); # else _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); # endif _GL_CXXALIASWARN (fputc); #endif #if @GNULIB_FPUTS@ # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fputs # define fputs rpl_fputs # endif _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); # else _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); # endif _GL_CXXALIASWARN (fputs); #endif #if @GNULIB_FREAD@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fread # define fread rpl_fread # endif _GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream) _GL_ARG_NONNULL ((4))); _GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); # else _GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); # endif _GL_CXXALIASWARN (fread); #endif #if @GNULIB_FREOPEN@ # if @REPLACE_FREOPEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef freopen # define freopen rpl_freopen # endif _GL_FUNCDECL_RPL (freopen, FILE *, (const char *filename, const char *mode, FILE *stream) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (freopen, FILE *, (const char *filename, const char *mode, FILE *stream)); # else _GL_CXXALIAS_SYS (freopen, FILE *, (const char *filename, const char *mode, FILE *stream)); # endif _GL_CXXALIASWARN (freopen); #elif defined GNULIB_POSIXCHECK # undef freopen /* Assume freopen is always declared. */ _GL_WARN_ON_USE (freopen, "freopen on native Windows platforms is not POSIX compliant - " "use gnulib module freopen for portability"); #endif #if @GNULIB_FSCANF@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fscanf # define fscanf rpl_fscanf # endif _GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...) _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...)); # else _GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...)); # endif _GL_CXXALIASWARN (fscanf); #endif /* Set up the following warnings, based on which modules are in use. GNU Coding Standards discourage the use of fseek, since it imposes an arbitrary limitation on some 32-bit hosts. Remember that the fseek module depends on the fseeko module, so we only have three cases to consider: 1. The developer is not using either module. Issue a warning under GNULIB_POSIXCHECK for both functions, to remind them that both functions have bugs on some systems. _GL_NO_LARGE_FILES has no impact on this warning. 2. The developer is using both modules. They may be unaware of the arbitrary limitations of fseek, so issue a warning under GNULIB_POSIXCHECK. On the other hand, they may be using both modules intentionally, so the developer can define _GL_NO_LARGE_FILES in the compilation units where the use of fseek is safe, to silence the warning. 3. The developer is using the fseeko module, but not fseek. Gnulib guarantees that fseek will still work around platform bugs in that case, but we presume that the developer is aware of the pitfalls of fseek and was trying to avoid it, so issue a warning even when GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be defined to silence the warning in particular compilation units. In C++ compilations with GNULIB_NAMESPACE, in order to avoid that fseek gets defined as a macro, it is recommended that the developer uses the fseek module, even if he is not calling the fseek function. Most gnulib clients that perform stream operations should fall into category 3. */ #if @GNULIB_FSEEK@ # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES # define _GL_FSEEK_WARN /* Category 2, above. */ # undef fseek # endif # if @REPLACE_FSEEK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fseek # define fseek rpl_fseek # endif _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); # else _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); # endif _GL_CXXALIASWARN (fseek); #endif #if @GNULIB_FSEEKO@ # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES # define _GL_FSEEK_WARN /* Category 3, above. */ # undef fseek # endif # if @REPLACE_FSEEKO@ /* Provide an fseeko function that is aware of a preceding fflush(), and which detects pipes. */ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fseeko # define fseeko rpl_fseeko # endif _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); # else # if ! @HAVE_DECL_FSEEKO@ _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); # endif _GL_CXXALIASWARN (fseeko); #elif defined GNULIB_POSIXCHECK # define _GL_FSEEK_WARN /* Category 1, above. */ # undef fseek # undef fseeko # if HAVE_RAW_DECL_FSEEKO _GL_WARN_ON_USE (fseeko, "fseeko is unportable - " "use gnulib module fseeko for portability"); # endif #endif #ifdef _GL_FSEEK_WARN # undef _GL_FSEEK_WARN /* Here, either fseek is undefined (but C89 guarantees that it is declared), or it is defined as rpl_fseek (declared above). */ _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " "on 32-bit platforms - " "use fseeko function for handling of large files"); #endif /* ftell, ftello. See the comments on fseek/fseeko. */ #if @GNULIB_FTELL@ # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES # define _GL_FTELL_WARN /* Category 2, above. */ # undef ftell # endif # if @REPLACE_FTELL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ftell # define ftell rpl_ftell # endif _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); # else _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); # endif _GL_CXXALIASWARN (ftell); #endif #if @GNULIB_FTELLO@ # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES # define _GL_FTELL_WARN /* Category 3, above. */ # undef ftell # endif # if @REPLACE_FTELLO@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ftello # define ftello rpl_ftello # endif _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); # else # if ! @HAVE_DECL_FTELLO@ _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); # endif _GL_CXXALIASWARN (ftello); #elif defined GNULIB_POSIXCHECK # define _GL_FTELL_WARN /* Category 1, above. */ # undef ftell # undef ftello # if HAVE_RAW_DECL_FTELLO _GL_WARN_ON_USE (ftello, "ftello is unportable - " "use gnulib module ftello for portability"); # endif #endif #ifdef _GL_FTELL_WARN # undef _GL_FTELL_WARN /* Here, either ftell is undefined (but C89 guarantees that it is declared), or it is defined as rpl_ftell (declared above). */ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " "on 32-bit platforms - " "use ftello function for handling of large files"); #endif #if @GNULIB_FWRITE@ # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fwrite # define fwrite rpl_fwrite # endif _GL_FUNCDECL_RPL (fwrite, size_t, (const void *ptr, size_t s, size_t n, FILE *stream) _GL_ARG_NONNULL ((1, 4))); _GL_CXXALIAS_RPL (fwrite, size_t, (const void *ptr, size_t s, size_t n, FILE *stream)); # else _GL_CXXALIAS_SYS (fwrite, size_t, (const void *ptr, size_t s, size_t n, FILE *stream)); /* Work around bug 11959 when fortifying glibc 2.4 through 2.15 , which sometimes causes an unwanted diagnostic for fwrite calls. This affects only function declaration attributes under certain versions of gcc and clang, and is not needed for C++. */ # if (0 < __USE_FORTIFY_LEVEL \ && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ && !defined __cplusplus) # undef fwrite # undef fwrite_unlocked extern size_t __REDIRECT (rpl_fwrite, (const void *__restrict, size_t, size_t, FILE *__restrict), fwrite); extern size_t __REDIRECT (rpl_fwrite_unlocked, (const void *__restrict, size_t, size_t, FILE *__restrict), fwrite_unlocked); # define fwrite rpl_fwrite # define fwrite_unlocked rpl_fwrite_unlocked # endif # endif _GL_CXXALIASWARN (fwrite); #endif #if @GNULIB_GETC@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getc # define getc rpl_fgetc # endif _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (getc, int, (FILE *stream)); # endif _GL_CXXALIASWARN (getc); #endif #if @GNULIB_GETCHAR@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getchar # define getchar rpl_getchar # endif _GL_FUNCDECL_RPL (getchar, int, (void)); _GL_CXXALIAS_RPL (getchar, int, (void)); # else _GL_CXXALIAS_SYS (getchar, int, (void)); # endif _GL_CXXALIASWARN (getchar); #endif #if @GNULIB_GETDELIM@ /* Read input, up to (and including) the next occurrence of DELIMITER, from STREAM, store it in *LINEPTR (and NUL-terminate it). *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE bytes of space. It is realloc'd as necessary. Return the number of bytes read and stored at *LINEPTR (not including the NUL terminator), or -1 on error or EOF. */ # if @REPLACE_GETDELIM@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getdelim # define getdelim rpl_getdelim # endif _GL_FUNCDECL_RPL (getdelim, ssize_t, (char **lineptr, size_t *linesize, int delimiter, FILE *stream) _GL_ARG_NONNULL ((1, 2, 4))); _GL_CXXALIAS_RPL (getdelim, ssize_t, (char **lineptr, size_t *linesize, int delimiter, FILE *stream)); # else # if !@HAVE_DECL_GETDELIM@ _GL_FUNCDECL_SYS (getdelim, ssize_t, (char **lineptr, size_t *linesize, int delimiter, FILE *stream) _GL_ARG_NONNULL ((1, 2, 4))); # endif _GL_CXXALIAS_SYS (getdelim, ssize_t, (char **lineptr, size_t *linesize, int delimiter, FILE *stream)); # endif _GL_CXXALIASWARN (getdelim); #elif defined GNULIB_POSIXCHECK # undef getdelim # if HAVE_RAW_DECL_GETDELIM _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " "use gnulib module getdelim for portability"); # endif #endif #if @GNULIB_GETLINE@ /* Read a line, up to (and including) the next newline, from STREAM, store it in *LINEPTR (and NUL-terminate it). *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE bytes of space. It is realloc'd as necessary. Return the number of bytes read and stored at *LINEPTR (not including the NUL terminator), or -1 on error or EOF. */ # if @REPLACE_GETLINE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getline # define getline rpl_getline # endif _GL_FUNCDECL_RPL (getline, ssize_t, (char **lineptr, size_t *linesize, FILE *stream) _GL_ARG_NONNULL ((1, 2, 3))); _GL_CXXALIAS_RPL (getline, ssize_t, (char **lineptr, size_t *linesize, FILE *stream)); # else # if !@HAVE_DECL_GETLINE@ _GL_FUNCDECL_SYS (getline, ssize_t, (char **lineptr, size_t *linesize, FILE *stream) _GL_ARG_NONNULL ((1, 2, 3))); # endif _GL_CXXALIAS_SYS (getline, ssize_t, (char **lineptr, size_t *linesize, FILE *stream)); # endif # if @HAVE_DECL_GETLINE@ _GL_CXXALIASWARN (getline); # endif #elif defined GNULIB_POSIXCHECK # undef getline # if HAVE_RAW_DECL_GETLINE _GL_WARN_ON_USE (getline, "getline is unportable - " "use gnulib module getline for portability"); # endif #endif /* It is very rare that the developer ever has full control of stdin, so any use of gets warrants an unconditional warning; besides, C11 removed it. */ #undef gets #if HAVE_RAW_DECL_GETS && !defined __cplusplus _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); #endif #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ struct obstack; /* Grow an obstack with formatted output. Return the number of bytes added to OBS. No trailing nul byte is added, and the object should be closed with obstack_finish before use. Upon memory allocation error, call obstack_alloc_failed_handler. Upon other error, return -1. */ # if @REPLACE_OBSTACK_PRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define obstack_printf rpl_obstack_printf # endif _GL_FUNCDECL_RPL (obstack_printf, int, (struct obstack *obs, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (obstack_printf, int, (struct obstack *obs, const char *format, ...)); # else # if !@HAVE_DECL_OBSTACK_PRINTF@ _GL_FUNCDECL_SYS (obstack_printf, int, (struct obstack *obs, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (obstack_printf, int, (struct obstack *obs, const char *format, ...)); # endif _GL_CXXALIASWARN (obstack_printf); # if @REPLACE_OBSTACK_PRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define obstack_vprintf rpl_obstack_vprintf # endif _GL_FUNCDECL_RPL (obstack_vprintf, int, (struct obstack *obs, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (obstack_vprintf, int, (struct obstack *obs, const char *format, va_list args)); # else # if !@HAVE_DECL_OBSTACK_PRINTF@ _GL_FUNCDECL_SYS (obstack_vprintf, int, (struct obstack *obs, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (obstack_vprintf, int, (struct obstack *obs, const char *format, va_list args)); # endif _GL_CXXALIASWARN (obstack_vprintf); #endif #if @GNULIB_PCLOSE@ # if !@HAVE_PCLOSE@ _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); _GL_CXXALIASWARN (pclose); #elif defined GNULIB_POSIXCHECK # undef pclose # if HAVE_RAW_DECL_PCLOSE _GL_WARN_ON_USE (pclose, "pclose is unportable - " "use gnulib module pclose for more portability"); # endif #endif #if @GNULIB_PERROR@ /* Print a message to standard error, describing the value of ERRNO, (if STRING is not NULL and not empty) prefixed with STRING and ": ", and terminated with a newline. */ # if @REPLACE_PERROR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define perror rpl_perror # endif _GL_FUNCDECL_RPL (perror, void, (const char *string)); _GL_CXXALIAS_RPL (perror, void, (const char *string)); # else _GL_CXXALIAS_SYS (perror, void, (const char *string)); # endif _GL_CXXALIASWARN (perror); #elif defined GNULIB_POSIXCHECK # undef perror /* Assume perror is always declared. */ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " "use gnulib module perror for portability"); #endif #if @GNULIB_POPEN@ # if @REPLACE_POPEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef popen # define popen rpl_popen # endif _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); # else # if !@HAVE_POPEN@ _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); # endif _GL_CXXALIASWARN (popen); #elif defined GNULIB_POSIXCHECK # undef popen # if HAVE_RAW_DECL_POPEN _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " "use gnulib module popen or pipe for more portability"); # endif #endif #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) # if defined __GNUC__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) /* Don't break __attribute__((format(printf,M,N))). */ # define printf __printf__ # endif # if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ _GL_FUNCDECL_RPL_1 (__printf__, int, (const char *format, ...) __asm__ (@ASM_SYMBOL_PREFIX@ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) _GL_ARG_NONNULL ((1))); # else _GL_FUNCDECL_RPL_1 (__printf__, int, (const char *format, ...) __asm__ (@ASM_SYMBOL_PREFIX@ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); # else # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define printf rpl_printf # endif _GL_FUNCDECL_RPL (printf, int, (const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); # endif # define GNULIB_overrides_printf 1 # else _GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); # endif _GL_CXXALIASWARN (printf); #endif #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK # if !GNULIB_overrides_printf # undef printf # endif /* Assume printf is always declared. */ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " "use gnulib module printf-posix for portable " "POSIX compliance"); #endif #if @GNULIB_PUTC@ # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef putc # define putc rpl_fputc # endif _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); # else _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); # endif _GL_CXXALIASWARN (putc); #endif #if @GNULIB_PUTCHAR@ # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef putchar # define putchar rpl_putchar # endif _GL_FUNCDECL_RPL (putchar, int, (int c)); _GL_CXXALIAS_RPL (putchar, int, (int c)); # else _GL_CXXALIAS_SYS (putchar, int, (int c)); # endif _GL_CXXALIASWARN (putchar); #endif #if @GNULIB_PUTS@ # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef puts # define puts rpl_puts # endif _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (puts, int, (const char *string)); # else _GL_CXXALIAS_SYS (puts, int, (const char *string)); # endif _GL_CXXALIASWARN (puts); #endif #if @GNULIB_REMOVE@ # if @REPLACE_REMOVE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef remove # define remove rpl_remove # endif _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (remove, int, (const char *name)); # else _GL_CXXALIAS_SYS (remove, int, (const char *name)); # endif _GL_CXXALIASWARN (remove); #elif defined GNULIB_POSIXCHECK # undef remove /* Assume remove is always declared. */ _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " "use gnulib module remove for more portability"); #endif #if @GNULIB_RENAME@ # if @REPLACE_RENAME@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef rename # define rename rpl_rename # endif _GL_FUNCDECL_RPL (rename, int, (const char *old_filename, const char *new_filename) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (rename, int, (const char *old_filename, const char *new_filename)); # else _GL_CXXALIAS_SYS (rename, int, (const char *old_filename, const char *new_filename)); # endif _GL_CXXALIASWARN (rename); #elif defined GNULIB_POSIXCHECK # undef rename /* Assume rename is always declared. */ _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " "use gnulib module rename for more portability"); #endif #if @GNULIB_RENAMEAT@ # if @REPLACE_RENAMEAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef renameat # define renameat rpl_renameat # endif _GL_FUNCDECL_RPL (renameat, int, (int fd1, char const *file1, int fd2, char const *file2) _GL_ARG_NONNULL ((2, 4))); _GL_CXXALIAS_RPL (renameat, int, (int fd1, char const *file1, int fd2, char const *file2)); # else # if !@HAVE_RENAMEAT@ _GL_FUNCDECL_SYS (renameat, int, (int fd1, char const *file1, int fd2, char const *file2) _GL_ARG_NONNULL ((2, 4))); # endif _GL_CXXALIAS_SYS (renameat, int, (int fd1, char const *file1, int fd2, char const *file2)); # endif _GL_CXXALIASWARN (renameat); #elif defined GNULIB_POSIXCHECK # undef renameat # if HAVE_RAW_DECL_RENAMEAT _GL_WARN_ON_USE (renameat, "renameat is not portable - " "use gnulib module renameat for portability"); # endif #endif #if @GNULIB_SCANF@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if defined __GNUC__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef scanf /* Don't break __attribute__((format(scanf,M,N))). */ # define scanf __scanf__ # endif _GL_FUNCDECL_RPL_1 (__scanf__, int, (const char *format, ...) __asm__ (@ASM_SYMBOL_PREFIX@ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...)); # else # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef scanf # define scanf rpl_scanf # endif _GL_FUNCDECL_RPL (scanf, int, (const char *format, ...) _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (scanf, int, (const char *format, ...)); # endif # else _GL_CXXALIAS_SYS (scanf, int, (const char *format, ...)); # endif _GL_CXXALIASWARN (scanf); #endif #if @GNULIB_SNPRINTF@ # if @REPLACE_SNPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define snprintf rpl_snprintf # endif _GL_FUNCDECL_RPL (snprintf, int, (char *str, size_t size, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) _GL_ARG_NONNULL ((3))); _GL_CXXALIAS_RPL (snprintf, int, (char *str, size_t size, const char *format, ...)); # else # if !@HAVE_DECL_SNPRINTF@ _GL_FUNCDECL_SYS (snprintf, int, (char *str, size_t size, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) _GL_ARG_NONNULL ((3))); # endif _GL_CXXALIAS_SYS (snprintf, int, (char *str, size_t size, const char *format, ...)); # endif _GL_CXXALIASWARN (snprintf); #elif defined GNULIB_POSIXCHECK # undef snprintf # if HAVE_RAW_DECL_SNPRINTF _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " "use gnulib module snprintf for portability"); # endif #endif /* Some people would argue that all sprintf uses should be warned about (for example, OpenBSD issues a link warning for it), since it can cause security holes due to buffer overruns. However, we believe that sprintf can be used safely, and is more efficient than snprintf in those safe cases; and as proof of our belief, we use sprintf in several gnulib modules. So this header intentionally avoids adding a warning to sprintf except when GNULIB_POSIXCHECK is defined. */ #if @GNULIB_SPRINTF_POSIX@ # if @REPLACE_SPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define sprintf rpl_sprintf # endif _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); # else _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); # endif _GL_CXXALIASWARN (sprintf); #elif defined GNULIB_POSIXCHECK # undef sprintf /* Assume sprintf is always declared. */ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " "use gnulib module sprintf-posix for portable " "POSIX compliance"); #endif #if @GNULIB_TMPFILE@ # if @REPLACE_TMPFILE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define tmpfile rpl_tmpfile # endif _GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); # else _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); # endif _GL_CXXALIASWARN (tmpfile); #elif defined GNULIB_POSIXCHECK # undef tmpfile # if HAVE_RAW_DECL_TMPFILE _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " "use gnulib module tmpfile for portability"); # endif #endif #if @GNULIB_VASPRINTF@ /* Write formatted output to a string dynamically allocated with malloc(). If the memory allocation succeeds, store the address of the string in *RESULT and return the number of resulting bytes, excluding the trailing NUL. Upon memory allocation error, or some other error, return -1. */ # if @REPLACE_VASPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define asprintf rpl_asprintf # endif _GL_FUNCDECL_RPL (asprintf, int, (char **result, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (asprintf, int, (char **result, const char *format, ...)); # else # if !@HAVE_VASPRINTF@ _GL_FUNCDECL_SYS (asprintf, int, (char **result, const char *format, ...) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (asprintf, int, (char **result, const char *format, ...)); # endif _GL_CXXALIASWARN (asprintf); # if @REPLACE_VASPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define vasprintf rpl_vasprintf # endif _GL_FUNCDECL_RPL (vasprintf, int, (char **result, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (vasprintf, int, (char **result, const char *format, va_list args)); # else # if !@HAVE_VASPRINTF@ _GL_FUNCDECL_SYS (vasprintf, int, (char **result, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (vasprintf, int, (char **result, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vasprintf); #endif #if @GNULIB_VDPRINTF@ # if @REPLACE_VDPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define vdprintf rpl_vdprintf # endif _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); # else # if !@HAVE_VDPRINTF@ _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) _GL_ARG_NONNULL ((2))); # endif /* Need to cast, because on Solaris, the third parameter will likely be __va_list args. */ _GL_CXXALIAS_SYS_CAST (vdprintf, int, (int fd, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vdprintf); #elif defined GNULIB_POSIXCHECK # undef vdprintf # if HAVE_RAW_DECL_VDPRINTF _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " "use gnulib module vdprintf for portability"); # endif #endif #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define vfprintf rpl_vfprintf # endif # define GNULIB_overrides_vfprintf 1 # if @GNULIB_VFPRINTF_POSIX@ _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) _GL_ARG_NONNULL ((1, 2))); # else _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); # else /* Need to cast, because on Solaris, the third parameter is __va_list args and GCC's fixincludes did not change this to __gnuc_va_list. */ _GL_CXXALIAS_SYS_CAST (vfprintf, int, (FILE *fp, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vfprintf); #endif #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK # if !GNULIB_overrides_vfprintf # undef vfprintf # endif /* Assume vfprintf is always declared. */ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " "use gnulib module vfprintf-posix for portable " "POSIX compliance"); #endif #if @GNULIB_VFSCANF@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef vfscanf # define vfscanf rpl_vfscanf # endif _GL_FUNCDECL_RPL (vfscanf, int, (FILE *stream, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (vfscanf, int, (FILE *stream, const char *format, va_list args)); # else _GL_CXXALIAS_SYS (vfscanf, int, (FILE *stream, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vfscanf); #endif #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define vprintf rpl_vprintf # endif # define GNULIB_overrides_vprintf 1 # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0) _GL_ARG_NONNULL ((1))); # else _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); # else /* Need to cast, because on Solaris, the second parameter is __va_list args and GCC's fixincludes did not change this to __gnuc_va_list. */ _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); # endif _GL_CXXALIASWARN (vprintf); #endif #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK # if !GNULIB_overrides_vprintf # undef vprintf # endif /* Assume vprintf is always declared. */ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " "use gnulib module vprintf-posix for portable " "POSIX compliance"); #endif #if @GNULIB_VSCANF@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef vscanf # define vscanf rpl_vscanf # endif _GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args)); # else _GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args)); # endif _GL_CXXALIASWARN (vscanf); #endif #if @GNULIB_VSNPRINTF@ # if @REPLACE_VSNPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define vsnprintf rpl_vsnprintf # endif _GL_FUNCDECL_RPL (vsnprintf, int, (char *str, size_t size, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3))); _GL_CXXALIAS_RPL (vsnprintf, int, (char *str, size_t size, const char *format, va_list args)); # else # if !@HAVE_DECL_VSNPRINTF@ _GL_FUNCDECL_SYS (vsnprintf, int, (char *str, size_t size, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3))); # endif _GL_CXXALIAS_SYS (vsnprintf, int, (char *str, size_t size, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vsnprintf); #elif defined GNULIB_POSIXCHECK # undef vsnprintf # if HAVE_RAW_DECL_VSNPRINTF _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " "use gnulib module vsnprintf for portability"); # endif #endif #if @GNULIB_VSPRINTF_POSIX@ # if @REPLACE_VSPRINTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define vsprintf rpl_vsprintf # endif _GL_FUNCDECL_RPL (vsprintf, int, (char *str, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (vsprintf, int, (char *str, const char *format, va_list args)); # else /* Need to cast, because on Solaris, the third parameter is __va_list args and GCC's fixincludes did not change this to __gnuc_va_list. */ _GL_CXXALIAS_SYS_CAST (vsprintf, int, (char *str, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vsprintf); #elif defined GNULIB_POSIXCHECK # undef vsprintf /* Assume vsprintf is always declared. */ _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " "use gnulib module vsprintf-posix for portable " "POSIX compliance"); #endif #endif /* _@GUARD_PREFIX@_STDIO_H */ #endif /* _@GUARD_PREFIX@_STDIO_H */ #endif lftp-4.6.3a/lib/human.h0000644000015000007670000000537212466374011011615 00000000000000/* human.h -- print human readable file size Copyright (C) 1996-2007, 2009-2015 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 . */ /* Written by Paul Eggert and Larry McVoy. */ #ifndef HUMAN_H_ # define HUMAN_H_ 1 # include # include # include # include # include /* A conservative bound on the maximum length of a human-readable string. The output can be the square of the largest uintmax_t, so double its size before converting to a bound. log10 (2.0) < 146/485. Add 1 for integer division truncation. Also, the output can have a thousands separator between every digit, so multiply by MB_LEN_MAX + 1 and then subtract MB_LEN_MAX. Append 1 for a space before the suffix. Finally, append 3, the maximum length of a suffix. */ # define LONGEST_HUMAN_READABLE \ ((2 * sizeof (uintmax_t) * CHAR_BIT * 146 / 485 + 1) * (MB_LEN_MAX + 1) \ - MB_LEN_MAX + 1 + 3) /* Options for human_readable. */ enum { /* Unless otherwise specified these options may be ORed together. */ /* The following three options are mutually exclusive. */ /* Round to plus infinity (default). */ human_ceiling = 0, /* Round to nearest, ties to even. */ human_round_to_nearest = 1, /* Round to minus infinity. */ human_floor = 2, /* Group digits together, e.g. "1,000,000". This uses the locale-defined grouping; the traditional C locale does not group, so this has effect only if some other locale is in use. */ human_group_digits = 4, /* When autoscaling, suppress ".0" at end. */ human_suppress_point_zero = 8, /* Scale output and use SI-style units, ignoring the output block size. */ human_autoscale = 16, /* Prefer base 1024 to base 1000. */ human_base_1024 = 32, /* Prepend " " before unit symbol. */ human_space_before_unit = 64, /* Append SI prefix, e.g. "k" or "M". */ human_SI = 128, /* Append "B" (if base 1000) or "iB" (if base 1024) to SI prefix. */ human_B = 256 }; char *human_readable (uintmax_t, char *, int, uintmax_t, uintmax_t); enum strtol_error human_options (char const *, int *, uintmax_t *); #endif /* HUMAN_H_ */ lftp-4.6.3a/lib/isnand-nolibm.h0000644000015000007670000000221612466374011013231 00000000000000/* Test for NaN that does not need libm. Copyright (C) 2007-2015 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 . */ #if HAVE_ISNAND_IN_LIBC /* Get declaration of isnan macro. */ # include # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnand # define isnand(x) __builtin_isnan ((double)(x)) # else # undef isnand # define isnand(x) isnan ((double)(x)) # endif #else /* Test whether X is a NaN. */ # undef isnand # define isnand rpl_isnand extern int isnand (double x); #endif lftp-4.6.3a/lib/glthread/0000755000015000007670000000000012540300655012173 500000000000000lftp-4.6.3a/lib/glthread/threadlib.c0000644000015000007670000000353612466374011014230 00000000000000/* Multithreading primitives. Copyright (C) 2005-2015 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 . */ /* Written by Bruno Haible , 2005. */ #include /* ========================================================================= */ #if USE_POSIX_THREADS /* Use the POSIX threads library. */ # include # include # if PTHREAD_IN_USE_DETECTION_HARD /* The function to be executed by a dummy thread. */ static void * dummy_thread_func (void *arg) { return arg; } int glthread_in_use (void) { static int tested; static int result; /* 1: linked with -lpthread, 0: only with libc */ if (!tested) { pthread_t thread; if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) /* Thread creation failed. */ result = 0; else { /* Thread creation works. */ void *retval; if (pthread_join (thread, &retval) != 0) abort (); result = 1; } tested = 1; } return result; } # endif #endif /* ========================================================================= */ /* This declaration is solely to ensure that after preprocessing this file is never empty. */ typedef int dummy; lftp-4.6.3a/lib/glthread/lock.h0000644000015000007670000010665212466374011013232 00000000000000/* Locking in multithreaded situations. Copyright (C) 2005-2015 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 . */ /* Written by Bruno Haible , 2005. Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, gthr-win32.h. */ /* This file contains locking primitives for use with a given thread library. It does not contain primitives for creating threads or for other synchronization primitives. Normal (non-recursive) locks: Type: gl_lock_t Declaration: gl_lock_define(extern, name) Initializer: gl_lock_define_initialized(, name) Initialization: gl_lock_init (name); Taking the lock: gl_lock_lock (name); Releasing the lock: gl_lock_unlock (name); De-initialization: gl_lock_destroy (name); Equivalent functions with control of error handling: Initialization: err = glthread_lock_init (&name); Taking the lock: err = glthread_lock_lock (&name); Releasing the lock: err = glthread_lock_unlock (&name); De-initialization: err = glthread_lock_destroy (&name); Read-Write (non-recursive) locks: Type: gl_rwlock_t Declaration: gl_rwlock_define(extern, name) Initializer: gl_rwlock_define_initialized(, name) Initialization: gl_rwlock_init (name); Taking the lock: gl_rwlock_rdlock (name); gl_rwlock_wrlock (name); Releasing the lock: gl_rwlock_unlock (name); De-initialization: gl_rwlock_destroy (name); Equivalent functions with control of error handling: Initialization: err = glthread_rwlock_init (&name); Taking the lock: err = glthread_rwlock_rdlock (&name); err = glthread_rwlock_wrlock (&name); Releasing the lock: err = glthread_rwlock_unlock (&name); De-initialization: err = glthread_rwlock_destroy (&name); Recursive locks: Type: gl_recursive_lock_t Declaration: gl_recursive_lock_define(extern, name) Initializer: gl_recursive_lock_define_initialized(, name) Initialization: gl_recursive_lock_init (name); Taking the lock: gl_recursive_lock_lock (name); Releasing the lock: gl_recursive_lock_unlock (name); De-initialization: gl_recursive_lock_destroy (name); Equivalent functions with control of error handling: Initialization: err = glthread_recursive_lock_init (&name); Taking the lock: err = glthread_recursive_lock_lock (&name); Releasing the lock: err = glthread_recursive_lock_unlock (&name); De-initialization: err = glthread_recursive_lock_destroy (&name); Once-only execution: Type: gl_once_t Initializer: gl_once_define(extern, name) Execution: gl_once (name, initfunction); Equivalent functions with control of error handling: Execution: err = glthread_once (&name, initfunction); */ #ifndef _LOCK_H #define _LOCK_H #include #include /* ========================================================================= */ #if USE_POSIX_THREADS /* Use the POSIX threads library. */ # include # ifdef __cplusplus extern "C" { # endif # if PTHREAD_IN_USE_DETECTION_HARD /* The pthread_in_use() detection needs to be done at runtime. */ # define pthread_in_use() \ glthread_in_use () extern int glthread_in_use (void); # endif # if USE_POSIX_THREADS_WEAK /* Use weak references to the POSIX threads library. */ /* Weak references avoid dragging in external libraries if the other parts of the program don't use them. Here we use them, because we don't want every program that uses libintl to depend on libpthread. This assumes that libpthread would not be loaded after libintl; i.e. if libintl is loaded first, by an executable that does not depend on libpthread, and then a module is dynamically loaded that depends on libpthread, libintl will not be multithread-safe. */ /* The way to test at runtime whether libpthread is present is to test whether a function pointer's value, such as &pthread_mutex_init, is non-NULL. However, some versions of GCC have a bug through which, in PIC mode, &foo != NULL always evaluates to true if there is a direct call to foo(...) in the same function. To avoid this, we test the address of a function in libpthread that we don't use. */ # pragma weak pthread_mutex_init # pragma weak pthread_mutex_lock # pragma weak pthread_mutex_unlock # pragma weak pthread_mutex_destroy # pragma weak pthread_rwlock_init # pragma weak pthread_rwlock_rdlock # pragma weak pthread_rwlock_wrlock # pragma weak pthread_rwlock_unlock # pragma weak pthread_rwlock_destroy # pragma weak pthread_once # pragma weak pthread_cond_init # pragma weak pthread_cond_wait # pragma weak pthread_cond_signal # pragma weak pthread_cond_broadcast # pragma weak pthread_cond_destroy # pragma weak pthread_mutexattr_init # pragma weak pthread_mutexattr_settype # pragma weak pthread_mutexattr_destroy # ifndef pthread_self # pragma weak pthread_self # endif # if !PTHREAD_IN_USE_DETECTION_HARD # pragma weak pthread_cancel # define pthread_in_use() (pthread_cancel != NULL) # endif # else # if !PTHREAD_IN_USE_DETECTION_HARD # define pthread_in_use() 1 # endif # endif /* -------------------------- gl_lock_t datatype -------------------------- */ typedef pthread_mutex_t gl_lock_t; # define gl_lock_define(STORAGECLASS, NAME) \ STORAGECLASS pthread_mutex_t NAME; # define gl_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer; # define gl_lock_initializer \ PTHREAD_MUTEX_INITIALIZER # define glthread_lock_init(LOCK) \ (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0) # define glthread_lock_lock(LOCK) \ (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) # define glthread_lock_unlock(LOCK) \ (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) # define glthread_lock_destroy(LOCK) \ (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) /* ------------------------- gl_rwlock_t datatype ------------------------- */ # if HAVE_PTHREAD_RWLOCK # ifdef PTHREAD_RWLOCK_INITIALIZER typedef pthread_rwlock_t gl_rwlock_t; # define gl_rwlock_define(STORAGECLASS, NAME) \ STORAGECLASS pthread_rwlock_t NAME; # define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; # define gl_rwlock_initializer \ PTHREAD_RWLOCK_INITIALIZER # define glthread_rwlock_init(LOCK) \ (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) # define glthread_rwlock_rdlock(LOCK) \ (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0) # define glthread_rwlock_wrlock(LOCK) \ (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0) # define glthread_rwlock_unlock(LOCK) \ (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0) # define glthread_rwlock_destroy(LOCK) \ (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0) # else typedef struct { int initialized; pthread_mutex_t guard; /* protects the initialization */ pthread_rwlock_t rwlock; /* read-write lock */ } gl_rwlock_t; # define gl_rwlock_define(STORAGECLASS, NAME) \ STORAGECLASS gl_rwlock_t NAME; # define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; # define gl_rwlock_initializer \ { 0, PTHREAD_MUTEX_INITIALIZER } # define glthread_rwlock_init(LOCK) \ (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) # define glthread_rwlock_rdlock(LOCK) \ (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) # define glthread_rwlock_wrlock(LOCK) \ (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) # define glthread_rwlock_unlock(LOCK) \ (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) # define glthread_rwlock_destroy(LOCK) \ (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); # endif # else typedef struct { pthread_mutex_t lock; /* protects the remaining fields */ pthread_cond_t waiting_readers; /* waiting readers */ pthread_cond_t waiting_writers; /* waiting writers */ unsigned int waiting_writers_count; /* number of waiting writers */ int runcount; /* number of readers running, or -1 when a writer runs */ } gl_rwlock_t; # define gl_rwlock_define(STORAGECLASS, NAME) \ STORAGECLASS gl_rwlock_t NAME; # define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; # define gl_rwlock_initializer \ { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } # define glthread_rwlock_init(LOCK) \ (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) # define glthread_rwlock_rdlock(LOCK) \ (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) # define glthread_rwlock_wrlock(LOCK) \ (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) # define glthread_rwlock_unlock(LOCK) \ (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) # define glthread_rwlock_destroy(LOCK) \ (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); # endif /* --------------------- gl_recursive_lock_t datatype --------------------- */ # if HAVE_PTHREAD_MUTEX_RECURSIVE # if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP typedef pthread_mutex_t gl_recursive_lock_t; # define gl_recursive_lock_define(STORAGECLASS, NAME) \ STORAGECLASS pthread_mutex_t NAME; # define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer; # ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER # define gl_recursive_lock_initializer \ PTHREAD_RECURSIVE_MUTEX_INITIALIZER # else # define gl_recursive_lock_initializer \ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP # endif # define glthread_recursive_lock_init(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) # define glthread_recursive_lock_lock(LOCK) \ (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) # define glthread_recursive_lock_unlock(LOCK) \ (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) # define glthread_recursive_lock_destroy(LOCK) \ (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); # else typedef struct { pthread_mutex_t recmutex; /* recursive mutex */ pthread_mutex_t guard; /* protects the initialization */ int initialized; } gl_recursive_lock_t; # define gl_recursive_lock_define(STORAGECLASS, NAME) \ STORAGECLASS gl_recursive_lock_t NAME; # define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; # define gl_recursive_lock_initializer \ { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 } # define glthread_recursive_lock_init(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) # define glthread_recursive_lock_lock(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) # define glthread_recursive_lock_unlock(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) # define glthread_recursive_lock_destroy(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); # endif # else /* Old versions of POSIX threads on Solaris did not have recursive locks. We have to implement them ourselves. */ typedef struct { pthread_mutex_t mutex; pthread_t owner; unsigned long depth; } gl_recursive_lock_t; # define gl_recursive_lock_define(STORAGECLASS, NAME) \ STORAGECLASS gl_recursive_lock_t NAME; # define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; # define gl_recursive_lock_initializer \ { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 } # define glthread_recursive_lock_init(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) # define glthread_recursive_lock_lock(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) # define glthread_recursive_lock_unlock(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) # define glthread_recursive_lock_destroy(LOCK) \ (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); # endif /* -------------------------- gl_once_t datatype -------------------------- */ typedef pthread_once_t gl_once_t; # define gl_once_define(STORAGECLASS, NAME) \ STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; # define glthread_once(ONCE_CONTROL, INITFUNCTION) \ (pthread_in_use () \ ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) extern int glthread_once_singlethreaded (pthread_once_t *once_control); # ifdef __cplusplus } # endif #endif /* ========================================================================= */ #if USE_PTH_THREADS /* Use the GNU Pth threads library. */ # include # ifdef __cplusplus extern "C" { # endif # if USE_PTH_THREADS_WEAK /* Use weak references to the GNU Pth threads library. */ # pragma weak pth_mutex_init # pragma weak pth_mutex_acquire # pragma weak pth_mutex_release # pragma weak pth_rwlock_init # pragma weak pth_rwlock_acquire # pragma weak pth_rwlock_release # pragma weak pth_once # pragma weak pth_cancel # define pth_in_use() (pth_cancel != NULL) # else # define pth_in_use() 1 # endif /* -------------------------- gl_lock_t datatype -------------------------- */ typedef pth_mutex_t gl_lock_t; # define gl_lock_define(STORAGECLASS, NAME) \ STORAGECLASS pth_mutex_t NAME; # define gl_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS pth_mutex_t NAME = gl_lock_initializer; # define gl_lock_initializer \ PTH_MUTEX_INIT # define glthread_lock_init(LOCK) \ (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0) # define glthread_lock_lock(LOCK) \ (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) # define glthread_lock_unlock(LOCK) \ (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0) # define glthread_lock_destroy(LOCK) \ ((void)(LOCK), 0) /* ------------------------- gl_rwlock_t datatype ------------------------- */ typedef pth_rwlock_t gl_rwlock_t; # define gl_rwlock_define(STORAGECLASS, NAME) \ STORAGECLASS pth_rwlock_t NAME; # define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer; # define gl_rwlock_initializer \ PTH_RWLOCK_INIT # define glthread_rwlock_init(LOCK) \ (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0) # define glthread_rwlock_rdlock(LOCK) \ (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0) # define glthread_rwlock_wrlock(LOCK) \ (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0) # define glthread_rwlock_unlock(LOCK) \ (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0) # define glthread_rwlock_destroy(LOCK) \ ((void)(LOCK), 0) /* --------------------- gl_recursive_lock_t datatype --------------------- */ /* In Pth, mutexes are recursive by default. */ typedef pth_mutex_t gl_recursive_lock_t; # define gl_recursive_lock_define(STORAGECLASS, NAME) \ STORAGECLASS pth_mutex_t NAME; # define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer; # define gl_recursive_lock_initializer \ PTH_MUTEX_INIT # define glthread_recursive_lock_init(LOCK) \ (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0) # define glthread_recursive_lock_lock(LOCK) \ (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) # define glthread_recursive_lock_unlock(LOCK) \ (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0) # define glthread_recursive_lock_destroy(LOCK) \ ((void)(LOCK), 0) /* -------------------------- gl_once_t datatype -------------------------- */ typedef pth_once_t gl_once_t; # define gl_once_define(STORAGECLASS, NAME) \ STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT; # define glthread_once(ONCE_CONTROL, INITFUNCTION) \ (pth_in_use () \ ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)); extern int glthread_once_singlethreaded (pth_once_t *once_control); # ifdef __cplusplus } # endif #endif /* ========================================================================= */ #if USE_SOLARIS_THREADS /* Use the old Solaris threads library. */ # include # include # ifdef __cplusplus extern "C" { # endif # if USE_SOLARIS_THREADS_WEAK /* Use weak references to the old Solaris threads library. */ # pragma weak mutex_init # pragma weak mutex_lock # pragma weak mutex_unlock # pragma weak mutex_destroy # pragma weak rwlock_init # pragma weak rw_rdlock # pragma weak rw_wrlock # pragma weak rw_unlock # pragma weak rwlock_destroy # pragma weak thr_self # pragma weak thr_suspend # define thread_in_use() (thr_suspend != NULL) # else # define thread_in_use() 1 # endif /* -------------------------- gl_lock_t datatype -------------------------- */ typedef mutex_t gl_lock_t; # define gl_lock_define(STORAGECLASS, NAME) \ STORAGECLASS mutex_t NAME; # define gl_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS mutex_t NAME = gl_lock_initializer; # define gl_lock_initializer \ DEFAULTMUTEX # define glthread_lock_init(LOCK) \ (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0) # define glthread_lock_lock(LOCK) \ (thread_in_use () ? mutex_lock (LOCK) : 0) # define glthread_lock_unlock(LOCK) \ (thread_in_use () ? mutex_unlock (LOCK) : 0) # define glthread_lock_destroy(LOCK) \ (thread_in_use () ? mutex_destroy (LOCK) : 0) /* ------------------------- gl_rwlock_t datatype ------------------------- */ typedef rwlock_t gl_rwlock_t; # define gl_rwlock_define(STORAGECLASS, NAME) \ STORAGECLASS rwlock_t NAME; # define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS rwlock_t NAME = gl_rwlock_initializer; # define gl_rwlock_initializer \ DEFAULTRWLOCK # define glthread_rwlock_init(LOCK) \ (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0) # define glthread_rwlock_rdlock(LOCK) \ (thread_in_use () ? rw_rdlock (LOCK) : 0) # define glthread_rwlock_wrlock(LOCK) \ (thread_in_use () ? rw_wrlock (LOCK) : 0) # define glthread_rwlock_unlock(LOCK) \ (thread_in_use () ? rw_unlock (LOCK) : 0) # define glthread_rwlock_destroy(LOCK) \ (thread_in_use () ? rwlock_destroy (LOCK) : 0) /* --------------------- gl_recursive_lock_t datatype --------------------- */ /* Old Solaris threads did not have recursive locks. We have to implement them ourselves. */ typedef struct { mutex_t mutex; thread_t owner; unsigned long depth; } gl_recursive_lock_t; # define gl_recursive_lock_define(STORAGECLASS, NAME) \ STORAGECLASS gl_recursive_lock_t NAME; # define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; # define gl_recursive_lock_initializer \ { DEFAULTMUTEX, (thread_t) 0, 0 } # define glthread_recursive_lock_init(LOCK) \ (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) # define glthread_recursive_lock_lock(LOCK) \ (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) # define glthread_recursive_lock_unlock(LOCK) \ (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) # define glthread_recursive_lock_destroy(LOCK) \ (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); /* -------------------------- gl_once_t datatype -------------------------- */ typedef struct { volatile int inited; mutex_t mutex; } gl_once_t; # define gl_once_define(STORAGECLASS, NAME) \ STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX }; # define glthread_once(ONCE_CONTROL, INITFUNCTION) \ (thread_in_use () \ ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void)); extern int glthread_once_singlethreaded (gl_once_t *once_control); # ifdef __cplusplus } # endif #endif /* ========================================================================= */ #if USE_WINDOWS_THREADS # define WIN32_LEAN_AND_MEAN /* avoid including junk */ # include # ifdef __cplusplus extern "C" { # endif /* We can use CRITICAL_SECTION directly, rather than the native Windows Event, Mutex, Semaphore types, because - we need only to synchronize inside a single process (address space), not inter-process locking, - we don't need to support trylock operations. (TryEnterCriticalSection does not work on Windows 95/98/ME. Packages that need trylock usually define their own mutex type.) */ /* There is no way to statically initialize a CRITICAL_SECTION. It needs to be done lazily, once only. For this we need spinlocks. */ typedef struct { volatile int done; volatile long started; } gl_spinlock_t; /* -------------------------- gl_lock_t datatype -------------------------- */ typedef struct { gl_spinlock_t guard; /* protects the initialization */ CRITICAL_SECTION lock; } gl_lock_t; # define gl_lock_define(STORAGECLASS, NAME) \ STORAGECLASS gl_lock_t NAME; # define gl_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS gl_lock_t NAME = gl_lock_initializer; # define gl_lock_initializer \ { { 0, -1 } } # define glthread_lock_init(LOCK) \ (glthread_lock_init_func (LOCK), 0) # define glthread_lock_lock(LOCK) \ glthread_lock_lock_func (LOCK) # define glthread_lock_unlock(LOCK) \ glthread_lock_unlock_func (LOCK) # define glthread_lock_destroy(LOCK) \ glthread_lock_destroy_func (LOCK) extern void glthread_lock_init_func (gl_lock_t *lock); extern int glthread_lock_lock_func (gl_lock_t *lock); extern int glthread_lock_unlock_func (gl_lock_t *lock); extern int glthread_lock_destroy_func (gl_lock_t *lock); /* ------------------------- gl_rwlock_t datatype ------------------------- */ /* It is impossible to implement read-write locks using plain locks, without introducing an extra thread dedicated to managing read-write locks. Therefore here we need to use the low-level Event type. */ typedef struct { HANDLE *array; /* array of waiting threads, each represented by an event */ unsigned int count; /* number of waiting threads */ unsigned int alloc; /* length of allocated array */ unsigned int offset; /* index of first waiting thread in array */ } gl_carray_waitqueue_t; typedef struct { gl_spinlock_t guard; /* protects the initialization */ CRITICAL_SECTION lock; /* protects the remaining fields */ gl_carray_waitqueue_t waiting_readers; /* waiting readers */ gl_carray_waitqueue_t waiting_writers; /* waiting writers */ int runcount; /* number of readers running, or -1 when a writer runs */ } gl_rwlock_t; # define gl_rwlock_define(STORAGECLASS, NAME) \ STORAGECLASS gl_rwlock_t NAME; # define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; # define gl_rwlock_initializer \ { { 0, -1 } } # define glthread_rwlock_init(LOCK) \ (glthread_rwlock_init_func (LOCK), 0) # define glthread_rwlock_rdlock(LOCK) \ glthread_rwlock_rdlock_func (LOCK) # define glthread_rwlock_wrlock(LOCK) \ glthread_rwlock_wrlock_func (LOCK) # define glthread_rwlock_unlock(LOCK) \ glthread_rwlock_unlock_func (LOCK) # define glthread_rwlock_destroy(LOCK) \ glthread_rwlock_destroy_func (LOCK) extern void glthread_rwlock_init_func (gl_rwlock_t *lock); extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock); extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock); extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock); extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock); /* --------------------- gl_recursive_lock_t datatype --------------------- */ /* The native Windows documentation says that CRITICAL_SECTION already implements a recursive lock. But we need not rely on it: It's easy to implement a recursive lock without this assumption. */ typedef struct { gl_spinlock_t guard; /* protects the initialization */ DWORD owner; unsigned long depth; CRITICAL_SECTION lock; } gl_recursive_lock_t; # define gl_recursive_lock_define(STORAGECLASS, NAME) \ STORAGECLASS gl_recursive_lock_t NAME; # define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; # define gl_recursive_lock_initializer \ { { 0, -1 }, 0, 0 } # define glthread_recursive_lock_init(LOCK) \ (glthread_recursive_lock_init_func (LOCK), 0) # define glthread_recursive_lock_lock(LOCK) \ glthread_recursive_lock_lock_func (LOCK) # define glthread_recursive_lock_unlock(LOCK) \ glthread_recursive_lock_unlock_func (LOCK) # define glthread_recursive_lock_destroy(LOCK) \ glthread_recursive_lock_destroy_func (LOCK) extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock); extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock); /* -------------------------- gl_once_t datatype -------------------------- */ typedef struct { volatile int inited; volatile long started; CRITICAL_SECTION lock; } gl_once_t; # define gl_once_define(STORAGECLASS, NAME) \ STORAGECLASS gl_once_t NAME = { -1, -1 }; # define glthread_once(ONCE_CONTROL, INITFUNCTION) \ (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0) extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void)); # ifdef __cplusplus } # endif #endif /* ========================================================================= */ #if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS) /* Provide dummy implementation if threads are not supported. */ /* -------------------------- gl_lock_t datatype -------------------------- */ typedef int gl_lock_t; # define gl_lock_define(STORAGECLASS, NAME) # define gl_lock_define_initialized(STORAGECLASS, NAME) # define glthread_lock_init(NAME) 0 # define glthread_lock_lock(NAME) 0 # define glthread_lock_unlock(NAME) 0 # define glthread_lock_destroy(NAME) 0 /* ------------------------- gl_rwlock_t datatype ------------------------- */ typedef int gl_rwlock_t; # define gl_rwlock_define(STORAGECLASS, NAME) # define gl_rwlock_define_initialized(STORAGECLASS, NAME) # define glthread_rwlock_init(NAME) 0 # define glthread_rwlock_rdlock(NAME) 0 # define glthread_rwlock_wrlock(NAME) 0 # define glthread_rwlock_unlock(NAME) 0 # define glthread_rwlock_destroy(NAME) 0 /* --------------------- gl_recursive_lock_t datatype --------------------- */ typedef int gl_recursive_lock_t; # define gl_recursive_lock_define(STORAGECLASS, NAME) # define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) # define glthread_recursive_lock_init(NAME) 0 # define glthread_recursive_lock_lock(NAME) 0 # define glthread_recursive_lock_unlock(NAME) 0 # define glthread_recursive_lock_destroy(NAME) 0 /* -------------------------- gl_once_t datatype -------------------------- */ typedef int gl_once_t; # define gl_once_define(STORAGECLASS, NAME) \ STORAGECLASS gl_once_t NAME = 0; # define glthread_once(ONCE_CONTROL, INITFUNCTION) \ (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0) #endif /* ========================================================================= */ /* Macros with built-in error handling. */ /* -------------------------- gl_lock_t datatype -------------------------- */ #define gl_lock_init(NAME) \ do \ { \ if (glthread_lock_init (&NAME)) \ abort (); \ } \ while (0) #define gl_lock_lock(NAME) \ do \ { \ if (glthread_lock_lock (&NAME)) \ abort (); \ } \ while (0) #define gl_lock_unlock(NAME) \ do \ { \ if (glthread_lock_unlock (&NAME)) \ abort (); \ } \ while (0) #define gl_lock_destroy(NAME) \ do \ { \ if (glthread_lock_destroy (&NAME)) \ abort (); \ } \ while (0) /* ------------------------- gl_rwlock_t datatype ------------------------- */ #define gl_rwlock_init(NAME) \ do \ { \ if (glthread_rwlock_init (&NAME)) \ abort (); \ } \ while (0) #define gl_rwlock_rdlock(NAME) \ do \ { \ if (glthread_rwlock_rdlock (&NAME)) \ abort (); \ } \ while (0) #define gl_rwlock_wrlock(NAME) \ do \ { \ if (glthread_rwlock_wrlock (&NAME)) \ abort (); \ } \ while (0) #define gl_rwlock_unlock(NAME) \ do \ { \ if (glthread_rwlock_unlock (&NAME)) \ abort (); \ } \ while (0) #define gl_rwlock_destroy(NAME) \ do \ { \ if (glthread_rwlock_destroy (&NAME)) \ abort (); \ } \ while (0) /* --------------------- gl_recursive_lock_t datatype --------------------- */ #define gl_recursive_lock_init(NAME) \ do \ { \ if (glthread_recursive_lock_init (&NAME)) \ abort (); \ } \ while (0) #define gl_recursive_lock_lock(NAME) \ do \ { \ if (glthread_recursive_lock_lock (&NAME)) \ abort (); \ } \ while (0) #define gl_recursive_lock_unlock(NAME) \ do \ { \ if (glthread_recursive_lock_unlock (&NAME)) \ abort (); \ } \ while (0) #define gl_recursive_lock_destroy(NAME) \ do \ { \ if (glthread_recursive_lock_destroy (&NAME)) \ abort (); \ } \ while (0) /* -------------------------- gl_once_t datatype -------------------------- */ #define gl_once(NAME, INITFUNCTION) \ do \ { \ if (glthread_once (&NAME, INITFUNCTION)) \ abort (); \ } \ while (0) /* ========================================================================= */ #endif /* _LOCK_H */ lftp-4.6.3a/lib/glthread/lock.c0000644000015000007670000006417012466374011013223 00000000000000/* Locking in multithreaded situations. Copyright (C) 2005-2015 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 . */ /* Written by Bruno Haible , 2005. Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, gthr-win32.h. */ #include #include "glthread/lock.h" /* ========================================================================= */ #if USE_POSIX_THREADS /* -------------------------- gl_lock_t datatype -------------------------- */ /* ------------------------- gl_rwlock_t datatype ------------------------- */ # if HAVE_PTHREAD_RWLOCK # if !defined PTHREAD_RWLOCK_INITIALIZER int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) { int err; err = pthread_rwlock_init (&lock->rwlock, NULL); if (err != 0) return err; lock->initialized = 1; return 0; } int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) { if (!lock->initialized) { int err; err = pthread_mutex_lock (&lock->guard); if (err != 0) return err; if (!lock->initialized) { err = glthread_rwlock_init_multithreaded (lock); if (err != 0) { pthread_mutex_unlock (&lock->guard); return err; } } err = pthread_mutex_unlock (&lock->guard); if (err != 0) return err; } return pthread_rwlock_rdlock (&lock->rwlock); } int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) { if (!lock->initialized) { int err; err = pthread_mutex_lock (&lock->guard); if (err != 0) return err; if (!lock->initialized) { err = glthread_rwlock_init_multithreaded (lock); if (err != 0) { pthread_mutex_unlock (&lock->guard); return err; } } err = pthread_mutex_unlock (&lock->guard); if (err != 0) return err; } return pthread_rwlock_wrlock (&lock->rwlock); } int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) { if (!lock->initialized) return EINVAL; return pthread_rwlock_unlock (&lock->rwlock); } int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) { int err; if (!lock->initialized) return EINVAL; err = pthread_rwlock_destroy (&lock->rwlock); if (err != 0) return err; lock->initialized = 0; return 0; } # endif # else int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) { int err; err = pthread_mutex_init (&lock->lock, NULL); if (err != 0) return err; err = pthread_cond_init (&lock->waiting_readers, NULL); if (err != 0) return err; err = pthread_cond_init (&lock->waiting_writers, NULL); if (err != 0) return err; lock->waiting_writers_count = 0; lock->runcount = 0; return 0; } int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) { int err; err = pthread_mutex_lock (&lock->lock); if (err != 0) return err; /* Test whether only readers are currently running, and whether the runcount field will not overflow. */ /* POSIX says: "It is implementation-defined whether the calling thread acquires the lock when a writer does not hold the lock and there are writers blocked on the lock." Let's say, no: give the writers a higher priority. */ while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) { /* This thread has to wait for a while. Enqueue it among the waiting_readers. */ err = pthread_cond_wait (&lock->waiting_readers, &lock->lock); if (err != 0) { pthread_mutex_unlock (&lock->lock); return err; } } lock->runcount++; return pthread_mutex_unlock (&lock->lock); } int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) { int err; err = pthread_mutex_lock (&lock->lock); if (err != 0) return err; /* Test whether no readers or writers are currently running. */ while (!(lock->runcount == 0)) { /* This thread has to wait for a while. Enqueue it among the waiting_writers. */ lock->waiting_writers_count++; err = pthread_cond_wait (&lock->waiting_writers, &lock->lock); if (err != 0) { lock->waiting_writers_count--; pthread_mutex_unlock (&lock->lock); return err; } lock->waiting_writers_count--; } lock->runcount--; /* runcount becomes -1 */ return pthread_mutex_unlock (&lock->lock); } int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) { int err; err = pthread_mutex_lock (&lock->lock); if (err != 0) return err; if (lock->runcount < 0) { /* Drop a writer lock. */ if (!(lock->runcount == -1)) { pthread_mutex_unlock (&lock->lock); return EINVAL; } lock->runcount = 0; } else { /* Drop a reader lock. */ if (!(lock->runcount > 0)) { pthread_mutex_unlock (&lock->lock); return EINVAL; } lock->runcount--; } if (lock->runcount == 0) { /* POSIX recommends that "write locks shall take precedence over read locks", to avoid "writer starvation". */ if (lock->waiting_writers_count > 0) { /* Wake up one of the waiting writers. */ err = pthread_cond_signal (&lock->waiting_writers); if (err != 0) { pthread_mutex_unlock (&lock->lock); return err; } } else { /* Wake up all waiting readers. */ err = pthread_cond_broadcast (&lock->waiting_readers); if (err != 0) { pthread_mutex_unlock (&lock->lock); return err; } } } return pthread_mutex_unlock (&lock->lock); } int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) { int err; err = pthread_mutex_destroy (&lock->lock); if (err != 0) return err; err = pthread_cond_destroy (&lock->waiting_readers); if (err != 0) return err; err = pthread_cond_destroy (&lock->waiting_writers); if (err != 0) return err; return 0; } # endif /* --------------------- gl_recursive_lock_t datatype --------------------- */ # if HAVE_PTHREAD_MUTEX_RECURSIVE # if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) { pthread_mutexattr_t attributes; int err; err = pthread_mutexattr_init (&attributes); if (err != 0) return err; err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); if (err != 0) { pthread_mutexattr_destroy (&attributes); return err; } err = pthread_mutex_init (lock, &attributes); if (err != 0) { pthread_mutexattr_destroy (&attributes); return err; } err = pthread_mutexattr_destroy (&attributes); if (err != 0) return err; return 0; } # else int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) { pthread_mutexattr_t attributes; int err; err = pthread_mutexattr_init (&attributes); if (err != 0) return err; err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); if (err != 0) { pthread_mutexattr_destroy (&attributes); return err; } err = pthread_mutex_init (&lock->recmutex, &attributes); if (err != 0) { pthread_mutexattr_destroy (&attributes); return err; } err = pthread_mutexattr_destroy (&attributes); if (err != 0) return err; lock->initialized = 1; return 0; } int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) { if (!lock->initialized) { int err; err = pthread_mutex_lock (&lock->guard); if (err != 0) return err; if (!lock->initialized) { err = glthread_recursive_lock_init_multithreaded (lock); if (err != 0) { pthread_mutex_unlock (&lock->guard); return err; } } err = pthread_mutex_unlock (&lock->guard); if (err != 0) return err; } return pthread_mutex_lock (&lock->recmutex); } int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) { if (!lock->initialized) return EINVAL; return pthread_mutex_unlock (&lock->recmutex); } int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) { int err; if (!lock->initialized) return EINVAL; err = pthread_mutex_destroy (&lock->recmutex); if (err != 0) return err; lock->initialized = 0; return 0; } # endif # else int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) { int err; err = pthread_mutex_init (&lock->mutex, NULL); if (err != 0) return err; lock->owner = (pthread_t) 0; lock->depth = 0; return 0; } int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) { pthread_t self = pthread_self (); if (lock->owner != self) { int err; err = pthread_mutex_lock (&lock->mutex); if (err != 0) return err; lock->owner = self; } if (++(lock->depth) == 0) /* wraparound? */ { lock->depth--; return EAGAIN; } return 0; } int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) { if (lock->owner != pthread_self ()) return EPERM; if (lock->depth == 0) return EINVAL; if (--(lock->depth) == 0) { lock->owner = (pthread_t) 0; return pthread_mutex_unlock (&lock->mutex); } else return 0; } int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) { if (lock->owner != (pthread_t) 0) return EBUSY; return pthread_mutex_destroy (&lock->mutex); } # endif /* -------------------------- gl_once_t datatype -------------------------- */ static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT; int glthread_once_singlethreaded (pthread_once_t *once_control) { /* We don't know whether pthread_once_t is an integer type, a floating-point type, a pointer type, or a structure type. */ char *firstbyte = (char *)once_control; if (*firstbyte == *(const char *)&fresh_once) { /* First time use of once_control. Invert the first byte. */ *firstbyte = ~ *(const char *)&fresh_once; return 1; } else return 0; } #endif /* ========================================================================= */ #if USE_PTH_THREADS /* Use the GNU Pth threads library. */ /* -------------------------- gl_lock_t datatype -------------------------- */ /* ------------------------- gl_rwlock_t datatype ------------------------- */ /* --------------------- gl_recursive_lock_t datatype --------------------- */ /* -------------------------- gl_once_t datatype -------------------------- */ static void glthread_once_call (void *arg) { void (**gl_once_temp_addr) (void) = (void (**) (void)) arg; void (*initfunction) (void) = *gl_once_temp_addr; initfunction (); } int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)) { void (*temp) (void) = initfunction; return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0); } int glthread_once_singlethreaded (pth_once_t *once_control) { /* We know that pth_once_t is an integer type. */ if (*once_control == PTH_ONCE_INIT) { /* First time use of once_control. Invert the marker. */ *once_control = ~ PTH_ONCE_INIT; return 1; } else return 0; } #endif /* ========================================================================= */ #if USE_SOLARIS_THREADS /* Use the old Solaris threads library. */ /* -------------------------- gl_lock_t datatype -------------------------- */ /* ------------------------- gl_rwlock_t datatype ------------------------- */ /* --------------------- gl_recursive_lock_t datatype --------------------- */ int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) { int err; err = mutex_init (&lock->mutex, USYNC_THREAD, NULL); if (err != 0) return err; lock->owner = (thread_t) 0; lock->depth = 0; return 0; } int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) { thread_t self = thr_self (); if (lock->owner != self) { int err; err = mutex_lock (&lock->mutex); if (err != 0) return err; lock->owner = self; } if (++(lock->depth) == 0) /* wraparound? */ { lock->depth--; return EAGAIN; } return 0; } int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) { if (lock->owner != thr_self ()) return EPERM; if (lock->depth == 0) return EINVAL; if (--(lock->depth) == 0) { lock->owner = (thread_t) 0; return mutex_unlock (&lock->mutex); } else return 0; } int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) { if (lock->owner != (thread_t) 0) return EBUSY; return mutex_destroy (&lock->mutex); } /* -------------------------- gl_once_t datatype -------------------------- */ int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void)) { if (!once_control->inited) { int err; /* Use the mutex to guarantee that if another thread is already calling the initfunction, this thread waits until it's finished. */ err = mutex_lock (&once_control->mutex); if (err != 0) return err; if (!once_control->inited) { once_control->inited = 1; initfunction (); } return mutex_unlock (&once_control->mutex); } else return 0; } int glthread_once_singlethreaded (gl_once_t *once_control) { /* We know that gl_once_t contains an integer type. */ if (!once_control->inited) { /* First time use of once_control. Invert the marker. */ once_control->inited = ~ 0; return 1; } else return 0; } #endif /* ========================================================================= */ #if USE_WINDOWS_THREADS /* -------------------------- gl_lock_t datatype -------------------------- */ void glthread_lock_init_func (gl_lock_t *lock) { InitializeCriticalSection (&lock->lock); lock->guard.done = 1; } int glthread_lock_lock_func (gl_lock_t *lock) { if (!lock->guard.done) { if (InterlockedIncrement (&lock->guard.started) == 0) /* This thread is the first one to need this lock. Initialize it. */ glthread_lock_init (lock); else /* Yield the CPU while waiting for another thread to finish initializing this lock. */ while (!lock->guard.done) Sleep (0); } EnterCriticalSection (&lock->lock); return 0; } int glthread_lock_unlock_func (gl_lock_t *lock) { if (!lock->guard.done) return EINVAL; LeaveCriticalSection (&lock->lock); return 0; } int glthread_lock_destroy_func (gl_lock_t *lock) { if (!lock->guard.done) return EINVAL; DeleteCriticalSection (&lock->lock); lock->guard.done = 0; return 0; } /* ------------------------- gl_rwlock_t datatype ------------------------- */ /* In this file, the waitqueues are implemented as circular arrays. */ #define gl_waitqueue_t gl_carray_waitqueue_t static void gl_waitqueue_init (gl_waitqueue_t *wq) { wq->array = NULL; wq->count = 0; wq->alloc = 0; wq->offset = 0; } /* Enqueues the current thread, represented by an event, in a wait queue. Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */ static HANDLE gl_waitqueue_add (gl_waitqueue_t *wq) { HANDLE event; unsigned int index; if (wq->count == wq->alloc) { unsigned int new_alloc = 2 * wq->alloc + 1; HANDLE *new_array = (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE)); if (new_array == NULL) /* No more memory. */ return INVALID_HANDLE_VALUE; /* Now is a good opportunity to rotate the array so that its contents starts at offset 0. */ if (wq->offset > 0) { unsigned int old_count = wq->count; unsigned int old_alloc = wq->alloc; unsigned int old_offset = wq->offset; unsigned int i; if (old_offset + old_count > old_alloc) { unsigned int limit = old_offset + old_count - old_alloc; for (i = 0; i < limit; i++) new_array[old_alloc + i] = new_array[i]; } for (i = 0; i < old_count; i++) new_array[i] = new_array[old_offset + i]; wq->offset = 0; } wq->array = new_array; wq->alloc = new_alloc; } /* Whether the created event is a manual-reset one or an auto-reset one, does not matter, since we will wait on it only once. */ event = CreateEvent (NULL, TRUE, FALSE, NULL); if (event == INVALID_HANDLE_VALUE) /* No way to allocate an event. */ return INVALID_HANDLE_VALUE; index = wq->offset + wq->count; if (index >= wq->alloc) index -= wq->alloc; wq->array[index] = event; wq->count++; return event; } /* Notifies the first thread from a wait queue and dequeues it. */ static void gl_waitqueue_notify_first (gl_waitqueue_t *wq) { SetEvent (wq->array[wq->offset + 0]); wq->offset++; wq->count--; if (wq->count == 0 || wq->offset == wq->alloc) wq->offset = 0; } /* Notifies all threads from a wait queue and dequeues them all. */ static void gl_waitqueue_notify_all (gl_waitqueue_t *wq) { unsigned int i; for (i = 0; i < wq->count; i++) { unsigned int index = wq->offset + i; if (index >= wq->alloc) index -= wq->alloc; SetEvent (wq->array[index]); } wq->count = 0; wq->offset = 0; } void glthread_rwlock_init_func (gl_rwlock_t *lock) { InitializeCriticalSection (&lock->lock); gl_waitqueue_init (&lock->waiting_readers); gl_waitqueue_init (&lock->waiting_writers); lock->runcount = 0; lock->guard.done = 1; } int glthread_rwlock_rdlock_func (gl_rwlock_t *lock) { if (!lock->guard.done) { if (InterlockedIncrement (&lock->guard.started) == 0) /* This thread is the first one to need this lock. Initialize it. */ glthread_rwlock_init (lock); else /* Yield the CPU while waiting for another thread to finish initializing this lock. */ while (!lock->guard.done) Sleep (0); } EnterCriticalSection (&lock->lock); /* Test whether only readers are currently running, and whether the runcount field will not overflow. */ if (!(lock->runcount + 1 > 0)) { /* This thread has to wait for a while. Enqueue it among the waiting_readers. */ HANDLE event = gl_waitqueue_add (&lock->waiting_readers); if (event != INVALID_HANDLE_VALUE) { DWORD result; LeaveCriticalSection (&lock->lock); /* Wait until another thread signals this event. */ result = WaitForSingleObject (event, INFINITE); if (result == WAIT_FAILED || result == WAIT_TIMEOUT) abort (); CloseHandle (event); /* The thread which signalled the event already did the bookkeeping: removed us from the waiting_readers, incremented lock->runcount. */ if (!(lock->runcount > 0)) abort (); return 0; } else { /* Allocation failure. Weird. */ do { LeaveCriticalSection (&lock->lock); Sleep (1); EnterCriticalSection (&lock->lock); } while (!(lock->runcount + 1 > 0)); } } lock->runcount++; LeaveCriticalSection (&lock->lock); return 0; } int glthread_rwlock_wrlock_func (gl_rwlock_t *lock) { if (!lock->guard.done) { if (InterlockedIncrement (&lock->guard.started) == 0) /* This thread is the first one to need this lock. Initialize it. */ glthread_rwlock_init (lock); else /* Yield the CPU while waiting for another thread to finish initializing this lock. */ while (!lock->guard.done) Sleep (0); } EnterCriticalSection (&lock->lock); /* Test whether no readers or writers are currently running. */ if (!(lock->runcount == 0)) { /* This thread has to wait for a while. Enqueue it among the waiting_writers. */ HANDLE event = gl_waitqueue_add (&lock->waiting_writers); if (event != INVALID_HANDLE_VALUE) { DWORD result; LeaveCriticalSection (&lock->lock); /* Wait until another thread signals this event. */ result = WaitForSingleObject (event, INFINITE); if (result == WAIT_FAILED || result == WAIT_TIMEOUT) abort (); CloseHandle (event); /* The thread which signalled the event already did the bookkeeping: removed us from the waiting_writers, set lock->runcount = -1. */ if (!(lock->runcount == -1)) abort (); return 0; } else { /* Allocation failure. Weird. */ do { LeaveCriticalSection (&lock->lock); Sleep (1); EnterCriticalSection (&lock->lock); } while (!(lock->runcount == 0)); } } lock->runcount--; /* runcount becomes -1 */ LeaveCriticalSection (&lock->lock); return 0; } int glthread_rwlock_unlock_func (gl_rwlock_t *lock) { if (!lock->guard.done) return EINVAL; EnterCriticalSection (&lock->lock); if (lock->runcount < 0) { /* Drop a writer lock. */ if (!(lock->runcount == -1)) abort (); lock->runcount = 0; } else { /* Drop a reader lock. */ if (!(lock->runcount > 0)) { LeaveCriticalSection (&lock->lock); return EPERM; } lock->runcount--; } if (lock->runcount == 0) { /* POSIX recommends that "write locks shall take precedence over read locks", to avoid "writer starvation". */ if (lock->waiting_writers.count > 0) { /* Wake up one of the waiting writers. */ lock->runcount--; gl_waitqueue_notify_first (&lock->waiting_writers); } else { /* Wake up all waiting readers. */ lock->runcount += lock->waiting_readers.count; gl_waitqueue_notify_all (&lock->waiting_readers); } } LeaveCriticalSection (&lock->lock); return 0; } int glthread_rwlock_destroy_func (gl_rwlock_t *lock) { if (!lock->guard.done) return EINVAL; if (lock->runcount != 0) return EBUSY; DeleteCriticalSection (&lock->lock); if (lock->waiting_readers.array != NULL) free (lock->waiting_readers.array); if (lock->waiting_writers.array != NULL) free (lock->waiting_writers.array); lock->guard.done = 0; return 0; } /* --------------------- gl_recursive_lock_t datatype --------------------- */ void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock) { lock->owner = 0; lock->depth = 0; InitializeCriticalSection (&lock->lock); lock->guard.done = 1; } int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock) { if (!lock->guard.done) { if (InterlockedIncrement (&lock->guard.started) == 0) /* This thread is the first one to need this lock. Initialize it. */ glthread_recursive_lock_init (lock); else /* Yield the CPU while waiting for another thread to finish initializing this lock. */ while (!lock->guard.done) Sleep (0); } { DWORD self = GetCurrentThreadId (); if (lock->owner != self) { EnterCriticalSection (&lock->lock); lock->owner = self; } if (++(lock->depth) == 0) /* wraparound? */ { lock->depth--; return EAGAIN; } } return 0; } int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock) { if (lock->owner != GetCurrentThreadId ()) return EPERM; if (lock->depth == 0) return EINVAL; if (--(lock->depth) == 0) { lock->owner = 0; LeaveCriticalSection (&lock->lock); } return 0; } int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock) { if (lock->owner != 0) return EBUSY; DeleteCriticalSection (&lock->lock); lock->guard.done = 0; return 0; } /* -------------------------- gl_once_t datatype -------------------------- */ void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void)) { if (once_control->inited <= 0) { if (InterlockedIncrement (&once_control->started) == 0) { /* This thread is the first one to come to this once_control. */ InitializeCriticalSection (&once_control->lock); EnterCriticalSection (&once_control->lock); once_control->inited = 0; initfunction (); once_control->inited = 1; LeaveCriticalSection (&once_control->lock); } else { /* Undo last operation. */ InterlockedDecrement (&once_control->started); /* Some other thread has already started the initialization. Yield the CPU while waiting for the other thread to finish initializing and taking the lock. */ while (once_control->inited < 0) Sleep (0); if (once_control->inited <= 0) { /* Take the lock. This blocks until the other thread has finished calling the initfunction. */ EnterCriticalSection (&once_control->lock); LeaveCriticalSection (&once_control->lock); if (!(once_control->inited > 0)) abort (); } } } } #endif /* ========================================================================= */ lftp-4.6.3a/lib/sys_stat.in.h0000644000015000007670000004767112466374012012774 00000000000000/* Provide a more complete sys/stat header file. Copyright (C) 2005-2015 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 . */ /* Written by Eric Blake, Paul Eggert, and Jim Meyering. */ /* This file is supposed to be used on platforms where is incomplete. It is intended to provide definitions and prototypes needed by an application. Start with what the system provides. */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined __need_system_sys_stat_h /* Special invocation convention. */ #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_SYS_STAT_H /* Get nlink_t. May also define off_t to a 64-bit type on native Windows. */ #include /* Get struct timespec. */ #include /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ #ifndef _@GUARD_PREFIX@_SYS_STAT_H #define _@GUARD_PREFIX@_SYS_STAT_H /* 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. */ /* Before doing "#define mkdir rpl_mkdir" below, we need to include all headers that may declare mkdir(). Native Windows platforms declare mkdir in and/or , not in . */ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # include /* mingw32, mingw64 */ # include /* mingw64, MSVC 9 */ #endif /* Native Windows platforms declare umask() in . */ #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) # include #endif /* Large File Support on native Windows. */ #if @WINDOWS_64_BIT_ST_SIZE@ # define stat _stati64 #endif #ifndef S_IFIFO # ifdef _S_IFIFO # define S_IFIFO _S_IFIFO # endif #endif #ifndef S_IFMT # define S_IFMT 0170000 #endif #if STAT_MACROS_BROKEN # undef S_ISBLK # undef S_ISCHR # undef S_ISDIR # undef S_ISFIFO # undef S_ISLNK # undef S_ISNAM # undef S_ISMPB # undef S_ISMPC # undef S_ISNWK # undef S_ISREG # undef S_ISSOCK #endif #ifndef S_ISBLK # ifdef S_IFBLK # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) # else # define S_ISBLK(m) 0 # endif #endif #ifndef S_ISCHR # ifdef S_IFCHR # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) # else # define S_ISCHR(m) 0 # endif #endif #ifndef S_ISDIR # ifdef S_IFDIR # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) # else # define S_ISDIR(m) 0 # endif #endif #ifndef S_ISDOOR /* Solaris 2.5 and up */ # define S_ISDOOR(m) 0 #endif #ifndef S_ISFIFO # ifdef S_IFIFO # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) # else # define S_ISFIFO(m) 0 # endif #endif #ifndef S_ISLNK # ifdef S_IFLNK # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) # else # define S_ISLNK(m) 0 # endif #endif #ifndef S_ISMPB /* V7 */ # ifdef S_IFMPB # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) # else # define S_ISMPB(m) 0 # define S_ISMPC(m) 0 # endif #endif #ifndef S_ISMPX /* AIX */ # define S_ISMPX(m) 0 #endif #ifndef S_ISNAM /* Xenix */ # ifdef S_IFNAM # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) # else # define S_ISNAM(m) 0 # endif #endif #ifndef S_ISNWK /* HP/UX */ # ifdef S_IFNWK # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) # else # define S_ISNWK(m) 0 # endif #endif #ifndef S_ISPORT /* Solaris 10 and up */ # define S_ISPORT(m) 0 #endif #ifndef S_ISREG # ifdef S_IFREG # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) # else # define S_ISREG(m) 0 # endif #endif #ifndef S_ISSOCK # ifdef S_IFSOCK # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) # else # define S_ISSOCK(m) 0 # endif #endif #ifndef S_TYPEISMQ # define S_TYPEISMQ(p) 0 #endif #ifndef S_TYPEISTMO # define S_TYPEISTMO(p) 0 #endif #ifndef S_TYPEISSEM # ifdef S_INSEM # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) # else # define S_TYPEISSEM(p) 0 # endif #endif #ifndef S_TYPEISSHM # ifdef S_INSHD # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) # else # define S_TYPEISSHM(p) 0 # endif #endif /* high performance ("contiguous data") */ #ifndef S_ISCTG # define S_ISCTG(p) 0 #endif /* Cray DMF (data migration facility): off line, with data */ #ifndef S_ISOFD # define S_ISOFD(p) 0 #endif /* Cray DMF (data migration facility): off line, with no data */ #ifndef S_ISOFL # define S_ISOFL(p) 0 #endif /* 4.4BSD whiteout */ #ifndef S_ISWHT # define S_ISWHT(m) 0 #endif /* If any of the following are undefined, define them to their de facto standard values. */ #if !S_ISUID # define S_ISUID 04000 #endif #if !S_ISGID # define S_ISGID 02000 #endif /* S_ISVTX is a common extension to POSIX. */ #ifndef S_ISVTX # define S_ISVTX 01000 #endif #if !S_IRUSR && S_IREAD # define S_IRUSR S_IREAD #endif #if !S_IRUSR # define S_IRUSR 00400 #endif #if !S_IRGRP # define S_IRGRP (S_IRUSR >> 3) #endif #if !S_IROTH # define S_IROTH (S_IRUSR >> 6) #endif #if !S_IWUSR && S_IWRITE # define S_IWUSR S_IWRITE #endif #if !S_IWUSR # define S_IWUSR 00200 #endif #if !S_IWGRP # define S_IWGRP (S_IWUSR >> 3) #endif #if !S_IWOTH # define S_IWOTH (S_IWUSR >> 6) #endif #if !S_IXUSR && S_IEXEC # define S_IXUSR S_IEXEC #endif #if !S_IXUSR # define S_IXUSR 00100 #endif #if !S_IXGRP # define S_IXGRP (S_IXUSR >> 3) #endif #if !S_IXOTH # define S_IXOTH (S_IXUSR >> 6) #endif #if !S_IRWXU # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) #endif #if !S_IRWXG # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) #endif #if !S_IRWXO # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) #endif /* S_IXUGO is a common extension to POSIX. */ #if !S_IXUGO # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) #endif #ifndef S_IRWXUGO # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) #endif /* Macros for futimens and utimensat. */ #ifndef UTIME_NOW # define UTIME_NOW (-1) # define UTIME_OMIT (-2) #endif #if @GNULIB_FCHMODAT@ # if !@HAVE_FCHMODAT@ _GL_FUNCDECL_SYS (fchmodat, int, (int fd, char const *file, mode_t mode, int flag) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (fchmodat, int, (int fd, char const *file, mode_t mode, int flag)); _GL_CXXALIASWARN (fchmodat); #elif defined GNULIB_POSIXCHECK # undef fchmodat # if HAVE_RAW_DECL_FCHMODAT _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - " "use gnulib module openat for portability"); # endif #endif #if @GNULIB_FSTAT@ # if @REPLACE_FSTAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fstat # define fstat rpl_fstat # endif _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); # else _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); # endif _GL_CXXALIASWARN (fstat); #elif @WINDOWS_64_BIT_ST_SIZE@ /* Above, we define stat to _stati64. */ # define fstat _fstati64 #elif defined GNULIB_POSIXCHECK # undef fstat # if HAVE_RAW_DECL_FSTAT _GL_WARN_ON_USE (fstat, "fstat has portability problems - " "use gnulib module fstat for portability"); # endif #endif #if @GNULIB_FSTATAT@ # if @REPLACE_FSTATAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fstatat # define fstatat rpl_fstatat # endif _GL_FUNCDECL_RPL (fstatat, int, (int fd, char const *name, struct stat *st, int flags) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (fstatat, int, (int fd, char const *name, struct stat *st, int flags)); # else # if !@HAVE_FSTATAT@ _GL_FUNCDECL_SYS (fstatat, int, (int fd, char const *name, struct stat *st, int flags) _GL_ARG_NONNULL ((2, 3))); # endif _GL_CXXALIAS_SYS (fstatat, int, (int fd, char const *name, struct stat *st, int flags)); # endif _GL_CXXALIASWARN (fstatat); #elif defined GNULIB_POSIXCHECK # undef fstatat # if HAVE_RAW_DECL_FSTATAT _GL_WARN_ON_USE (fstatat, "fstatat is not portable - " "use gnulib module openat for portability"); # endif #endif #if @GNULIB_FUTIMENS@ /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens implementation relies on futimesat, which on Solaris 10 makes an invocation to futimens that is meant to invoke the libc's futimens(), not gnulib's futimens(). */ # if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef futimens # define futimens rpl_futimens # endif _GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2])); _GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2])); # else # if !@HAVE_FUTIMENS@ _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2])); # endif _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2])); # endif # if @HAVE_FUTIMENS@ _GL_CXXALIASWARN (futimens); # endif #elif defined GNULIB_POSIXCHECK # undef futimens # if HAVE_RAW_DECL_FUTIMENS _GL_WARN_ON_USE (futimens, "futimens is not portable - " "use gnulib module futimens for portability"); # endif #endif #if @GNULIB_LCHMOD@ /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME denotes a symbolic link. */ # if !@HAVE_LCHMOD@ /* The lchmod replacement follows symbolic links. Callers should take this into account; lchmod should be applied only to arguments that are known to not be symbolic links. On hosts that lack lchmod, this can lead to race conditions between the check and the invocation of lchmod, but we know of no workarounds that are reliable in general. You might try requesting support for lchmod from your operating system supplier. */ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define lchmod chmod # endif /* Need to cast, because on mingw, the second parameter of chmod is int mode. */ _GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int, (const char *filename, mode_t mode)); # else # if 0 /* assume already declared */ _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode)); # endif # if @HAVE_LCHMOD@ _GL_CXXALIASWARN (lchmod); # endif #elif defined GNULIB_POSIXCHECK # undef lchmod # if HAVE_RAW_DECL_LCHMOD _GL_WARN_ON_USE (lchmod, "lchmod is unportable - " "use gnulib module lchmod for portability"); # endif #endif #if @GNULIB_LSTAT@ # if ! @HAVE_LSTAT@ /* mingw does not support symlinks, therefore it does not have lstat. But without links, stat does just fine. */ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define lstat stat # endif _GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf)); # elif @REPLACE_LSTAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef lstat # define lstat rpl_lstat # endif _GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf)); # else _GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf)); # endif # if @HAVE_LSTAT@ _GL_CXXALIASWARN (lstat); # endif #elif defined GNULIB_POSIXCHECK # undef lstat # if HAVE_RAW_DECL_LSTAT _GL_WARN_ON_USE (lstat, "lstat is unportable - " "use gnulib module lstat for portability"); # endif #endif #if @REPLACE_MKDIR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mkdir # define mkdir rpl_mkdir # endif _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); #else /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. Additionally, it declares _mkdir (and depending on compile flags, an alias mkdir), only in the nonstandard includes and , which are included above. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # if !GNULIB_defined_rpl_mkdir static int rpl_mkdir (char const *name, mode_t mode) { return _mkdir (name); } # define GNULIB_defined_rpl_mkdir 1 # endif # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mkdir rpl_mkdir # endif _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); # else _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); # endif #endif _GL_CXXALIASWARN (mkdir); #if @GNULIB_MKDIRAT@ # if !@HAVE_MKDIRAT@ _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)); _GL_CXXALIASWARN (mkdirat); #elif defined GNULIB_POSIXCHECK # undef mkdirat # if HAVE_RAW_DECL_MKDIRAT _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - " "use gnulib module openat for portability"); # endif #endif #if @GNULIB_MKFIFO@ # if @REPLACE_MKFIFO@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mkfifo # define mkfifo rpl_mkfifo # endif _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode)); # else # if !@HAVE_MKFIFO@ _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode)); # endif _GL_CXXALIASWARN (mkfifo); #elif defined GNULIB_POSIXCHECK # undef mkfifo # if HAVE_RAW_DECL_MKFIFO _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - " "use gnulib module mkfifo for portability"); # endif #endif #if @GNULIB_MKFIFOAT@ # if !@HAVE_MKFIFOAT@ _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)); _GL_CXXALIASWARN (mkfifoat); #elif defined GNULIB_POSIXCHECK # undef mkfifoat # if HAVE_RAW_DECL_MKFIFOAT _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - " "use gnulib module mkfifoat for portability"); # endif #endif #if @GNULIB_MKNOD@ # if @REPLACE_MKNOD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mknod # define mknod rpl_mknod # endif _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)); # else # if !@HAVE_MKNOD@ _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev) _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */ _GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev)); # endif _GL_CXXALIASWARN (mknod); #elif defined GNULIB_POSIXCHECK # undef mknod # if HAVE_RAW_DECL_MKNOD _GL_WARN_ON_USE (mknod, "mknod is not portable - " "use gnulib module mknod for portability"); # endif #endif #if @GNULIB_MKNODAT@ # if !@HAVE_MKNODAT@ _GL_FUNCDECL_SYS (mknodat, int, (int fd, char const *file, mode_t mode, dev_t dev) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (mknodat, int, (int fd, char const *file, mode_t mode, dev_t dev)); _GL_CXXALIASWARN (mknodat); #elif defined GNULIB_POSIXCHECK # undef mknodat # if HAVE_RAW_DECL_MKNODAT _GL_WARN_ON_USE (mknodat, "mknodat is not portable - " "use gnulib module mkfifoat for portability"); # endif #endif #if @GNULIB_STAT@ # if @REPLACE_STAT@ /* We can't use the object-like #define stat rpl_stat, because of struct stat. This means that rpl_stat will not be used if the user does (stat)(a,b). Oh well. */ # if defined _AIX && defined stat && defined _LARGE_FILES /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, so we have to replace stat64() instead of stat(). */ # undef stat64 # define stat64(name, st) rpl_stat (name, st) # elif @WINDOWS_64_BIT_ST_SIZE@ /* Above, we define stat to _stati64. */ # if defined __MINGW32__ && defined _stati64 # ifndef _USE_32BIT_TIME_T /* The system headers define _stati64 to _stat64. */ # undef _stat64 # define _stat64(name, st) rpl_stat (name, st) # endif # elif defined _MSC_VER && defined _stati64 # ifdef _USE_32BIT_TIME_T /* The system headers define _stati64 to _stat32i64. */ # undef _stat32i64 # define _stat32i64(name, st) rpl_stat (name, st) # else /* The system headers define _stati64 to _stat64. */ # undef _stat64 # define _stat64(name, st) rpl_stat (name, st) # endif # else # undef _stati64 # define _stati64(name, st) rpl_stat (name, st) # endif # elif defined __MINGW32__ && defined stat # ifdef _USE_32BIT_TIME_T /* The system headers define stat to _stat32i64. */ # undef _stat32i64 # define _stat32i64(name, st) rpl_stat (name, st) # else /* The system headers define stat to _stat64. */ # undef _stat64 # define _stat64(name, st) rpl_stat (name, st) # endif # elif defined _MSC_VER && defined stat # ifdef _USE_32BIT_TIME_T /* The system headers define stat to _stat32. */ # undef _stat32 # define _stat32(name, st) rpl_stat (name, st) # else /* The system headers define stat to _stat64i32. */ # undef _stat64i32 # define _stat64i32(name, st) rpl_stat (name, st) # endif # else /* !(_AIX ||__MINGW32__ || _MSC_VER) */ # undef stat # define stat(name, st) rpl_stat (name, st) # endif /* !_LARGE_FILES */ _GL_EXTERN_C int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef stat # if HAVE_RAW_DECL_STAT _GL_WARN_ON_USE (stat, "stat is unportable - " "use gnulib module stat for portability"); # endif #endif #if @GNULIB_UTIMENSAT@ /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat implementation relies on futimesat, which on Solaris 10 makes an invocation to utimensat that is meant to invoke the libc's utimensat(), not gnulib's utimensat(). */ # if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef utimensat # define utimensat rpl_utimensat # endif _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name, struct timespec const times[2], int flag) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name, struct timespec const times[2], int flag)); # else # if !@HAVE_UTIMENSAT@ _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name, struct timespec const times[2], int flag) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name, struct timespec const times[2], int flag)); # endif # if @HAVE_UTIMENSAT@ _GL_CXXALIASWARN (utimensat); # endif #elif defined GNULIB_POSIXCHECK # undef utimensat # if HAVE_RAW_DECL_UTIMENSAT _GL_WARN_ON_USE (utimensat, "utimensat is not portable - " "use gnulib module utimensat for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_SYS_STAT_H */ #endif /* _@GUARD_PREFIX@_SYS_STAT_H */ #endif lftp-4.6.3a/lib/regex_internal.h0000644000015000007670000006176112466374012013520 00000000000000/* Extended regular expression matching and search library. Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . The GNU C Library 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. The GNU C Library 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 the GNU C Library; if not, see . */ #ifndef _REGEX_INTERNAL_H #define _REGEX_INTERNAL_H 1 #include #include #include #include #include #include #include #include #include #include #include #ifdef _LIBC # include # define lock_define(name) __libc_lock_define (, name) # define lock_init(lock) (__libc_lock_init (lock), 0) # define lock_fini(lock) 0 # define lock_lock(lock) __libc_lock_lock (lock) # define lock_unlock(lock) __libc_lock_unlock (lock) #elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO # include "glthread/lock.h" /* Use gl_lock_define if empty macro arguments are known to work. Otherwise, fall back on less-portable substitutes. */ # if ((defined __GNUC__ && !defined __STRICT_ANSI__) \ || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__)) # define lock_define(name) gl_lock_define (, name) # elif USE_POSIX_THREADS # define lock_define(name) pthread_mutex_t name; # elif USE_PTH_THREADS # define lock_define(name) pth_mutex_t name; # elif USE_SOLARIS_THREADS # define lock_define(name) mutex_t name; # elif USE_WINDOWS_THREADS # define lock_define(name) gl_lock_t name; # else # define lock_define(name) # endif # define lock_init(lock) glthread_lock_init (&(lock)) # define lock_fini(lock) glthread_lock_destroy (&(lock)) # define lock_lock(lock) glthread_lock_lock (&(lock)) # define lock_unlock(lock) glthread_lock_unlock (&(lock)) #elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO # include # define lock_define(name) pthread_mutex_t name; # define lock_init(lock) pthread_mutex_init (&(lock), 0) # define lock_fini(lock) pthread_mutex_destroy (&(lock)) # define lock_lock(lock) pthread_mutex_lock (&(lock)) # define lock_unlock(lock) pthread_mutex_unlock (&(lock)) #else # define lock_define(name) # define lock_init(lock) 0 # define lock_fini(lock) ((void) 0) /* The 'dfa' avoids an "unused variable 'dfa'" warning from GCC. */ # define lock_lock(lock) ((void) dfa) # define lock_unlock(lock) ((void) 0) #endif /* In case that the system doesn't have isblank(). */ #if !defined _LIBC && ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK)) # define isblank(ch) ((ch) == ' ' || (ch) == '\t') #endif #ifdef _LIBC # ifndef _RE_DEFINE_LOCALE_FUNCTIONS # define _RE_DEFINE_LOCALE_FUNCTIONS 1 # include # include # include # endif #endif /* This is for other GNU distributions with internationalized messages. */ #if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC # include # ifdef _LIBC # undef gettext # define gettext(msgid) \ __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES) # endif #else # define gettext(msgid) (msgid) #endif #ifndef gettext_noop /* This define is so xgettext can find the internationalizable strings. */ # define gettext_noop(String) String #endif #if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE) || _LIBC # define RE_ENABLE_I18N #endif #if __GNUC__ >= 3 # define BE(expr, val) __builtin_expect (expr, val) #else # define BE(expr, val) (expr) #endif /* Number of ASCII characters. */ #define ASCII_CHARS 0x80 /* Number of single byte characters. */ #define SBC_MAX (UCHAR_MAX + 1) #define COLL_ELEM_LEN_MAX 8 /* The character which represents newline. */ #define NEWLINE_CHAR '\n' #define WIDE_NEWLINE_CHAR L'\n' /* Rename to standard API for using out of glibc. */ #ifndef _LIBC # undef __wctype # undef __iswctype # define __wctype wctype # define __iswctype iswctype # define __btowc btowc # define __mbrtowc mbrtowc # define __wcrtomb wcrtomb # define __regfree regfree # define attribute_hidden #endif /* not _LIBC */ #if __GNUC__ < 3 + (__GNUC_MINOR__ < 1) # define __attribute__(arg) #endif typedef __re_idx_t Idx; #ifdef _REGEX_LARGE_OFFSETS # define IDX_MAX (SIZE_MAX - 2) #else # define IDX_MAX INT_MAX #endif /* Special return value for failure to match. */ #define REG_MISSING ((Idx) -1) /* Special return value for internal error. */ #define REG_ERROR ((Idx) -2) /* Test whether N is a valid index, and is not one of the above. */ #ifdef _REGEX_LARGE_OFFSETS # define REG_VALID_INDEX(n) ((Idx) (n) < REG_ERROR) #else # define REG_VALID_INDEX(n) (0 <= (n)) #endif /* Test whether N is a valid nonzero index. */ #ifdef _REGEX_LARGE_OFFSETS # define REG_VALID_NONZERO_INDEX(n) ((Idx) ((n) - 1) < (Idx) (REG_ERROR - 1)) #else # define REG_VALID_NONZERO_INDEX(n) (0 < (n)) #endif /* A hash value, suitable for computing hash tables. */ typedef __re_size_t re_hashval_t; /* An integer used to represent a set of bits. It must be unsigned, and must be at least as wide as unsigned int. */ typedef unsigned long int bitset_word_t; /* All bits set in a bitset_word_t. */ #define BITSET_WORD_MAX ULONG_MAX /* Number of bits in a bitset_word_t. For portability to hosts with padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)'; instead, deduce it directly from BITSET_WORD_MAX. Avoid greater-than-32-bit integers and unconditional shifts by more than 31 bits, as they're not portable. */ #if BITSET_WORD_MAX == 0xffffffffUL # define BITSET_WORD_BITS 32 #elif BITSET_WORD_MAX >> 31 >> 4 == 1 # define BITSET_WORD_BITS 36 #elif BITSET_WORD_MAX >> 31 >> 16 == 1 # define BITSET_WORD_BITS 48 #elif BITSET_WORD_MAX >> 31 >> 28 == 1 # define BITSET_WORD_BITS 60 #elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1 # define BITSET_WORD_BITS 64 #elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1 # define BITSET_WORD_BITS 72 #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1 # define BITSET_WORD_BITS 128 #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1 # define BITSET_WORD_BITS 256 #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1 # define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */ # if BITSET_WORD_BITS <= SBC_MAX # error "Invalid SBC_MAX" # endif #else # error "Add case for new bitset_word_t size" #endif /* Number of bitset_word_t values in a bitset_t. */ #define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) typedef bitset_word_t bitset_t[BITSET_WORDS]; typedef bitset_word_t *re_bitset_ptr_t; typedef const bitset_word_t *re_const_bitset_ptr_t; #define PREV_WORD_CONSTRAINT 0x0001 #define PREV_NOTWORD_CONSTRAINT 0x0002 #define NEXT_WORD_CONSTRAINT 0x0004 #define NEXT_NOTWORD_CONSTRAINT 0x0008 #define PREV_NEWLINE_CONSTRAINT 0x0010 #define NEXT_NEWLINE_CONSTRAINT 0x0020 #define PREV_BEGBUF_CONSTRAINT 0x0040 #define NEXT_ENDBUF_CONSTRAINT 0x0080 #define WORD_DELIM_CONSTRAINT 0x0100 #define NOT_WORD_DELIM_CONSTRAINT 0x0200 typedef enum { INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, LINE_FIRST = PREV_NEWLINE_CONSTRAINT, LINE_LAST = NEXT_NEWLINE_CONSTRAINT, BUF_FIRST = PREV_BEGBUF_CONSTRAINT, BUF_LAST = NEXT_ENDBUF_CONSTRAINT, WORD_DELIM = WORD_DELIM_CONSTRAINT, NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT } re_context_type; typedef struct { Idx alloc; Idx nelem; Idx *elems; } re_node_set; typedef enum { NON_TYPE = 0, /* Node type, These are used by token, node, tree. */ CHARACTER = 1, END_OF_RE = 2, SIMPLE_BRACKET = 3, OP_BACK_REF = 4, OP_PERIOD = 5, #ifdef RE_ENABLE_I18N COMPLEX_BRACKET = 6, OP_UTF8_PERIOD = 7, #endif /* RE_ENABLE_I18N */ /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used when the debugger shows values of this enum type. */ #define EPSILON_BIT 8 OP_OPEN_SUBEXP = EPSILON_BIT | 0, OP_CLOSE_SUBEXP = EPSILON_BIT | 1, OP_ALT = EPSILON_BIT | 2, OP_DUP_ASTERISK = EPSILON_BIT | 3, ANCHOR = EPSILON_BIT | 4, /* Tree type, these are used only by tree. */ CONCAT = 16, SUBEXP = 17, /* Token type, these are used only by token. */ OP_DUP_PLUS = 18, OP_DUP_QUESTION, OP_OPEN_BRACKET, OP_CLOSE_BRACKET, OP_CHARSET_RANGE, OP_OPEN_DUP_NUM, OP_CLOSE_DUP_NUM, OP_NON_MATCH_LIST, OP_OPEN_COLL_ELEM, OP_CLOSE_COLL_ELEM, OP_OPEN_EQUIV_CLASS, OP_CLOSE_EQUIV_CLASS, OP_OPEN_CHAR_CLASS, OP_CLOSE_CHAR_CLASS, OP_WORD, OP_NOTWORD, OP_SPACE, OP_NOTSPACE, BACK_SLASH } re_token_type_t; #ifdef RE_ENABLE_I18N typedef struct { /* Multibyte characters. */ wchar_t *mbchars; /* Collating symbols. */ # ifdef _LIBC int32_t *coll_syms; # endif /* Equivalence classes. */ # ifdef _LIBC int32_t *equiv_classes; # endif /* Range expressions. */ # ifdef _LIBC uint32_t *range_starts; uint32_t *range_ends; # else /* not _LIBC */ wchar_t *range_starts; wchar_t *range_ends; # endif /* not _LIBC */ /* Character classes. */ wctype_t *char_classes; /* If this character set is the non-matching list. */ unsigned int non_match : 1; /* # of multibyte characters. */ Idx nmbchars; /* # of collating symbols. */ Idx ncoll_syms; /* # of equivalence classes. */ Idx nequiv_classes; /* # of range expressions. */ Idx nranges; /* # of character classes. */ Idx nchar_classes; } re_charset_t; #endif /* RE_ENABLE_I18N */ typedef struct { union { unsigned char c; /* for CHARACTER */ re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ #ifdef RE_ENABLE_I18N re_charset_t *mbcset; /* for COMPLEX_BRACKET */ #endif /* RE_ENABLE_I18N */ Idx idx; /* for BACK_REF */ re_context_type ctx_type; /* for ANCHOR */ } opr; #if __GNUC__ >= 2 && !defined __STRICT_ANSI__ re_token_type_t type : 8; #else re_token_type_t type; #endif unsigned int constraint : 10; /* context constraint */ unsigned int duplicated : 1; unsigned int opt_subexp : 1; #ifdef RE_ENABLE_I18N unsigned int accept_mb : 1; /* These 2 bits can be moved into the union if needed (e.g. if running out of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ unsigned int mb_partial : 1; #endif unsigned int word_char : 1; } re_token_t; #define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT) struct re_string_t { /* Indicate the raw buffer which is the original string passed as an argument of regexec(), re_search(), etc.. */ const unsigned char *raw_mbs; /* Store the multibyte string. In case of "case insensitive mode" like REG_ICASE, upper cases of the string are stored, otherwise MBS points the same address that RAW_MBS points. */ unsigned char *mbs; #ifdef RE_ENABLE_I18N /* Store the wide character string which is corresponding to MBS. */ wint_t *wcs; Idx *offsets; mbstate_t cur_state; #endif /* Index in RAW_MBS. Each character mbs[i] corresponds to raw_mbs[raw_mbs_idx + i]. */ Idx raw_mbs_idx; /* The length of the valid characters in the buffers. */ Idx valid_len; /* The corresponding number of bytes in raw_mbs array. */ Idx valid_raw_len; /* The length of the buffers MBS and WCS. */ Idx bufs_len; /* The index in MBS, which is updated by re_string_fetch_byte. */ Idx cur_idx; /* length of RAW_MBS array. */ Idx raw_len; /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */ Idx len; /* End of the buffer may be shorter than its length in the cases such as re_match_2, re_search_2. Then, we use STOP for end of the buffer instead of LEN. */ Idx raw_stop; /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */ Idx stop; /* The context of mbs[0]. We store the context independently, since the context of mbs[0] may be different from raw_mbs[0], which is the beginning of the input string. */ unsigned int tip_context; /* The translation passed as a part of an argument of re_compile_pattern. */ RE_TRANSLATE_TYPE trans; /* Copy of re_dfa_t's word_char. */ re_const_bitset_ptr_t word_char; /* true if REG_ICASE. */ unsigned char icase; unsigned char is_utf8; unsigned char map_notascii; unsigned char mbs_allocated; unsigned char offsets_needed; unsigned char newline_anchor; unsigned char word_ops_used; int mb_cur_max; }; typedef struct re_string_t re_string_t; struct re_dfa_t; typedef struct re_dfa_t re_dfa_t; #ifndef _LIBC # define internal_function #endif #ifndef NOT_IN_libc static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) internal_function; # ifdef RE_ENABLE_I18N static void build_wcs_buffer (re_string_t *pstr) internal_function; static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr) internal_function; # endif /* RE_ENABLE_I18N */ static void build_upper_buffer (re_string_t *pstr) internal_function; static void re_string_translate_buffer (re_string_t *pstr) internal_function; static unsigned int re_string_context_at (const re_string_t *input, Idx idx, int eflags) internal_function __attribute__ ((pure)); #endif #define re_string_peek_byte(pstr, offset) \ ((pstr)->mbs[(pstr)->cur_idx + offset]) #define re_string_fetch_byte(pstr) \ ((pstr)->mbs[(pstr)->cur_idx++]) #define re_string_first_byte(pstr, idx) \ ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF) #define re_string_is_single_byte_char(pstr, idx) \ ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \ || (pstr)->wcs[(idx) + 1] != WEOF)) #define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx) #define re_string_cur_idx(pstr) ((pstr)->cur_idx) #define re_string_get_buffer(pstr) ((pstr)->mbs) #define re_string_length(pstr) ((pstr)->len) #define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx]) #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) #if defined _LIBC || HAVE_ALLOCA # include #endif #ifndef _LIBC # if HAVE_ALLOCA /* The OS usually guarantees only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely allocate anything larger than 4096 bytes. Also care for the possibility of a few compiler-allocated temporary stack slots. */ # define __libc_use_alloca(n) ((n) < 4032) # else /* alloca is implemented with malloc, so just use malloc. */ # define __libc_use_alloca(n) 0 # undef alloca # define alloca(n) malloc (n) # endif #endif #ifdef _LIBC # define MALLOC_0_IS_NONNULL 1 #elif !defined MALLOC_0_IS_NONNULL # define MALLOC_0_IS_NONNULL 0 #endif #ifndef MAX # define MAX(a,b) ((a) < (b) ? (b) : (a)) #endif #ifndef MIN # define MIN(a,b) ((a) < (b) ? (a) : (b)) #endif #define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) #define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) #define re_free(p) free (p) struct bin_tree_t { struct bin_tree_t *parent; struct bin_tree_t *left; struct bin_tree_t *right; struct bin_tree_t *first; struct bin_tree_t *next; re_token_t token; /* 'node_idx' is the index in dfa->nodes, if 'type' == 0. Otherwise 'type' indicate the type of this node. */ Idx node_idx; }; typedef struct bin_tree_t bin_tree_t; #define BIN_TREE_STORAGE_SIZE \ ((1024 - sizeof (void *)) / sizeof (bin_tree_t)) struct bin_tree_storage_t { struct bin_tree_storage_t *next; bin_tree_t data[BIN_TREE_STORAGE_SIZE]; }; typedef struct bin_tree_storage_t bin_tree_storage_t; #define CONTEXT_WORD 1 #define CONTEXT_NEWLINE (CONTEXT_WORD << 1) #define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1) #define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1) #define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD) #define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE) #define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF) #define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF) #define IS_ORDINARY_CONTEXT(c) ((c) == 0) #define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_') #define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR) #define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_') #define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR) #define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \ ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\ || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context))) #define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \ ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \ || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context))) struct re_dfastate_t { re_hashval_t hash; re_node_set nodes; re_node_set non_eps_nodes; re_node_set inveclosure; re_node_set *entrance_nodes; struct re_dfastate_t **trtable, **word_trtable; unsigned int context : 4; unsigned int halt : 1; /* If this state can accept "multi byte". Note that we refer to multibyte characters, and multi character collating elements as "multi byte". */ unsigned int accept_mb : 1; /* If this state has backreference node(s). */ unsigned int has_backref : 1; unsigned int has_constraint : 1; }; typedef struct re_dfastate_t re_dfastate_t; struct re_state_table_entry { Idx num; Idx alloc; re_dfastate_t **array; }; /* Array type used in re_sub_match_last_t and re_sub_match_top_t. */ typedef struct { Idx next_idx; Idx alloc; re_dfastate_t **array; } state_array_t; /* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */ typedef struct { Idx node; Idx str_idx; /* The position NODE match at. */ state_array_t path; } re_sub_match_last_t; /* Store information about the node NODE whose type is OP_OPEN_SUBEXP. And information about the node, whose type is OP_CLOSE_SUBEXP, corresponding to NODE is stored in LASTS. */ typedef struct { Idx str_idx; Idx node; state_array_t *path; Idx alasts; /* Allocation size of LASTS. */ Idx nlasts; /* The number of LASTS. */ re_sub_match_last_t **lasts; } re_sub_match_top_t; struct re_backref_cache_entry { Idx node; Idx str_idx; Idx subexp_from; Idx subexp_to; char more; char unused; unsigned short int eps_reachable_subexps_map; }; typedef struct { /* The string object corresponding to the input string. */ re_string_t input; #if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) const re_dfa_t *const dfa; #else const re_dfa_t *dfa; #endif /* EFLAGS of the argument of regexec. */ int eflags; /* Where the matching ends. */ Idx match_last; Idx last_node; /* The state log used by the matcher. */ re_dfastate_t **state_log; Idx state_log_top; /* Back reference cache. */ Idx nbkref_ents; Idx abkref_ents; struct re_backref_cache_entry *bkref_ents; int max_mb_elem_len; Idx nsub_tops; Idx asub_tops; re_sub_match_top_t **sub_tops; } re_match_context_t; typedef struct { re_dfastate_t **sifted_states; re_dfastate_t **limited_states; Idx last_node; Idx last_str_idx; re_node_set limits; } re_sift_context_t; struct re_fail_stack_ent_t { Idx idx; Idx node; regmatch_t *regs; re_node_set eps_via_nodes; }; struct re_fail_stack_t { Idx num; Idx alloc; struct re_fail_stack_ent_t *stack; }; struct re_dfa_t { re_token_t *nodes; size_t nodes_alloc; size_t nodes_len; Idx *nexts; Idx *org_indices; re_node_set *edests; re_node_set *eclosures; re_node_set *inveclosures; struct re_state_table_entry *state_table; re_dfastate_t *init_state; re_dfastate_t *init_state_word; re_dfastate_t *init_state_nl; re_dfastate_t *init_state_begbuf; bin_tree_t *str_tree; bin_tree_storage_t *str_tree_storage; re_bitset_ptr_t sb_char; int str_tree_storage_idx; /* number of subexpressions 're_nsub' is in regex_t. */ re_hashval_t state_hash_mask; Idx init_node; Idx nbackref; /* The number of backreference in this dfa. */ /* Bitmap expressing which backreference is used. */ bitset_word_t used_bkref_map; bitset_word_t completed_bkref_map; unsigned int has_plural_match : 1; /* If this dfa has "multibyte node", which is a backreference or a node which can accept multibyte character or multi character collating element. */ unsigned int has_mb_node : 1; unsigned int is_utf8 : 1; unsigned int map_notascii : 1; unsigned int word_ops_used : 1; int mb_cur_max; bitset_t word_char; reg_syntax_t syntax; Idx *subexp_map; #ifdef DEBUG char* re_str; #endif lock_define (lock) }; #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) #define re_node_set_remove(set,id) \ (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1)) #define re_node_set_empty(p) ((p)->nelem = 0) #define re_node_set_free(set) re_free ((set)->elems) typedef enum { SB_CHAR, MB_CHAR, EQUIV_CLASS, COLL_SYM, CHAR_CLASS } bracket_elem_type; typedef struct { bracket_elem_type type; union { unsigned char ch; unsigned char *name; wchar_t wch; } opr; } bracket_elem_t; /* Functions for bitset_t operation. */ static void bitset_set (bitset_t set, Idx i) { set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS; } static void bitset_clear (bitset_t set, Idx i) { set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS); } static bool bitset_contain (const bitset_t set, Idx i) { return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1; } static void bitset_empty (bitset_t set) { memset (set, '\0', sizeof (bitset_t)); } static void bitset_set_all (bitset_t set) { memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS)); if (SBC_MAX % BITSET_WORD_BITS != 0) set[BITSET_WORDS - 1] = ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1; } static void bitset_copy (bitset_t dest, const bitset_t src) { memcpy (dest, src, sizeof (bitset_t)); } static void __attribute__ ((unused)) bitset_not (bitset_t set) { int bitset_i; for (bitset_i = 0; bitset_i < SBC_MAX / BITSET_WORD_BITS; ++bitset_i) set[bitset_i] = ~set[bitset_i]; if (SBC_MAX % BITSET_WORD_BITS != 0) set[BITSET_WORDS - 1] = ((((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1) & ~set[BITSET_WORDS - 1]); } static void __attribute__ ((unused)) bitset_merge (bitset_t dest, const bitset_t src) { int bitset_i; for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) dest[bitset_i] |= src[bitset_i]; } static void __attribute__ ((unused)) bitset_mask (bitset_t dest, const bitset_t src) { int bitset_i; for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) dest[bitset_i] &= src[bitset_i]; } #ifdef RE_ENABLE_I18N /* Functions for re_string. */ static int internal_function __attribute__ ((pure, unused)) re_string_char_size_at (const re_string_t *pstr, Idx idx) { int byte_idx; if (pstr->mb_cur_max == 1) return 1; for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx) if (pstr->wcs[idx + byte_idx] != WEOF) break; return byte_idx; } static wint_t internal_function __attribute__ ((pure, unused)) re_string_wchar_at (const re_string_t *pstr, Idx idx) { if (pstr->mb_cur_max == 1) return (wint_t) pstr->mbs[idx]; return (wint_t) pstr->wcs[idx]; } # ifndef NOT_IN_libc static int internal_function __attribute__ ((pure, unused)) re_string_elem_size_at (const re_string_t *pstr, Idx idx) { # ifdef _LIBC const unsigned char *p, *extra; const int32_t *table, *indirect; # include uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); if (nrules != 0) { table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); p = pstr->mbs + idx; findidx (&p, pstr->len - idx); return p - pstr->mbs - idx; } else # endif /* _LIBC */ return 1; } # endif #endif /* RE_ENABLE_I18N */ #ifndef __GNUC_PREREQ # if defined __GNUC__ && defined __GNUC_MINOR__ # define __GNUC_PREREQ(maj, min) \ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) # else # define __GNUC_PREREQ(maj, min) 0 # endif #endif #if __GNUC_PREREQ (3,4) # undef __attribute_warn_unused_result__ # define __attribute_warn_unused_result__ \ __attribute__ ((__warn_unused_result__)) #else # define __attribute_warn_unused_result__ /* empty */ #endif #endif /* _REGEX_INTERNAL_H */ lftp-4.6.3a/lib/sys_socket.c0000644000015000007670000000013412122621313012642 00000000000000#include #define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE #include "sys/socket.h" lftp-4.6.3a/lib/exitfail.h0000644000015000007670000000140212466374011012300 00000000000000/* Failure exit status Copyright (C) 2002, 2009-2015 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 . */ extern int volatile exit_failure; lftp-4.6.3a/lib/sha1.h0000644000015000007670000000632512466374012011341 00000000000000/* Declarations of functions and data types used for SHA1 sum library functions. Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2015 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 . */ #ifndef SHA1_H # define SHA1_H 1 # include # include # if HAVE_OPENSSL_SHA1 # include # endif # ifdef __cplusplus extern "C" { # endif #define SHA1_DIGEST_SIZE 20 # if HAVE_OPENSSL_SHA1 # define GL_OPENSSL_NAME 1 # include "gl_openssl.h" # else /* Structure to save state of computation between the single steps. */ struct sha1_ctx { uint32_t A; uint32_t B; uint32_t C; uint32_t D; uint32_t E; uint32_t total[2]; uint32_t buflen; uint32_t buffer[32]; }; /* Initialize structure containing state of computation. */ extern void sha1_init_ctx (struct sha1_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 20 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); /* Put result from CTX in first 20 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf); /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *sha1_buffer (const char *buffer, size_t len, void *resblock); # endif /* Compute SHA1 message digest for bytes read from STREAM. The resulting message digest number will be written into the 20 bytes beginning at RESBLOCK. */ extern int sha1_stream (FILE *stream, void *resblock); # ifdef __cplusplus } # endif #endif lftp-4.6.3a/lib/isnanl.c0000644000015000007670000000152512466374011011760 00000000000000/* Test for NaN that does not need libm. Copyright (C) 2007, 2009-2015 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 . */ /* Written by Bruno Haible , 2007. */ #define USE_LONG_DOUBLE #include "isnan.c" lftp-4.6.3a/lib/iconv.in.h0000644000015000007670000000674412466374011012234 00000000000000/* A GNU-like . Copyright (C) 2007-2015 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 . */ #ifndef _@GUARD_PREFIX@_ICONV_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_ICONV_H@ #ifndef _@GUARD_PREFIX@_ICONV_H #define _@GUARD_PREFIX@_ICONV_H /* 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. */ #if @GNULIB_ICONV@ # if @REPLACE_ICONV_OPEN@ /* An iconv_open wrapper that supports the IANA standardized encoding names ("ISO-8859-1" etc.) as far as possible. */ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define iconv_open rpl_iconv_open # endif _GL_FUNCDECL_RPL (iconv_open, iconv_t, (const char *tocode, const char *fromcode) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (iconv_open, iconv_t, (const char *tocode, const char *fromcode)); # else _GL_CXXALIAS_SYS (iconv_open, iconv_t, (const char *tocode, const char *fromcode)); # endif _GL_CXXALIASWARN (iconv_open); #endif #if @REPLACE_ICONV_UTF@ /* Special constants for supporting UTF-{16,32}{BE,LE} encodings. Not public. */ # define _ICONV_UTF8_UTF16BE (iconv_t)(-161) # define _ICONV_UTF8_UTF16LE (iconv_t)(-162) # define _ICONV_UTF8_UTF32BE (iconv_t)(-163) # define _ICONV_UTF8_UTF32LE (iconv_t)(-164) # define _ICONV_UTF16BE_UTF8 (iconv_t)(-165) # define _ICONV_UTF16LE_UTF8 (iconv_t)(-166) # define _ICONV_UTF32BE_UTF8 (iconv_t)(-167) # define _ICONV_UTF32LE_UTF8 (iconv_t)(-168) #endif #if @GNULIB_ICONV@ # if @REPLACE_ICONV@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define iconv rpl_iconv # endif _GL_FUNCDECL_RPL (iconv, size_t, (iconv_t cd, @ICONV_CONST@ char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)); _GL_CXXALIAS_RPL (iconv, size_t, (iconv_t cd, @ICONV_CONST@ char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)); # else _GL_CXXALIAS_SYS (iconv, size_t, (iconv_t cd, @ICONV_CONST@ char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)); # endif _GL_CXXALIASWARN (iconv); # ifndef ICONV_CONST # define ICONV_CONST @ICONV_CONST@ # endif #endif #if @GNULIB_ICONV@ # if @REPLACE_ICONV@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define iconv_close rpl_iconv_close # endif _GL_FUNCDECL_RPL (iconv_close, int, (iconv_t cd)); _GL_CXXALIAS_RPL (iconv_close, int, (iconv_t cd)); # else _GL_CXXALIAS_SYS (iconv_close, int, (iconv_t cd)); # endif _GL_CXXALIASWARN (iconv_close); #endif #endif /* _@GUARD_PREFIX@_ICONV_H */ #endif /* _@GUARD_PREFIX@_ICONV_H */ lftp-4.6.3a/lib/mbsrtowcs-state.c0000644000015000007670000000312412466374011013632 00000000000000/* Convert string to wide string. Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. 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 . */ #include #include /* Internal state used by the functions mbsrtowcs() and mbsnrtowcs(). */ mbstate_t _gl_mbsrtowcs_state /* The state must initially be in the "initial state"; so, zero-initialize it. On most systems, putting it into BSS is sufficient. Not so on Mac OS X 10.3, see . When it needs an initializer, use 0 or {0} as initializer? 0 only works when mbstate_t is a scalar type (such as when gnulib defines it, or on AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)). */ #if defined __ELF__ /* On ELF systems, variables in BSS behave well. */ #else /* Use braces, to be on the safe side. */ = { 0 } #endif ; lftp-4.6.3a/lib/quote.h0000644000015000007670000000350212466374011011633 00000000000000/* quote.h - prototypes for quote.c Copyright (C) 1998-2001, 2003, 2009-2015 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 . */ #ifndef QUOTE_H_ # define QUOTE_H_ 1 # include /* The quoting options used by quote_n and quote. Its type is incomplete, so it's useful only in expressions like '"e_quoting_options'. */ extern struct quoting_options quote_quoting_options; /* Return an unambiguous printable representation of ARG (of size ARGSIZE), allocated in slot N, suitable for diagnostics. If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE. */ char const *quote_n_mem (int n, char const *arg, size_t argsize); /* Return an unambiguous printable representation of ARG (of size ARGSIZE), suitable for diagnostics. If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE. */ char const *quote_mem (char const *arg, size_t argsize); /* Return an unambiguous printable representation of ARG, allocated in slot N, suitable for diagnostics. */ char const *quote_n (int n, char const *arg); /* Return an unambiguous printable representation of ARG, suitable for diagnostics. */ char const *quote (char const *arg); #endif /* !QUOTE_H_ */ lftp-4.6.3a/lib/strdup.c0000644000015000007670000000247012466374012012016 00000000000000/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2015 Free Software Foundation, Inc. This file is part of 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, 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 . */ #ifndef _LIBC # include #endif /* Get specification. */ #include #include #undef __strdup #ifdef _LIBC # undef strdup #endif #ifndef weak_alias # define __strdup strdup #endif /* Duplicate S, returning an identical malloc'd string. */ char * __strdup (const char *s) { size_t len = strlen (s) + 1; void *new = malloc (len); if (new == NULL) return NULL; return (char *) memcpy (new, s, len); } #ifdef libc_hidden_def libc_hidden_def (__strdup) #endif #ifdef weak_alias weak_alias (__strdup, strdup) #endif lftp-4.6.3a/lib/strptime.c0000644000015000007670000010750412466374012012350 00000000000000/* Copyright (C) 2002, 2004-2005, 2007, 2009-2015 Free Software Foundation, Inc. This file is part of 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, 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 . */ #ifndef _LIBC # include #endif #include #include #include #ifdef _LIBC # include #endif #include #include #include #ifdef _LIBC # include "../locale/localeinfo.h" #endif #ifndef _LIBC enum ptime_locale_status { not, loc, raw }; #endif #define match_char(ch1, ch2) if (ch1 != ch2) return NULL #if defined _LIBC && defined __GNUC__ && __GNUC__ >= 2 # define match_string(cs1, s2) \ ({ size_t len = strlen (cs1); \ int result = __strncasecmp_l ((cs1), (s2), len, locale) == 0; \ if (result) (s2) += len; \ result; }) #else /* Oh come on. Get a reasonable compiler. */ # define match_string(cs1, s2) \ (strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1)) #endif /* We intentionally do not use isdigit() for testing because this will lead to problems with the wide character version. */ #define get_number(from, to, n) \ do { \ int __n = n; \ val = 0; \ while (*rp == ' ') \ ++rp; \ if (*rp < '0' || *rp > '9') \ return NULL; \ do { \ val *= 10; \ val += *rp++ - '0'; \ } while (--__n > 0 && val * 10 <= to && *rp >= '0' && *rp <= '9'); \ if (val < from || val > to) \ return NULL; \ } while (0) #ifdef _NL_CURRENT # define get_alt_number(from, to, n) \ ({ \ __label__ do_normal; \ \ if (*decided != raw) \ { \ val = _nl_parse_alt_digit (&rp HELPER_LOCALE_ARG); \ if (val == -1 && *decided != loc) \ { \ *decided = loc; \ goto do_normal; \ } \ if (val < from || val > to) \ return NULL; \ } \ else \ { \ do_normal: \ get_number (from, to, n); \ } \ 0; \ }) #else # define get_alt_number(from, to, n) \ /* We don't have the alternate representation. */ \ get_number(from, to, n) #endif #define recursive(new_fmt) \ (*(new_fmt) != '\0' \ && (rp = __strptime_internal (rp, (new_fmt), tm, \ decided, era_cnt LOCALE_ARG)) != NULL) #ifdef _LIBC /* This is defined in locale/C-time.c in the GNU libc. */ extern const struct locale_data _nl_C_LC_TIME attribute_hidden; # define weekday_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (DAY_1)].string) # define ab_weekday_name \ (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string) # define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string) # define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string) # define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string) # define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string) # define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string) # define HERE_PM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (PM_STR)].string) # define HERE_T_FMT_AMPM \ (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT_AMPM)].string) # define HERE_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT)].string) # define strncasecmp(s1, s2, n) __strncasecmp (s1, s2, n) #else static char const weekday_name[][10] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; static char const ab_weekday_name[][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static char const month_name[][10] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; static char const ab_month_name[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; # define HERE_D_T_FMT "%a %b %e %H:%M:%S %Y" # define HERE_D_FMT "%m/%d/%y" # define HERE_AM_STR "AM" # define HERE_PM_STR "PM" # define HERE_T_FMT_AMPM "%I:%M:%S %p" # define HERE_T_FMT "%H:%M:%S" static const unsigned short int __mon_yday[2][13] = { /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, /* Leap years. */ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; #endif #if defined _LIBC /* We use this code also for the extended locale handling where the function gets as an additional argument the locale which has to be used. To access the values we have to redefine the _NL_CURRENT macro. */ # define strptime __strptime_l # undef _NL_CURRENT # define _NL_CURRENT(category, item) \ (current->values[_NL_ITEM_INDEX (item)].string) # undef _NL_CURRENT_WORD # define _NL_CURRENT_WORD(category, item) \ (current->values[_NL_ITEM_INDEX (item)].word) # define LOCALE_PARAM , locale # define LOCALE_ARG , locale # define LOCALE_PARAM_PROTO , __locale_t locale # define LOCALE_PARAM_DECL __locale_t locale; # define HELPER_LOCALE_ARG , current # define ISSPACE(Ch) __isspace_l (Ch, locale) #else # define LOCALE_PARAM # define LOCALE_ARG # define LOCALE_PARAM_DECL # define LOCALE_PARAM_PROTO # define HELPER_LOCALE_ARG # define ISSPACE(Ch) isspace (Ch) #endif #ifndef __isleap /* Nonzero if YEAR is a leap year (every 4 years, except every 100th isn't, and every 400th is). */ # define __isleap(year) \ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) #endif /* Compute the day of the week. */ static void day_of_the_week (struct tm *tm) { /* We know that January 1st 1970 was a Thursday (= 4). Compute the difference between this data in the one on TM and so determine the weekday. */ int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2); int wday = (-473 + (365 * (tm->tm_year - 70)) + (corr_year / 4) - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0) + (((corr_year / 4) / 25) / 4) + __mon_yday[0][tm->tm_mon] + tm->tm_mday - 1); tm->tm_wday = ((wday % 7) + 7) % 7; } /* Compute the day of the year. */ static void day_of_the_year (struct tm *tm) { tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon] + (tm->tm_mday - 1)); } #ifdef _LIBC char * internal_function #else static char * #endif __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM) const char *rp; const char *fmt; struct tm *tm; enum ptime_locale_status *decided; int era_cnt; LOCALE_PARAM_DECL { #ifdef _LIBC struct locale_data *const current = locale->__locales[LC_TIME]; #endif int cnt; size_t val; int have_I, is_pm; int century, want_century; int want_era; int have_wday, want_xday; int have_yday; int have_mon, have_mday; int have_uweek, have_wweek; int week_no; #ifdef _NL_CURRENT size_t num_eras; struct era_entry *era = NULL; const char *rp_backup; #endif have_I = is_pm = 0; century = -1; want_century = 0; want_era = 0; week_no = 0; have_wday = want_xday = have_yday = have_mon = have_mday = have_uweek = 0; have_wweek = 0; while (*fmt != '\0') { /* A white space in the format string matches 0 more or white space in the input string. */ if (ISSPACE (*fmt)) { while (ISSPACE (*rp)) ++rp; ++fmt; continue; } /* Any character but '%' must be matched by the same character in the iput string. */ if (*fmt != '%') { match_char (*fmt++, *rp++); continue; } ++fmt; #ifndef _NL_CURRENT /* We need this for handling the 'E' modifier. */ start_over: #else /* Make back up of current processing pointer. */ rp_backup = rp; #endif switch (*fmt++) { case '%': /* Match the '%' character itself. */ match_char ('%', *rp++); break; case 'a': case 'A': /* Match day of week. */ for (cnt = 0; cnt < 7; ++cnt) { #ifdef _NL_CURRENT if (*decided !=raw) { if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp)) { if (*decided == not && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt), weekday_name[cnt])) *decided = loc; break; } if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp)) { if (*decided == not && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), ab_weekday_name[cnt])) *decided = loc; break; } } #endif if (*decided != loc && (match_string (weekday_name[cnt], rp) || match_string (ab_weekday_name[cnt], rp))) { *decided = raw; break; } } if (cnt == 7) /* Does not match a weekday name. */ return NULL; tm->tm_wday = cnt; have_wday = 1; break; case 'b': case 'B': case 'h': /* Match month name. */ for (cnt = 0; cnt < 12; ++cnt) { #ifdef _NL_CURRENT if (*decided !=raw) { if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp)) { if (*decided == not && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt), month_name[cnt])) *decided = loc; break; } if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp)) { if (*decided == not && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), ab_month_name[cnt])) *decided = loc; break; } } #endif if (match_string (month_name[cnt], rp) || match_string (ab_month_name[cnt], rp)) { *decided = raw; break; } } if (cnt == 12) /* Does not match a month name. */ return NULL; tm->tm_mon = cnt; want_xday = 1; break; case 'c': /* Match locale's date and time format. */ #ifdef _NL_CURRENT if (*decided != raw) { if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT))) { if (*decided == loc) return NULL; else rp = rp_backup; } else { if (*decided == not && strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT)) *decided = loc; want_xday = 1; break; } *decided = raw; } #endif if (!recursive (HERE_D_T_FMT)) return NULL; want_xday = 1; break; case 'C': /* Match century number. */ #ifdef _NL_CURRENT match_century: #endif get_number (0, 99, 2); century = val; want_xday = 1; break; case 'd': case 'e': /* Match day of month. */ get_number (1, 31, 2); tm->tm_mday = val; have_mday = 1; want_xday = 1; break; case 'F': if (!recursive ("%Y-%m-%d")) return NULL; want_xday = 1; break; case 'x': #ifdef _NL_CURRENT if (*decided != raw) { if (!recursive (_NL_CURRENT (LC_TIME, D_FMT))) { if (*decided == loc) return NULL; else rp = rp_backup; } else { if (*decided == not && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT)) *decided = loc; want_xday = 1; break; } *decided = raw; } #endif /* Fall through. */ case 'D': /* Match standard day format. */ if (!recursive (HERE_D_FMT)) return NULL; want_xday = 1; break; case 'k': case 'H': /* Match hour in 24-hour clock. */ get_number (0, 23, 2); tm->tm_hour = val; have_I = 0; break; case 'l': /* Match hour in 12-hour clock. GNU extension. */ case 'I': /* Match hour in 12-hour clock. */ get_number (1, 12, 2); tm->tm_hour = val % 12; have_I = 1; break; case 'j': /* Match day number of year. */ get_number (1, 366, 3); tm->tm_yday = val - 1; have_yday = 1; break; case 'm': /* Match number of month. */ get_number (1, 12, 2); tm->tm_mon = val - 1; have_mon = 1; want_xday = 1; break; case 'M': /* Match minute. */ get_number (0, 59, 2); tm->tm_min = val; break; case 'n': case 't': /* Match any white space. */ while (ISSPACE (*rp)) ++rp; break; case 'p': /* Match locale's equivalent of AM/PM. */ #ifdef _NL_CURRENT if (*decided != raw) { if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp)) { if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR)) *decided = loc; break; } if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp)) { if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR)) *decided = loc; is_pm = 1; break; } *decided = raw; } #endif if (!match_string (HERE_AM_STR, rp)) { if (match_string (HERE_PM_STR, rp)) is_pm = 1; else return NULL; } break; case 'r': #ifdef _NL_CURRENT if (*decided != raw) { if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM))) { if (*decided == loc) return NULL; else rp = rp_backup; } else { if (*decided == not && strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM), HERE_T_FMT_AMPM)) *decided = loc; break; } *decided = raw; } #endif if (!recursive (HERE_T_FMT_AMPM)) return NULL; break; case 'R': if (!recursive ("%H:%M")) return NULL; break; case 's': { /* The number of seconds may be very high so we cannot use the 'get_number' macro. Instead read the number character for character and construct the result while doing this. */ time_t secs = 0; if (*rp < '0' || *rp > '9') /* We need at least one digit. */ return NULL; do { secs *= 10; secs += *rp++ - '0'; } while (*rp >= '0' && *rp <= '9'); if (localtime_r (&secs, tm) == NULL) /* Error in function. */ return NULL; } break; case 'S': get_number (0, 61, 2); tm->tm_sec = val; break; case 'X': #ifdef _NL_CURRENT if (*decided != raw) { if (!recursive (_NL_CURRENT (LC_TIME, T_FMT))) { if (*decided == loc) return NULL; else rp = rp_backup; } else { if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT)) *decided = loc; break; } *decided = raw; } #endif /* Fall through. */ case 'T': if (!recursive (HERE_T_FMT)) return NULL; break; case 'u': get_number (1, 7, 1); tm->tm_wday = val % 7; have_wday = 1; break; case 'g': get_number (0, 99, 2); /* XXX This cannot determine any field in TM. */ break; case 'G': if (*rp < '0' || *rp > '9') return NULL; /* XXX Ignore the number since we would need some more information to compute a real date. */ do ++rp; while (*rp >= '0' && *rp <= '9'); break; case 'U': get_number (0, 53, 2); week_no = val; have_uweek = 1; break; case 'W': get_number (0, 53, 2); week_no = val; have_wweek = 1; break; case 'V': get_number (0, 53, 2); /* XXX This cannot determine any field in TM without some information. */ break; case 'w': /* Match number of weekday. */ get_number (0, 6, 1); tm->tm_wday = val; have_wday = 1; break; case 'y': #ifdef _NL_CURRENT match_year_in_century: #endif /* Match year within century. */ get_number (0, 99, 2); /* The "Year 2000: The Millennium Rollover" paper suggests that values in the range 69-99 refer to the twentieth century. */ tm->tm_year = val >= 69 ? val : val + 100; /* Indicate that we want to use the century, if specified. */ want_century = 1; want_xday = 1; break; case 'Y': /* Match year including century number. */ get_number (0, 9999, 4); tm->tm_year = val - 1900; want_century = 0; want_xday = 1; break; case 'Z': /* XXX How to handle this? */ break; case 'z': /* We recognize two formats: if two digits are given, these specify hours. If fours digits are used, minutes are also specified. */ { bool neg _GL_UNUSED; int n; val = 0; while (*rp == ' ') ++rp; if (*rp != '+' && *rp != '-') return NULL; neg = *rp++ == '-'; n = 0; while (n < 4 && *rp >= '0' && *rp <= '9') { val = val * 10 + *rp++ - '0'; ++n; } if (n == 2) val *= 100; else if (n != 4) /* Only two or four digits recognized. */ return NULL; else { /* We have to convert the minutes into decimal. */ if (val % 100 >= 60) return NULL; val = (val / 100) * 100 + ((val % 100) * 50) / 30; } if (val > 1200) return NULL; #if defined _LIBC || HAVE_TM_GMTOFF tm->tm_gmtoff = (val * 3600) / 100; if (neg) tm->tm_gmtoff = -tm->tm_gmtoff; #endif } break; case 'E': #ifdef _NL_CURRENT switch (*fmt++) { case 'c': /* Match locale's alternate date and time format. */ if (*decided != raw) { const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT); if (*fmt == '\0') fmt = _NL_CURRENT (LC_TIME, D_T_FMT); if (!recursive (fmt)) { if (*decided == loc) return NULL; else rp = rp_backup; } else { if (strcmp (fmt, HERE_D_T_FMT)) *decided = loc; want_xday = 1; break; } *decided = raw; } /* The C locale has no era information, so use the normal representation. */ if (!recursive (HERE_D_T_FMT)) return NULL; want_xday = 1; break; case 'C': if (*decided != raw) { if (era_cnt >= 0) { era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); if (era != NULL && match_string (era->era_name, rp)) { *decided = loc; break; } else return NULL; } num_eras = _NL_CURRENT_WORD (LC_TIME, _NL_TIME_ERA_NUM_ENTRIES); for (era_cnt = 0; era_cnt < (int) num_eras; ++era_cnt, rp = rp_backup) { era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); if (era != NULL && match_string (era->era_name, rp)) { *decided = loc; break; } } if (era_cnt != (int) num_eras) break; era_cnt = -1; if (*decided == loc) return NULL; *decided = raw; } /* The C locale has no era information, so use the normal representation. */ goto match_century; case 'y': if (*decided != raw) { get_number(0, 9999, 4); tm->tm_year = val; want_era = 1; want_xday = 1; want_century = 1; if (era_cnt >= 0) { assert (*decided == loc); era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); bool match = false; if (era != NULL) { int delta = ((tm->tm_year - era->offset) * era->absolute_direction); match = (delta >= 0 && delta < (((int64_t) era->stop_date[0] - (int64_t) era->start_date[0]) * era->absolute_direction)); } if (! match) return NULL; break; } num_eras = _NL_CURRENT_WORD (LC_TIME, _NL_TIME_ERA_NUM_ENTRIES); for (era_cnt = 0; era_cnt < (int) num_eras; ++era_cnt) { era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); if (era != NULL) { int delta = ((tm->tm_year - era->offset) * era->absolute_direction); if (delta >= 0 && delta < (((int64_t) era->stop_date[0] - (int64_t) era->start_date[0]) * era->absolute_direction)) { *decided = loc; break; } } } if (era_cnt != (int) num_eras) break; era_cnt = -1; if (*decided == loc) return NULL; *decided = raw; } goto match_year_in_century; case 'Y': if (*decided != raw) { num_eras = _NL_CURRENT_WORD (LC_TIME, _NL_TIME_ERA_NUM_ENTRIES); for (era_cnt = 0; era_cnt < (int) num_eras; ++era_cnt, rp = rp_backup) { era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); if (era != NULL && recursive (era->era_format)) break; } if (era_cnt == (int) num_eras) { era_cnt = -1; if (*decided == loc) return NULL; else rp = rp_backup; } else { *decided = loc; era_cnt = -1; break; } *decided = raw; } get_number (0, 9999, 4); tm->tm_year = val - 1900; want_century = 0; want_xday = 1; break; case 'x': if (*decided != raw) { const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT); if (*fmt == '\0') fmt = _NL_CURRENT (LC_TIME, D_FMT); if (!recursive (fmt)) { if (*decided == loc) return NULL; else rp = rp_backup; } else { if (strcmp (fmt, HERE_D_FMT)) *decided = loc; break; } *decided = raw; } if (!recursive (HERE_D_FMT)) return NULL; break; case 'X': if (*decided != raw) { const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT); if (*fmt == '\0') fmt = _NL_CURRENT (LC_TIME, T_FMT); if (!recursive (fmt)) { if (*decided == loc) return NULL; else rp = rp_backup; } else { if (strcmp (fmt, HERE_T_FMT)) *decided = loc; break; } *decided = raw; } if (!recursive (HERE_T_FMT)) return NULL; break; default: return NULL; } break; #else /* We have no information about the era format. Just use the normal format. */ if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y' && *fmt != 'x' && *fmt != 'X') /* This is an illegal format. */ return NULL; goto start_over; #endif case 'O': switch (*fmt++) { case 'd': case 'e': /* Match day of month using alternate numeric symbols. */ get_alt_number (1, 31, 2); tm->tm_mday = val; have_mday = 1; want_xday = 1; break; case 'H': /* Match hour in 24-hour clock using alternate numeric symbols. */ get_alt_number (0, 23, 2); tm->tm_hour = val; have_I = 0; break; case 'I': /* Match hour in 12-hour clock using alternate numeric symbols. */ get_alt_number (1, 12, 2); tm->tm_hour = val % 12; have_I = 1; break; case 'm': /* Match month using alternate numeric symbols. */ get_alt_number (1, 12, 2); tm->tm_mon = val - 1; have_mon = 1; want_xday = 1; break; case 'M': /* Match minutes using alternate numeric symbols. */ get_alt_number (0, 59, 2); tm->tm_min = val; break; case 'S': /* Match seconds using alternate numeric symbols. */ get_alt_number (0, 61, 2); tm->tm_sec = val; break; case 'U': get_alt_number (0, 53, 2); week_no = val; have_uweek = 1; break; case 'W': get_alt_number (0, 53, 2); week_no = val; have_wweek = 1; break; case 'V': get_alt_number (0, 53, 2); /* XXX This cannot determine any field in TM without further information. */ break; case 'w': /* Match number of weekday using alternate numeric symbols. */ get_alt_number (0, 6, 1); tm->tm_wday = val; have_wday = 1; break; case 'y': /* Match year within century using alternate numeric symbols. */ get_alt_number (0, 99, 2); tm->tm_year = val >= 69 ? val : val + 100; want_xday = 1; break; default: return NULL; } break; default: return NULL; } } if (have_I && is_pm) tm->tm_hour += 12; if (century != -1) { if (want_century) tm->tm_year = tm->tm_year % 100 + (century - 19) * 100; else /* Only the century, but not the year. Strange, but so be it. */ tm->tm_year = (century - 19) * 100; } if (era_cnt != -1) { #ifdef _NL_CURRENT era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG); if (era == NULL) return NULL; if (want_era) tm->tm_year = (era->start_date[0] + ((tm->tm_year - era->offset) * era->absolute_direction)); else /* Era start year assumed. */ tm->tm_year = era->start_date[0]; #endif } else if (want_era) { /* No era found but we have seen an E modifier. Rectify some values. */ if (want_century && century == -1 && tm->tm_year < 69) tm->tm_year += 100; } if (want_xday && !have_wday) { if ( !(have_mon && have_mday) && have_yday) { /* We don't have tm_mon and/or tm_mday, compute them. */ int t_mon = 0; while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday) t_mon++; if (!have_mon) tm->tm_mon = t_mon - 1; if (!have_mday) tm->tm_mday = (tm->tm_yday - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1); } day_of_the_week (tm); } if (want_xday && !have_yday) day_of_the_year (tm); if ((have_uweek || have_wweek) && have_wday) { int save_wday = tm->tm_wday; int save_mday = tm->tm_mday; int save_mon = tm->tm_mon; int w_offset = have_uweek ? 0 : 1; tm->tm_mday = 1; tm->tm_mon = 0; day_of_the_week (tm); if (have_mday) tm->tm_mday = save_mday; if (have_mon) tm->tm_mon = save_mon; if (!have_yday) tm->tm_yday = ((7 - (tm->tm_wday - w_offset)) % 7 + (week_no - 1) *7 + save_wday - w_offset); if (!have_mday || !have_mon) { int t_mon = 0; while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday) t_mon++; if (!have_mon) tm->tm_mon = t_mon - 1; if (!have_mday) tm->tm_mday = (tm->tm_yday - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1); } tm->tm_wday = save_wday; } return (char *) rp; } char * strptime (buf, format, tm LOCALE_PARAM) const char *restrict buf; const char *restrict format; struct tm *restrict tm; LOCALE_PARAM_DECL { enum ptime_locale_status decided; #ifdef _NL_CURRENT decided = not; #else decided = raw; #endif return __strptime_internal (buf, format, tm, &decided, -1 LOCALE_ARG); } #ifdef _LIBC weak_alias (__strptime_l, strptime_l) #endif lftp-4.6.3a/lib/iconv_open-solaris.gperf0000644000015000007670000000154312122621312015152 00000000000000struct mapping { int standard_name; const char vendor_name[10 + 1]; }; %struct-type %language=ANSI-C %define slot-name standard_name %define hash-function-name mapping_hash %define lookup-function-name mapping_lookup %readonly-tables %global-table %define word-array-name mappings %pic %% # On Solaris 10, look in the "iconv -l" output. Some aliases are advertised but # not actually supported by the iconv() function and by the 'iconv' program. # For example: # $ echo abc | iconv -f 646 -t ISO-8859-1 # Not supported 646 to ISO-8859-1 # $ echo abc | iconv -f 646 -t ISO8859-1 $ abc ASCII, "646" ISO-8859-1, "ISO8859-1" ISO-8859-2, "ISO8859-2" ISO-8859-3, "ISO8859-3" ISO-8859-4, "ISO8859-4" ISO-8859-5, "ISO8859-5" ISO-8859-6, "ISO8859-6" ISO-8859-7, "ISO8859-7" ISO-8859-8, "ISO8859-8" ISO-8859-9, "ISO8859-9" ISO-8859-15, "ISO8859-15" CP1251, "ansi-1251" lftp-4.6.3a/lib/argmatch.h0000644000015000007670000000770712466374011012277 00000000000000/* argmatch.h -- definitions and prototypes for argmatch.c Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2015 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 . */ /* Written by David MacKenzie Modified by Akim Demaille */ #ifndef ARGMATCH_H_ # define ARGMATCH_H_ 1 # include # include "verify.h" #ifdef __cplusplus extern "C" { #endif # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) /* Assert there are as many real arguments as there are values (argument list ends with a NULL guard). */ # define ARGMATCH_VERIFY(Arglist, Vallist) \ verify (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1) /* Return the index of the element of ARGLIST (NULL terminated) that matches with ARG. If VALLIST is not NULL, then use it to resolve false ambiguities (i.e., different matches of ARG but corresponding to the same values in VALLIST). */ ptrdiff_t argmatch (char const *arg, char const *const *arglist, char const *vallist, size_t valsize) _GL_ATTRIBUTE_PURE; # define ARGMATCH(Arg, Arglist, Vallist) \ argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist)) /* xargmatch calls this function when it fails. This function should not return. By default, this is a function that calls ARGMATCH_DIE which in turn defaults to 'exit (exit_failure)'. */ typedef void (*argmatch_exit_fn) (void); extern argmatch_exit_fn argmatch_die; /* Report on stderr why argmatch failed. Report correct values. */ void argmatch_invalid (char const *context, char const *value, ptrdiff_t problem); /* Left for compatibility with the old name invalid_arg */ # define invalid_arg(Context, Value, Problem) \ argmatch_invalid (Context, Value, Problem) /* Report on stderr the list of possible arguments. */ void argmatch_valid (char const *const *arglist, char const *vallist, size_t valsize); # define ARGMATCH_VALID(Arglist, Vallist) \ argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist)) /* Same as argmatch, but upon failure, report an explanation of the failure, and exit using the function EXIT_FN. */ ptrdiff_t __xargmatch_internal (char const *context, char const *arg, char const *const *arglist, char const *vallist, size_t valsize, argmatch_exit_fn exit_fn); /* Programmer friendly interface to __xargmatch_internal. */ # define XARGMATCH(Context, Arg, Arglist, Vallist) \ ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \ (char const *) (Vallist), \ sizeof *(Vallist), \ argmatch_die)]) /* Convert a value into a corresponding argument. */ char const *argmatch_to_argument (char const *value, char const *const *arglist, char const *vallist, size_t valsize) _GL_ATTRIBUTE_PURE; # define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \ argmatch_to_argument (Value, Arglist, \ (char const *) (Vallist), sizeof *(Vallist)) #ifdef __cplusplus } #endif #endif /* ARGMATCH_H_ */ lftp-4.6.3a/lib/mbswidth.c0000644000015000007670000001425012466374011012314 00000000000000/* Determine the number of screen columns needed for a string. Copyright (C) 2000-2015 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 . */ /* Written by Bruno Haible . */ #include /* Specification. */ #include "mbswidth.h" /* Get MB_CUR_MAX. */ #include #include /* Get isprint(). */ #include /* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ #include /* Get iswcntrl(). */ #include /* Get INT_MAX. */ #include /* Returns the number of columns needed to represent the multibyte character string pointed to by STRING. If a non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. With flags = MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE, this is the multibyte analogue of the wcswidth function. */ int mbswidth (const char *string, int flags) { return mbsnwidth (string, strlen (string), flags); } /* Returns the number of columns needed to represent the multibyte character string pointed to by STRING of length NBYTES. If a non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. */ int mbsnwidth (const char *string, size_t nbytes, int flags) { const char *p = string; const char *plimit = p + nbytes; int width; width = 0; if (MB_CUR_MAX > 1) { while (p < plimit) switch (*p) { case ' ': case '!': case '"': case '#': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': case '~': /* These characters are printable ASCII characters. */ p++; width++; break; default: /* If we have a multibyte sequence, scan it up to its end. */ { mbstate_t mbstate; memset (&mbstate, 0, sizeof mbstate); do { wchar_t wc; size_t bytes; int w; bytes = mbrtowc (&wc, p, plimit - p, &mbstate); if (bytes == (size_t) -1) /* An invalid multibyte sequence was encountered. */ { if (!(flags & MBSW_REJECT_INVALID)) { p++; width++; break; } else return -1; } if (bytes == (size_t) -2) /* An incomplete multibyte character at the end. */ { if (!(flags & MBSW_REJECT_INVALID)) { p = plimit; width++; break; } else return -1; } if (bytes == 0) /* A null wide character was encountered. */ bytes = 1; w = wcwidth (wc); if (w >= 0) /* A printable multibyte character. */ { if (w > INT_MAX - width) goto overflow; width += w; } else /* An unprintable multibyte character. */ if (!(flags & MBSW_REJECT_UNPRINTABLE)) { if (!iswcntrl (wc)) { if (width == INT_MAX) goto overflow; width++; } } else return -1; p += bytes; } while (! mbsinit (&mbstate)); } break; } return width; } while (p < plimit) { unsigned char c = (unsigned char) *p++; if (isprint (c)) { if (width == INT_MAX) goto overflow; width++; } else if (!(flags & MBSW_REJECT_UNPRINTABLE)) { if (!iscntrl (c)) { if (width == INT_MAX) goto overflow; width++; } } else return -1; } return width; overflow: return INT_MAX; } lftp-4.6.3a/lib/printf-args.c0000644000015000007670000001463212466374011012733 00000000000000/* Decomposed printf argument list. Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2015 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 . */ /* This file can be parametrized with the following macros: ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. PRINTF_FETCHARGS Name of the function to be defined. STATIC Set to 'static' to declare the function static. */ #ifndef PRINTF_FETCHARGS # include #endif /* Specification. */ #ifndef PRINTF_FETCHARGS # include "printf-args.h" #endif #ifdef STATIC STATIC #endif int PRINTF_FETCHARGS (va_list args, arguments *a) { size_t i; argument *ap; for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++) switch (ap->type) { case TYPE_SCHAR: ap->a.a_schar = va_arg (args, /*signed char*/ int); break; case TYPE_UCHAR: ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); break; case TYPE_SHORT: ap->a.a_short = va_arg (args, /*short*/ int); break; case TYPE_USHORT: ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); break; case TYPE_INT: ap->a.a_int = va_arg (args, int); break; case TYPE_UINT: ap->a.a_uint = va_arg (args, unsigned int); break; case TYPE_LONGINT: ap->a.a_longint = va_arg (args, long int); break; case TYPE_ULONGINT: ap->a.a_ulongint = va_arg (args, unsigned long int); break; #if HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: ap->a.a_longlongint = va_arg (args, long long int); break; case TYPE_ULONGLONGINT: ap->a.a_ulonglongint = va_arg (args, unsigned long long int); break; #endif case TYPE_DOUBLE: ap->a.a_double = va_arg (args, double); break; case TYPE_LONGDOUBLE: ap->a.a_longdouble = va_arg (args, long double); break; case TYPE_CHAR: ap->a.a_char = va_arg (args, int); break; #if HAVE_WINT_T case TYPE_WIDE_CHAR: /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by default argument promotions", this is not the case in mingw32, where wint_t is 'unsigned short'. */ ap->a.a_wide_char = (sizeof (wint_t) < sizeof (int) ? (wint_t) va_arg (args, int) : va_arg (args, wint_t)); break; #endif case TYPE_STRING: ap->a.a_string = va_arg (args, const char *); /* A null pointer is an invalid argument for "%s", but in practice it occurs quite frequently in printf statements that produce debug output. Use a fallback in this case. */ if (ap->a.a_string == NULL) ap->a.a_string = "(NULL)"; break; #if HAVE_WCHAR_T case TYPE_WIDE_STRING: ap->a.a_wide_string = va_arg (args, const wchar_t *); /* A null pointer is an invalid argument for "%ls", but in practice it occurs quite frequently in printf statements that produce debug output. Use a fallback in this case. */ if (ap->a.a_wide_string == NULL) { static const wchar_t wide_null_string[] = { (wchar_t)'(', (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', (wchar_t)')', (wchar_t)0 }; ap->a.a_wide_string = wide_null_string; } break; #endif case TYPE_POINTER: ap->a.a_pointer = va_arg (args, void *); break; case TYPE_COUNT_SCHAR_POINTER: ap->a.a_count_schar_pointer = va_arg (args, signed char *); break; case TYPE_COUNT_SHORT_POINTER: ap->a.a_count_short_pointer = va_arg (args, short *); break; case TYPE_COUNT_INT_POINTER: ap->a.a_count_int_pointer = va_arg (args, int *); break; case TYPE_COUNT_LONGINT_POINTER: ap->a.a_count_longint_pointer = va_arg (args, long int *); break; #if HAVE_LONG_LONG_INT case TYPE_COUNT_LONGLONGINT_POINTER: ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); break; #endif #if ENABLE_UNISTDIO /* The unistdio extensions. */ case TYPE_U8_STRING: ap->a.a_u8_string = va_arg (args, const uint8_t *); /* A null pointer is an invalid argument for "%U", but in practice it occurs quite frequently in printf statements that produce debug output. Use a fallback in this case. */ if (ap->a.a_u8_string == NULL) { static const uint8_t u8_null_string[] = { '(', 'N', 'U', 'L', 'L', ')', 0 }; ap->a.a_u8_string = u8_null_string; } break; case TYPE_U16_STRING: ap->a.a_u16_string = va_arg (args, const uint16_t *); /* A null pointer is an invalid argument for "%lU", but in practice it occurs quite frequently in printf statements that produce debug output. Use a fallback in this case. */ if (ap->a.a_u16_string == NULL) { static const uint16_t u16_null_string[] = { '(', 'N', 'U', 'L', 'L', ')', 0 }; ap->a.a_u16_string = u16_null_string; } break; case TYPE_U32_STRING: ap->a.a_u32_string = va_arg (args, const uint32_t *); /* A null pointer is an invalid argument for "%llU", but in practice it occurs quite frequently in printf statements that produce debug output. Use a fallback in this case. */ if (ap->a.a_u32_string == NULL) { static const uint32_t u32_null_string[] = { '(', 'N', 'U', 'L', 'L', ')', 0 }; ap->a.a_u32_string = u32_null_string; } break; #endif default: /* Unknown type. */ return -1; } return 0; } lftp-4.6.3a/lib/isnand.c0000644000015000007670000000146712466374011011755 00000000000000/* Test for NaN that does not need libm. Copyright (C) 2008-2015 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 . */ /* Written by Bruno Haible , 2008. */ #include "isnan.c" lftp-4.6.3a/lib/strerror.c0000644000015000007670000000404312466374012012355 00000000000000/* strerror.c --- POSIX compatible system error routine Copyright (C) 2007-2015 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 . */ #include /* Specification. */ #include #include #include #include #include #include "intprops.h" #include "strerror-override.h" #include "verify.h" /* Use the system functions, not the gnulib overrides in this file. */ #undef sprintf char * strerror (int n) #undef strerror { static char buf[STACKBUF_LEN]; size_t len; /* Cast away const, due to the historical signature of strerror; callers should not be modifying the string. */ const char *msg = strerror_override (n); if (msg) return (char *) msg; msg = strerror (n); /* Our strerror_r implementation might use the system's strerror buffer, so all other clients of strerror have to see the error copied into a buffer that we manage. This is not thread-safe, even if the system strerror is, but portable programs shouldn't be using strerror if they care about thread-safety. */ if (!msg || !*msg) { static char const fmt[] = "Unknown error %d"; verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n)); sprintf (buf, fmt, n); errno = EINVAL; return buf; } /* Fix STACKBUF_LEN if this ever aborts. */ len = strlen (msg); if (sizeof buf <= len) abort (); return memcpy (buf, msg, len + 1); } lftp-4.6.3a/lib/printf-frexpl.c0000644000015000007670000000210012466374011013262 00000000000000/* Split a 'long double' into fraction and mantissa, for hexadecimal printf. Copyright (C) 2007, 2009-2015 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 . */ #include #if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Specification. */ # include "printf-frexpl.h" # include "printf-frexp.h" long double printf_frexpl (long double x, int *expptr) { return printf_frexp (x, expptr); } #else # define USE_LONG_DOUBLE # include "printf-frexp.c" #endif lftp-4.6.3a/lib/unistd.c0000644000015000007670000000012412122621313011761 00000000000000#include #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE #include "unistd.h" lftp-4.6.3a/lib/string.in.h0000644000015000007670000011741412533305067012421 00000000000000/* A GNU-like . Copyright (C) 1995-1996, 2001-2015 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 . */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined _GL_ALREADY_INCLUDING_STRING_H /* Special invocation convention: - On OS X/NetBSD we have a sequence of nested includes -> -> "string.h" In this situation system _chk variants due to -D_FORTIFY_SOURCE might be used after any replacements defined here. */ #@INCLUDE_NEXT@ @NEXT_STRING_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_STRING_H #define _GL_ALREADY_INCLUDING_STRING_H /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STRING_H@ #undef _GL_ALREADY_INCLUDING_STRING_H #ifndef _@GUARD_PREFIX@_STRING_H #define _@GUARD_PREFIX@_STRING_H /* NetBSD 5.0 mis-defines NULL. */ #include /* MirBSD defines mbslen as a macro. */ #if @GNULIB_MBSLEN@ && defined __MirBSD__ # include #endif /* The __attribute__ feature is available in gcc versions 2.5 and later. The attribute __pure__ was added in gcc 2.96. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else # define _GL_ATTRIBUTE_PURE /* empty */ #endif /* NetBSD 5.0 declares strsignal in , not in . */ /* But in any case avoid namespace pollution on glibc systems. */ #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ && ! defined __GLIBC__ # include #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. */ /* Find the index of the least-significant set bit. */ #if @GNULIB_FFSL@ # if !@HAVE_FFSL@ _GL_FUNCDECL_SYS (ffsl, int, (long int i)); # endif _GL_CXXALIAS_SYS (ffsl, int, (long int i)); _GL_CXXALIASWARN (ffsl); #elif defined GNULIB_POSIXCHECK # undef ffsl # if HAVE_RAW_DECL_FFSL _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); # endif #endif /* Find the index of the least-significant set bit. */ #if @GNULIB_FFSLL@ # if !@HAVE_FFSLL@ _GL_FUNCDECL_SYS (ffsll, int, (long long int i)); # endif _GL_CXXALIAS_SYS (ffsll, int, (long long int i)); _GL_CXXALIASWARN (ffsll); #elif defined GNULIB_POSIXCHECK # undef ffsll # if HAVE_RAW_DECL_FFSLL _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); # endif #endif /* Return the first instance of C within N bytes of S, or NULL. */ #if @GNULIB_MEMCHR@ # if @REPLACE_MEMCHR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define memchr rpl_memchr # endif _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); # else # if ! @HAVE_MEMCHR@ _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: extern "C" { const void * std::memchr (const void *, int, size_t); } extern "C++" { void * std::memchr (void *, int, size_t); } */ _GL_CXXALIAS_SYS_CAST2 (memchr, void *, (void const *__s, int __c, size_t __n), void const *, (void const *__s, int __c, size_t __n)); # endif # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); _GL_CXXALIASWARN1 (memchr, void const *, (void const *__s, int __c, size_t __n)); # else _GL_CXXALIASWARN (memchr); # endif #elif defined GNULIB_POSIXCHECK # undef memchr /* Assume memchr is always declared. */ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " "use gnulib module memchr for portability" ); #endif /* Return the first occurrence of NEEDLE in HAYSTACK. */ #if @GNULIB_MEMMEM@ # if @REPLACE_MEMMEM@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define memmem rpl_memmem # endif _GL_FUNCDECL_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 3))); _GL_CXXALIAS_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len)); # else # if ! @HAVE_DECL_MEMMEM@ _GL_FUNCDECL_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 3))); # endif _GL_CXXALIAS_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len)); # endif _GL_CXXALIASWARN (memmem); #elif defined GNULIB_POSIXCHECK # undef memmem # if HAVE_RAW_DECL_MEMMEM _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " "use gnulib module memmem-simple for portability, " "and module memmem for speed" ); # endif #endif /* Copy N bytes of SRC to DEST, return pointer to bytes after the last written byte. */ #if @GNULIB_MEMPCPY@ # if ! @HAVE_MEMPCPY@ _GL_FUNCDECL_SYS (mempcpy, void *, (void *restrict __dest, void const *restrict __src, size_t __n) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (mempcpy, void *, (void *restrict __dest, void const *restrict __src, size_t __n)); _GL_CXXALIASWARN (mempcpy); #elif defined GNULIB_POSIXCHECK # undef mempcpy # if HAVE_RAW_DECL_MEMPCPY _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " "use gnulib module mempcpy for portability"); # endif #endif /* Search backwards through a block for a byte (specified as an int). */ #if @GNULIB_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const void * std::memrchr (const void *, int, size_t); } extern "C++" { void * std::memrchr (void *, int, size_t); } */ _GL_CXXALIAS_SYS_CAST2 (memrchr, void *, (void const *, int, size_t), void const *, (void const *, int, size_t)); # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); # else _GL_CXXALIASWARN (memrchr); # endif #elif defined GNULIB_POSIXCHECK # undef memrchr # if HAVE_RAW_DECL_MEMRCHR _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " "use gnulib module memrchr for portability"); # endif #endif /* Find the first occurrence of C in S. More efficient than memchr(S,C,N), at the expense of undefined behavior if C does not occur within N bytes. */ #if @GNULIB_RAWMEMCHR@ # if ! @HAVE_RAWMEMCHR@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const void * std::rawmemchr (const void *, int); } extern "C++" { void * std::rawmemchr (void *, int); } */ _GL_CXXALIAS_SYS_CAST2 (rawmemchr, void *, (void const *__s, int __c_in), void const *, (void const *__s, int __c_in)); # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); # else _GL_CXXALIASWARN (rawmemchr); # endif #elif defined GNULIB_POSIXCHECK # undef rawmemchr # if HAVE_RAW_DECL_RAWMEMCHR _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " "use gnulib module rawmemchr for portability"); # endif #endif /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ #if @GNULIB_STPCPY@ # if ! @HAVE_STPCPY@ _GL_FUNCDECL_SYS (stpcpy, char *, (char *restrict __dst, char const *restrict __src) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (stpcpy, char *, (char *restrict __dst, char const *restrict __src)); _GL_CXXALIASWARN (stpcpy); #elif defined GNULIB_POSIXCHECK # undef stpcpy # if HAVE_RAW_DECL_STPCPY _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " "use gnulib module stpcpy for portability"); # endif #endif /* Copy no more than N bytes of SRC to DST, returning a pointer past the last non-NUL byte written into DST. */ #if @GNULIB_STPNCPY@ # if @REPLACE_STPNCPY@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef stpncpy # define stpncpy rpl_stpncpy # endif _GL_FUNCDECL_RPL (stpncpy, char *, (char *restrict __dst, char const *restrict __src, size_t __n) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (stpncpy, char *, (char *restrict __dst, char const *restrict __src, size_t __n)); # else # if ! @HAVE_STPNCPY@ _GL_FUNCDECL_SYS (stpncpy, char *, (char *restrict __dst, char const *restrict __src, size_t __n) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (stpncpy, char *, (char *restrict __dst, char const *restrict __src, size_t __n)); # endif _GL_CXXALIASWARN (stpncpy); #elif defined GNULIB_POSIXCHECK # undef stpncpy # if HAVE_RAW_DECL_STPNCPY _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " "use gnulib module stpncpy for portability"); # endif #endif #if defined GNULIB_POSIXCHECK /* strchr() does not work with multibyte strings if the locale encoding is GB18030 and the character to be searched is a digit. */ # undef strchr /* Assume strchr is always declared. */ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " "in some multibyte locales - " "use mbschr if you care about internationalization"); #endif /* Find the first occurrence of C in S or the final NUL byte. */ #if @GNULIB_STRCHRNUL@ # if @REPLACE_STRCHRNUL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define strchrnul rpl_strchrnul # endif _GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strchrnul, char *, (const char *str, int ch)); # else # if ! @HAVE_STRCHRNUL@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const char * std::strchrnul (const char *, int); } extern "C++" { char * std::strchrnul (char *, int); } */ _GL_CXXALIAS_SYS_CAST2 (strchrnul, char *, (char const *__s, int __c_in), char const *, (char const *__s, int __c_in)); # endif # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); # else _GL_CXXALIASWARN (strchrnul); # endif #elif defined GNULIB_POSIXCHECK # undef strchrnul # if HAVE_RAW_DECL_STRCHRNUL _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " "use gnulib module strchrnul for portability"); # endif #endif /* Duplicate S, returning an identical malloc'd string. */ #if @GNULIB_STRDUP@ # if @REPLACE_STRDUP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strdup # define strdup rpl_strdup # endif _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); # else # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup /* strdup exists as a function and as a macro. Get rid of the macro. */ # undef strdup # endif # if !(@HAVE_DECL_STRDUP@ || defined strdup) _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); # endif _GL_CXXALIASWARN (strdup); #elif defined GNULIB_POSIXCHECK # undef strdup # if HAVE_RAW_DECL_STRDUP _GL_WARN_ON_USE (strdup, "strdup is unportable - " "use gnulib module strdup for portability"); # endif #endif /* Append no more than N characters from SRC onto DEST. */ #if @GNULIB_STRNCAT@ # if @REPLACE_STRNCAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strncat # define strncat rpl_strncat # endif _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); # else _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); # endif _GL_CXXALIASWARN (strncat); #elif defined GNULIB_POSIXCHECK # undef strncat # if HAVE_RAW_DECL_STRNCAT _GL_WARN_ON_USE (strncat, "strncat is unportable - " "use gnulib module strncat for portability"); # endif #endif /* Return a newly allocated copy of at most N bytes of STRING. */ #if @GNULIB_STRNDUP@ # if @REPLACE_STRNDUP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strndup # define strndup rpl_strndup # endif _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); # else # if ! @HAVE_DECL_STRNDUP@ _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); # endif _GL_CXXALIASWARN (strndup); #elif defined GNULIB_POSIXCHECK # undef strndup # if HAVE_RAW_DECL_STRNDUP _GL_WARN_ON_USE (strndup, "strndup is unportable - " "use gnulib module strndup for portability"); # endif #endif /* Find the length (number of bytes) of STRING, but scan at most MAXLEN bytes. If no '\0' terminator is found in that many bytes, return MAXLEN. */ #if @GNULIB_STRNLEN@ # if @REPLACE_STRNLEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strnlen # define strnlen rpl_strnlen # endif _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); # else # if ! @HAVE_DECL_STRNLEN@ _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); # endif _GL_CXXALIASWARN (strnlen); #elif defined GNULIB_POSIXCHECK # undef strnlen # if HAVE_RAW_DECL_STRNLEN _GL_WARN_ON_USE (strnlen, "strnlen is unportable - " "use gnulib module strnlen for portability"); # endif #endif #if defined GNULIB_POSIXCHECK /* strcspn() assumes the second argument is a list of single-byte characters. Even in this simple case, it does not work with multibyte strings if the locale encoding is GB18030 and one of the characters to be searched is a digit. */ # undef strcspn /* Assume strcspn is always declared. */ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " "in multibyte locales - " "use mbscspn if you care about internationalization"); #endif /* Find the first occurrence in S of any character in ACCEPT. */ #if @GNULIB_STRPBRK@ # if ! @HAVE_STRPBRK@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: extern "C" { const char * strpbrk (const char *, const char *); } extern "C++" { char * strpbrk (char *, const char *); } */ _GL_CXXALIAS_SYS_CAST2 (strpbrk, char *, (char const *__s, char const *__accept), const char *, (char const *__s, char const *__accept)); # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); _GL_CXXALIASWARN1 (strpbrk, char const *, (char const *__s, char const *__accept)); # else _GL_CXXALIASWARN (strpbrk); # endif # if defined GNULIB_POSIXCHECK /* strpbrk() assumes the second argument is a list of single-byte characters. Even in this simple case, it does not work with multibyte strings if the locale encoding is GB18030 and one of the characters to be searched is a digit. */ # undef strpbrk _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " "in multibyte locales - " "use mbspbrk if you care about internationalization"); # endif #elif defined GNULIB_POSIXCHECK # undef strpbrk # if HAVE_RAW_DECL_STRPBRK _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " "use gnulib module strpbrk for portability"); # endif #endif #if defined GNULIB_POSIXCHECK /* strspn() assumes the second argument is a list of single-byte characters. Even in this simple case, it cannot work with multibyte strings. */ # undef strspn /* Assume strspn is always declared. */ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " "in multibyte locales - " "use mbsspn if you care about internationalization"); #endif #if defined GNULIB_POSIXCHECK /* strrchr() does not work with multibyte strings if the locale encoding is GB18030 and the character to be searched is a digit. */ # undef strrchr /* Assume strrchr is always declared. */ _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " "in some multibyte locales - " "use mbsrchr if you care about internationalization"); #endif /* Search the next delimiter (char listed in DELIM) starting at *STRINGP. If one is found, overwrite it with a NUL, and advance *STRINGP to point to the next char after it. Otherwise, set *STRINGP to NULL. If *STRINGP was already NULL, nothing happens. Return the old value of *STRINGP. This is a variant of strtok() that is multithread-safe and supports empty fields. Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. Caveat: It doesn't work with multibyte strings unless all of the delimiter characters are ASCII characters < 0x30. See also strtok_r(). */ #if @GNULIB_STRSEP@ # if ! @HAVE_STRSEP@ _GL_FUNCDECL_SYS (strsep, char *, (char **restrict __stringp, char const *restrict __delim) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (strsep, char *, (char **restrict __stringp, char const *restrict __delim)); _GL_CXXALIASWARN (strsep); # if defined GNULIB_POSIXCHECK # undef strsep _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " "in multibyte locales - " "use mbssep if you care about internationalization"); # endif #elif defined GNULIB_POSIXCHECK # undef strsep # if HAVE_RAW_DECL_STRSEP _GL_WARN_ON_USE (strsep, "strsep is unportable - " "use gnulib module strsep for portability"); # endif #endif #if @GNULIB_STRSTR@ # if @REPLACE_STRSTR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define strstr rpl_strstr # endif _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); # else /* On some systems, this function is defined as an overloaded function: extern "C++" { const char * strstr (const char *, const char *); } extern "C++" { char * strstr (char *, const char *); } */ _GL_CXXALIAS_SYS_CAST2 (strstr, char *, (const char *haystack, const char *needle), const char *, (const char *haystack, const char *needle)); # endif # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); _GL_CXXALIASWARN1 (strstr, const char *, (const char *haystack, const char *needle)); # else _GL_CXXALIASWARN (strstr); # endif #elif defined GNULIB_POSIXCHECK /* strstr() does not work with multibyte strings if the locale encoding is different from UTF-8: POSIX says that it operates on "strings", and "string" in POSIX is defined as a sequence of bytes, not of characters. */ # undef strstr /* Assume strstr is always declared. */ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " "work correctly on character strings in most " "multibyte locales - " "use mbsstr if you care about internationalization, " "or use strstr if you care about speed"); #endif /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive comparison. */ #if @GNULIB_STRCASESTR@ # if @REPLACE_STRCASESTR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define strcasestr rpl_strcasestr # endif _GL_FUNCDECL_RPL (strcasestr, char *, (const char *haystack, const char *needle) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strcasestr, char *, (const char *haystack, const char *needle)); # else # if ! @HAVE_STRCASESTR@ _GL_FUNCDECL_SYS (strcasestr, char *, (const char *haystack, const char *needle) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const char * strcasestr (const char *, const char *); } extern "C++" { char * strcasestr (char *, const char *); } */ _GL_CXXALIAS_SYS_CAST2 (strcasestr, char *, (const char *haystack, const char *needle), const char *, (const char *haystack, const char *needle)); # endif # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); _GL_CXXALIASWARN1 (strcasestr, const char *, (const char *haystack, const char *needle)); # else _GL_CXXALIASWARN (strcasestr); # endif #elif defined GNULIB_POSIXCHECK /* strcasestr() does not work with multibyte strings: It is a glibc extension, and glibc implements it only for unibyte locales. */ # undef strcasestr # if HAVE_RAW_DECL_STRCASESTR _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " "strings in multibyte locales - " "use mbscasestr if you care about " "internationalization, or use c-strcasestr if you want " "a locale independent function"); # endif #endif /* Parse S into tokens separated by characters in DELIM. If S is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: char s[] = "-abc-=-def"; char *sp; x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL x = strtok_r(NULL, "=", &sp); // x = NULL // s = "abc\0-def\0" This is a variant of strtok() that is multithread-safe. For the POSIX documentation for this function, see: http://www.opengroup.org/susv3xsh/strtok.html Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. Caveat: It doesn't work with multibyte strings unless all of the delimiter characters are ASCII characters < 0x30. See also strsep(). */ #if @GNULIB_STRTOK_R@ # if @REPLACE_STRTOK_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strtok_r # define strtok_r rpl_strtok_r # endif _GL_FUNCDECL_RPL (strtok_r, char *, (char *restrict s, char const *restrict delim, char **restrict save_ptr) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (strtok_r, char *, (char *restrict s, char const *restrict delim, char **restrict save_ptr)); # else # if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK # undef strtok_r # endif # if ! @HAVE_DECL_STRTOK_R@ _GL_FUNCDECL_SYS (strtok_r, char *, (char *restrict s, char const *restrict delim, char **restrict save_ptr) _GL_ARG_NONNULL ((2, 3))); # endif _GL_CXXALIAS_SYS (strtok_r, char *, (char *restrict s, char const *restrict delim, char **restrict save_ptr)); # endif _GL_CXXALIASWARN (strtok_r); # if defined GNULIB_POSIXCHECK _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " "strings in multibyte locales - " "use mbstok_r if you care about internationalization"); # endif #elif defined GNULIB_POSIXCHECK # undef strtok_r # if HAVE_RAW_DECL_STRTOK_R _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " "use gnulib module strtok_r for portability"); # endif #endif /* The following functions are not specified by POSIX. They are gnulib extensions. */ #if @GNULIB_MBSLEN@ /* Return the number of multibyte characters in the character string STRING. This considers multibyte characters, unlike strlen, which counts bytes. */ # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ # undef mbslen # endif # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mbslen rpl_mbslen # endif _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); # else _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); # endif _GL_CXXALIASWARN (mbslen); #endif #if @GNULIB_MBSNLEN@ /* Return the number of multibyte characters in the character string starting at STRING and ending at STRING + LEN. */ _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1)); #endif #if @GNULIB_MBSCHR@ /* Locate the first single-byte character C in the character string STRING, and return a pointer to it. Return NULL if C is not found in STRING. Unlike strchr(), this function works correctly in multibyte locales with encodings such as GB18030. */ # if defined __hpux # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ # endif _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); # else _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); # endif _GL_CXXALIASWARN (mbschr); #endif #if @GNULIB_MBSRCHR@ /* Locate the last single-byte character C in the character string STRING, and return a pointer to it. Return NULL if C is not found in STRING. Unlike strrchr(), this function works correctly in multibyte locales with encodings such as GB18030. */ # if defined __hpux || defined __INTERIX # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mbsrchr rpl_mbsrchr /* avoid collision with system function */ # endif _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); # else _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); # endif _GL_CXXALIASWARN (mbsrchr); #endif #if @GNULIB_MBSSTR@ /* Find the first occurrence of the character string NEEDLE in the character string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. Unlike strstr(), this function works correctly in multibyte locales with encodings different from UTF-8. */ _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSCASECMP@ /* Compare the character 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 may, in multibyte locales, return 0 for strings of different lengths! Unlike strcasecmp(), this function works correctly in multibyte locales. */ _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSNCASECMP@ /* Compare the initial segment of the character string S1 consisting of at most N characters with the initial segment of the character string S2 consisting of at most N characters, ignoring case, returning less than, equal to or greater than zero if the initial segment of S1 is lexicographically less than, equal to or greater than the initial segment of S2. Note: This function may, in multibyte locales, return 0 for initial segments of different lengths! Unlike strncasecmp(), this function works correctly in multibyte locales. But beware that N is not a byte count but a character count! */ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSPCASECMP@ /* Compare the initial segment of the character string STRING consisting of at most mbslen (PREFIX) characters with the character string PREFIX, ignoring case. If the two match, return a pointer to the first byte after this prefix in STRING. Otherwise, return NULL. Note: This function may, in multibyte locales, return non-NULL if STRING is of smaller length than PREFIX! Unlike strncasecmp(), this function works correctly in multibyte locales. */ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSCASESTR@ /* Find the first occurrence of the character string NEEDLE in the character string HAYSTACK, using case-insensitive comparison. Note: This function may, in multibyte locales, return success even if strlen (haystack) < strlen (needle) ! Unlike strcasestr(), this function works correctly in multibyte locales. */ _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSCSPN@ /* Find the first occurrence in the character string STRING of any character in the character string ACCEPT. Return the number of bytes from the beginning of the string to this occurrence, or to the end of the string if none exists. Unlike strcspn(), this function works correctly in multibyte locales. */ _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSPBRK@ /* Find the first occurrence in the character string STRING of any character in the character string ACCEPT. Return the pointer to it, or NULL if none exists. Unlike strpbrk(), this function works correctly in multibyte locales. */ # if defined __hpux # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ # endif _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); # else _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); # endif _GL_CXXALIASWARN (mbspbrk); #endif #if @GNULIB_MBSSPN@ /* Find the first occurrence in the character string STRING of any character not in the character string REJECT. Return the number of bytes from the beginning of the string to this occurrence, or to the end of the string if none exists. Unlike strspn(), this function works correctly in multibyte locales. */ _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSSEP@ /* Search the next delimiter (multibyte character listed in the character string DELIM) starting at the character string *STRINGP. If one is found, overwrite it with a NUL, and advance *STRINGP to point to the next multibyte character after it. Otherwise, set *STRINGP to NULL. If *STRINGP was already NULL, nothing happens. Return the old value of *STRINGP. This is a variant of mbstok_r() that supports empty fields. Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. See also mbstok_r(). */ _GL_EXTERN_C char * mbssep (char **stringp, const char *delim) _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSTOK_R@ /* Parse the character string STRING into tokens separated by characters in the character string DELIM. If STRING is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: char s[] = "-abc-=-def"; char *sp; x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL x = mbstok_r(NULL, "=", &sp); // x = NULL // s = "abc\0-def\0" Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. See also mbssep(). */ _GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) _GL_ARG_NONNULL ((2, 3)); #endif /* Map any int, typically from errno, into an error message. */ #if @GNULIB_STRERROR@ # if @REPLACE_STRERROR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strerror # define strerror rpl_strerror # endif _GL_FUNCDECL_RPL (strerror, char *, (int)); _GL_CXXALIAS_RPL (strerror, char *, (int)); # else _GL_CXXALIAS_SYS (strerror, char *, (int)); # endif _GL_CXXALIASWARN (strerror); #elif defined GNULIB_POSIXCHECK # undef strerror /* Assume strerror is always declared. */ _GL_WARN_ON_USE (strerror, "strerror is unportable - " "use gnulib module strerror to guarantee non-NULL result"); #endif /* Map any int, typically from errno, into an error message. Multithread-safe. Uses the POSIX declaration, not the glibc declaration. */ #if @GNULIB_STRERROR_R@ # if @REPLACE_STRERROR_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strerror_r # define strerror_r rpl_strerror_r # endif _GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); # else # if !@HAVE_DECL_STRERROR_R@ _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); # endif # if @HAVE_DECL_STRERROR_R@ _GL_CXXALIASWARN (strerror_r); # endif #elif defined GNULIB_POSIXCHECK # undef strerror_r # if HAVE_RAW_DECL_STRERROR_R _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " "use gnulib module strerror_r-posix for portability"); # endif #endif #if @GNULIB_STRSIGNAL@ # if @REPLACE_STRSIGNAL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define strsignal rpl_strsignal # endif _GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); # else # if ! @HAVE_DECL_STRSIGNAL@ _GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); # endif /* Need to cast, because on Cygwin 1.5.x systems, the return type is 'const char *'. */ _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); # endif _GL_CXXALIASWARN (strsignal); #elif defined GNULIB_POSIXCHECK # undef strsignal # if HAVE_RAW_DECL_STRSIGNAL _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " "use gnulib module strsignal for portability"); # endif #endif #if @GNULIB_STRVERSCMP@ # if !@HAVE_STRVERSCMP@ _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); _GL_CXXALIASWARN (strverscmp); #elif defined GNULIB_POSIXCHECK # undef strverscmp # if HAVE_RAW_DECL_STRVERSCMP _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " "use gnulib module strverscmp for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_STRING_H */ #endif /* _@GUARD_PREFIX@_STRING_H */ #endif lftp-4.6.3a/lib/xalloc-oversized.h0000644000015000007670000000322712466374012013775 00000000000000/* xalloc-oversized.h -- memory allocation size checking Copyright (C) 1990-2000, 2003-2004, 2006-2015 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 . */ #ifndef XALLOC_OVERSIZED_H_ # define XALLOC_OVERSIZED_H_ # include /* Return 1 if an array of N objects, each of size S, cannot exist due to size arithmetic overflow. S must be positive and N must be nonnegative. This is a macro, not a function, so that it works correctly even when SIZE_MAX < N. By gnulib convention, SIZE_MAX represents overflow in size calculations, so the conservative dividend to use here is SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. However, malloc (SIZE_MAX) fails on all known hosts where sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for exactly-SIZE_MAX allocations on such hosts; this avoids a test and branch when S is known to be 1. */ # define xalloc_oversized(n, s) \ ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) #endif /* !XALLOC_OVERSIZED_H_ */ lftp-4.6.3a/lib/unistr.in.h0000644000015000007670000005517512466374012012445 00000000000000/* Elementary Unicode string functions. Copyright (C) 2001-2002, 2005-2015 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 . */ #ifndef _UNISTR_H #define _UNISTR_H #include "unitypes.h" /* Get common macros for C. */ #include "unused-parameter.h" /* Get bool. */ #include /* Get size_t. */ #include #ifdef __cplusplus extern "C" { #endif /* Conventions: All functions prefixed with u8_ operate on UTF-8 encoded strings. Their unit is an uint8_t (1 byte). All functions prefixed with u16_ operate on UTF-16 encoded strings. Their unit is an uint16_t (a 2-byte word). All functions prefixed with u32_ operate on UCS-4 encoded strings. Their unit is an uint32_t (a 4-byte word). All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly n units. All arguments starting with "str" and the arguments of functions starting with u8_str/u16_str/u32_str denote a NUL terminated string, i.e. a string which terminates at the first NUL unit. This termination unit is considered part of the string for all memory allocation purposes, but is not considered part of the string for all other logical purposes. Functions returning a string result take a (resultbuf, lengthp) argument pair. If resultbuf is not NULL and the result fits into *lengthp units, it is put in resultbuf, and resultbuf is returned. Otherwise, a freshly allocated string is returned. In both cases, *lengthp is set to the length (number of units) of the returned string. In case of error, NULL is returned and errno is set. */ /* Elementary string checks. */ /* Check whether an UTF-8 string is well-formed. Return NULL if valid, or a pointer to the first invalid unit otherwise. */ extern const uint8_t * u8_check (const uint8_t *s, size_t n) _UC_ATTRIBUTE_PURE; /* Check whether an UTF-16 string is well-formed. Return NULL if valid, or a pointer to the first invalid unit otherwise. */ extern const uint16_t * u16_check (const uint16_t *s, size_t n) _UC_ATTRIBUTE_PURE; /* Check whether an UCS-4 string is well-formed. Return NULL if valid, or a pointer to the first invalid unit otherwise. */ extern const uint32_t * u32_check (const uint32_t *s, size_t n) _UC_ATTRIBUTE_PURE; /* Elementary string conversions. */ /* Convert an UTF-8 string to an UTF-16 string. */ extern uint16_t * u8_to_u16 (const uint8_t *s, size_t n, uint16_t *resultbuf, size_t *lengthp); /* Convert an UTF-8 string to an UCS-4 string. */ extern uint32_t * u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf, size_t *lengthp); /* Convert an UTF-16 string to an UTF-8 string. */ extern uint8_t * u16_to_u8 (const uint16_t *s, size_t n, uint8_t *resultbuf, size_t *lengthp); /* Convert an UTF-16 string to an UCS-4 string. */ extern uint32_t * u16_to_u32 (const uint16_t *s, size_t n, uint32_t *resultbuf, size_t *lengthp); /* Convert an UCS-4 string to an UTF-8 string. */ extern uint8_t * u32_to_u8 (const uint32_t *s, size_t n, uint8_t *resultbuf, size_t *lengthp); /* Convert an UCS-4 string to an UTF-16 string. */ extern uint16_t * u32_to_u16 (const uint32_t *s, size_t n, uint16_t *resultbuf, size_t *lengthp); /* Elementary string functions. */ /* Return the length (number of units) of the first character in S, which is no longer than N. Return 0 if it is the NUL character. Return -1 upon failure. */ /* Similar to mblen(), except that s must not be NULL. */ extern int u8_mblen (const uint8_t *s, size_t n) _UC_ATTRIBUTE_PURE; extern int u16_mblen (const uint16_t *s, size_t n) _UC_ATTRIBUTE_PURE; extern int u32_mblen (const uint32_t *s, size_t n) _UC_ATTRIBUTE_PURE; /* Return the length (number of units) of the first character in S, putting its 'ucs4_t' representation in *PUC. Upon failure, *PUC is set to 0xfffd, and an appropriate number of units is returned. The number of available units, N, must be > 0. */ /* Similar to mbtowc(), except that puc and s must not be NULL, n must be > 0, and the NUL character is not treated specially. */ /* The variants with _safe suffix are safe, even if the library is compiled without --enable-safety. */ #if GNULIB_UNISTR_U8_MBTOUC_UNSAFE || HAVE_LIBUNISTRING # if !HAVE_INLINE extern int u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n); # else extern int u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n); static inline int u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n) { uint8_t c = *s; if (c < 0x80) { *puc = c; return 1; } else return u8_mbtouc_unsafe_aux (puc, s, n); } # endif #endif #if GNULIB_UNISTR_U16_MBTOUC_UNSAFE || HAVE_LIBUNISTRING # if !HAVE_INLINE extern int u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n); # else extern int u16_mbtouc_unsafe_aux (ucs4_t *puc, const uint16_t *s, size_t n); static inline int u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n) { uint16_t c = *s; if (c < 0xd800 || c >= 0xe000) { *puc = c; return 1; } else return u16_mbtouc_unsafe_aux (puc, s, n); } # endif #endif #if GNULIB_UNISTR_U32_MBTOUC_UNSAFE || HAVE_LIBUNISTRING # if !HAVE_INLINE extern int u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n); # else static inline int u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER) { uint32_t c = *s; # if CONFIG_UNICODE_SAFETY if (c < 0xd800 || (c >= 0xe000 && c < 0x110000)) # endif *puc = c; # if CONFIG_UNICODE_SAFETY else /* invalid multibyte character */ *puc = 0xfffd; # endif return 1; } # endif #endif #if GNULIB_UNISTR_U8_MBTOUC || HAVE_LIBUNISTRING # if !HAVE_INLINE extern int u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n); # else extern int u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n); static inline int u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n) { uint8_t c = *s; if (c < 0x80) { *puc = c; return 1; } else return u8_mbtouc_aux (puc, s, n); } # endif #endif #if GNULIB_UNISTR_U16_MBTOUC || HAVE_LIBUNISTRING # if !HAVE_INLINE extern int u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n); # else extern int u16_mbtouc_aux (ucs4_t *puc, const uint16_t *s, size_t n); static inline int u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n) { uint16_t c = *s; if (c < 0xd800 || c >= 0xe000) { *puc = c; return 1; } else return u16_mbtouc_aux (puc, s, n); } # endif #endif #if GNULIB_UNISTR_U32_MBTOUC || HAVE_LIBUNISTRING # if !HAVE_INLINE extern int u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n); # else static inline int u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER) { uint32_t c = *s; if (c < 0xd800 || (c >= 0xe000 && c < 0x110000)) *puc = c; else /* invalid multibyte character */ *puc = 0xfffd; return 1; } # endif #endif /* Return the length (number of units) of the first character in S, putting its 'ucs4_t' representation in *PUC. Upon failure, *PUC is set to 0xfffd, and -1 is returned for an invalid sequence of units, -2 is returned for an incomplete sequence of units. The number of available units, N, must be > 0. */ /* Similar to u*_mbtouc(), except that the return value gives more details about the failure, similar to mbrtowc(). */ #if GNULIB_UNISTR_U8_MBTOUCR || HAVE_LIBUNISTRING extern int u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n); #endif #if GNULIB_UNISTR_U16_MBTOUCR || HAVE_LIBUNISTRING extern int u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n); #endif #if GNULIB_UNISTR_U32_MBTOUCR || HAVE_LIBUNISTRING extern int u32_mbtoucr (ucs4_t *puc, const uint32_t *s, size_t n); #endif /* Put the multibyte character represented by UC in S, returning its length. Return -1 upon failure, -2 if the number of available units, N, is too small. The latter case cannot occur if N >= 6/2/1, respectively. */ /* Similar to wctomb(), except that s must not be NULL, and the argument n must be specified. */ #if GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING /* Auxiliary function, also used by u8_chr, u8_strchr, u8_strrchr. */ extern int u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n); # if !HAVE_INLINE extern int u8_uctomb (uint8_t *s, ucs4_t uc, int n); # else static inline int u8_uctomb (uint8_t *s, ucs4_t uc, int n) { if (uc < 0x80 && n > 0) { s[0] = uc; return 1; } else return u8_uctomb_aux (s, uc, n); } # endif #endif #if GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING /* Auxiliary function, also used by u16_chr, u16_strchr, u16_strrchr. */ extern int u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n); # if !HAVE_INLINE extern int u16_uctomb (uint16_t *s, ucs4_t uc, int n); # else static inline int u16_uctomb (uint16_t *s, ucs4_t uc, int n) { if (uc < 0xd800 && n > 0) { s[0] = uc; return 1; } else return u16_uctomb_aux (s, uc, n); } # endif #endif #if GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING # if !HAVE_INLINE extern int u32_uctomb (uint32_t *s, ucs4_t uc, int n); # else static inline int u32_uctomb (uint32_t *s, ucs4_t uc, int n) { if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000)) { if (n > 0) { *s = uc; return 1; } else return -2; } else return -1; } # endif #endif /* Copy N units from SRC to DEST. */ /* Similar to memcpy(). */ extern uint8_t * u8_cpy (uint8_t *dest, const uint8_t *src, size_t n); extern uint16_t * u16_cpy (uint16_t *dest, const uint16_t *src, size_t n); extern uint32_t * u32_cpy (uint32_t *dest, const uint32_t *src, size_t n); /* Copy N units from SRC to DEST, guaranteeing correct behavior for overlapping memory areas. */ /* Similar to memmove(). */ extern uint8_t * u8_move (uint8_t *dest, const uint8_t *src, size_t n); extern uint16_t * u16_move (uint16_t *dest, const uint16_t *src, size_t n); extern uint32_t * u32_move (uint32_t *dest, const uint32_t *src, size_t n); /* Set the first N characters of S to UC. UC should be a character that occupies only 1 unit. */ /* Similar to memset(). */ extern uint8_t * u8_set (uint8_t *s, ucs4_t uc, size_t n); extern uint16_t * u16_set (uint16_t *s, ucs4_t uc, size_t n); extern uint32_t * u32_set (uint32_t *s, ucs4_t uc, size_t n); /* Compare S1 and S2, each of length N. */ /* Similar to memcmp(). */ extern int u8_cmp (const uint8_t *s1, const uint8_t *s2, size_t n) _UC_ATTRIBUTE_PURE; extern int u16_cmp (const uint16_t *s1, const uint16_t *s2, size_t n) _UC_ATTRIBUTE_PURE; extern int u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n) _UC_ATTRIBUTE_PURE; /* Compare S1 and S2. */ /* Similar to the gnulib function memcmp2(). */ extern int u8_cmp2 (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2) _UC_ATTRIBUTE_PURE; extern int u16_cmp2 (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2) _UC_ATTRIBUTE_PURE; extern int u32_cmp2 (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2) _UC_ATTRIBUTE_PURE; /* Search the string at S for UC. */ /* Similar to memchr(). */ extern uint8_t * u8_chr (const uint8_t *s, size_t n, ucs4_t uc) _UC_ATTRIBUTE_PURE; extern uint16_t * u16_chr (const uint16_t *s, size_t n, ucs4_t uc) _UC_ATTRIBUTE_PURE; extern uint32_t * u32_chr (const uint32_t *s, size_t n, ucs4_t uc) _UC_ATTRIBUTE_PURE; /* Count the number of Unicode characters in the N units from S. */ /* Similar to mbsnlen(). */ extern size_t u8_mbsnlen (const uint8_t *s, size_t n) _UC_ATTRIBUTE_PURE; extern size_t u16_mbsnlen (const uint16_t *s, size_t n) _UC_ATTRIBUTE_PURE; extern size_t u32_mbsnlen (const uint32_t *s, size_t n) _UC_ATTRIBUTE_PURE; /* Elementary string functions with memory allocation. */ /* Make a freshly allocated copy of S, of length N. */ extern uint8_t * u8_cpy_alloc (const uint8_t *s, size_t n); extern uint16_t * u16_cpy_alloc (const uint16_t *s, size_t n); extern uint32_t * u32_cpy_alloc (const uint32_t *s, size_t n); /* Elementary string functions on NUL terminated strings. */ /* Return the length (number of units) of the first character in S. Return 0 if it is the NUL character. Return -1 upon failure. */ extern int u8_strmblen (const uint8_t *s) _UC_ATTRIBUTE_PURE; extern int u16_strmblen (const uint16_t *s) _UC_ATTRIBUTE_PURE; extern int u32_strmblen (const uint32_t *s) _UC_ATTRIBUTE_PURE; /* Return the length (number of units) of the first character in S, putting its 'ucs4_t' representation in *PUC. Return 0 if it is the NUL character. Return -1 upon failure. */ extern int u8_strmbtouc (ucs4_t *puc, const uint8_t *s); extern int u16_strmbtouc (ucs4_t *puc, const uint16_t *s); extern int u32_strmbtouc (ucs4_t *puc, const uint32_t *s); /* Forward iteration step. Advances the pointer past the next character, or returns NULL if the end of the string has been reached. Puts the character's 'ucs4_t' representation in *PUC. */ extern const uint8_t * u8_next (ucs4_t *puc, const uint8_t *s); extern const uint16_t * u16_next (ucs4_t *puc, const uint16_t *s); extern const uint32_t * u32_next (ucs4_t *puc, const uint32_t *s); /* Backward iteration step. Advances the pointer to point to the previous character, or returns NULL if the beginning of the string had been reached. Puts the character's 'ucs4_t' representation in *PUC. */ extern const uint8_t * u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start); extern const uint16_t * u16_prev (ucs4_t *puc, const uint16_t *s, const uint16_t *start); extern const uint32_t * u32_prev (ucs4_t *puc, const uint32_t *s, const uint32_t *start); /* Return the number of units in S. */ /* Similar to strlen(), wcslen(). */ extern size_t u8_strlen (const uint8_t *s) _UC_ATTRIBUTE_PURE; extern size_t u16_strlen (const uint16_t *s) _UC_ATTRIBUTE_PURE; extern size_t u32_strlen (const uint32_t *s) _UC_ATTRIBUTE_PURE; /* Return the number of units in S, but at most MAXLEN. */ /* Similar to strnlen(), wcsnlen(). */ extern size_t u8_strnlen (const uint8_t *s, size_t maxlen) _UC_ATTRIBUTE_PURE; extern size_t u16_strnlen (const uint16_t *s, size_t maxlen) _UC_ATTRIBUTE_PURE; extern size_t u32_strnlen (const uint32_t *s, size_t maxlen) _UC_ATTRIBUTE_PURE; /* Copy SRC to DEST. */ /* Similar to strcpy(), wcscpy(). */ extern uint8_t * u8_strcpy (uint8_t *dest, const uint8_t *src); extern uint16_t * u16_strcpy (uint16_t *dest, const uint16_t *src); extern uint32_t * u32_strcpy (uint32_t *dest, const uint32_t *src); /* Copy SRC to DEST, returning the address of the terminating NUL in DEST. */ /* Similar to stpcpy(). */ extern uint8_t * u8_stpcpy (uint8_t *dest, const uint8_t *src); extern uint16_t * u16_stpcpy (uint16_t *dest, const uint16_t *src); extern uint32_t * u32_stpcpy (uint32_t *dest, const uint32_t *src); /* Copy no more than N units of SRC to DEST. */ /* Similar to strncpy(), wcsncpy(). */ extern uint8_t * u8_strncpy (uint8_t *dest, const uint8_t *src, size_t n); extern uint16_t * u16_strncpy (uint16_t *dest, const uint16_t *src, size_t n); extern uint32_t * u32_strncpy (uint32_t *dest, const uint32_t *src, size_t n); /* Copy no more than N units of SRC to DEST. Return a pointer past the last non-NUL unit written into DEST. */ /* Similar to stpncpy(). */ extern uint8_t * u8_stpncpy (uint8_t *dest, const uint8_t *src, size_t n); extern uint16_t * u16_stpncpy (uint16_t *dest, const uint16_t *src, size_t n); extern uint32_t * u32_stpncpy (uint32_t *dest, const uint32_t *src, size_t n); /* Append SRC onto DEST. */ /* Similar to strcat(), wcscat(). */ extern uint8_t * u8_strcat (uint8_t *dest, const uint8_t *src); extern uint16_t * u16_strcat (uint16_t *dest, const uint16_t *src); extern uint32_t * u32_strcat (uint32_t *dest, const uint32_t *src); /* Append no more than N units of SRC onto DEST. */ /* Similar to strncat(), wcsncat(). */ extern uint8_t * u8_strncat (uint8_t *dest, const uint8_t *src, size_t n); extern uint16_t * u16_strncat (uint16_t *dest, const uint16_t *src, size_t n); extern uint32_t * u32_strncat (uint32_t *dest, const uint32_t *src, size_t n); /* Compare S1 and S2. */ /* Similar to strcmp(), wcscmp(). */ #ifdef __sun /* Avoid a collision with the u8_strcmp() function in Solaris 11 libc. */ extern int u8_strcmp_gnu (const uint8_t *s1, const uint8_t *s2) _UC_ATTRIBUTE_PURE; # define u8_strcmp u8_strcmp_gnu #else extern int u8_strcmp (const uint8_t *s1, const uint8_t *s2) _UC_ATTRIBUTE_PURE; #endif extern int u16_strcmp (const uint16_t *s1, const uint16_t *s2) _UC_ATTRIBUTE_PURE; extern int u32_strcmp (const uint32_t *s1, const uint32_t *s2) _UC_ATTRIBUTE_PURE; /* Compare S1 and S2 using the collation rules of the current locale. Return -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2. Upon failure, set errno and return any value. */ /* Similar to strcoll(), wcscoll(). */ extern int u8_strcoll (const uint8_t *s1, const uint8_t *s2); extern int u16_strcoll (const uint16_t *s1, const uint16_t *s2); extern int u32_strcoll (const uint32_t *s1, const uint32_t *s2); /* Compare no more than N units of S1 and S2. */ /* Similar to strncmp(), wcsncmp(). */ extern int u8_strncmp (const uint8_t *s1, const uint8_t *s2, size_t n) _UC_ATTRIBUTE_PURE; extern int u16_strncmp (const uint16_t *s1, const uint16_t *s2, size_t n) _UC_ATTRIBUTE_PURE; extern int u32_strncmp (const uint32_t *s1, const uint32_t *s2, size_t n) _UC_ATTRIBUTE_PURE; /* Duplicate S, returning an identical malloc'd string. */ /* Similar to strdup(), wcsdup(). */ extern uint8_t * u8_strdup (const uint8_t *s); extern uint16_t * u16_strdup (const uint16_t *s); extern uint32_t * u32_strdup (const uint32_t *s); /* Find the first occurrence of UC in STR. */ /* Similar to strchr(), wcschr(). */ extern uint8_t * u8_strchr (const uint8_t *str, ucs4_t uc) _UC_ATTRIBUTE_PURE; extern uint16_t * u16_strchr (const uint16_t *str, ucs4_t uc) _UC_ATTRIBUTE_PURE; extern uint32_t * u32_strchr (const uint32_t *str, ucs4_t uc) _UC_ATTRIBUTE_PURE; /* Find the last occurrence of UC in STR. */ /* Similar to strrchr(), wcsrchr(). */ extern uint8_t * u8_strrchr (const uint8_t *str, ucs4_t uc) _UC_ATTRIBUTE_PURE; extern uint16_t * u16_strrchr (const uint16_t *str, ucs4_t uc) _UC_ATTRIBUTE_PURE; extern uint32_t * u32_strrchr (const uint32_t *str, ucs4_t uc) _UC_ATTRIBUTE_PURE; /* Return the length of the initial segment of STR which consists entirely of Unicode characters not in REJECT. */ /* Similar to strcspn(), wcscspn(). */ extern size_t u8_strcspn (const uint8_t *str, const uint8_t *reject) _UC_ATTRIBUTE_PURE; extern size_t u16_strcspn (const uint16_t *str, const uint16_t *reject) _UC_ATTRIBUTE_PURE; extern size_t u32_strcspn (const uint32_t *str, const uint32_t *reject) _UC_ATTRIBUTE_PURE; /* Return the length of the initial segment of STR which consists entirely of Unicode characters in ACCEPT. */ /* Similar to strspn(), wcsspn(). */ extern size_t u8_strspn (const uint8_t *str, const uint8_t *accept) _UC_ATTRIBUTE_PURE; extern size_t u16_strspn (const uint16_t *str, const uint16_t *accept) _UC_ATTRIBUTE_PURE; extern size_t u32_strspn (const uint32_t *str, const uint32_t *accept) _UC_ATTRIBUTE_PURE; /* Find the first occurrence in STR of any character in ACCEPT. */ /* Similar to strpbrk(), wcspbrk(). */ extern uint8_t * u8_strpbrk (const uint8_t *str, const uint8_t *accept) _UC_ATTRIBUTE_PURE; extern uint16_t * u16_strpbrk (const uint16_t *str, const uint16_t *accept) _UC_ATTRIBUTE_PURE; extern uint32_t * u32_strpbrk (const uint32_t *str, const uint32_t *accept) _UC_ATTRIBUTE_PURE; /* Find the first occurrence of NEEDLE in HAYSTACK. */ /* Similar to strstr(), wcsstr(). */ extern uint8_t * u8_strstr (const uint8_t *haystack, const uint8_t *needle) _UC_ATTRIBUTE_PURE; extern uint16_t * u16_strstr (const uint16_t *haystack, const uint16_t *needle) _UC_ATTRIBUTE_PURE; extern uint32_t * u32_strstr (const uint32_t *haystack, const uint32_t *needle) _UC_ATTRIBUTE_PURE; /* Test whether STR starts with PREFIX. */ extern bool u8_startswith (const uint8_t *str, const uint8_t *prefix) _UC_ATTRIBUTE_PURE; extern bool u16_startswith (const uint16_t *str, const uint16_t *prefix) _UC_ATTRIBUTE_PURE; extern bool u32_startswith (const uint32_t *str, const uint32_t *prefix) _UC_ATTRIBUTE_PURE; /* Test whether STR ends with SUFFIX. */ extern bool u8_endswith (const uint8_t *str, const uint8_t *suffix) _UC_ATTRIBUTE_PURE; extern bool u16_endswith (const uint16_t *str, const uint16_t *suffix) _UC_ATTRIBUTE_PURE; extern bool u32_endswith (const uint32_t *str, const uint32_t *suffix) _UC_ATTRIBUTE_PURE; /* Divide STR into tokens separated by characters in DELIM. This interface is actually more similar to wcstok than to strtok. */ /* Similar to strtok_r(), wcstok(). */ extern uint8_t * u8_strtok (uint8_t *str, const uint8_t *delim, uint8_t **ptr); extern uint16_t * u16_strtok (uint16_t *str, const uint16_t *delim, uint16_t **ptr); extern uint32_t * u32_strtok (uint32_t *str, const uint32_t *delim, uint32_t **ptr); #ifdef __cplusplus } #endif #endif /* _UNISTR_H */ lftp-4.6.3a/lib/wctype.in.h0000644000015000007670000003210212466374012012415 00000000000000/* A substitute for ISO C99 , for platforms that lack it. Copyright (C) 2006-2015 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 . */ /* Written by Bruno Haible and Paul Eggert. */ /* * ISO C 99 for platforms that lack it. * * * iswctype, towctrans, towlower, towupper, wctrans, wctype, * wctrans_t, and wctype_t are not yet implemented. */ #ifndef _@GUARD_PREFIX@_WCTYPE_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if @HAVE_WINT_T@ /* Solaris 2.5 has a bug: must be included before . Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ # include # include # include # include #endif /* mingw has declarations of towupper and towlower in as well . Include in advance to avoid rpl_ prefix being added to the declarations. */ #ifdef __MINGW32__ # include #endif /* Include the original if it exists. BeOS 5 has the functions but no . */ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_WCTYPE_H@ # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@ #endif #ifndef _@GUARD_PREFIX@_WCTYPE_H #define _@GUARD_PREFIX@_WCTYPE_H #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_WCTYPE_INLINE # define _GL_WCTYPE_INLINE _GL_INLINE #endif /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_WARN_ON_USE is copied here. */ /* Solaris 2.6 includes which includes which #defines a number of identifiers in the application namespace. Revert these #defines. */ #ifdef __sun # undef multibyte # undef eucw1 # undef eucw2 # undef eucw3 # undef scrw1 # undef scrw2 # undef scrw3 #endif /* Define wint_t and WEOF. (Also done in wchar.in.h.) */ #if !@HAVE_WINT_T@ && !defined wint_t # define wint_t int # ifndef WEOF # define WEOF -1 # endif #else /* MSVC defines wint_t as 'unsigned short' in . This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be "unchanged by default argument promotions". Override it. */ # if defined _MSC_VER # if !GNULIB_defined_wint_t # include typedef unsigned int rpl_wint_t; # undef wint_t # define wint_t rpl_wint_t # define GNULIB_defined_wint_t 1 # endif # endif # ifndef WEOF # define WEOF ((wint_t) -1) # endif #endif #if !GNULIB_defined_wctype_functions /* FreeBSD 4.4 to 4.11 has but lacks the functions. Linux libc5 has and the functions but they are broken. Assume all 11 functions (all isw* except iswblank) are implemented the same way, or not at all. */ # if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ /* IRIX 5.3 has macros but no functions, its isw* macros refer to an undefined variable _ctmp_ and to macros like _P, and they refer to system functions like _iswctype that are not in the standard C library. Rather than try to get ancient buggy implementations like this to work, just disable them. */ # undef iswalnum # undef iswalpha # undef iswblank # undef iswcntrl # undef iswdigit # undef iswgraph # undef iswlower # undef iswprint # undef iswpunct # undef iswspace # undef iswupper # undef iswxdigit # undef towlower # undef towupper /* Linux libc5 has and the functions but they are broken. */ # if @REPLACE_ISWCNTRL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define iswalnum rpl_iswalnum # define iswalpha rpl_iswalpha # define iswblank rpl_iswblank # define iswcntrl rpl_iswcntrl # define iswdigit rpl_iswdigit # define iswgraph rpl_iswgraph # define iswlower rpl_iswlower # define iswprint rpl_iswprint # define iswpunct rpl_iswpunct # define iswspace rpl_iswspace # define iswupper rpl_iswupper # define iswxdigit rpl_iswxdigit # endif # endif # if @REPLACE_TOWLOWER@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define towlower rpl_towlower # define towupper rpl_towupper # endif # endif _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswalnum # else iswalnum # endif (wint_t wc) { return ((wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswalpha # else iswalpha # endif (wint_t wc) { return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswblank # else iswblank # endif (wint_t wc) { return wc == ' ' || wc == '\t'; } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswcntrl # else iswcntrl # endif (wint_t wc) { return (wc & ~0x1f) == 0 || wc == 0x7f; } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswdigit # else iswdigit # endif (wint_t wc) { return wc >= '0' && wc <= '9'; } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswgraph # else iswgraph # endif (wint_t wc) { return wc >= '!' && wc <= '~'; } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswlower # else iswlower # endif (wint_t wc) { return wc >= 'a' && wc <= 'z'; } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswprint # else iswprint # endif (wint_t wc) { return wc >= ' ' && wc <= '~'; } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswpunct # else iswpunct # endif (wint_t wc) { return (wc >= '!' && wc <= '~' && !((wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswspace # else iswspace # endif (wint_t wc) { return (wc == ' ' || wc == '\t' || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswupper # else iswupper # endif (wint_t wc) { return wc >= 'A' && wc <= 'Z'; } _GL_WCTYPE_INLINE int # if @REPLACE_ISWCNTRL@ rpl_iswxdigit # else iswxdigit # endif (wint_t wc) { return ((wc >= '0' && wc <= '9') || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); } _GL_WCTYPE_INLINE wint_t # if @REPLACE_TOWLOWER@ rpl_towlower # else towlower # endif (wint_t wc) { return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); } _GL_WCTYPE_INLINE wint_t # if @REPLACE_TOWLOWER@ rpl_towupper # else towupper # endif (wint_t wc) { return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); } # elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@) /* Only the iswblank function is missing. */ # if @REPLACE_ISWBLANK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define iswblank rpl_iswblank # endif _GL_FUNCDECL_RPL (iswblank, int, (wint_t wc)); # else _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc)); # endif # endif # if defined __MINGW32__ /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. The functions towlower and towupper are implemented in the MSVCRT library to take a wchar_t argument and return a wchar_t result. mingw declares these functions to take a wint_t argument and return a wint_t result. This means that: 1. When the user passes an argument outside the range 0x0000..0xFFFF, the function will look only at the lower 16 bits. This is allowed according to POSIX. 2. The return value is returned in the lower 16 bits of the result register. The upper 16 bits are random: whatever happened to be in that part of the result register. We need to fix this by adding a zero-extend from wchar_t to wint_t after the call. */ _GL_WCTYPE_INLINE wint_t rpl_towlower (wint_t wc) { return (wint_t) (wchar_t) towlower (wc); } # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define towlower rpl_towlower # endif _GL_WCTYPE_INLINE wint_t rpl_towupper (wint_t wc) { return (wint_t) (wchar_t) towupper (wc); } # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define towupper rpl_towupper # endif # endif /* __MINGW32__ */ # define GNULIB_defined_wctype_functions 1 #endif #if @REPLACE_ISWCNTRL@ _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc)); _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc)); #else _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); #endif _GL_CXXALIASWARN (iswalnum); _GL_CXXALIASWARN (iswalpha); _GL_CXXALIASWARN (iswcntrl); _GL_CXXALIASWARN (iswdigit); _GL_CXXALIASWARN (iswgraph); _GL_CXXALIASWARN (iswlower); _GL_CXXALIASWARN (iswprint); _GL_CXXALIASWARN (iswpunct); _GL_CXXALIASWARN (iswspace); _GL_CXXALIASWARN (iswupper); _GL_CXXALIASWARN (iswxdigit); #if @GNULIB_ISWBLANK@ # if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@ _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc)); # else _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); # endif _GL_CXXALIASWARN (iswblank); #endif #if !@HAVE_WCTYPE_T@ # if !GNULIB_defined_wctype_t typedef void * wctype_t; # define GNULIB_defined_wctype_t 1 # endif #endif /* Get a descriptor for a wide character property. */ #if @GNULIB_WCTYPE@ # if !@HAVE_WCTYPE_T@ _GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); # endif _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); _GL_CXXALIASWARN (wctype); #elif defined GNULIB_POSIXCHECK # undef wctype # if HAVE_RAW_DECL_WCTYPE _GL_WARN_ON_USE (wctype, "wctype is unportable - " "use gnulib module wctype for portability"); # endif #endif /* Test whether a wide character has a given property. The argument WC must be either a wchar_t value or WEOF. The argument DESC must have been returned by the wctype() function. */ #if @GNULIB_ISWCTYPE@ # if !@HAVE_WCTYPE_T@ _GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); # endif _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); _GL_CXXALIASWARN (iswctype); #elif defined GNULIB_POSIXCHECK # undef iswctype # if HAVE_RAW_DECL_ISWCTYPE _GL_WARN_ON_USE (iswctype, "iswctype is unportable - " "use gnulib module iswctype for portability"); # endif #endif #if @REPLACE_TOWLOWER@ || defined __MINGW32__ _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); #else _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); #endif _GL_CXXALIASWARN (towlower); _GL_CXXALIASWARN (towupper); #if !@HAVE_WCTRANS_T@ # if !GNULIB_defined_wctrans_t typedef void * wctrans_t; # define GNULIB_defined_wctrans_t 1 # endif #endif /* Get a descriptor for a wide character case conversion. */ #if @GNULIB_WCTRANS@ # if !@HAVE_WCTRANS_T@ _GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name)); # endif _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); _GL_CXXALIASWARN (wctrans); #elif defined GNULIB_POSIXCHECK # undef wctrans # if HAVE_RAW_DECL_WCTRANS _GL_WARN_ON_USE (wctrans, "wctrans is unportable - " "use gnulib module wctrans for portability"); # endif #endif /* Perform a given case conversion on a wide character. The argument WC must be either a wchar_t value or WEOF. The argument DESC must have been returned by the wctrans() function. */ #if @GNULIB_TOWCTRANS@ # if !@HAVE_WCTRANS_T@ _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); # endif _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); _GL_CXXALIASWARN (towctrans); #elif defined GNULIB_POSIXCHECK # undef towctrans # if HAVE_RAW_DECL_TOWCTRANS _GL_WARN_ON_USE (towctrans, "towctrans is unportable - " "use gnulib module towctrans for portability"); # endif #endif _GL_INLINE_HEADER_END #endif /* _@GUARD_PREFIX@_WCTYPE_H */ #endif /* _@GUARD_PREFIX@_WCTYPE_H */ lftp-4.6.3a/lib/fnmatch_loop.c0000644000015000007670000013161612466374011013152 00000000000000/* Copyright (C) 1991-1993, 1996-2006, 2009-2015 Free Software Foundation, Inc. This file is part of 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, 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 . */ /* Match STRING against the file name pattern PATTERN, returning zero if it matches, nonzero if not. */ static int EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, bool no_leading_period, int flags) internal_function; static const CHAR *END (const CHAR *patternp) internal_function; static int internal_function FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, bool no_leading_period, int flags) { register const CHAR *p = pattern, *n = string; register UCHAR c; #ifdef _LIBC # if WIDE_CHAR_VERSION const char *collseq = (const char *) _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC); # else const UCHAR *collseq = (const UCHAR *) _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQMB); # endif #endif while ((c = *p++) != L_('\0')) { bool new_no_leading_period = false; c = FOLD (c); switch (c) { case L_('?'): if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') { int res; res = EXT (c, p, n, string_end, no_leading_period, flags); if (res != -1) return res; } if (n == string_end) return FNM_NOMATCH; else if (*n == L_('/') && (flags & FNM_FILE_NAME)) return FNM_NOMATCH; else if (*n == L_('.') && no_leading_period) return FNM_NOMATCH; break; case L_('\\'): if (!(flags & FNM_NOESCAPE)) { c = *p++; if (c == L_('\0')) /* Trailing \ loses. */ return FNM_NOMATCH; c = FOLD (c); } if (n == string_end || FOLD ((UCHAR) *n) != c) return FNM_NOMATCH; break; case L_('*'): if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') { int res; res = EXT (c, p, n, string_end, no_leading_period, flags); if (res != -1) return res; } if (n != string_end && *n == L_('.') && no_leading_period) return FNM_NOMATCH; for (c = *p++; c == L_('?') || c == L_('*'); c = *p++) { if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0) { const CHAR *endp = END (p); if (endp != p) { /* This is a pattern. Skip over it. */ p = endp; continue; } } if (c == L_('?')) { /* A ? needs to match one character. */ if (n == string_end) /* There isn't another character; no match. */ return FNM_NOMATCH; else if (*n == L_('/') && __builtin_expect (flags & FNM_FILE_NAME, 0)) /* A slash does not match a wildcard under FNM_FILE_NAME. */ return FNM_NOMATCH; else /* One character of the string is consumed in matching this ? wildcard, so *??? won't match if there are less than three characters. */ ++n; } } if (c == L_('\0')) /* The wildcard(s) is/are the last element of the pattern. If the name is a file name and contains another slash this means it cannot match, unless the FNM_LEADING_DIR flag is set. */ { int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH; if (flags & FNM_FILE_NAME) { if (flags & FNM_LEADING_DIR) result = 0; else { if (MEMCHR (n, L_('/'), string_end - n) == NULL) result = 0; } } return result; } else { const CHAR *endp; endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'), string_end - n); if (endp == NULL) endp = string_end; if (c == L_('[') || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0 && (c == L_('@') || c == L_('+') || c == L_('!')) && *p == L_('('))) { int flags2 = ((flags & FNM_FILE_NAME) ? flags : (flags & ~FNM_PERIOD)); bool no_leading_period2 = no_leading_period; for (--p; n < endp; ++n, no_leading_period2 = false) if (FCT (p, n, string_end, no_leading_period2, flags2) == 0) return 0; } else if (c == L_('/') && (flags & FNM_FILE_NAME)) { while (n < string_end && *n != L_('/')) ++n; if (n < string_end && *n == L_('/') && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags) == 0)) return 0; } else { int flags2 = ((flags & FNM_FILE_NAME) ? flags : (flags & ~FNM_PERIOD)); int no_leading_period2 = no_leading_period; if (c == L_('\\') && !(flags & FNM_NOESCAPE)) c = *p; c = FOLD (c); for (--p; n < endp; ++n, no_leading_period2 = false) if (FOLD ((UCHAR) *n) == c && (FCT (p, n, string_end, no_leading_period2, flags2) == 0)) return 0; } } /* If we come here no match is possible with the wildcard. */ return FNM_NOMATCH; case L_('['): { /* Nonzero if the sense of the character class is inverted. */ const CHAR *p_init = p; const CHAR *n_init = n; register bool not; CHAR cold; UCHAR fn; if (posixly_correct == 0) posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; if (n == string_end) return FNM_NOMATCH; if (*n == L_('.') && no_leading_period) return FNM_NOMATCH; if (*n == L_('/') && (flags & FNM_FILE_NAME)) /* '/' cannot be matched. */ return FNM_NOMATCH; not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^'))); if (not) ++p; fn = FOLD ((UCHAR) *n); c = *p++; for (;;) { bool is_range = false; if (!(flags & FNM_NOESCAPE) && c == L_('\\')) { if (*p == L_('\0')) return FNM_NOMATCH; c = FOLD ((UCHAR) *p); ++p; goto normal_bracket; } else if (c == L_('[') && *p == L_(':')) { /* Leave room for the null. */ CHAR str[CHAR_CLASS_MAX_LENGTH + 1]; size_t c1 = 0; #if defined _LIBC || WIDE_CHAR_SUPPORT wctype_t wt; #endif const CHAR *startp = p; for (;;) { if (c1 == CHAR_CLASS_MAX_LENGTH) /* The name is too long and therefore the pattern is ill-formed. */ return FNM_NOMATCH; c = *++p; if (c == L_(':') && p[1] == L_(']')) { p += 2; break; } if (c < L_('a') || c >= L_('z')) { /* This cannot possibly be a character class name. Match it as a normal range. */ p = startp; c = L_('['); goto normal_bracket; } str[c1++] = c; } str[c1] = L_('\0'); #if defined _LIBC || WIDE_CHAR_SUPPORT wt = IS_CHAR_CLASS (str); if (wt == 0) /* Invalid character class name. */ return FNM_NOMATCH; # if defined _LIBC && ! WIDE_CHAR_VERSION /* The following code is glibc specific but does there a good job in speeding up the code since we can avoid the btowc() call. */ if (_ISCTYPE ((UCHAR) *n, wt)) goto matched; # else if (ISWCTYPE (BTOWC ((UCHAR) *n), wt)) goto matched; # endif #else if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n)) || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n)) || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n)) || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n)) || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n)) || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n)) || (STREQ (str, L_("lower")) && islower ((UCHAR) *n)) || (STREQ (str, L_("print")) && isprint ((UCHAR) *n)) || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n)) || (STREQ (str, L_("space")) && isspace ((UCHAR) *n)) || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n)) || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n))) goto matched; #endif c = *p++; } #ifdef _LIBC else if (c == L_('[') && *p == L_('=')) { UCHAR str[1]; uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); const CHAR *startp = p; c = *++p; if (c == L_('\0')) { p = startp; c = L_('['); goto normal_bracket; } str[0] = c; c = *++p; if (c != L_('=') || p[1] != L_(']')) { p = startp; c = L_('['); goto normal_bracket; } p += 2; if (nrules == 0) { if ((UCHAR) *n == str[0]) goto matched; } else { const int32_t *table; # if WIDE_CHAR_VERSION const int32_t *weights; const int32_t *extra; # else const unsigned char *weights; const unsigned char *extra; # endif const int32_t *indirect; int32_t idx; const UCHAR *cp = (const UCHAR *) str; /* This #include defines a local function! */ # if WIDE_CHAR_VERSION # include # else # include # endif # if WIDE_CHAR_VERSION table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC); weights = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC); extra = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC); indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC); # else table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); # endif idx = findidx (&cp); if (idx != 0) { /* We found a table entry. Now see whether the character we are currently at has the same equivalence class value. */ int len = weights[idx & 0xffffff]; int32_t idx2; const UCHAR *np = (const UCHAR *) n; idx2 = findidx (&np); if (idx2 != 0 && (idx >> 24) == (idx2 >> 24) && len == weights[idx2 & 0xffffff]) { int cnt = 0; idx &= 0xffffff; idx2 &= 0xffffff; while (cnt < len && (weights[idx + 1 + cnt] == weights[idx2 + 1 + cnt])) ++cnt; if (cnt == len) goto matched; } } } c = *p++; } #endif else if (c == L_('\0')) { /* [ unterminated, treat as normal character. */ p = p_init; n = n_init; c = L_('['); goto normal_match; } else { #ifdef _LIBC bool is_seqval = false; if (c == L_('[') && *p == L_('.')) { uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); const CHAR *startp = p; size_t c1 = 0; while (1) { c = *++p; if (c == L_('.') && p[1] == L_(']')) { p += 2; break; } if (c == '\0') return FNM_NOMATCH; ++c1; } /* We have to handling the symbols differently in ranges since then the collation sequence is important. */ is_range = *p == L_('-') && p[1] != L_('\0'); if (nrules == 0) { /* There are no names defined in the collation data. Therefore we only accept the trivial names consisting of the character itself. */ if (c1 != 1) return FNM_NOMATCH; if (!is_range && *n == startp[1]) goto matched; cold = startp[1]; c = *p++; } else { int32_t table_size; const int32_t *symb_table; # ifdef WIDE_CHAR_VERSION char str[c1]; size_t strcnt; # else # define str (startp + 1) # endif const unsigned char *extra; int32_t idx; int32_t elem; int32_t second; int32_t hash; # ifdef WIDE_CHAR_VERSION /* We have to convert the name to a single-byte string. This is possible since the names consist of ASCII characters and the internal representation is UCS4. */ for (strcnt = 0; strcnt < c1; ++strcnt) str[strcnt] = startp[1 + strcnt]; # endif table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB); extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); /* Locate the character in the hashing table. */ hash = elem_hash (str, c1); idx = 0; elem = hash % table_size; if (symb_table[2 * elem] != 0) { second = hash % (table_size - 2) + 1; do { /* First compare the hashing value. */ if (symb_table[2 * elem] == hash && (c1 == extra[symb_table[2 * elem + 1]]) && memcmp (str, &extra[symb_table[2 * elem + 1] + 1], c1) == 0) { /* Yep, this is the entry. */ idx = symb_table[2 * elem + 1]; idx += 1 + extra[idx]; break; } /* Next entry. */ elem += second; } while (symb_table[2 * elem] != 0); } if (symb_table[2 * elem] != 0) { /* Compare the byte sequence but only if this is not part of a range. */ # ifdef WIDE_CHAR_VERSION int32_t *wextra; idx += 1 + extra[idx]; /* Adjust for the alignment. */ idx = (idx + 3) & ~3; wextra = (int32_t *) &extra[idx + 4]; # endif if (! is_range) { # ifdef WIDE_CHAR_VERSION for (c1 = 0; (int32_t) c1 < wextra[idx]; ++c1) if (n[c1] != wextra[1 + c1]) break; if ((int32_t) c1 == wextra[idx]) goto matched; # else for (c1 = 0; c1 < extra[idx]; ++c1) if (n[c1] != extra[1 + c1]) break; if (c1 == extra[idx]) goto matched; # endif } /* Get the collation sequence value. */ is_seqval = true; # ifdef WIDE_CHAR_VERSION cold = wextra[1 + wextra[idx]]; # else /* Adjust for the alignment. */ idx += 1 + extra[idx]; idx = (idx + 3) & ~4; cold = *((int32_t *) &extra[idx]); # endif c = *p++; } else if (c1 == 1) { /* No valid character. Match it as a single byte. */ if (!is_range && *n == str[0]) goto matched; cold = str[0]; c = *p++; } else return FNM_NOMATCH; } } else # undef str #endif { c = FOLD (c); normal_bracket: /* We have to handling the symbols differently in ranges since then the collation sequence is important. */ is_range = (*p == L_('-') && p[1] != L_('\0') && p[1] != L_(']')); if (!is_range && c == fn) goto matched; #if _LIBC /* This is needed if we goto normal_bracket; from outside of is_seqval's scope. */ is_seqval = false; #endif cold = c; c = *p++; } if (c == L_('-') && *p != L_(']')) { #if _LIBC /* We have to find the collation sequence value for C. Collation sequence is nothing we can regularly access. The sequence value is defined by the order in which the definitions of the collation values for the various characters appear in the source file. A strange concept, nowhere documented. */ uint32_t fcollseq; uint32_t lcollseq; UCHAR cend = *p++; # ifdef WIDE_CHAR_VERSION /* Search in the 'names' array for the characters. */ fcollseq = __collseq_table_lookup (collseq, fn); if (fcollseq == ~((uint32_t) 0)) /* XXX We don't know anything about the character we are supposed to match. This means we are failing. */ goto range_not_matched; if (is_seqval) lcollseq = cold; else lcollseq = __collseq_table_lookup (collseq, cold); # else fcollseq = collseq[fn]; lcollseq = is_seqval ? cold : collseq[(UCHAR) cold]; # endif is_seqval = false; if (cend == L_('[') && *p == L_('.')) { uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); const CHAR *startp = p; size_t c1 = 0; while (1) { c = *++p; if (c == L_('.') && p[1] == L_(']')) { p += 2; break; } if (c == '\0') return FNM_NOMATCH; ++c1; } if (nrules == 0) { /* There are no names defined in the collation data. Therefore we only accept the trivial names consisting of the character itself. */ if (c1 != 1) return FNM_NOMATCH; cend = startp[1]; } else { int32_t table_size; const int32_t *symb_table; # ifdef WIDE_CHAR_VERSION char str[c1]; size_t strcnt; # else # define str (startp + 1) # endif const unsigned char *extra; int32_t idx; int32_t elem; int32_t second; int32_t hash; # ifdef WIDE_CHAR_VERSION /* We have to convert the name to a single-byte string. This is possible since the names consist of ASCII characters and the internal representation is UCS4. */ for (strcnt = 0; strcnt < c1; ++strcnt) str[strcnt] = startp[1 + strcnt]; # endif table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB); extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); /* Locate the character in the hashing table. */ hash = elem_hash (str, c1); idx = 0; elem = hash % table_size; if (symb_table[2 * elem] != 0) { second = hash % (table_size - 2) + 1; do { /* First compare the hashing value. */ if (symb_table[2 * elem] == hash && (c1 == extra[symb_table[2 * elem + 1]]) && memcmp (str, &extra[symb_table[2 * elem + 1] + 1], c1) == 0) { /* Yep, this is the entry. */ idx = symb_table[2 * elem + 1]; idx += 1 + extra[idx]; break; } /* Next entry. */ elem += second; } while (symb_table[2 * elem] != 0); } if (symb_table[2 * elem] != 0) { /* Compare the byte sequence but only if this is not part of a range. */ # ifdef WIDE_CHAR_VERSION int32_t *wextra; idx += 1 + extra[idx]; /* Adjust for the alignment. */ idx = (idx + 3) & ~4; wextra = (int32_t *) &extra[idx + 4]; # endif /* Get the collation sequence value. */ is_seqval = true; # ifdef WIDE_CHAR_VERSION cend = wextra[1 + wextra[idx]]; # else /* Adjust for the alignment. */ idx += 1 + extra[idx]; idx = (idx + 3) & ~4; cend = *((int32_t *) &extra[idx]); # endif } else if (symb_table[2 * elem] != 0 && c1 == 1) { cend = str[0]; c = *p++; } else return FNM_NOMATCH; } # undef str } else { if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) cend = *p++; if (cend == L_('\0')) return FNM_NOMATCH; cend = FOLD (cend); } /* XXX It is not entirely clear to me how to handle characters which are not mentioned in the collation specification. */ if ( # ifdef WIDE_CHAR_VERSION lcollseq == 0xffffffff || # endif lcollseq <= fcollseq) { /* We have to look at the upper bound. */ uint32_t hcollseq; if (is_seqval) hcollseq = cend; else { # ifdef WIDE_CHAR_VERSION hcollseq = __collseq_table_lookup (collseq, cend); if (hcollseq == ~((uint32_t) 0)) { /* Hum, no information about the upper bound. The matching succeeds if the lower bound is matched exactly. */ if (lcollseq != fcollseq) goto range_not_matched; goto matched; } # else hcollseq = collseq[cend]; # endif } if (lcollseq <= hcollseq && fcollseq <= hcollseq) goto matched; } # ifdef WIDE_CHAR_VERSION range_not_matched: # endif #else /* We use a boring value comparison of the character values. This is better than comparing using 'strcoll' since the latter would have surprising and sometimes fatal consequences. */ UCHAR cend = *p++; if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) cend = *p++; if (cend == L_('\0')) return FNM_NOMATCH; /* It is a range. */ if (cold <= fn && fn <= cend) goto matched; #endif c = *p++; } } if (c == L_(']')) break; } if (!not) return FNM_NOMATCH; break; matched: /* Skip the rest of the [...] that already matched. */ do { ignore_next: c = *p++; if (c == L_('\0')) /* [... (unterminated) loses. */ return FNM_NOMATCH; if (!(flags & FNM_NOESCAPE) && c == L_('\\')) { if (*p == L_('\0')) return FNM_NOMATCH; /* XXX 1003.2d11 is unclear if this is right. */ ++p; } else if (c == L_('[') && *p == L_(':')) { int c1 = 0; const CHAR *startp = p; while (1) { c = *++p; if (++c1 == CHAR_CLASS_MAX_LENGTH) return FNM_NOMATCH; if (*p == L_(':') && p[1] == L_(']')) break; if (c < L_('a') || c >= L_('z')) { p = startp; goto ignore_next; } } p += 2; c = *p++; } else if (c == L_('[') && *p == L_('=')) { c = *++p; if (c == L_('\0')) return FNM_NOMATCH; c = *++p; if (c != L_('=') || p[1] != L_(']')) return FNM_NOMATCH; p += 2; c = *p++; } else if (c == L_('[') && *p == L_('.')) { ++p; while (1) { c = *++p; if (c == '\0') return FNM_NOMATCH; if (*p == L_('.') && p[1] == L_(']')) break; } p += 2; c = *p++; } } while (c != L_(']')); if (not) return FNM_NOMATCH; } break; case L_('+'): case L_('@'): case L_('!'): if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') { int res; res = EXT (c, p, n, string_end, no_leading_period, flags); if (res != -1) return res; } goto normal_match; case L_('/'): if (NO_LEADING_PERIOD (flags)) { if (n == string_end || c != (UCHAR) *n) return FNM_NOMATCH; new_no_leading_period = true; break; } /* FALLTHROUGH */ default: normal_match: if (n == string_end || c != FOLD ((UCHAR) *n)) return FNM_NOMATCH; } no_leading_period = new_no_leading_period; ++n; } if (n == string_end) return 0; if ((flags & FNM_LEADING_DIR) && n != string_end && *n == L_('/')) /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ return 0; return FNM_NOMATCH; } static const CHAR * internal_function END (const CHAR *pattern) { const CHAR *p = pattern; while (1) if (*++p == L_('\0')) /* This is an invalid pattern. */ return pattern; else if (*p == L_('[')) { /* Handle brackets special. */ if (posixly_correct == 0) posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; /* Skip the not sign. We have to recognize it because of a possibly following ']'. */ if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) ++p; /* A leading ']' is recognized as such. */ if (*p == L_(']')) ++p; /* Skip over all characters of the list. */ while (*p != L_(']')) if (*p++ == L_('\0')) /* This is no valid pattern. */ return pattern; } else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@') || *p == L_('!')) && p[1] == L_('(')) p = END (p + 1); else if (*p == L_(')')) break; return p + 1; } static int internal_function EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, bool no_leading_period, int flags) { const CHAR *startp; size_t level; struct patternlist { struct patternlist *next; CHAR str[1]; } *list = NULL; struct patternlist **lastp = &list; size_t pattern_len = STRLEN (pattern); const CHAR *p; const CHAR *rs; enum { ALLOCA_LIMIT = 8000 }; /* Parse the pattern. Store the individual parts in the list. */ level = 0; for (startp = p = pattern + 1; ; ++p) if (*p == L_('\0')) /* This is an invalid pattern. */ return -1; else if (*p == L_('[')) { /* Handle brackets special. */ if (posixly_correct == 0) posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; /* Skip the not sign. We have to recognize it because of a possibly following ']'. */ if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) ++p; /* A leading ']' is recognized as such. */ if (*p == L_(']')) ++p; /* Skip over all characters of the list. */ while (*p != L_(']')) if (*p++ == L_('\0')) /* This is no valid pattern. */ return -1; } else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@') || *p == L_('!')) && p[1] == L_('(')) /* Remember the nesting level. */ ++level; else if (*p == L_(')')) { if (level-- == 0) { /* This means we found the end of the pattern. */ #define NEW_PATTERN \ struct patternlist *newp; \ size_t plen; \ size_t plensize; \ size_t newpsize; \ \ plen = (opt == L_('?') || opt == L_('@') \ ? pattern_len \ : p - startp + 1UL); \ plensize = plen * sizeof (CHAR); \ newpsize = offsetof (struct patternlist, str) + plensize; \ if ((size_t) -1 / sizeof (CHAR) < plen \ || newpsize < offsetof (struct patternlist, str) \ || ALLOCA_LIMIT <= newpsize) \ return -1; \ newp = (struct patternlist *) alloca (newpsize); \ *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \ newp->next = NULL; \ *lastp = newp; \ lastp = &newp->next NEW_PATTERN; break; } } else if (*p == L_('|')) { if (level == 0) { NEW_PATTERN; startp = p + 1; } } assert (list != NULL); assert (p[-1] == L_(')')); #undef NEW_PATTERN switch (opt) { case L_('*'): if (FCT (p, string, string_end, no_leading_period, flags) == 0) return 0; /* FALLTHROUGH */ case L_('+'): do { for (rs = string; rs <= string_end; ++rs) /* First match the prefix with the current pattern with the current pattern. */ if (FCT (list->str, string, rs, no_leading_period, flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0 /* This was successful. Now match the rest with the rest of the pattern. */ && (FCT (p, rs, string_end, rs == string ? no_leading_period : rs[-1] == '/' && NO_LEADING_PERIOD (flags), flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0 /* This didn't work. Try the whole pattern. */ || (rs != string && FCT (pattern - 1, rs, string_end, rs == string ? no_leading_period : rs[-1] == '/' && NO_LEADING_PERIOD (flags), flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0))) /* It worked. Signal success. */ return 0; } while ((list = list->next) != NULL); /* None of the patterns lead to a match. */ return FNM_NOMATCH; case L_('?'): if (FCT (p, string, string_end, no_leading_period, flags) == 0) return 0; /* FALLTHROUGH */ case L_('@'): do /* I cannot believe it but 'strcat' is actually acceptable here. Match the entire string with the prefix from the pattern list and the rest of the pattern following the pattern list. */ if (FCT (STRCAT (list->str, p), string, string_end, no_leading_period, flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0) /* It worked. Signal success. */ return 0; while ((list = list->next) != NULL); /* None of the patterns lead to a match. */ return FNM_NOMATCH; case L_('!'): for (rs = string; rs <= string_end; ++rs) { struct patternlist *runp; for (runp = list; runp != NULL; runp = runp->next) if (FCT (runp->str, string, rs, no_leading_period, flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0) break; /* If none of the patterns matched see whether the rest does. */ if (runp == NULL && (FCT (p, rs, string_end, rs == string ? no_leading_period : rs[-1] == '/' && NO_LEADING_PERIOD (flags), flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)) /* This is successful. */ return 0; } /* None of the patterns together with the rest of the pattern lead to a match. */ return FNM_NOMATCH; default: assert (! "Invalid extended matching operator"); break; } return -1; } #undef FOLD #undef CHAR #undef UCHAR #undef INT #undef FCT #undef EXT #undef END #undef MEMPCPY #undef MEMCHR #undef STRLEN #undef STRCAT #undef L_ #undef BTOWC lftp-4.6.3a/lib/modechange.c0000644000015000007670000003143412466374011012570 00000000000000/* modechange.c -- file mode manipulation Copyright (C) 1989-1990, 1997-1999, 2001, 2003-2006, 2009-2015 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 . */ /* Written by David MacKenzie */ /* The ASCII mode string is compiled into an array of 'struct modechange', which can then be applied to each file to be changed. We do this instead of re-parsing the ASCII string for each file because the compiled form requires less computation to use; when changing the mode of many files, this probably results in a performance gain. */ #include #include "modechange.h" #include #include "stat-macros.h" #include "xalloc.h" #include /* The traditional octal values corresponding to each mode bit. */ #define SUID 04000 #define SGID 02000 #define SVTX 01000 #define RUSR 00400 #define WUSR 00200 #define XUSR 00100 #define RGRP 00040 #define WGRP 00020 #define XGRP 00010 #define ROTH 00004 #define WOTH 00002 #define XOTH 00001 #define ALLM 07777 /* all octal mode bits */ /* Convert OCTAL, which uses one of the traditional octal values, to an internal mode_t value. */ static mode_t octal_to_mode (unsigned int octal) { /* Help the compiler optimize the usual case where mode_t uses the traditional octal representation. */ return ((S_ISUID == SUID && S_ISGID == SGID && S_ISVTX == SVTX && S_IRUSR == RUSR && S_IWUSR == WUSR && S_IXUSR == XUSR && S_IRGRP == RGRP && S_IWGRP == WGRP && S_IXGRP == XGRP && S_IROTH == ROTH && S_IWOTH == WOTH && S_IXOTH == XOTH) ? octal : (mode_t) ((octal & SUID ? S_ISUID : 0) | (octal & SGID ? S_ISGID : 0) | (octal & SVTX ? S_ISVTX : 0) | (octal & RUSR ? S_IRUSR : 0) | (octal & WUSR ? S_IWUSR : 0) | (octal & XUSR ? S_IXUSR : 0) | (octal & RGRP ? S_IRGRP : 0) | (octal & WGRP ? S_IWGRP : 0) | (octal & XGRP ? S_IXGRP : 0) | (octal & ROTH ? S_IROTH : 0) | (octal & WOTH ? S_IWOTH : 0) | (octal & XOTH ? S_IXOTH : 0))); } /* Special operations flags. */ enum { /* For the sentinel at the end of the mode changes array. */ MODE_DONE, /* The typical case. */ MODE_ORDINARY_CHANGE, /* In addition to the typical case, affect the execute bits if at least one execute bit is set already, or if the file is a directory. */ MODE_X_IF_ANY_X, /* Instead of the typical case, copy some existing permissions for u, g, or o onto the other two. Which of u, g, or o is copied is determined by which bits are set in the 'value' field. */ MODE_COPY_EXISTING }; /* Description of a mode change. */ struct mode_change { char op; /* One of "=+-". */ char flag; /* Special operations flag. */ mode_t affected; /* Set for u, g, o, or a. */ mode_t value; /* Bits to add/remove. */ mode_t mentioned; /* Bits explicitly mentioned. */ }; /* Return a mode_change array with the specified "=ddd"-style mode change operation, where NEW_MODE is "ddd" and MENTIONED contains the bits explicitly mentioned in the mode are MENTIONED. */ static struct mode_change * make_node_op_equals (mode_t new_mode, mode_t mentioned) { struct mode_change *p = xmalloc (2 * sizeof *p); p->op = '='; p->flag = MODE_ORDINARY_CHANGE; p->affected = CHMOD_MODE_BITS; p->value = new_mode; p->mentioned = mentioned; p[1].flag = MODE_DONE; return p; } /* Return a pointer to an array of file mode change operations created from MODE_STRING, an ASCII string that contains either an octal number specifying an absolute mode, or symbolic mode change operations with the form: [ugoa...][[+-=][rwxXstugo...]...][,...] Return NULL if 'mode_string' does not contain a valid representation of file mode change operations. */ struct mode_change * mode_compile (char const *mode_string) { /* The array of mode-change directives to be returned. */ struct mode_change *mc; size_t used = 0; char const *p; if ('0' <= *mode_string && *mode_string < '8') { unsigned int octal_mode = 0; mode_t mode; mode_t mentioned; p = mode_string; do { octal_mode = 8 * octal_mode + *p++ - '0'; if (ALLM < octal_mode) return NULL; } while ('0' <= *p && *p < '8'); if (*p) return NULL; mode = octal_to_mode (octal_mode); mentioned = (p - mode_string < 5 ? (mode & (S_ISUID | S_ISGID)) | S_ISVTX | S_IRWXUGO : CHMOD_MODE_BITS); return make_node_op_equals (mode, mentioned); } /* Allocate enough space to hold the result. */ { size_t needed = 1; for (p = mode_string; *p; p++) needed += (*p == '=' || *p == '+' || *p == '-'); mc = xnmalloc (needed, sizeof *mc); } /* One loop iteration for each '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'. */ for (p = mode_string; ; p++) { /* Which bits in the mode are operated on. */ mode_t affected = 0; /* Turn on all the bits in 'affected' for each group given. */ for (;; p++) switch (*p) { default: goto invalid; case 'u': affected |= S_ISUID | S_IRWXU; break; case 'g': affected |= S_ISGID | S_IRWXG; break; case 'o': affected |= S_ISVTX | S_IRWXO; break; case 'a': affected |= CHMOD_MODE_BITS; break; case '=': case '+': case '-': goto no_more_affected; } no_more_affected:; do { char op = *p++; mode_t value; mode_t mentioned = 0; char flag = MODE_COPY_EXISTING; struct mode_change *change; switch (*p) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': { unsigned int octal_mode = 0; do { octal_mode = 8 * octal_mode + *p++ - '0'; if (ALLM < octal_mode) goto invalid; } while ('0' <= *p && *p < '8'); if (affected || (*p && *p != ',')) goto invalid; affected = mentioned = CHMOD_MODE_BITS; value = octal_to_mode (octal_mode); flag = MODE_ORDINARY_CHANGE; break; } case 'u': /* Set the affected bits to the value of the "u" bits on the same file. */ value = S_IRWXU; p++; break; case 'g': /* Set the affected bits to the value of the "g" bits on the same file. */ value = S_IRWXG; p++; break; case 'o': /* Set the affected bits to the value of the "o" bits on the same file. */ value = S_IRWXO; p++; break; default: value = 0; flag = MODE_ORDINARY_CHANGE; for (;; p++) switch (*p) { case 'r': value |= S_IRUSR | S_IRGRP | S_IROTH; break; case 'w': value |= S_IWUSR | S_IWGRP | S_IWOTH; break; case 'x': value |= S_IXUSR | S_IXGRP | S_IXOTH; break; case 'X': flag = MODE_X_IF_ANY_X; break; case 's': /* Set the setuid/gid bits if 'u' or 'g' is selected. */ value |= S_ISUID | S_ISGID; break; case 't': /* Set the "save text image" bit if 'o' is selected. */ value |= S_ISVTX; break; default: goto no_more_values; } no_more_values:; } change = &mc[used++]; change->op = op; change->flag = flag; change->affected = affected; change->value = value; change->mentioned = (mentioned ? mentioned : affected ? affected & value : value); } while (*p == '=' || *p == '+' || *p == '-'); if (*p != ',') break; } if (*p == 0) { mc[used].flag = MODE_DONE; return mc; } invalid: free (mc); return NULL; } /* Return a file mode change operation that sets permissions to match those of REF_FILE. Return NULL (setting errno) if REF_FILE can't be accessed. */ struct mode_change * mode_create_from_ref (const char *ref_file) { struct stat ref_stats; if (stat (ref_file, &ref_stats) != 0) return NULL; return make_node_op_equals (ref_stats.st_mode, CHMOD_MODE_BITS); } /* Return the file mode bits of OLDMODE (which is the mode of a directory if DIR), assuming the umask is UMASK_VALUE, adjusted as indicated by the list of change operations CHANGES. If DIR, the type 'X' change affects the returned value even if no execute bits were set in OLDMODE, and set user and group ID bits are preserved unless CHANGES mentioned them. If PMODE_BITS is not null, store into *PMODE_BITS a mask denoting file mode bits that are affected by CHANGES. The returned value and *PMODE_BITS contain only file mode bits. For example, they have the S_IFMT bits cleared on a standard Unix-like host. */ mode_t mode_adjust (mode_t oldmode, bool dir, mode_t umask_value, struct mode_change const *changes, mode_t *pmode_bits) { /* The adjusted mode. */ mode_t newmode = oldmode & CHMOD_MODE_BITS; /* File mode bits that CHANGES cares about. */ mode_t mode_bits = 0; for (; changes->flag != MODE_DONE; changes++) { mode_t affected = changes->affected; mode_t omit_change = (dir ? S_ISUID | S_ISGID : 0) & ~ changes->mentioned; mode_t value = changes->value; switch (changes->flag) { case MODE_ORDINARY_CHANGE: break; case MODE_COPY_EXISTING: /* Isolate in 'value' the bits in 'newmode' to copy. */ value &= newmode; /* Copy the isolated bits to the other two parts. */ value |= ((value & (S_IRUSR | S_IRGRP | S_IROTH) ? S_IRUSR | S_IRGRP | S_IROTH : 0) | (value & (S_IWUSR | S_IWGRP | S_IWOTH) ? S_IWUSR | S_IWGRP | S_IWOTH : 0) | (value & (S_IXUSR | S_IXGRP | S_IXOTH) ? S_IXUSR | S_IXGRP | S_IXOTH : 0)); break; case MODE_X_IF_ANY_X: /* Affect the execute bits if execute bits are already set or if the file is a directory. */ if ((newmode & (S_IXUSR | S_IXGRP | S_IXOTH)) | dir) value |= S_IXUSR | S_IXGRP | S_IXOTH; break; } /* If WHO was specified, limit the change to the affected bits. Otherwise, apply the umask. Either way, omit changes as requested. */ value &= (affected ? affected : ~umask_value) & ~ omit_change; switch (changes->op) { case '=': /* If WHO was specified, preserve the previous values of bits that are not affected by this change operation. Otherwise, clear all the bits. */ { mode_t preserved = (affected ? ~affected : 0) | omit_change; mode_bits |= CHMOD_MODE_BITS & ~preserved; newmode = (newmode & preserved) | value; break; } case '+': mode_bits |= value; newmode |= value; break; case '-': mode_bits |= value; newmode &= ~value; break; } } if (pmode_bits) *pmode_bits = mode_bits; return newmode; } lftp-4.6.3a/lib/time.in.h0000644000015000007670000002353212466374012012047 00000000000000/* A more-standard . Copyright (C) 2007-2015 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 . */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* Don't get in the way of glibc when it includes time.h merely to declare a few standard symbols, rather than to declare all the symbols. Also, Solaris 8 eventually includes itself recursively; if that is happening, just include the system without adding our own declarations. */ #if (defined __need_time_t || defined __need_clock_t \ || defined __need_timespec \ || defined _@GUARD_PREFIX@_TIME_H) # @INCLUDE_NEXT@ @NEXT_TIME_H@ #else # define _@GUARD_PREFIX@_TIME_H # @INCLUDE_NEXT@ @NEXT_TIME_H@ /* NetBSD 5.0 mis-defines NULL. */ # include /* 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. */ /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). Or they define it with the wrong member names or define it in (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it, but the pthreads-win32 library defines it in . */ # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ # include # elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ # include # elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ # include # else # ifdef __cplusplus extern "C" { # endif # if !GNULIB_defined_struct_timespec # undef timespec # define timespec rpl_timespec struct timespec { time_t tv_sec; long int tv_nsec; }; # define GNULIB_defined_struct_timespec 1 # endif # ifdef __cplusplus } # endif # endif # endif # if !GNULIB_defined_struct_time_t_must_be_integral /* Per http://austingroupbugs.net/view.php?id=327, POSIX requires time_t to be an integer type, even though C99 permits floating point. We don't know of any implementation that uses floating point, and it is much easier to write code that doesn't have to worry about that corner case, so we force the issue. */ struct __time_t_must_be_integral { unsigned int __floating_time_t_unsupported : (time_t) 1; }; # define GNULIB_defined_struct_time_t_must_be_integral 1 # endif /* Sleep for at least RQTP seconds unless interrupted, If interrupted, return -1 and store the remaining time into RMTP. See . */ # if @GNULIB_NANOSLEEP@ # if @REPLACE_NANOSLEEP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define nanosleep rpl_nanosleep # endif _GL_FUNCDECL_RPL (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp)); # else # if ! @HAVE_NANOSLEEP@ _GL_FUNCDECL_SYS (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp)); # endif _GL_CXXALIASWARN (nanosleep); # endif /* Return the 'time_t' representation of TP and normalize TP. */ # if @GNULIB_MKTIME@ # if @REPLACE_MKTIME@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define mktime rpl_mktime # endif _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); # else _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); # endif _GL_CXXALIASWARN (mktime); # endif /* Convert TIMER to RESULT, assuming local time and UTC respectively. See and . */ # if @GNULIB_TIME_R@ # if @REPLACE_LOCALTIME_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef localtime_r # define localtime_r rpl_localtime_r # endif _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else # if ! @HAVE_DECL_LOCALTIME_R@ _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # endif # if @HAVE_DECL_LOCALTIME_R@ _GL_CXXALIASWARN (localtime_r); # endif # if @REPLACE_LOCALTIME_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef gmtime_r # define gmtime_r rpl_gmtime_r # endif _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else # if ! @HAVE_DECL_LOCALTIME_R@ _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # endif # if @HAVE_DECL_LOCALTIME_R@ _GL_CXXALIASWARN (gmtime_r); # endif # endif /* Convert TIMER to RESULT, assuming local time and UTC respectively. See and . */ # if @GNULIB_GETTIMEOFDAY@ # if @REPLACE_LOCALTIME@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef localtime # define localtime rpl_localtime # endif _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); # else _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); # endif _GL_CXXALIASWARN (localtime); # endif # if @GNULIB_GETTIMEOFDAY@ # if @REPLACE_GMTIME@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef gmtime # define gmtime rpl_gmtime # endif _GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); # else _GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer)); # endif _GL_CXXALIASWARN (gmtime); # endif /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store the resulting broken-down time into TM. See . */ # if @GNULIB_STRPTIME@ # if ! @HAVE_STRPTIME@ _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, char const *restrict __format, struct tm *restrict __tm) _GL_ARG_NONNULL ((1, 2, 3))); # endif _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, char const *restrict __format, struct tm *restrict __tm)); _GL_CXXALIASWARN (strptime); # endif /* Convert TM to a time_t value, assuming UTC. */ # if @GNULIB_TIMEGM@ # if @REPLACE_TIMEGM@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef timegm # define timegm rpl_timegm # endif _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); # else # if ! @HAVE_TIMEGM@ _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); # endif _GL_CXXALIASWARN (timegm); # endif /* Encourage applications to avoid unsafe functions that can overrun buffers when given outlandish struct tm values. Portable applications should use strftime (or even sprintf) instead. */ # if defined GNULIB_POSIXCHECK # undef asctime _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " "better use strftime (or even sprintf) instead"); # endif # if defined GNULIB_POSIXCHECK # undef asctime_r _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " "better use strftime (or even sprintf) instead"); # endif # if defined GNULIB_POSIXCHECK # undef ctime _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " "better use strftime (or even sprintf) instead"); # endif # if defined GNULIB_POSIXCHECK # undef ctime_r _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " "better use strftime (or even sprintf) instead"); # endif #endif lftp-4.6.3a/lib/memmem.c0000644000015000007670000000534412466374011011754 00000000000000/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2015 Free Software Foundation, Inc. This file is part of 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, 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 . */ /* This particular implementation was written by Eric Blake, 2008. */ #ifndef _LIBC # include #endif /* Specification of memmem. */ #include #ifndef _LIBC # define __builtin_expect(expr, val) (expr) #endif #define RETURN_TYPE void * #define AVAILABLE(h, h_l, j, n_l) ((j) <= (h_l) - (n_l)) #include "str-two-way.h" /* Return the first occurrence of NEEDLE in HAYSTACK. Return HAYSTACK if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in HAYSTACK. */ void * memmem (const void *haystack_start, size_t haystack_len, const void *needle_start, size_t needle_len) { /* Abstract memory is considered to be an array of 'unsigned char' values, not an array of 'char' values. See ISO C 99 section 6.2.6.1. */ const unsigned char *haystack = (const unsigned char *) haystack_start; const unsigned char *needle = (const unsigned char *) needle_start; if (needle_len == 0) /* The first occurrence of the empty string is deemed to occur at the beginning of the string. */ return (void *) haystack; /* Sanity check, otherwise the loop might search through the whole memory. */ if (__builtin_expect (haystack_len < needle_len, 0)) return NULL; /* Use optimizations in memchr when possible, to reduce the search size of haystack using a linear algorithm with a smaller coefficient. However, avoid memchr for long needles, since we can often achieve sublinear performance. */ if (needle_len < LONG_NEEDLE_THRESHOLD) { haystack = memchr (haystack, *needle, haystack_len); if (!haystack || __builtin_expect (needle_len == 1, 0)) return (void *) haystack; haystack_len -= haystack - (const unsigned char *) haystack_start; if (haystack_len < needle_len) return NULL; return two_way_short_needle (haystack, haystack_len, needle, needle_len); } else return two_way_long_needle (haystack, haystack_len, needle, needle_len); } #undef LONG_NEEDLE_THRESHOLD lftp-4.6.3a/lib/gettimeofday.c0000644000015000007670000000775112466374011013164 00000000000000/* Provide gettimeofday for systems that don't have it or for which it's broken. Copyright (C) 2001-2003, 2005-2007, 2009-2015 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 . */ /* written by Jim Meyering */ #include /* Specification. */ #include #include #if HAVE_SYS_TIMEB_H # include #endif #if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME /* Work around the bug in some systems whereby gettimeofday clobbers the static buffer that localtime uses for its return value. The gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has this problem. The tzset replacement is necessary for at least Solaris 2.5, 2.5.1, and 2.6. */ static struct tm tm_zero_buffer; static struct tm *localtime_buffer_addr = &tm_zero_buffer; # undef localtime extern struct tm *localtime (time_t const *); # undef gmtime extern struct tm *gmtime (time_t const *); /* This is a wrapper for localtime. It is used only on systems for which gettimeofday clobbers the static buffer used for localtime's result. On the first call, record the address of the static buffer that localtime uses for its result. */ struct tm * rpl_localtime (time_t const *timep) { struct tm *tm = localtime (timep); if (localtime_buffer_addr == &tm_zero_buffer) localtime_buffer_addr = tm; return tm; } /* Same as above, since gmtime and localtime use the same buffer. */ struct tm * rpl_gmtime (time_t const *timep) { struct tm *tm = gmtime (timep); if (localtime_buffer_addr == &tm_zero_buffer) localtime_buffer_addr = tm; return tm; } #endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ #if TZSET_CLOBBERS_LOCALTIME # undef tzset extern void tzset (void); /* This is a wrapper for tzset, for systems on which tzset may clobber the static buffer used for localtime's result. */ void rpl_tzset (void) { /* Save and restore the contents of the buffer used for localtime's result around the call to tzset. */ struct tm save = *localtime_buffer_addr; tzset (); *localtime_buffer_addr = save; } #endif /* This is a wrapper for gettimeofday. It is used only on systems that lack this function, or whose implementation of this function causes problems. */ int gettimeofday (struct timeval *restrict tv, void *restrict tz) { #undef gettimeofday #if HAVE_GETTIMEOFDAY # if GETTIMEOFDAY_CLOBBERS_LOCALTIME /* Save and restore the contents of the buffer used for localtime's result around the call to gettimeofday. */ struct tm save = *localtime_buffer_addr; # endif # if defined timeval /* 'struct timeval' overridden by gnulib? */ # undef timeval struct timeval otv; int result = gettimeofday (&otv, (struct timezone *) tz); if (result == 0) { tv->tv_sec = otv.tv_sec; tv->tv_usec = otv.tv_usec; } # else int result = gettimeofday (tv, (struct timezone *) tz); # endif # if GETTIMEOFDAY_CLOBBERS_LOCALTIME *localtime_buffer_addr = save; # endif return result; #else # if HAVE__FTIME struct _timeb timebuf; _ftime (&timebuf); tv->tv_sec = timebuf.time; tv->tv_usec = timebuf.millitm * 1000; # else # if !defined OK_TO_USE_1S_CLOCK # error "Only 1-second nominal clock resolution found. Is that intended?" \ "If so, compile with the -DOK_TO_USE_1S_CLOCK option." # endif tv->tv_sec = time (NULL); tv->tv_usec = 0; # endif return 0; #endif } lftp-4.6.3a/lib/iconv_open-aix.h0000644000015000007670000002365112122621410013406 00000000000000/* ANSI-C code produced by gperf version 3.0.4 */ /* Command-line: gperf -m 10 ./iconv_open-aix.gperf */ /* Computed positions: -k'4,$' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "./iconv_open-aix.gperf" struct mapping { int standard_name; const char vendor_name[10 + 1]; }; #define TOTAL_KEYWORDS 32 #define MIN_WORD_LENGTH 4 #define MAX_WORD_LENGTH 11 #define MIN_HASH_VALUE 6 #define MAX_HASH_VALUE 44 /* maximum key range = 39, duplicates = 0 */ #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static unsigned int mapping_hash (register const char *str, register unsigned int len) { static const unsigned char asso_values[] = { 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 0, 4, 25, 0, 11, 24, 9, 17, 3, 14, 21, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 3, 45, 1, 45, 45, 45, 45, 0, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45 }; return len + asso_values[(unsigned char)str[3]+2] + asso_values[(unsigned char)str[len - 1]]; } struct stringpool_t { char stringpool_str6[sizeof("EUC-TW")]; char stringpool_str7[sizeof("EUC-KR")]; char stringpool_str8[sizeof("CP852")]; char stringpool_str9[sizeof("EUC-JP")]; char stringpool_str10[sizeof("ISO-8859-2")]; char stringpool_str11[sizeof("CP857")]; char stringpool_str12[sizeof("CP850")]; char stringpool_str13[sizeof("ISO-8859-7")]; char stringpool_str14[sizeof("CP932")]; char stringpool_str15[sizeof("GB2312")]; char stringpool_str16[sizeof("BIG5")]; char stringpool_str17[sizeof("CP437")]; char stringpool_str19[sizeof("ISO-8859-5")]; char stringpool_str20[sizeof("ISO-8859-15")]; char stringpool_str21[sizeof("ISO-8859-3")]; char stringpool_str22[sizeof("ISO-8859-13")]; char stringpool_str23[sizeof("CP1046")]; char stringpool_str24[sizeof("ISO-8859-8")]; char stringpool_str25[sizeof("CP856")]; char stringpool_str26[sizeof("CP1125")]; char stringpool_str27[sizeof("ISO-8859-6")]; char stringpool_str28[sizeof("CP865")]; char stringpool_str29[sizeof("CP922")]; char stringpool_str30[sizeof("CP1252")]; char stringpool_str31[sizeof("ISO-8859-9")]; char stringpool_str33[sizeof("CP943")]; char stringpool_str34[sizeof("ISO-8859-4")]; char stringpool_str35[sizeof("ISO-8859-1")]; char stringpool_str38[sizeof("CP1129")]; char stringpool_str40[sizeof("CP869")]; char stringpool_str41[sizeof("CP1124")]; char stringpool_str44[sizeof("CP861")]; }; static const struct stringpool_t stringpool_contents = { "EUC-TW", "EUC-KR", "CP852", "EUC-JP", "ISO-8859-2", "CP857", "CP850", "ISO-8859-7", "CP932", "GB2312", "BIG5", "CP437", "ISO-8859-5", "ISO-8859-15", "ISO-8859-3", "ISO-8859-13", "CP1046", "ISO-8859-8", "CP856", "CP1125", "ISO-8859-6", "CP865", "CP922", "CP1252", "ISO-8859-9", "CP943", "ISO-8859-4", "ISO-8859-1", "CP1129", "CP869", "CP1124", "CP861" }; #define stringpool ((const char *) &stringpool_contents) static const struct mapping mappings[] = { {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, #line 43 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str6, "IBM-eucTW"}, #line 42 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str7, "IBM-eucKR"}, #line 25 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str8, "IBM-852"}, #line 41 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str9, "IBM-eucJP"}, #line 14 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str10, "ISO8859-2"}, #line 27 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str11, "IBM-857"}, #line 24 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str12, "IBM-850"}, #line 19 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str13, "ISO8859-7"}, #line 33 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str14, "IBM-932"}, #line 40 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, "IBM-eucCN"}, #line 44 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str16, "big5"}, #line 23 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str17, "IBM-437"}, {-1}, #line 17 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str19, "ISO8859-5"}, #line 22 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str20, "ISO8859-15"}, #line 15 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str21, "ISO8859-3"}, #line 31 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str22, "IBM-921"}, #line 35 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str23, "IBM-1046"}, #line 20 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str24, "ISO8859-8"}, #line 26 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str25, "IBM-856"}, #line 37 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str26, "IBM-1125"}, #line 18 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str27, "ISO8859-6"}, #line 29 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str28, "IBM-865"}, #line 32 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str29, "IBM-922"}, #line 39 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str30, "IBM-1252"}, #line 21 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str31, "ISO8859-9"}, {-1}, #line 34 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str33, "IBM-943"}, #line 16 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str34, "ISO8859-4"}, #line 13 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str35, "ISO8859-1"}, {-1}, {-1}, #line 38 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str38, "IBM-1129"}, {-1}, #line 30 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str40, "IBM-869"}, #line 36 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str41, "IBM-1124"}, {-1}, {-1}, #line 28 "./iconv_open-aix.gperf" {(int)(long)&((struct stringpool_t *)0)->stringpool_str44, "IBM-861"} }; #ifdef __GNUC__ __inline #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ __attribute__ ((__gnu_inline__)) #endif #endif const struct mapping * mapping_lookup (register const char *str, register unsigned int len) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { register int key = mapping_hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) { register int o = mappings[key].standard_name; if (o >= 0) { register const char *s = o + stringpool; if (*str == *s && !strcmp (str + 1, s + 1)) return &mappings[key]; } } } return 0; } lftp-4.6.3a/lib/c-strncasecmp.c0000644000015000007670000000310612466374011013233 00000000000000/* c-strncasecmp.c -- case insensitive string comparator in C locale Copyright (C) 1998-1999, 2005-2006, 2009-2015 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 . */ #include /* Specification. */ #include "c-strcase.h" #include #include "c-ctype.h" int c_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 = c_tolower (*p1); c2 = c_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); } lftp-4.6.3a/lib/filemode.c0000644000015000007670000001203512466374011012256 00000000000000/* filemode.c -- make a string describing file modes Copyright (C) 1985, 1990, 1993, 1998-2000, 2004, 2006, 2009-2015 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 . */ #include #include "filemode.h" /* The following is for Cray DMF (Data Migration Facility), which is a HSM file system. A migrated file has a 'st_dm_mode' that is different from the normal 'st_mode', so any tests for migrated files should use the former. */ #if HAVE_ST_DM_MODE # define IS_MIGRATED_FILE(statp) \ (S_ISOFD (statp->st_dm_mode) || S_ISOFL (statp->st_dm_mode)) #else # define IS_MIGRATED_FILE(statp) 0 #endif #if ! HAVE_DECL_STRMODE /* Return a character indicating the type of file described by file mode BITS: '-' regular file 'b' block special file 'c' character special file 'C' high performance ("contiguous data") file 'd' directory 'D' door 'l' symbolic link 'm' multiplexed file (7th edition Unix; obsolete) 'n' network special file (HP-UX) 'p' fifo (named pipe) 'P' port 's' socket 'w' whiteout (4.4BSD) '?' some other file type */ static char ftypelet (mode_t bits) { /* These are the most common, so test for them first. */ if (S_ISREG (bits)) return '-'; if (S_ISDIR (bits)) return 'd'; /* Other letters standardized by POSIX 1003.1-2004. */ if (S_ISBLK (bits)) return 'b'; if (S_ISCHR (bits)) return 'c'; if (S_ISLNK (bits)) return 'l'; if (S_ISFIFO (bits)) return 'p'; /* Other file types (though not letters) standardized by POSIX. */ if (S_ISSOCK (bits)) return 's'; /* Nonstandard file types. */ if (S_ISCTG (bits)) return 'C'; if (S_ISDOOR (bits)) return 'D'; if (S_ISMPB (bits) || S_ISMPC (bits) || S_ISMPX (bits)) return 'm'; if (S_ISNWK (bits)) return 'n'; if (S_ISPORT (bits)) return 'P'; if (S_ISWHT (bits)) return 'w'; return '?'; } /* Like filemodestring, but rely only on MODE. */ void strmode (mode_t mode, char *str) { str[0] = ftypelet (mode); str[1] = mode & S_IRUSR ? 'r' : '-'; str[2] = mode & S_IWUSR ? 'w' : '-'; str[3] = (mode & S_ISUID ? (mode & S_IXUSR ? 's' : 'S') : (mode & S_IXUSR ? 'x' : '-')); str[4] = mode & S_IRGRP ? 'r' : '-'; str[5] = mode & S_IWGRP ? 'w' : '-'; str[6] = (mode & S_ISGID ? (mode & S_IXGRP ? 's' : 'S') : (mode & S_IXGRP ? 'x' : '-')); str[7] = mode & S_IROTH ? 'r' : '-'; str[8] = mode & S_IWOTH ? 'w' : '-'; str[9] = (mode & S_ISVTX ? (mode & S_IXOTH ? 't' : 'T') : (mode & S_IXOTH ? 'x' : '-')); str[10] = ' '; str[11] = '\0'; } #endif /* ! HAVE_DECL_STRMODE */ /* filemodestring - fill in string STR with an ls-style ASCII representation of the st_mode field of file stats block STATP. 12 characters are stored in STR. The characters stored in STR are: 0 File type, as in ftypelet above, except that other letters are used for files whose type cannot be determined solely from st_mode: 'F' semaphore 'M' migrated file (Cray DMF) 'Q' message queue 'S' shared memory object 'T' typed memory object 1 'r' if the owner may read, '-' otherwise. 2 'w' if the owner may write, '-' otherwise. 3 'x' if the owner may execute, 's' if the file is set-user-id, '-' otherwise. 'S' if the file is set-user-id, but the execute bit isn't set. 4 'r' if group members may read, '-' otherwise. 5 'w' if group members may write, '-' otherwise. 6 'x' if group members may execute, 's' if the file is set-group-id, '-' otherwise. 'S' if it is set-group-id but not executable. 7 'r' if any user may read, '-' otherwise. 8 'w' if any user may write, '-' otherwise. 9 'x' if any user may execute, 't' if the file is "sticky" (will be retained in swap space after execution), '-' otherwise. 'T' if the file is sticky but not executable. 10 ' ' for compatibility with 4.4BSD strmode, since this interface does not support ACLs. 11 '\0'. */ void filemodestring (struct stat const *statp, char *str) { strmode (statp->st_mode, str); if (S_TYPEISSEM (statp)) str[0] = 'F'; else if (IS_MIGRATED_FILE (statp)) str[0] = 'M'; else if (S_TYPEISMQ (statp)) str[0] = 'Q'; else if (S_TYPEISSHM (statp)) str[0] = 'S'; else if (S_TYPEISTMO (statp)) str[0] = 'T'; } lftp-4.6.3a/lib/btowc.c0000644000015000007670000000210712466374011011607 00000000000000/* Convert unibyte character to wide character. Copyright (C) 2008, 2010-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. 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 . */ #include /* Specification. */ #include #include #include wint_t btowc (int c) { if (c != EOF) { char buf[1]; wchar_t wc; buf[0] = c; if (mbtowc (&wc, buf, 1) >= 0) return wc; } return WEOF; } lftp-4.6.3a/lib/xstrtoumax.c0000644000015000007670000000025212122621313012713 00000000000000#define __strtol strtoumax #define __strtol_t uintmax_t #define __xstrtol xstrtoumax #define STRTOL_T_MINIMUM 0 #define STRTOL_T_MAXIMUM UINTMAX_MAX #include "xstrtol.c" lftp-4.6.3a/lib/config.charset0000644000015000007670000005473612466374011013164 00000000000000#! /bin/sh # Output a system dependent table of character encoding aliases. # # Copyright (C) 2000-2004, 2006-2015 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 . # # The table consists of lines of the form # ALIAS CANONICAL # # ALIAS is the (system dependent) result of "nl_langinfo (CODESET)". # ALIAS is compared in a case sensitive way. # # CANONICAL is the GNU canonical name for this character encoding. # It must be an encoding supported by libiconv. Support by GNU libc is # also desirable. CANONICAL is case insensitive. Usually an upper case # MIME charset name is preferred. # The current list of GNU canonical charset names is as follows. # # name MIME? used by which systems # (darwin = Mac OS X, woe32 = native Windows) # # ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin # ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin # ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin # ISO-8859-3 Y glibc solaris cygwin # ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin # ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin # ISO-8859-6 Y glibc aix hpux solaris cygwin # ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin # ISO-8859-8 Y glibc aix hpux osf solaris cygwin # ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin # ISO-8859-13 glibc netbsd openbsd darwin cygwin # ISO-8859-14 glibc cygwin # ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin # KOI8-R Y glibc solaris freebsd netbsd openbsd darwin # KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin # KOI8-T glibc # CP437 dos # CP775 dos # CP850 aix osf dos # CP852 dos # CP855 dos # CP856 aix # CP857 dos # CP861 dos # CP862 dos # CP864 dos # CP865 dos # CP866 freebsd netbsd openbsd darwin dos # CP869 dos # CP874 woe32 dos # CP922 aix # CP932 aix cygwin woe32 dos # CP943 aix # CP949 osf darwin woe32 dos # CP950 woe32 dos # CP1046 aix # CP1124 aix # CP1125 dos # CP1129 aix # CP1131 darwin # CP1250 woe32 # CP1251 glibc solaris netbsd openbsd darwin cygwin woe32 # CP1252 aix woe32 # CP1253 woe32 # CP1254 woe32 # CP1255 glibc woe32 # CP1256 woe32 # CP1257 woe32 # GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin # EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin # EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin # EUC-TW glibc aix hpux irix osf solaris netbsd # BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin # BIG5-HKSCS glibc solaris darwin # GBK glibc aix osf solaris darwin cygwin woe32 dos # GB18030 glibc solaris netbsd darwin # SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin # JOHAB glibc solaris woe32 # TIS-620 glibc aix hpux osf solaris cygwin # VISCII Y glibc # TCVN5712-1 glibc # ARMSCII-8 glibc darwin # GEORGIAN-PS glibc cygwin # PT154 glibc # HP-ROMAN8 hpux # HP-ARABIC8 hpux # HP-GREEK8 hpux # HP-HEBREW8 hpux # HP-TURKISH8 hpux # HP-KANA8 hpux # DEC-KANJI osf # DEC-HANYU osf # UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin # # Note: Names which are not marked as being a MIME name should not be used in # Internet protocols for information interchange (mail, news, etc.). # # Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications # must understand both names and treat them as equivalent. # # The first argument passed to this file is the canonical host specification, # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM host="$1" os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'` echo "# This file contains a table of character encoding aliases," echo "# suitable for operating system '${os}'." echo "# It was automatically generated from config.charset." # List of references, updated during installation: echo "# Packages using this file: " case "$os" in linux-gnulibc1*) # Linux libc5 doesn't have nl_langinfo(CODESET); therefore # localcharset.c falls back to using the full locale name # from the environment variables. echo "C ASCII" echo "POSIX ASCII" for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \ en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \ en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \ es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \ et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \ fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \ it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \ sv_FI sv_SE; do echo "$l ISO-8859-1" echo "$l.iso-8859-1 ISO-8859-1" echo "$l.iso-8859-15 ISO-8859-15" echo "$l.iso-8859-15@euro ISO-8859-15" echo "$l@euro ISO-8859-15" echo "$l.cp-437 CP437" echo "$l.cp-850 CP850" echo "$l.cp-1252 CP1252" echo "$l.cp-1252@euro CP1252" #echo "$l.atari-st ATARI-ST" # not a commonly used encoding echo "$l.utf-8 UTF-8" echo "$l.utf-8@euro UTF-8" done for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \ sl_SI sr sr_CS sr_YU; do echo "$l ISO-8859-2" echo "$l.iso-8859-2 ISO-8859-2" echo "$l.cp-852 CP852" echo "$l.cp-1250 CP1250" echo "$l.utf-8 UTF-8" done for l in mk mk_MK ru ru_RU; do echo "$l ISO-8859-5" echo "$l.iso-8859-5 ISO-8859-5" echo "$l.koi8-r KOI8-R" echo "$l.cp-866 CP866" echo "$l.cp-1251 CP1251" echo "$l.utf-8 UTF-8" done for l in ar ar_SA; do echo "$l ISO-8859-6" echo "$l.iso-8859-6 ISO-8859-6" echo "$l.cp-864 CP864" #echo "$l.cp-868 CP868" # not a commonly used encoding echo "$l.cp-1256 CP1256" echo "$l.utf-8 UTF-8" done for l in el el_GR gr gr_GR; do echo "$l ISO-8859-7" echo "$l.iso-8859-7 ISO-8859-7" echo "$l.cp-869 CP869" echo "$l.cp-1253 CP1253" echo "$l.cp-1253@euro CP1253" echo "$l.utf-8 UTF-8" echo "$l.utf-8@euro UTF-8" done for l in he he_IL iw iw_IL; do echo "$l ISO-8859-8" echo "$l.iso-8859-8 ISO-8859-8" echo "$l.cp-862 CP862" echo "$l.cp-1255 CP1255" echo "$l.utf-8 UTF-8" done for l in tr tr_TR; do echo "$l ISO-8859-9" echo "$l.iso-8859-9 ISO-8859-9" echo "$l.cp-857 CP857" echo "$l.cp-1254 CP1254" echo "$l.utf-8 UTF-8" done for l in lt lt_LT lv lv_LV; do #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name echo "$l ISO-8859-13" done for l in ru_UA uk uk_UA; do echo "$l KOI8-U" done for l in zh zh_CN; do #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name echo "$l GB2312" done for l in ja ja_JP ja_JP.EUC; do echo "$l EUC-JP" done for l in ko ko_KR; do echo "$l EUC-KR" done for l in th th_TH; do echo "$l TIS-620" done for l in fa fa_IR; do #echo "$l ISIRI-3342" # a broken encoding echo "$l.utf-8 UTF-8" done ;; linux* | *-gnu*) # With glibc-2.1 or newer, we don't need any canonicalization, # because glibc has iconv and both glibc and libiconv support all # GNU canonical names directly. Therefore, the Makefile does not # need to install the alias file at all. # The following applies only to glibc-2.0.x and older libcs. echo "ISO_646.IRV:1983 ASCII" ;; aix*) echo "ISO8859-1 ISO-8859-1" echo "ISO8859-2 ISO-8859-2" echo "ISO8859-5 ISO-8859-5" echo "ISO8859-6 ISO-8859-6" echo "ISO8859-7 ISO-8859-7" echo "ISO8859-8 ISO-8859-8" echo "ISO8859-9 ISO-8859-9" echo "ISO8859-15 ISO-8859-15" echo "IBM-850 CP850" echo "IBM-856 CP856" echo "IBM-921 ISO-8859-13" echo "IBM-922 CP922" echo "IBM-932 CP932" echo "IBM-943 CP943" echo "IBM-1046 CP1046" echo "IBM-1124 CP1124" echo "IBM-1129 CP1129" echo "IBM-1252 CP1252" echo "IBM-eucCN GB2312" echo "IBM-eucJP EUC-JP" echo "IBM-eucKR EUC-KR" echo "IBM-eucTW EUC-TW" echo "big5 BIG5" echo "GBK GBK" echo "TIS-620 TIS-620" echo "UTF-8 UTF-8" ;; hpux*) echo "iso88591 ISO-8859-1" echo "iso88592 ISO-8859-2" echo "iso88595 ISO-8859-5" echo "iso88596 ISO-8859-6" echo "iso88597 ISO-8859-7" echo "iso88598 ISO-8859-8" echo "iso88599 ISO-8859-9" echo "iso885915 ISO-8859-15" echo "roman8 HP-ROMAN8" echo "arabic8 HP-ARABIC8" echo "greek8 HP-GREEK8" echo "hebrew8 HP-HEBREW8" echo "turkish8 HP-TURKISH8" echo "kana8 HP-KANA8" echo "tis620 TIS-620" echo "big5 BIG5" echo "eucJP EUC-JP" echo "eucKR EUC-KR" echo "eucTW EUC-TW" echo "hp15CN GB2312" #echo "ccdc ?" # what is this? echo "SJIS SHIFT_JIS" echo "utf8 UTF-8" ;; irix*) echo "ISO8859-1 ISO-8859-1" echo "ISO8859-2 ISO-8859-2" echo "ISO8859-5 ISO-8859-5" echo "ISO8859-7 ISO-8859-7" echo "ISO8859-9 ISO-8859-9" echo "eucCN GB2312" echo "eucJP EUC-JP" echo "eucKR EUC-KR" echo "eucTW EUC-TW" ;; osf*) echo "ISO8859-1 ISO-8859-1" echo "ISO8859-2 ISO-8859-2" echo "ISO8859-4 ISO-8859-4" echo "ISO8859-5 ISO-8859-5" echo "ISO8859-7 ISO-8859-7" echo "ISO8859-8 ISO-8859-8" echo "ISO8859-9 ISO-8859-9" echo "ISO8859-15 ISO-8859-15" echo "cp850 CP850" echo "big5 BIG5" echo "dechanyu DEC-HANYU" echo "dechanzi GB2312" echo "deckanji DEC-KANJI" echo "deckorean EUC-KR" echo "eucJP EUC-JP" echo "eucKR EUC-KR" echo "eucTW EUC-TW" echo "GBK GBK" echo "KSC5601 CP949" echo "sdeckanji EUC-JP" echo "SJIS SHIFT_JIS" echo "TACTIS TIS-620" echo "UTF-8 UTF-8" ;; solaris*) echo "646 ASCII" echo "ISO8859-1 ISO-8859-1" echo "ISO8859-2 ISO-8859-2" echo "ISO8859-3 ISO-8859-3" echo "ISO8859-4 ISO-8859-4" echo "ISO8859-5 ISO-8859-5" echo "ISO8859-6 ISO-8859-6" echo "ISO8859-7 ISO-8859-7" echo "ISO8859-8 ISO-8859-8" echo "ISO8859-9 ISO-8859-9" echo "ISO8859-15 ISO-8859-15" echo "koi8-r KOI8-R" echo "ansi-1251 CP1251" echo "BIG5 BIG5" echo "Big5-HKSCS BIG5-HKSCS" echo "gb2312 GB2312" echo "GBK GBK" echo "GB18030 GB18030" echo "cns11643 EUC-TW" echo "5601 EUC-KR" echo "ko_KR.johap92 JOHAB" echo "eucJP EUC-JP" echo "PCK SHIFT_JIS" echo "TIS620.2533 TIS-620" #echo "sun_eu_greek ?" # what is this? echo "UTF-8 UTF-8" ;; freebsd*) # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore # localcharset.c falls back to using the full locale name # from the environment variables. echo "C ASCII" echo "US-ASCII ASCII" for l in la_LN lt_LN; do echo "$l.ASCII ASCII" done for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \ lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do echo "$l.ISO_8859-1 ISO-8859-1" echo "$l.DIS_8859-15 ISO-8859-15" done for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do echo "$l.ISO_8859-2 ISO-8859-2" done for l in la_LN lt_LT; do echo "$l.ISO_8859-4 ISO-8859-4" done for l in ru_RU ru_SU; do echo "$l.KOI8-R KOI8-R" echo "$l.ISO_8859-5 ISO-8859-5" echo "$l.CP866 CP866" done echo "uk_UA.KOI8-U KOI8-U" echo "zh_TW.BIG5 BIG5" echo "zh_TW.Big5 BIG5" echo "zh_CN.EUC GB2312" echo "ja_JP.EUC EUC-JP" echo "ja_JP.SJIS SHIFT_JIS" echo "ja_JP.Shift_JIS SHIFT_JIS" echo "ko_KR.EUC EUC-KR" ;; netbsd*) echo "646 ASCII" echo "ISO8859-1 ISO-8859-1" echo "ISO8859-2 ISO-8859-2" echo "ISO8859-4 ISO-8859-4" echo "ISO8859-5 ISO-8859-5" echo "ISO8859-7 ISO-8859-7" echo "ISO8859-13 ISO-8859-13" echo "ISO8859-15 ISO-8859-15" echo "eucCN GB2312" echo "eucJP EUC-JP" echo "eucKR EUC-KR" echo "eucTW EUC-TW" echo "BIG5 BIG5" echo "SJIS SHIFT_JIS" ;; openbsd*) echo "646 ASCII" echo "ISO8859-1 ISO-8859-1" echo "ISO8859-2 ISO-8859-2" echo "ISO8859-4 ISO-8859-4" echo "ISO8859-5 ISO-8859-5" echo "ISO8859-7 ISO-8859-7" echo "ISO8859-13 ISO-8859-13" echo "ISO8859-15 ISO-8859-15" ;; darwin[56]*) # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore # localcharset.c falls back to using the full locale name # from the environment variables. echo "C ASCII" for l in en_AU en_CA en_GB en_US la_LN; do echo "$l.US-ASCII ASCII" done for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \ nl_NL no_NO pt_PT sv_SE; do echo "$l ISO-8859-1" echo "$l.ISO8859-1 ISO-8859-1" echo "$l.ISO8859-15 ISO-8859-15" done for l in la_LN; do echo "$l.ISO8859-1 ISO-8859-1" echo "$l.ISO8859-15 ISO-8859-15" done for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do echo "$l.ISO8859-2 ISO-8859-2" done for l in la_LN lt_LT; do echo "$l.ISO8859-4 ISO-8859-4" done for l in ru_RU; do echo "$l.KOI8-R KOI8-R" echo "$l.ISO8859-5 ISO-8859-5" echo "$l.CP866 CP866" done for l in bg_BG; do echo "$l.CP1251 CP1251" done echo "uk_UA.KOI8-U KOI8-U" echo "zh_TW.BIG5 BIG5" echo "zh_TW.Big5 BIG5" echo "zh_CN.EUC GB2312" echo "ja_JP.EUC EUC-JP" echo "ja_JP.SJIS SHIFT_JIS" echo "ko_KR.EUC EUC-KR" ;; darwin*) # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is # useless: # - It returns the empty string when LANG is set to a locale of the # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8 # LC_CTYPE file. # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case. # - The documentation says: # "... all code that calls BSD system routines should ensure # that the const *char parameters of these routines are in UTF-8 # encoding. All BSD system functions expect their string # parameters to be in UTF-8 encoding and nothing else." # It also says # "An additional caveat is that string parameters for files, # paths, and other file-system entities must be in canonical # UTF-8. In a canonical UTF-8 Unicode string, all decomposable # characters are decomposed ..." # but this is not true: You can pass non-decomposed UTF-8 strings # to file system functions, and it is the OS which will convert # them to decomposed UTF-8 before accessing the file system. # - The Apple Terminal application displays UTF-8 by default. # - However, other applications are free to use different encodings: # - xterm uses ISO-8859-1 by default. # - TextEdit uses MacRoman by default. # We prefer UTF-8 over decomposed UTF-8-MAC because one should # minimize the use of decomposed Unicode. Unfortunately, through the # Darwin file system, decomposed UTF-8 strings are leaked into user # space nevertheless. # Then there are also the locales with encodings other than US-ASCII # and UTF-8. These locales can be occasionally useful to users (e.g. # when grepping through ISO-8859-1 encoded text files), when all their # file names are in US-ASCII. echo "ISO8859-1 ISO-8859-1" echo "ISO8859-2 ISO-8859-2" echo "ISO8859-4 ISO-8859-4" echo "ISO8859-5 ISO-8859-5" echo "ISO8859-7 ISO-8859-7" echo "ISO8859-9 ISO-8859-9" echo "ISO8859-13 ISO-8859-13" echo "ISO8859-15 ISO-8859-15" echo "KOI8-R KOI8-R" echo "KOI8-U KOI8-U" echo "CP866 CP866" echo "CP949 CP949" echo "CP1131 CP1131" echo "CP1251 CP1251" echo "eucCN GB2312" echo "GB2312 GB2312" echo "eucJP EUC-JP" echo "eucKR EUC-KR" echo "Big5 BIG5" echo "Big5HKSCS BIG5-HKSCS" echo "GBK GBK" echo "GB18030 GB18030" echo "SJIS SHIFT_JIS" echo "ARMSCII-8 ARMSCII-8" echo "PT154 PT154" #echo "ISCII-DEV ?" echo "* UTF-8" ;; beos* | haiku*) # BeOS and Haiku have a single locale, and it has UTF-8 encoding. echo "* UTF-8" ;; msdosdjgpp*) # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore # localcharset.c falls back to using the full locale name # from the environment variables. echo "#" echo "# The encodings given here may not all be correct." echo "# If you find that the encoding given for your language and" echo "# country is not the one your DOS machine actually uses, just" echo "# correct it in this file, and send a mail to" echo "# Juan Manuel Guerrero " echo "# and Bruno Haible ." echo "#" echo "C ASCII" # ISO-8859-1 languages echo "ca CP850" echo "ca_ES CP850" echo "da CP865" # not CP850 ?? echo "da_DK CP865" # not CP850 ?? echo "de CP850" echo "de_AT CP850" echo "de_CH CP850" echo "de_DE CP850" echo "en CP850" echo "en_AU CP850" # not CP437 ?? echo "en_CA CP850" echo "en_GB CP850" echo "en_NZ CP437" echo "en_US CP437" echo "en_ZA CP850" # not CP437 ?? echo "es CP850" echo "es_AR CP850" echo "es_BO CP850" echo "es_CL CP850" echo "es_CO CP850" echo "es_CR CP850" echo "es_CU CP850" echo "es_DO CP850" echo "es_EC CP850" echo "es_ES CP850" echo "es_GT CP850" echo "es_HN CP850" echo "es_MX CP850" echo "es_NI CP850" echo "es_PA CP850" echo "es_PY CP850" echo "es_PE CP850" echo "es_SV CP850" echo "es_UY CP850" echo "es_VE CP850" echo "et CP850" echo "et_EE CP850" echo "eu CP850" echo "eu_ES CP850" echo "fi CP850" echo "fi_FI CP850" echo "fr CP850" echo "fr_BE CP850" echo "fr_CA CP850" echo "fr_CH CP850" echo "fr_FR CP850" echo "ga CP850" echo "ga_IE CP850" echo "gd CP850" echo "gd_GB CP850" echo "gl CP850" echo "gl_ES CP850" echo "id CP850" # not CP437 ?? echo "id_ID CP850" # not CP437 ?? echo "is CP861" # not CP850 ?? echo "is_IS CP861" # not CP850 ?? echo "it CP850" echo "it_CH CP850" echo "it_IT CP850" echo "lt CP775" echo "lt_LT CP775" echo "lv CP775" echo "lv_LV CP775" echo "nb CP865" # not CP850 ?? echo "nb_NO CP865" # not CP850 ?? echo "nl CP850" echo "nl_BE CP850" echo "nl_NL CP850" echo "nn CP865" # not CP850 ?? echo "nn_NO CP865" # not CP850 ?? echo "no CP865" # not CP850 ?? echo "no_NO CP865" # not CP850 ?? echo "pt CP850" echo "pt_BR CP850" echo "pt_PT CP850" echo "sv CP850" echo "sv_SE CP850" # ISO-8859-2 languages echo "cs CP852" echo "cs_CZ CP852" echo "hr CP852" echo "hr_HR CP852" echo "hu CP852" echo "hu_HU CP852" echo "pl CP852" echo "pl_PL CP852" echo "ro CP852" echo "ro_RO CP852" echo "sk CP852" echo "sk_SK CP852" echo "sl CP852" echo "sl_SI CP852" echo "sq CP852" echo "sq_AL CP852" echo "sr CP852" # CP852 or CP866 or CP855 ?? echo "sr_CS CP852" # CP852 or CP866 or CP855 ?? echo "sr_YU CP852" # CP852 or CP866 or CP855 ?? # ISO-8859-3 languages echo "mt CP850" echo "mt_MT CP850" # ISO-8859-5 languages echo "be CP866" echo "be_BE CP866" echo "bg CP866" # not CP855 ?? echo "bg_BG CP866" # not CP855 ?? echo "mk CP866" # not CP855 ?? echo "mk_MK CP866" # not CP855 ?? echo "ru CP866" echo "ru_RU CP866" echo "uk CP1125" echo "uk_UA CP1125" # ISO-8859-6 languages echo "ar CP864" echo "ar_AE CP864" echo "ar_DZ CP864" echo "ar_EG CP864" echo "ar_IQ CP864" echo "ar_IR CP864" echo "ar_JO CP864" echo "ar_KW CP864" echo "ar_MA CP864" echo "ar_OM CP864" echo "ar_QA CP864" echo "ar_SA CP864" echo "ar_SY CP864" # ISO-8859-7 languages echo "el CP869" echo "el_GR CP869" # ISO-8859-8 languages echo "he CP862" echo "he_IL CP862" # ISO-8859-9 languages echo "tr CP857" echo "tr_TR CP857" # Japanese echo "ja CP932" echo "ja_JP CP932" # Chinese echo "zh_CN GBK" echo "zh_TW CP950" # not CP938 ?? # Korean echo "kr CP949" # not CP934 ?? echo "kr_KR CP949" # not CP934 ?? # Thai echo "th CP874" echo "th_TH CP874" # Other echo "eo CP850" echo "eo_EO CP850" ;; esac lftp-4.6.3a/lib/fstat.c0000644000015000007670000000460512466374011011617 00000000000000/* fstat() replacement. Copyright (C) 2011-2015 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 . */ /* If the user's config.h happens to include , let it include only the system's here, so that orig_fstat doesn't recurse to rpl_fstat. */ #define __need_system_sys_stat_h #include /* Get the original definition of fstat. It might be defined as a macro. */ #include #include #if _GL_WINDOWS_64_BIT_ST_SIZE # undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ # define stat _stati64 # undef fstat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ # define fstat _fstati64 #endif #undef __need_system_sys_stat_h static int orig_fstat (int fd, struct stat *buf) { return fstat (fd, buf); } /* Specification. */ /* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ #include "sys/stat.h" #include #include #if HAVE_MSVC_INVALID_PARAMETER_HANDLER # include "msvc-inval.h" #endif #if HAVE_MSVC_INVALID_PARAMETER_HANDLER static int fstat_nothrow (int fd, struct stat *buf) { int result; TRY_MSVC_INVAL { result = orig_fstat (fd, buf); } CATCH_MSVC_INVAL { result = -1; errno = EBADF; } DONE_MSVC_INVAL; return result; } #else # define fstat_nothrow orig_fstat #endif int rpl_fstat (int fd, struct stat *buf) { #if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY /* Handle the case when rpl_open() used a dummy file descriptor to work around an open() that can't normally visit directories. */ const char *name = _gl_directory_name (fd); if (name != NULL) return stat (name, buf); #endif return fstat_nothrow (fd, buf); } lftp-4.6.3a/lib/frexp.c0000644000015000007670000001036112466374011011616 00000000000000/* Split a double into fraction and mantissa. Copyright (C) 2007-2015 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 . */ /* Written by Paolo Bonzini , 2003, and Bruno Haible , 2007. */ #if ! defined USE_LONG_DOUBLE # include #endif /* Specification. */ #include #include #ifdef USE_LONG_DOUBLE # include "isnanl-nolibm.h" # include "fpucw.h" #else # include "isnand-nolibm.h" #endif /* This file assumes FLT_RADIX = 2. If FLT_RADIX is a power of 2 greater than 2, or not even a power of 2, some rounding errors can occur, so that then the returned mantissa is only guaranteed to be <= 1.0, not < 1.0. */ #ifdef USE_LONG_DOUBLE # define FUNC frexpl # define DOUBLE long double # define ISNAN isnanl # define DECL_ROUNDING DECL_LONG_DOUBLE_ROUNDING # define BEGIN_ROUNDING() BEGIN_LONG_DOUBLE_ROUNDING () # define END_ROUNDING() END_LONG_DOUBLE_ROUNDING () # define L_(literal) literal##L #else # define FUNC frexp # define DOUBLE double # define ISNAN isnand # define DECL_ROUNDING # define BEGIN_ROUNDING() # define END_ROUNDING() # define L_(literal) literal #endif DOUBLE FUNC (DOUBLE x, int *expptr) { int sign; int exponent; DECL_ROUNDING /* Test for NaN, infinity, and zero. */ if (ISNAN (x) || x + x == x) { *expptr = 0; return x; } sign = 0; if (x < 0) { x = - x; sign = -1; } BEGIN_ROUNDING (); { /* Since the exponent is an 'int', it fits in 64 bits. Therefore the loops are executed no more than 64 times. */ DOUBLE pow2[64]; /* pow2[i] = 2^2^i */ DOUBLE powh[64]; /* powh[i] = 2^-2^i */ int i; exponent = 0; if (x >= L_(1.0)) { /* A positive exponent. */ DOUBLE pow2_i; /* = pow2[i] */ DOUBLE powh_i; /* = powh[i] */ /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, x * 2^exponent = argument, x >= 1.0. */ for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); ; i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) { if (x >= pow2_i) { exponent += (1 << i); x *= powh_i; } else break; pow2[i] = pow2_i; powh[i] = powh_i; } /* Avoid making x too small, as it could become a denormalized number and thus lose precision. */ while (i > 0 && x < pow2[i - 1]) { i--; powh_i = powh[i]; } exponent += (1 << i); x *= powh_i; /* Here 2^-2^i <= x < 1.0. */ } else { /* A negative or zero exponent. */ DOUBLE pow2_i; /* = pow2[i] */ DOUBLE powh_i; /* = powh[i] */ /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, x * 2^exponent = argument, x < 1.0. */ for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); ; i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) { if (x < powh_i) { exponent -= (1 << i); x *= pow2_i; } else break; pow2[i] = pow2_i; powh[i] = powh_i; } /* Here 2^-2^i <= x < 1.0. */ } /* Invariants: x * 2^exponent = argument, and 2^-2^i <= x < 1.0. */ while (i > 0) { i--; if (x < powh[i]) { exponent -= (1 << i); x *= pow2[i]; } } /* Here 0.5 <= x < 1.0. */ } if (sign < 0) x = - x; END_ROUNDING (); *expptr = exponent; return x; } lftp-4.6.3a/lib/isnanl-nolibm.h0000644000015000007670000000230712466374011013242 00000000000000/* Test for NaN that does not need libm. Copyright (C) 2007-2015 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 . */ #if HAVE_ISNANL_IN_LIBC /* Get declaration of isnan macro or (older) isnanl function. */ # include # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) # elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) # endif #else /* Test whether X is a NaN. */ # undef isnanl # define isnanl rpl_isnanl extern int isnanl (long double x); #endif lftp-4.6.3a/lib/printf-args.h0000644000015000007670000000753312466374011012742 00000000000000/* Decomposed printf argument list. Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2015 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 . */ #ifndef _PRINTF_ARGS_H #define _PRINTF_ARGS_H /* This file can be parametrized with the following macros: ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. PRINTF_FETCHARGS Name of the function to be declared. STATIC Set to 'static' to declare the function static. */ /* Default parameters. */ #ifndef PRINTF_FETCHARGS # define PRINTF_FETCHARGS printf_fetchargs #endif /* Get size_t. */ #include /* Get wchar_t. */ #if HAVE_WCHAR_T # include #endif /* Get wint_t. */ #if HAVE_WINT_T # include #endif /* Get va_list. */ #include /* Argument types */ typedef enum { TYPE_NONE, TYPE_SCHAR, TYPE_UCHAR, TYPE_SHORT, TYPE_USHORT, TYPE_INT, TYPE_UINT, TYPE_LONGINT, TYPE_ULONGINT, #if HAVE_LONG_LONG_INT TYPE_LONGLONGINT, TYPE_ULONGLONGINT, #endif TYPE_DOUBLE, TYPE_LONGDOUBLE, TYPE_CHAR, #if HAVE_WINT_T TYPE_WIDE_CHAR, #endif TYPE_STRING, #if HAVE_WCHAR_T TYPE_WIDE_STRING, #endif TYPE_POINTER, TYPE_COUNT_SCHAR_POINTER, TYPE_COUNT_SHORT_POINTER, TYPE_COUNT_INT_POINTER, TYPE_COUNT_LONGINT_POINTER #if HAVE_LONG_LONG_INT , TYPE_COUNT_LONGLONGINT_POINTER #endif #if ENABLE_UNISTDIO /* The unistdio extensions. */ , TYPE_U8_STRING , TYPE_U16_STRING , TYPE_U32_STRING #endif } arg_type; /* Polymorphic argument */ typedef struct { arg_type type; union { signed char a_schar; unsigned char a_uchar; short a_short; unsigned short a_ushort; int a_int; unsigned int a_uint; long int a_longint; unsigned long int a_ulongint; #if HAVE_LONG_LONG_INT long long int a_longlongint; unsigned long long int a_ulonglongint; #endif float a_float; double a_double; long double a_longdouble; int a_char; #if HAVE_WINT_T wint_t a_wide_char; #endif const char* a_string; #if HAVE_WCHAR_T const wchar_t* a_wide_string; #endif void* a_pointer; signed char * a_count_schar_pointer; short * a_count_short_pointer; int * a_count_int_pointer; long int * a_count_longint_pointer; #if HAVE_LONG_LONG_INT long long int * a_count_longlongint_pointer; #endif #if ENABLE_UNISTDIO /* The unistdio extensions. */ const uint8_t * a_u8_string; const uint16_t * a_u16_string; const uint32_t * a_u32_string; #endif } a; } argument; /* Number of directly allocated arguments (no malloc() needed). */ #define N_DIRECT_ALLOC_ARGUMENTS 7 typedef struct { size_t count; argument *arg; argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS]; } arguments; /* Fetch the arguments, putting them into a. */ #ifdef STATIC STATIC #else extern #endif int PRINTF_FETCHARGS (va_list args, arguments *a); #endif /* _PRINTF_ARGS_H */ lftp-4.6.3a/lib/sys_uio.in.h0000644000015000007670000000317412466374012012603 00000000000000/* Substitute for . Copyright (C) 2011-2015 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 . */ # if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ # endif @PRAGMA_COLUMNS@ #ifndef _@GUARD_PREFIX@_SYS_UIO_H #if @HAVE_SYS_UIO_H@ /* On OpenBSD 4.4, assumes prior inclusion of . */ # include /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_SYS_UIO_H@ #endif #ifndef _@GUARD_PREFIX@_SYS_UIO_H #define _@GUARD_PREFIX@_SYS_UIO_H #if !@HAVE_SYS_UIO_H@ /* A platform that lacks . */ /* Get 'size_t' and 'ssize_t'. */ # include # ifdef __cplusplus extern "C" { # endif # if !GNULIB_defined_struct_iovec /* All known platforms that lack also lack any declaration of struct iovec in any other header. */ struct iovec { void *iov_base; size_t iov_len; }; # define GNULIB_defined_struct_iovec 1 # endif # ifdef __cplusplus } # endif #endif #endif /* _@GUARD_PREFIX@_SYS_UIO_H */ #endif /* _@GUARD_PREFIX@_SYS_UIO_H */ lftp-4.6.3a/lib/inet_pton.c0000644000015000007670000001537212466374011012500 00000000000000/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form Copyright (C) 2006, 2008-2015 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 . */ /* * Copyright (c) 1996,1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include /* Specification. */ #include #if HAVE_DECL_INET_PTON # undef inet_pton int rpl_inet_pton (int af, const char *restrict src, void *restrict dst) { return inet_pton (af, src, dst); } #else # include # include # include # define NS_INADDRSZ 4 # define NS_IN6ADDRSZ 16 # define NS_INT16SZ 2 /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ static int inet_pton4 (const char *src, unsigned char *dst); # if HAVE_IPV6 static int inet_pton6 (const char *src, unsigned char *dst); # endif /* int * inet_pton(af, src, dst) * convert from presentation format (which usually means ASCII printable) * to network format (which is usually some kind of binary format). * return: * 1 if the address was valid for the specified address family * 0 if the address wasn't valid ('dst' is untouched in this case) * -1 if some other error occurred ('dst' is untouched in this case, too) * author: * Paul Vixie, 1996. */ int inet_pton (int af, const char *restrict src, void *restrict dst) { switch (af) { case AF_INET: return (inet_pton4 (src, dst)); # if HAVE_IPV6 case AF_INET6: return (inet_pton6 (src, dst)); # endif default: errno = EAFNOSUPPORT; return (-1); } /* NOTREACHED */ } /* int * inet_pton4(src, dst) * like inet_aton() but without all the hexadecimal, octal (with the * exception of 0) and shorthand. * return: * 1 if 'src' is a valid dotted quad, else 0. * notice: * does not touch 'dst' unless it's returning 1. * author: * Paul Vixie, 1996. */ static int inet_pton4 (const char *restrict src, unsigned char *restrict dst) { int saw_digit, octets, ch; unsigned char tmp[NS_INADDRSZ], *tp; saw_digit = 0; octets = 0; *(tp = tmp) = 0; while ((ch = *src++) != '\0') { if (ch >= '0' && ch <= '9') { unsigned new = *tp * 10 + (ch - '0'); if (saw_digit && *tp == 0) return (0); if (new > 255) return (0); *tp = new; if (!saw_digit) { if (++octets > 4) return (0); saw_digit = 1; } } else if (ch == '.' && saw_digit) { if (octets == 4) return (0); *++tp = 0; saw_digit = 0; } else return (0); } if (octets < 4) return (0); memcpy (dst, tmp, NS_INADDRSZ); return (1); } # if HAVE_IPV6 /* int * inet_pton6(src, dst) * convert presentation level address to network order binary form. * return: * 1 if 'src' is a valid [RFC1884 2.2] address, else 0. * notice: * (1) does not touch 'dst' unless it's returning 1. * (2) :: in a full address is silently ignored. * credit: * inspired by Mark Andrews. * author: * Paul Vixie, 1996. */ static int inet_pton6 (const char *restrict src, unsigned char *restrict dst) { static const char xdigits[] = "0123456789abcdef"; unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; const char *curtok; int ch, saw_xdigit; unsigned val; tp = memset (tmp, '\0', NS_IN6ADDRSZ); endp = tp + NS_IN6ADDRSZ; colonp = NULL; /* Leading :: requires some special handling. */ if (*src == ':') if (*++src != ':') return (0); curtok = src; saw_xdigit = 0; val = 0; while ((ch = c_tolower (*src++)) != '\0') { const char *pch; pch = strchr (xdigits, ch); if (pch != NULL) { val <<= 4; val |= (pch - xdigits); if (val > 0xffff) return (0); saw_xdigit = 1; continue; } if (ch == ':') { curtok = src; if (!saw_xdigit) { if (colonp) return (0); colonp = tp; continue; } else if (*src == '\0') { return (0); } if (tp + NS_INT16SZ > endp) return (0); *tp++ = (u_char) (val >> 8) & 0xff; *tp++ = (u_char) val & 0xff; saw_xdigit = 0; val = 0; continue; } if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && inet_pton4 (curtok, tp) > 0) { tp += NS_INADDRSZ; saw_xdigit = 0; break; /* '\0' was seen by inet_pton4(). */ } return (0); } if (saw_xdigit) { if (tp + NS_INT16SZ > endp) return (0); *tp++ = (u_char) (val >> 8) & 0xff; *tp++ = (u_char) val & 0xff; } if (colonp != NULL) { /* * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ const int n = tp - colonp; int i; if (tp == endp) return (0); for (i = 1; i <= n; i++) { endp[-i] = colonp[n - i]; colonp[n - i] = 0; } tp = endp; } if (tp != endp) return (0); memcpy (dst, tmp, NS_IN6ADDRSZ); return (1); } # endif #endif lftp-4.6.3a/lib/c-strcaseeq.h0000644000015000007670000001077412466374011012721 00000000000000/* Optimized case-insensitive string comparison in C locale. Copyright (C) 2001-2002, 2007, 2009-2015 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 . */ /* Written by Bruno Haible . */ #include "c-strcase.h" #include "c-ctype.h" /* STRCASEEQ allows to optimize string comparison with a small literal string. STRCASEEQ (s, "UTF-8", 'U','T','F','-','8',0,0,0,0) is semantically equivalent to c_strcasecmp (s, "UTF-8") == 0 just faster. */ /* Help GCC to generate good code for string comparisons with immediate strings. */ #if defined (__GNUC__) && defined (__OPTIMIZE__) /* Case insensitive comparison of ASCII characters. */ # if C_CTYPE_ASCII # define CASEEQ(other,upper) \ (c_isupper (upper) ? ((other) & ~0x20) == (upper) : (other) == (upper)) # elif C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE # define CASEEQ(other,upper) \ (c_isupper (upper) ? (other) == (upper) || (other) == (upper) - 'A' + 'a' : (other) == (upper)) # else # define CASEEQ(other,upper) \ (c_toupper (other) == (upper)) # endif static inline int strcaseeq9 (const char *s1, const char *s2) { return c_strcasecmp (s1 + 9, s2 + 9) == 0; } static inline int strcaseeq8 (const char *s1, const char *s2, char s28) { if (CASEEQ (s1[8], s28)) { if (s28 == 0) return 1; else return strcaseeq9 (s1, s2); } else return 0; } static inline int strcaseeq7 (const char *s1, const char *s2, char s27, char s28) { if (CASEEQ (s1[7], s27)) { if (s27 == 0) return 1; else return strcaseeq8 (s1, s2, s28); } else return 0; } static inline int strcaseeq6 (const char *s1, const char *s2, char s26, char s27, char s28) { if (CASEEQ (s1[6], s26)) { if (s26 == 0) return 1; else return strcaseeq7 (s1, s2, s27, s28); } else return 0; } static inline int strcaseeq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28) { if (CASEEQ (s1[5], s25)) { if (s25 == 0) return 1; else return strcaseeq6 (s1, s2, s26, s27, s28); } else return 0; } static inline int strcaseeq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28) { if (CASEEQ (s1[4], s24)) { if (s24 == 0) return 1; else return strcaseeq5 (s1, s2, s25, s26, s27, s28); } else return 0; } static inline int strcaseeq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28) { if (CASEEQ (s1[3], s23)) { if (s23 == 0) return 1; else return strcaseeq4 (s1, s2, s24, s25, s26, s27, s28); } else return 0; } static inline int strcaseeq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28) { if (CASEEQ (s1[2], s22)) { if (s22 == 0) return 1; else return strcaseeq3 (s1, s2, s23, s24, s25, s26, s27, s28); } else return 0; } static inline int strcaseeq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) { if (CASEEQ (s1[1], s21)) { if (s21 == 0) return 1; else return strcaseeq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28); } else return 0; } static inline int strcaseeq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) { if (CASEEQ (s1[0], s20)) { if (s20 == 0) return 1; else return strcaseeq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28); } else return 0; } #define STRCASEEQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ strcaseeq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28) #else #define STRCASEEQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ (c_strcasecmp (s1, s2) == 0) #endif lftp-4.6.3a/lib/readlink.c0000644000015000007670000000446312466374011012271 00000000000000/* Stub for readlink(). Copyright (C) 2003-2007, 2009-2015 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 . */ #include /* Specification. */ #include #include #include #include #if !HAVE_READLINK /* readlink() substitute for systems that don't have a readlink() function, such as DJGPP 2.03 and mingw32. */ ssize_t readlink (const char *name, char *buf _GL_UNUSED, size_t bufsize _GL_UNUSED) { struct stat statbuf; /* In general we should use lstat() here, not stat(). But on platforms without symbolic links, lstat() - if it exists - would be equivalent to stat(), therefore we can use stat(). This saves us a configure check. */ if (stat (name, &statbuf) >= 0) errno = EINVAL; return -1; } #else /* HAVE_READLINK */ # undef readlink /* readlink() wrapper that uses correct types, for systems like cygwin 1.5.x where readlink returns int, and which rejects trailing slash, for Solaris 9. */ ssize_t rpl_readlink (const char *name, char *buf, size_t bufsize) { # if READLINK_TRAILING_SLASH_BUG size_t len = strlen (name); if (len && name[len - 1] == '/') { /* Even if name without the slash is a symlink to a directory, both lstat() and stat() must resolve the trailing slash to the directory rather than the symlink. We can therefore safely use stat() to distinguish between EINVAL and ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */ struct stat st; if (stat (name, &st) == 0) errno = EINVAL; return -1; } # endif /* READLINK_TRAILING_SLASH_BUG */ return readlink (name, buf, bufsize); } #endif /* HAVE_READLINK */ lftp-4.6.3a/lib/wchar.in.h0000644000015000007670000010167512466374012012222 00000000000000/* A substitute for ISO C99 , for platforms that have issues. Copyright (C) 2007-2015 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 . */ /* Written by Eric Blake. */ /* * ISO C 99 for platforms that have issues. * * * For now, this just ensures proper prerequisite inclusion order and * the declaration of wcwidth(). */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H /* Special invocation convention: - Inside glibc and uClibc header files. - On HP-UX 11.00 we have a sequence of nested includes -> -> , and the latter includes , once indirectly -> -> -> and once directly. In both situations 'wint_t' is not yet defined, therefore we cannot provide the function overrides; instead include only the system's . - On IRIX 6.5, similarly, we have an include -> , and the latter includes . But here, we have no way to detect whether is completely included or is still being included. */ #@INCLUDE_NEXT@ @NEXT_WCHAR_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_WCHAR_H #define _GL_ALREADY_INCLUDING_WCHAR_H #if @HAVE_FEATURES_H@ # include /* for __GLIBC__ */ #endif /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . In some builds of uClibc, is nonexistent and wchar_t is defined by . But avoid namespace pollution on glibc systems. */ #if !(defined __GLIBC__ && !defined __UCLIBC__) # include #endif #ifndef __GLIBC__ # include # include #endif /* Include the original if it exists. Some builds of uClibc lack it. */ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_WCHAR_H@ # @INCLUDE_NEXT@ @NEXT_WCHAR_H@ #endif #undef _GL_ALREADY_INCLUDING_WCHAR_H #ifndef _@GUARD_PREFIX@_WCHAR_H #define _@GUARD_PREFIX@_WCHAR_H /* The __attribute__ feature is available in gcc versions 2.5 and later. The attribute __pure__ was added in gcc 2.96. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else # define _GL_ATTRIBUTE_PURE /* empty */ #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. */ /* Define wint_t and WEOF. (Also done in wctype.in.h.) */ #if !@HAVE_WINT_T@ && !defined wint_t # define wint_t int # ifndef WEOF # define WEOF -1 # endif #else /* MSVC defines wint_t as 'unsigned short' in . This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be "unchanged by default argument promotions". Override it. */ # if defined _MSC_VER # if !GNULIB_defined_wint_t # include typedef unsigned int rpl_wint_t; # undef wint_t # define wint_t rpl_wint_t # define GNULIB_defined_wint_t 1 # endif # endif # ifndef WEOF # define WEOF ((wint_t) -1) # endif #endif /* Override mbstate_t if it is too small. On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for implementing mbrtowc for encodings like UTF-8. */ #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ # if !GNULIB_defined_mbstate_t typedef int rpl_mbstate_t; # undef mbstate_t # define mbstate_t rpl_mbstate_t # define GNULIB_defined_mbstate_t 1 # endif #endif /* Convert a single-byte character to a wide character. */ #if @GNULIB_BTOWC@ # if @REPLACE_BTOWC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef btowc # define btowc rpl_btowc # endif _GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); _GL_CXXALIAS_RPL (btowc, wint_t, (int c)); # else # if !@HAVE_BTOWC@ _GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (btowc, wint_t, (int c)); # endif _GL_CXXALIASWARN (btowc); #elif defined GNULIB_POSIXCHECK # undef btowc # if HAVE_RAW_DECL_BTOWC _GL_WARN_ON_USE (btowc, "btowc is unportable - " "use gnulib module btowc for portability"); # endif #endif /* Convert a wide character to a single-byte character. */ #if @GNULIB_WCTOB@ # if @REPLACE_WCTOB@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef wctob # define wctob rpl_wctob # endif _GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); _GL_CXXALIAS_RPL (wctob, int, (wint_t wc)); # else # if !defined wctob && !@HAVE_DECL_WCTOB@ /* wctob is provided by gnulib, or wctob exists but is not declared. */ _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); # endif _GL_CXXALIASWARN (wctob); #elif defined GNULIB_POSIXCHECK # undef wctob # if HAVE_RAW_DECL_WCTOB _GL_WARN_ON_USE (wctob, "wctob is unportable - " "use gnulib module wctob for portability"); # endif #endif /* Test whether *PS is in the initial state. */ #if @GNULIB_MBSINIT@ # if @REPLACE_MBSINIT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mbsinit # define mbsinit rpl_mbsinit # endif _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps)); _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps)); # else # if !@HAVE_MBSINIT@ _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps)); # endif _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); # endif _GL_CXXALIASWARN (mbsinit); #elif defined GNULIB_POSIXCHECK # undef mbsinit # if HAVE_RAW_DECL_MBSINIT _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - " "use gnulib module mbsinit for portability"); # endif #endif /* Convert a multibyte character to a wide character. */ #if @GNULIB_MBRTOWC@ # if @REPLACE_MBRTOWC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mbrtowc # define mbrtowc rpl_mbrtowc # endif _GL_FUNCDECL_RPL (mbrtowc, size_t, (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); _GL_CXXALIAS_RPL (mbrtowc, size_t, (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); # else # if !@HAVE_MBRTOWC@ _GL_FUNCDECL_SYS (mbrtowc, size_t, (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); # endif _GL_CXXALIAS_SYS (mbrtowc, size_t, (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); # endif _GL_CXXALIASWARN (mbrtowc); #elif defined GNULIB_POSIXCHECK # undef mbrtowc # if HAVE_RAW_DECL_MBRTOWC _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - " "use gnulib module mbrtowc for portability"); # endif #endif /* Recognize a multibyte character. */ #if @GNULIB_MBRLEN@ # if @REPLACE_MBRLEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mbrlen # define mbrlen rpl_mbrlen # endif _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); # else # if !@HAVE_MBRLEN@ _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); # endif _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); # endif _GL_CXXALIASWARN (mbrlen); #elif defined GNULIB_POSIXCHECK # undef mbrlen # if HAVE_RAW_DECL_MBRLEN _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - " "use gnulib module mbrlen for portability"); # endif #endif /* Convert a string to a wide string. */ #if @GNULIB_MBSRTOWCS@ # if @REPLACE_MBSRTOWCS@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mbsrtowcs # define mbsrtowcs rpl_mbsrtowcs # endif _GL_FUNCDECL_RPL (mbsrtowcs, size_t, (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (mbsrtowcs, size_t, (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)); # else # if !@HAVE_MBSRTOWCS@ _GL_FUNCDECL_SYS (mbsrtowcs, size_t, (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (mbsrtowcs, size_t, (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)); # endif _GL_CXXALIASWARN (mbsrtowcs); #elif defined GNULIB_POSIXCHECK # undef mbsrtowcs # if HAVE_RAW_DECL_MBSRTOWCS _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - " "use gnulib module mbsrtowcs for portability"); # endif #endif /* Convert a string to a wide string. */ #if @GNULIB_MBSNRTOWCS@ # if @REPLACE_MBSNRTOWCS@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef mbsnrtowcs # define mbsnrtowcs rpl_mbsnrtowcs # endif _GL_FUNCDECL_RPL (mbsnrtowcs, size_t, (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (mbsnrtowcs, size_t, (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)); # else # if !@HAVE_MBSNRTOWCS@ _GL_FUNCDECL_SYS (mbsnrtowcs, size_t, (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (mbsnrtowcs, size_t, (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)); # endif _GL_CXXALIASWARN (mbsnrtowcs); #elif defined GNULIB_POSIXCHECK # undef mbsnrtowcs # if HAVE_RAW_DECL_MBSNRTOWCS _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - " "use gnulib module mbsnrtowcs for portability"); # endif #endif /* Convert a wide character to a multibyte character. */ #if @GNULIB_WCRTOMB@ # if @REPLACE_WCRTOMB@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef wcrtomb # define wcrtomb rpl_wcrtomb # endif _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); # else # if !@HAVE_WCRTOMB@ _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); # endif _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); # endif _GL_CXXALIASWARN (wcrtomb); #elif defined GNULIB_POSIXCHECK # undef wcrtomb # if HAVE_RAW_DECL_WCRTOMB _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - " "use gnulib module wcrtomb for portability"); # endif #endif /* Convert a wide string to a string. */ #if @GNULIB_WCSRTOMBS@ # if @REPLACE_WCSRTOMBS@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef wcsrtombs # define wcsrtombs rpl_wcsrtombs # endif _GL_FUNCDECL_RPL (wcsrtombs, size_t, (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (wcsrtombs, size_t, (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)); # else # if !@HAVE_WCSRTOMBS@ _GL_FUNCDECL_SYS (wcsrtombs, size_t, (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (wcsrtombs, size_t, (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)); # endif _GL_CXXALIASWARN (wcsrtombs); #elif defined GNULIB_POSIXCHECK # undef wcsrtombs # if HAVE_RAW_DECL_WCSRTOMBS _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - " "use gnulib module wcsrtombs for portability"); # endif #endif /* Convert a wide string to a string. */ #if @GNULIB_WCSNRTOMBS@ # if @REPLACE_WCSNRTOMBS@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef wcsnrtombs # define wcsnrtombs rpl_wcsnrtombs # endif _GL_FUNCDECL_RPL (wcsnrtombs, size_t, (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (wcsnrtombs, size_t, (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)); # else # if !@HAVE_WCSNRTOMBS@ _GL_FUNCDECL_SYS (wcsnrtombs, size_t, (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (wcsnrtombs, size_t, (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)); # endif _GL_CXXALIASWARN (wcsnrtombs); #elif defined GNULIB_POSIXCHECK # undef wcsnrtombs # if HAVE_RAW_DECL_WCSNRTOMBS _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - " "use gnulib module wcsnrtombs for portability"); # endif #endif /* Return the number of screen columns needed for WC. */ #if @GNULIB_WCWIDTH@ # if @REPLACE_WCWIDTH@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef wcwidth # define wcwidth rpl_wcwidth # endif _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); # else # if !@HAVE_DECL_WCWIDTH@ /* wcwidth exists but is not declared. */ _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); # endif _GL_CXXALIASWARN (wcwidth); #elif defined GNULIB_POSIXCHECK # undef wcwidth # if HAVE_RAW_DECL_WCWIDTH _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - " "use gnulib module wcwidth for portability"); # endif #endif /* Search N wide characters of S for C. */ #if @GNULIB_WMEMCHR@ # if !@HAVE_WMEMCHR@ _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n) _GL_ATTRIBUTE_PURE); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t); wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t); } */ _GL_CXXALIAS_SYS_CAST2 (wmemchr, wchar_t *, (const wchar_t *, wchar_t, size_t), const wchar_t *, (const wchar_t *, wchar_t, size_t)); # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); _GL_CXXALIASWARN1 (wmemchr, const wchar_t *, (const wchar_t *s, wchar_t c, size_t n)); # else _GL_CXXALIASWARN (wmemchr); # endif #elif defined GNULIB_POSIXCHECK # undef wmemchr # if HAVE_RAW_DECL_WMEMCHR _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - " "use gnulib module wmemchr for portability"); # endif #endif /* Compare N wide characters of S1 and S2. */ #if @GNULIB_WMEMCMP@ # if !@HAVE_WMEMCMP@ _GL_FUNCDECL_SYS (wmemcmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wmemcmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n)); _GL_CXXALIASWARN (wmemcmp); #elif defined GNULIB_POSIXCHECK # undef wmemcmp # if HAVE_RAW_DECL_WMEMCMP _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - " "use gnulib module wmemcmp for portability"); # endif #endif /* Copy N wide characters of SRC to DEST. */ #if @GNULIB_WMEMCPY@ # if !@HAVE_WMEMCPY@ _GL_FUNCDECL_SYS (wmemcpy, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); # endif _GL_CXXALIAS_SYS (wmemcpy, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); _GL_CXXALIASWARN (wmemcpy); #elif defined GNULIB_POSIXCHECK # undef wmemcpy # if HAVE_RAW_DECL_WMEMCPY _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - " "use gnulib module wmemcpy for portability"); # endif #endif /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for overlapping memory areas. */ #if @GNULIB_WMEMMOVE@ # if !@HAVE_WMEMMOVE@ _GL_FUNCDECL_SYS (wmemmove, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); # endif _GL_CXXALIAS_SYS (wmemmove, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); _GL_CXXALIASWARN (wmemmove); #elif defined GNULIB_POSIXCHECK # undef wmemmove # if HAVE_RAW_DECL_WMEMMOVE _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - " "use gnulib module wmemmove for portability"); # endif #endif /* Set N wide characters of S to C. */ #if @GNULIB_WMEMSET@ # if !@HAVE_WMEMSET@ _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); # endif _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); _GL_CXXALIASWARN (wmemset); #elif defined GNULIB_POSIXCHECK # undef wmemset # if HAVE_RAW_DECL_WMEMSET _GL_WARN_ON_USE (wmemset, "wmemset is unportable - " "use gnulib module wmemset for portability"); # endif #endif /* Return the number of wide characters in S. */ #if @GNULIB_WCSLEN@ # if !@HAVE_WCSLEN@ _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); _GL_CXXALIASWARN (wcslen); #elif defined GNULIB_POSIXCHECK # undef wcslen # if HAVE_RAW_DECL_WCSLEN _GL_WARN_ON_USE (wcslen, "wcslen is unportable - " "use gnulib module wcslen for portability"); # endif #endif /* Return the number of wide characters in S, but at most MAXLEN. */ #if @GNULIB_WCSNLEN@ # if !@HAVE_WCSNLEN@ _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)); _GL_CXXALIASWARN (wcsnlen); #elif defined GNULIB_POSIXCHECK # undef wcsnlen # if HAVE_RAW_DECL_WCSNLEN _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - " "use gnulib module wcsnlen for portability"); # endif #endif /* Copy SRC to DEST. */ #if @GNULIB_WCSCPY@ # if !@HAVE_WCSCPY@ _GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); # endif _GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); _GL_CXXALIASWARN (wcscpy); #elif defined GNULIB_POSIXCHECK # undef wcscpy # if HAVE_RAW_DECL_WCSCPY _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - " "use gnulib module wcscpy for portability"); # endif #endif /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */ #if @GNULIB_WCPCPY@ # if !@HAVE_WCPCPY@ _GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); # endif _GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); _GL_CXXALIASWARN (wcpcpy); #elif defined GNULIB_POSIXCHECK # undef wcpcpy # if HAVE_RAW_DECL_WCPCPY _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - " "use gnulib module wcpcpy for portability"); # endif #endif /* Copy no more than N wide characters of SRC to DEST. */ #if @GNULIB_WCSNCPY@ # if !@HAVE_WCSNCPY@ _GL_FUNCDECL_SYS (wcsncpy, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); # endif _GL_CXXALIAS_SYS (wcsncpy, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); _GL_CXXALIASWARN (wcsncpy); #elif defined GNULIB_POSIXCHECK # undef wcsncpy # if HAVE_RAW_DECL_WCSNCPY _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - " "use gnulib module wcsncpy for portability"); # endif #endif /* Copy no more than N characters of SRC to DEST, returning the address of the last character written into DEST. */ #if @GNULIB_WCPNCPY@ # if !@HAVE_WCPNCPY@ _GL_FUNCDECL_SYS (wcpncpy, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); # endif _GL_CXXALIAS_SYS (wcpncpy, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); _GL_CXXALIASWARN (wcpncpy); #elif defined GNULIB_POSIXCHECK # undef wcpncpy # if HAVE_RAW_DECL_WCPNCPY _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - " "use gnulib module wcpncpy for portability"); # endif #endif /* Append SRC onto DEST. */ #if @GNULIB_WCSCAT@ # if !@HAVE_WCSCAT@ _GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); # endif _GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); _GL_CXXALIASWARN (wcscat); #elif defined GNULIB_POSIXCHECK # undef wcscat # if HAVE_RAW_DECL_WCSCAT _GL_WARN_ON_USE (wcscat, "wcscat is unportable - " "use gnulib module wcscat for portability"); # endif #endif /* Append no more than N wide characters of SRC onto DEST. */ #if @GNULIB_WCSNCAT@ # if !@HAVE_WCSNCAT@ _GL_FUNCDECL_SYS (wcsncat, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); # endif _GL_CXXALIAS_SYS (wcsncat, wchar_t *, (wchar_t *dest, const wchar_t *src, size_t n)); _GL_CXXALIASWARN (wcsncat); #elif defined GNULIB_POSIXCHECK # undef wcsncat # if HAVE_RAW_DECL_WCSNCAT _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - " "use gnulib module wcsncat for portability"); # endif #endif /* Compare S1 and S2. */ #if @GNULIB_WCSCMP@ # if !@HAVE_WCSCMP@ _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); _GL_CXXALIASWARN (wcscmp); #elif defined GNULIB_POSIXCHECK # undef wcscmp # if HAVE_RAW_DECL_WCSCMP _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - " "use gnulib module wcscmp for portability"); # endif #endif /* Compare no more than N wide characters of S1 and S2. */ #if @GNULIB_WCSNCMP@ # if !@HAVE_WCSNCMP@ _GL_FUNCDECL_SYS (wcsncmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcsncmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n)); _GL_CXXALIASWARN (wcsncmp); #elif defined GNULIB_POSIXCHECK # undef wcsncmp # if HAVE_RAW_DECL_WCSNCMP _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - " "use gnulib module wcsncmp for portability"); # endif #endif /* Compare S1 and S2, ignoring case. */ #if @GNULIB_WCSCASECMP@ # if !@HAVE_WCSCASECMP@ _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)); _GL_CXXALIASWARN (wcscasecmp); #elif defined GNULIB_POSIXCHECK # undef wcscasecmp # if HAVE_RAW_DECL_WCSCASECMP _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - " "use gnulib module wcscasecmp for portability"); # endif #endif /* Compare no more than N chars of S1 and S2, ignoring case. */ #if @GNULIB_WCSNCASECMP@ # if !@HAVE_WCSNCASECMP@ _GL_FUNCDECL_SYS (wcsncasecmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcsncasecmp, int, (const wchar_t *s1, const wchar_t *s2, size_t n)); _GL_CXXALIASWARN (wcsncasecmp); #elif defined GNULIB_POSIXCHECK # undef wcsncasecmp # if HAVE_RAW_DECL_WCSNCASECMP _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - " "use gnulib module wcsncasecmp for portability"); # endif #endif /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE category of the current locale. */ #if @GNULIB_WCSCOLL@ # if !@HAVE_WCSCOLL@ _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); # endif _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); _GL_CXXALIASWARN (wcscoll); #elif defined GNULIB_POSIXCHECK # undef wcscoll # if HAVE_RAW_DECL_WCSCOLL _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - " "use gnulib module wcscoll for portability"); # endif #endif /* Transform S2 into array pointed to by S1 such that if wcscmp is applied to two transformed strings the result is the as applying 'wcscoll' to the original strings. */ #if @GNULIB_WCSXFRM@ # if !@HAVE_WCSXFRM@ _GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); # endif _GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); _GL_CXXALIASWARN (wcsxfrm); #elif defined GNULIB_POSIXCHECK # undef wcsxfrm # if HAVE_RAW_DECL_WCSXFRM _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - " "use gnulib module wcsxfrm for portability"); # endif #endif /* Duplicate S, returning an identical malloc'd string. */ #if @GNULIB_WCSDUP@ # if !@HAVE_WCSDUP@ _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s)); # endif _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); _GL_CXXALIASWARN (wcsdup); #elif defined GNULIB_POSIXCHECK # undef wcsdup # if HAVE_RAW_DECL_WCSDUP _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " "use gnulib module wcsdup for portability"); # endif #endif /* Find the first occurrence of WC in WCS. */ #if @GNULIB_WCSCHR@ # if !@HAVE_WCSCHR@ _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc) _GL_ATTRIBUTE_PURE); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const wchar_t * std::wcschr (const wchar_t *, wchar_t); wchar_t * std::wcschr (wchar_t *, wchar_t); } */ _GL_CXXALIAS_SYS_CAST2 (wcschr, wchar_t *, (const wchar_t *, wchar_t), const wchar_t *, (const wchar_t *, wchar_t)); # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); # else _GL_CXXALIASWARN (wcschr); # endif #elif defined GNULIB_POSIXCHECK # undef wcschr # if HAVE_RAW_DECL_WCSCHR _GL_WARN_ON_USE (wcschr, "wcschr is unportable - " "use gnulib module wcschr for portability"); # endif #endif /* Find the last occurrence of WC in WCS. */ #if @GNULIB_WCSRCHR@ # if !@HAVE_WCSRCHR@ _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc) _GL_ATTRIBUTE_PURE); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const wchar_t * std::wcsrchr (const wchar_t *, wchar_t); wchar_t * std::wcsrchr (wchar_t *, wchar_t); } */ _GL_CXXALIAS_SYS_CAST2 (wcsrchr, wchar_t *, (const wchar_t *, wchar_t), const wchar_t *, (const wchar_t *, wchar_t)); # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); # else _GL_CXXALIASWARN (wcsrchr); # endif #elif defined GNULIB_POSIXCHECK # undef wcsrchr # if HAVE_RAW_DECL_WCSRCHR _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - " "use gnulib module wcsrchr for portability"); # endif #endif /* Return the length of the initial segmet of WCS which consists entirely of wide characters not in REJECT. */ #if @GNULIB_WCSCSPN@ # if !@HAVE_WCSCSPN@ _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); _GL_CXXALIASWARN (wcscspn); #elif defined GNULIB_POSIXCHECK # undef wcscspn # if HAVE_RAW_DECL_WCSCSPN _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - " "use gnulib module wcscspn for portability"); # endif #endif /* Return the length of the initial segmet of WCS which consists entirely of wide characters in ACCEPT. */ #if @GNULIB_WCSSPN@ # if !@HAVE_WCSSPN@ _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); _GL_CXXALIASWARN (wcsspn); #elif defined GNULIB_POSIXCHECK # undef wcsspn # if HAVE_RAW_DECL_WCSSPN _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - " "use gnulib module wcsspn for portability"); # endif #endif /* Find the first occurrence in WCS of any character in ACCEPT. */ #if @GNULIB_WCSPBRK@ # if !@HAVE_WCSPBRK@ _GL_FUNCDECL_SYS (wcspbrk, wchar_t *, (const wchar_t *wcs, const wchar_t *accept) _GL_ATTRIBUTE_PURE); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *); wchar_t * std::wcspbrk (wchar_t *, const wchar_t *); } */ _GL_CXXALIAS_SYS_CAST2 (wcspbrk, wchar_t *, (const wchar_t *, const wchar_t *), const wchar_t *, (const wchar_t *, const wchar_t *)); # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (wcspbrk, wchar_t *, (wchar_t *wcs, const wchar_t *accept)); _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, (const wchar_t *wcs, const wchar_t *accept)); # else _GL_CXXALIASWARN (wcspbrk); # endif #elif defined GNULIB_POSIXCHECK # undef wcspbrk # if HAVE_RAW_DECL_WCSPBRK _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - " "use gnulib module wcspbrk for portability"); # endif #endif /* Find the first occurrence of NEEDLE in HAYSTACK. */ #if @GNULIB_WCSSTR@ # if !@HAVE_WCSSTR@ _GL_FUNCDECL_SYS (wcsstr, wchar_t *, (const wchar_t *haystack, const wchar_t *needle) _GL_ATTRIBUTE_PURE); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); wchar_t * std::wcsstr (wchar_t *, const wchar_t *); } */ _GL_CXXALIAS_SYS_CAST2 (wcsstr, wchar_t *, (const wchar_t *, const wchar_t *), const wchar_t *, (const wchar_t *, const wchar_t *)); # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (wcsstr, wchar_t *, (wchar_t *haystack, const wchar_t *needle)); _GL_CXXALIASWARN1 (wcsstr, const wchar_t *, (const wchar_t *haystack, const wchar_t *needle)); # else _GL_CXXALIASWARN (wcsstr); # endif #elif defined GNULIB_POSIXCHECK # undef wcsstr # if HAVE_RAW_DECL_WCSSTR _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - " "use gnulib module wcsstr for portability"); # endif #endif /* Divide WCS into tokens separated by characters in DELIM. */ #if @GNULIB_WCSTOK@ # if !@HAVE_WCSTOK@ _GL_FUNCDECL_SYS (wcstok, wchar_t *, (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); # endif _GL_CXXALIAS_SYS (wcstok, wchar_t *, (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); _GL_CXXALIASWARN (wcstok); #elif defined GNULIB_POSIXCHECK # undef wcstok # if HAVE_RAW_DECL_WCSTOK _GL_WARN_ON_USE (wcstok, "wcstok is unportable - " "use gnulib module wcstok for portability"); # endif #endif /* Determine number of column positions required for first N wide characters (or fewer if S ends before this) in S. */ #if @GNULIB_WCSWIDTH@ # if @REPLACE_WCSWIDTH@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef wcswidth # define wcswidth rpl_wcswidth # endif _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n) _GL_ATTRIBUTE_PURE); _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n)); # else # if !@HAVE_WCSWIDTH@ _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n) _GL_ATTRIBUTE_PURE); # endif _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); # endif _GL_CXXALIASWARN (wcswidth); #elif defined GNULIB_POSIXCHECK # undef wcswidth # if HAVE_RAW_DECL_WCSWIDTH _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - " "use gnulib module wcswidth for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_WCHAR_H */ #endif /* _@GUARD_PREFIX@_WCHAR_H */ #endif lftp-4.6.3a/lib/md5.h0000644000015000007670000001031012466374011011156 00000000000000/* Declaration of functions and data types used for MD5 sum computing library functions. Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2015 Free Software Foundation, Inc. This file is part of 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, 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 . */ #ifndef _MD5_H #define _MD5_H 1 #include #include # if HAVE_OPENSSL_MD5 # include # endif #define MD5_DIGEST_SIZE 16 #define MD5_BLOCK_SIZE 64 #ifndef __GNUC_PREREQ # if defined __GNUC__ && defined __GNUC_MINOR__ # define __GNUC_PREREQ(maj, min) \ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) # else # define __GNUC_PREREQ(maj, min) 0 # endif #endif #ifndef __THROW # if defined __cplusplus && __GNUC_PREREQ (2,8) # define __THROW throw () # else # define __THROW # endif #endif #ifndef _LIBC # define __md5_buffer md5_buffer # define __md5_finish_ctx md5_finish_ctx # define __md5_init_ctx md5_init_ctx # define __md5_process_block md5_process_block # define __md5_process_bytes md5_process_bytes # define __md5_read_ctx md5_read_ctx # define __md5_stream md5_stream #endif # ifdef __cplusplus extern "C" { # endif # if HAVE_OPENSSL_MD5 # define GL_OPENSSL_NAME 5 # include "gl_openssl.h" # else /* Structure to save state of computation between the single steps. */ struct md5_ctx { uint32_t A; uint32_t B; uint32_t C; uint32_t D; uint32_t total[2]; uint32_t buflen; uint32_t buffer[32]; }; /* * The following three functions are build up the low level used in * the functions 'md5_stream' and 'md5_buffer'. */ /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW; /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void __md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) __THROW; /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void __md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) __THROW; /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; /* Put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *__md5_buffer (const char *buffer, size_t len, void *resblock) __THROW; # endif /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ extern int __md5_stream (FILE *stream, void *resblock) __THROW; # ifdef __cplusplus } # endif #endif /* md5.h */ lftp-4.6.3a/lib/pathmax.h0000644000015000007670000000555612466374011012153 00000000000000/* Define PATH_MAX somehow. Requires sys/types.h. Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2015 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 . */ #ifndef _PATHMAX_H # define _PATHMAX_H /* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, including the terminating NUL byte. PATH_MAX is not defined on systems which have no limit on filename length, such as GNU/Hurd. This file does *not* define PATH_MAX always. Programs that use this file can handle the GNU/Hurd case in several ways: - Either with a package-wide handling, or with a per-file handling, - Either through a #ifdef PATH_MAX or through a fallback like #ifndef PATH_MAX # define PATH_MAX 8192 #endif or through a fallback like #ifndef PATH_MAX # define PATH_MAX pathconf ("/", _PC_PATH_MAX) #endif */ # include # include # ifndef _POSIX_PATH_MAX # define _POSIX_PATH_MAX 256 # endif /* Don't include sys/param.h if it already has been. */ # if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN # include # endif # if !defined PATH_MAX && defined MAXPATHLEN # define PATH_MAX MAXPATHLEN # endif # ifdef __hpux /* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, *not* including the terminating NUL byte, and is set to 1023. Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is not defined at all any more. */ # undef PATH_MAX # define PATH_MAX 1024 # endif # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, section "Maximum Path Length Limitation", explains that the maximum size of a filename, including the terminating NUL byte, is 260 = 3 + 256 + 1. This is the same value as - FILENAME_MAX in , - _MAX_PATH in , - MAX_PATH in . Undefine the original value, because mingw's gets it wrong. */ # undef PATH_MAX # define PATH_MAX 260 # endif #endif /* _PATHMAX_H */ lftp-4.6.3a/lib/msvc-nothrow.c0000644000015000007670000000243412466374011013142 00000000000000/* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. Copyright (C) 2011-2015 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 . */ #include /* Specification. */ #include "msvc-nothrow.h" /* Get declarations of the native Windows API functions. */ #define WIN32_LEAN_AND_MEAN #include #include "msvc-inval.h" #undef _get_osfhandle #if HAVE_MSVC_INVALID_PARAMETER_HANDLER intptr_t _gl_nothrow_get_osfhandle (int fd) { intptr_t result; TRY_MSVC_INVAL { result = _get_osfhandle (fd); } CATCH_MSVC_INVAL { result = (intptr_t) INVALID_HANDLE_VALUE; } DONE_MSVC_INVAL; return result; } #endif lftp-4.6.3a/lib/malloc.c0000644000015000007670000000273212466374011011744 00000000000000/* malloc() function that is glibc compatible. Copyright (C) 1997-1998, 2006-2007, 2009-2015 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 . */ /* written by Jim Meyering and Bruno Haible */ #define _GL_USE_STDLIB_ALLOC 1 #include /* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ #ifdef malloc # define NEED_MALLOC_GNU 1 # undef malloc /* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ #elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU # define NEED_MALLOC_GNU 1 #endif #include #include /* Allocate an N-byte block of memory from the heap. If N is zero, allocate a 1-byte block. */ void * rpl_malloc (size_t n) { void *result; #if NEED_MALLOC_GNU if (n == 0) n = 1; #endif result = malloc (n); #if !HAVE_MALLOC_POSIX if (result == NULL) errno = ENOMEM; #endif return result; } lftp-4.6.3a/lib/printf-frexp.h0000644000015000007670000000206012466374011013120 00000000000000/* Split a double into fraction and mantissa, for hexadecimal printf. Copyright (C) 2007, 2009-2015 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 . */ /* Write a finite, positive number x as x = mantissa * 2^exp where exp >= DBL_MIN_EXP - 1, mantissa < 2.0, if x is not a denormalized number then mantissa >= 1.0. Store exp in *EXPPTR and return mantissa. */ extern double printf_frexp (double x, int *expptr); lftp-4.6.3a/lib/mbsrtowcs-impl.h0000644000015000007670000000713312466374011013464 00000000000000/* Convert string to wide string. Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. 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 . */ size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) { if (ps == NULL) ps = &_gl_mbsrtowcs_state; { const char *src = *srcp; if (dest != NULL) { wchar_t *destptr = dest; for (; len > 0; destptr++, len--) { size_t src_avail; size_t ret; /* An optimized variant of src_avail = strnlen1 (src, MB_LEN_MAX); */ if (src[0] == '\0') src_avail = 1; else if (src[1] == '\0') src_avail = 2; else if (src[2] == '\0') src_avail = 3; else if (MB_LEN_MAX <= 4 || src[3] == '\0') src_avail = 4; else src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); /* Parse the next multibyte character. */ ret = mbrtowc (destptr, src, src_avail, ps); if (ret == (size_t)(-2)) /* Encountered a multibyte character that extends past a '\0' byte or that is longer than MB_LEN_MAX bytes. Cannot happen. */ abort (); if (ret == (size_t)(-1)) goto bad_input; if (ret == 0) { src = NULL; /* Here mbsinit (ps). */ break; } src += ret; } *srcp = src; return destptr - dest; } else { /* Ignore dest and len, don't store *srcp at the end, and don't clobber *ps. */ mbstate_t state = *ps; size_t totalcount = 0; for (;; totalcount++) { size_t src_avail; size_t ret; /* An optimized variant of src_avail = strnlen1 (src, MB_LEN_MAX); */ if (src[0] == '\0') src_avail = 1; else if (src[1] == '\0') src_avail = 2; else if (src[2] == '\0') src_avail = 3; else if (MB_LEN_MAX <= 4 || src[3] == '\0') src_avail = 4; else src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); /* Parse the next multibyte character. */ ret = mbrtowc (NULL, src, src_avail, &state); if (ret == (size_t)(-2)) /* Encountered a multibyte character that extends past a '\0' byte or that is longer than MB_LEN_MAX bytes. Cannot happen. */ abort (); if (ret == (size_t)(-1)) goto bad_input2; if (ret == 0) { /* Here mbsinit (&state). */ break; } src += ret; } return totalcount; } bad_input: *srcp = src; bad_input2: errno = EILSEQ; return (size_t)(-1); } } lftp-4.6.3a/lib/closedir.c0000644000015000007670000000264212466374011012301 00000000000000/* Stop reading the entries of a directory. Copyright (C) 2006-2015 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 . */ #include /* Specification. */ #include #if REPLACE_FCHDIR # include #endif #if HAVE_CLOSEDIR /* Override closedir(), to keep track of the open file descriptors. Needed because there is a function dirfd(). */ #else # include # include "dirent-private.h" #endif int closedir (DIR *dirp) { # if REPLACE_FCHDIR int fd = dirfd (dirp); # endif int retval; #if HAVE_CLOSEDIR # undef closedir retval = closedir (dirp); #else if (dirp->current != INVALID_HANDLE_VALUE) FindClose (dirp->current); free (dirp); retval = 0; #endif #if REPLACE_FCHDIR if (retval >= 0) _gl_unregister_fd (fd); #endif return retval; } lftp-4.6.3a/lib/mbsinit.c0000644000015000007670000000370312466374011012141 00000000000000/* Test for initial conversion state. Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. 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 . */ #include /* Specification. */ #include #include "verify.h" #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ /* On native Windows, 'mbstate_t' is defined as 'int'. */ int mbsinit (const mbstate_t *ps) { return ps == NULL || *ps == 0; } #else /* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs() and wcrtomb(), wcsrtombs(). We assume that - sizeof (mbstate_t) >= 4, - only stateless encodings are supported (such as UTF-8 and EUC-JP, but not ISO-2022 variants), - for each encoding, the number of bytes for a wide character is <= 4. (This maximum is attained for UTF-8, GB18030, EUC-TW.) We define the meaning of mbstate_t as follows: - In mb -> wc direction, mbstate_t's first byte contains the number of buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. - In wc -> mb direction, mbstate_t contains no information. In other words, it is always in the initial state. */ verify (sizeof (mbstate_t) >= 4); int mbsinit (const mbstate_t *ps) { const char *pstate = (const char *)ps; return pstate == NULL || pstate[0] == 0; } #endif lftp-4.6.3a/lib/strstr.c0000644000015000007670000000577712466374012012053 00000000000000/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2015 Free Software Foundation, Inc. This file is part of 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, 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 . */ /* This particular implementation was written by Eric Blake, 2008. */ #ifndef _LIBC # include #endif /* Specification of strstr. */ #include #include #ifndef _LIBC # define __builtin_expect(expr, val) (expr) #endif #define RETURN_TYPE char * #define AVAILABLE(h, h_l, j, n_l) \ (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ && ((h_l) = (j) + (n_l))) #include "str-two-way.h" /* Return the first occurrence of NEEDLE in HAYSTACK. Return HAYSTACK if NEEDLE is empty, otherwise NULL if NEEDLE is not found in HAYSTACK. */ char * strstr (const char *haystack_start, const char *needle_start) { const char *haystack = haystack_start; const char *needle = needle_start; size_t needle_len; /* Length of NEEDLE. */ size_t haystack_len; /* Known minimum length of HAYSTACK. */ bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */ /* Determine length of NEEDLE, and in the process, make sure HAYSTACK is at least as long (no point processing all of a long NEEDLE if HAYSTACK is too short). */ while (*haystack && *needle) ok &= *haystack++ == *needle++; if (*needle) return NULL; if (ok) return (char *) haystack_start; /* Reduce the size of haystack using strchr, since it has a smaller linear coefficient than the Two-Way algorithm. */ needle_len = needle - needle_start; haystack = strchr (haystack_start + 1, *needle_start); if (!haystack || __builtin_expect (needle_len == 1, 0)) return (char *) haystack; needle -= needle_len; haystack_len = (haystack > haystack_start + needle_len ? 1 : needle_len + haystack_start - haystack); /* Perform the search. Abstract memory is considered to be an array of 'unsigned char' values, not an array of 'char' values. See ISO C 99 section 6.2.6.1. */ if (needle_len < LONG_NEEDLE_THRESHOLD) return two_way_short_needle ((const unsigned char *) haystack, haystack_len, (const unsigned char *) needle, needle_len); return two_way_long_needle ((const unsigned char *) haystack, haystack_len, (const unsigned char *) needle, needle_len); } #undef LONG_NEEDLE_THRESHOLD lftp-4.6.3a/lib/size_max.h0000644000015000007670000000221112466374012012312 00000000000000/* size_max.h -- declare SIZE_MAX through system headers Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. Written by Simon Josefsson. 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 . */ #ifndef GNULIB_SIZE_MAX_H #define GNULIB_SIZE_MAX_H /* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */ # include /* Get SIZE_MAX declaration on systems like glibc 2. */ # if HAVE_STDINT_H # include # endif /* On systems where these include files don't define it, SIZE_MAX is defined in config.h. */ #endif /* GNULIB_SIZE_MAX_H */ lftp-4.6.3a/lib/strerror-override.h0000644000015000007670000000374312466374012014205 00000000000000/* strerror-override.h --- POSIX compatible system error routine Copyright (C) 2010-2015 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 . */ #ifndef _GL_STRERROR_OVERRIDE_H # define _GL_STRERROR_OVERRIDE_H # include # include /* Reasonable buffer size that should never trigger ERANGE; if this proves too small, we intentionally abort(), to remind us to fix this value. */ # define STACKBUF_LEN 256 /* If ERRNUM maps to an errno value defined by gnulib, return a string describing the error. Otherwise return NULL. */ # if REPLACE_STRERROR_0 \ || GNULIB_defined_ESOCK \ || GNULIB_defined_ESTREAMS \ || GNULIB_defined_EWINSOCK \ || GNULIB_defined_ENOMSG \ || GNULIB_defined_EIDRM \ || GNULIB_defined_ENOLINK \ || GNULIB_defined_EPROTO \ || GNULIB_defined_EMULTIHOP \ || GNULIB_defined_EBADMSG \ || GNULIB_defined_EOVERFLOW \ || GNULIB_defined_ENOTSUP \ || GNULIB_defined_ENETRESET \ || GNULIB_defined_ECONNABORTED \ || GNULIB_defined_ESTALE \ || GNULIB_defined_EDQUOT \ || GNULIB_defined_ECANCELED \ || GNULIB_defined_EOWNERDEAD \ || GNULIB_defined_ENOTRECOVERABLE \ || GNULIB_defined_EILSEQ extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST; # else # define strerror_override(ignored) NULL # endif #endif /* _GL_STRERROR_OVERRIDE_H */ lftp-4.6.3a/lib/vsnprintf.c0000644000015000007670000000354012466374012012525 00000000000000/* Formatted output to strings. Copyright (C) 2004, 2006-2015 Free Software Foundation, Inc. Written by Simon Josefsson and Yoann Vandoorselaere . 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 . */ #ifdef HAVE_CONFIG_H # include #endif /* Specification. */ #include #include #include #include #include #include #include "vasnprintf.h" /* Print formatted output to string STR. Similar to vsprintf, but additional length SIZE limit how much is written into STR. Returns string length of formatted string (which may be larger than SIZE). STR may be NULL, in which case nothing will be written. On error, return a negative value. */ int vsnprintf (char *str, size_t size, const char *format, va_list args) { char *output; size_t len; size_t lenbuf = size; output = vasnprintf (str, &lenbuf, format, args); len = lenbuf; if (!output) return -1; if (output != str) { if (size) { size_t pruned_len = (len < size ? len : size - 1); memcpy (str, output, pruned_len); str[pruned_len] = '\0'; } free (output); } if (len > INT_MAX) { errno = EOVERFLOW; return -1; } return len; } lftp-4.6.3a/lib/c-strcasecmp.c0000644000015000007670000000304412466374011013056 00000000000000/* c-strcasecmp.c -- case insensitive string comparator in C locale Copyright (C) 1998-1999, 2005-2006, 2009-2015 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 . */ #include /* Specification. */ #include "c-strcase.h" #include #include "c-ctype.h" int c_strcasecmp (const char *s1, const char *s2) { 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) return 0; do { c1 = c_tolower (*p1); c2 = c_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); } lftp-4.6.3a/lib/unitypes.in.h0000644000015000007670000000316312466374012012767 00000000000000/* Elementary types and macros for the GNU UniString library. Copyright (C) 2002, 2005-2006, 2009-2015 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 . */ #ifndef _UNITYPES_H #define _UNITYPES_H /* Get uint8_t, uint16_t, uint32_t. */ #include /* Type representing a Unicode character. */ typedef uint32_t ucs4_t; /* Attribute of a function whose result depends only on the arguments (not pointers!) and which has no side effects. */ #ifndef _UC_ATTRIBUTE_CONST # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) # define _UC_ATTRIBUTE_CONST __attribute__ ((__const__)) # else # define _UC_ATTRIBUTE_CONST # endif #endif /* Attribute of a function whose result depends only on the arguments (possibly pointers) and global memory, and which has no side effects. */ #ifndef _UC_ATTRIBUTE_PURE # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) # define _UC_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else # define _UC_ATTRIBUTE_PURE # endif #endif #endif /* _UNITYPES_H */ lftp-4.6.3a/lib/regex.h0000644000015000007670000006060012466374012011613 00000000000000/* Definitions for data structures and routines for the regular expression library. Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library 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. The GNU C Library 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 the GNU C Library; if not, see . */ #ifndef _REGEX_H #define _REGEX_H 1 #include /* Allow the use in C++ code. */ #ifdef __cplusplus extern "C" { #endif /* Define __USE_GNU to declare GNU extensions that violate the POSIX name space rules. */ #ifdef _GNU_SOURCE # define __USE_GNU 1 #endif #ifdef _REGEX_LARGE_OFFSETS /* Use types and values that are wide enough to represent signed and unsigned byte offsets in memory. This currently works only when the regex code is used outside of the GNU C library; it is not yet supported within glibc itself, and glibc users should not define _REGEX_LARGE_OFFSETS. */ /* The type of nonnegative object indexes. Traditionally, GNU regex uses 'int' for these. Code that uses __re_idx_t should work regardless of whether the type is signed. */ typedef size_t __re_idx_t; /* The type of object sizes. */ typedef size_t __re_size_t; /* The type of object sizes, in places where the traditional code uses unsigned long int. */ typedef size_t __re_long_size_t; #else /* The traditional GNU regex implementation mishandles strings longer than INT_MAX. */ typedef int __re_idx_t; typedef unsigned int __re_size_t; typedef unsigned long int __re_long_size_t; #endif /* The following two types have to be signed and unsigned integer type wide enough to hold a value of a pointer. For most ANSI compilers ptrdiff_t and size_t should be likely OK. Still size of these two types is 2 for Microsoft C. Ugh... */ typedef long int s_reg_t; typedef unsigned long int active_reg_t; /* The following bits are used to determine the regexp syntax we recognize. The set/not-set meanings are chosen so that Emacs syntax remains the value 0. The bits are given in alphabetical order, and the definitions shifted by one from the previous bit; thus, when we add or remove a bit, only one other definition need change. */ typedef unsigned long int reg_syntax_t; #ifdef __USE_GNU /* If this bit is not set, then \ inside a bracket expression is literal. If set, then such a \ quotes the following character. */ # define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) /* If this bit is not set, then + and ? are operators, and \+ and \? are literals. If set, then \+ and \? are operators and + and ? are literals. */ # define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) /* If this bit is set, then character classes are supported. They are: [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. If not set, then character classes are not supported. */ # define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) /* If this bit is set, then ^ and $ are always anchors (outside bracket expressions, of course). If this bit is not set, then it depends: ^ is an anchor if it is at the beginning of a regular expression or after an open-group or an alternation operator; $ is an anchor if it is at the end of a regular expression, or before a close-group or an alternation operator. This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because POSIX draft 11.2 says that * etc. in leading positions is undefined. We already implemented a previous draft which made those constructs invalid, though, so we haven't changed the code back. */ # define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) /* If this bit is set, then special characters are always special regardless of where they are in the pattern. If this bit is not set, then special characters are special only in some contexts; otherwise they are ordinary. Specifically, * + ? and intervals are only special when not after the beginning, open-group, or alternation operator. */ # define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) /* If this bit is set, then *, +, ?, and { cannot be first in an re or immediately after an alternation or begin-group operator. */ # define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) /* If this bit is set, then . matches newline. If not set, then it doesn't. */ # define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) /* If this bit is set, then . doesn't match NUL. If not set, then it does. */ # define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) /* If this bit is set, nonmatching lists [^...] do not match newline. If not set, they do. */ # define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) /* If this bit is set, either \{...\} or {...} defines an interval, depending on RE_NO_BK_BRACES. If not set, \{, \}, {, and } are literals. */ # define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) /* If this bit is set, +, ? and | aren't recognized as operators. If not set, they are. */ # define RE_LIMITED_OPS (RE_INTERVALS << 1) /* If this bit is set, newline is an alternation operator. If not set, newline is literal. */ # define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) /* If this bit is set, then '{...}' defines an interval, and \{ and \} are literals. If not set, then '\{...\}' defines an interval. */ # define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) /* If this bit is set, (...) defines a group, and \( and \) are literals. If not set, \(...\) defines a group, and ( and ) are literals. */ # define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) /* If this bit is set, then \ matches . If not set, then \ is a back-reference. */ # define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) /* If this bit is set, then | is an alternation operator, and \| is literal. If not set, then \| is an alternation operator, and | is literal. */ # define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) /* If this bit is set, then an ending range point collating higher than the starting range point, as in [z-a], is invalid. If not set, then when ending range point collates higher than the starting range point, the range is ignored. */ # define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) /* If this bit is set, then an unmatched ) is ordinary. If not set, then an unmatched ) is invalid. */ # define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) /* If this bit is set, succeed as soon as we match the whole pattern, without further backtracking. */ # define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) /* If this bit is set, do not process the GNU regex operators. If not set, then the GNU regex operators are recognized. */ # define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) /* If this bit is set, turn on internal regex debugging. If not set, and debugging was on, turn it off. This only works if regex.c is compiled -DDEBUG. We define this bit always, so that all that's needed to turn on debugging is to recompile regex.c; the calling code can always have this bit set, and it won't affect anything in the normal case. */ # define RE_DEBUG (RE_NO_GNU_OPS << 1) /* If this bit is set, a syntactically invalid interval is treated as a string of ordinary characters. For example, the ERE 'a{1' is treated as 'a\{1'. */ # define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1) /* If this bit is set, then ignore case when matching. If not set, then case is significant. */ # define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) /* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only for ^, because it is difficult to scan the regex backwards to find whether ^ should be special. */ # define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) /* If this bit is set, then \{ cannot be first in a regex or immediately after an alternation, open-group or \} operator. */ # define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) /* If this bit is set, then no_sub will be set to 1 during re_compile_pattern. */ # define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1) #endif /* This global variable defines the particular regexp syntax to use (for some interfaces). When a regexp is compiled, the syntax used is stored in the pattern buffer, so changing this does not affect already-compiled regexps. */ extern reg_syntax_t re_syntax_options; #ifdef __USE_GNU /* Define combinations of the above bits for the standard possibilities. (The [[[ comments delimit what gets put into the Texinfo file, so don't delete them!) */ /* [[[begin syntaxes]]] */ # define RE_SYNTAX_EMACS 0 # define RE_SYNTAX_AWK \ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ | RE_CHAR_CLASSES \ | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) # define RE_SYNTAX_GNU_AWK \ ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ | RE_INVALID_INTERVAL_ORD) \ & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS \ | RE_CONTEXT_INVALID_OPS )) # define RE_SYNTAX_POSIX_AWK \ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ | RE_INTERVALS | RE_NO_GNU_OPS \ | RE_INVALID_INTERVAL_ORD) # define RE_SYNTAX_GREP \ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ | RE_NEWLINE_ALT) # define RE_SYNTAX_EGREP \ (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ | RE_NO_BK_VBAR) # define RE_SYNTAX_POSIX_EGREP \ (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ | RE_INVALID_INTERVAL_ORD) /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ # define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC # define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC /* Syntax bits common to both basic and extended POSIX regex syntax. */ # define _RE_SYNTAX_POSIX_COMMON \ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ | RE_INTERVALS | RE_NO_EMPTY_RANGES) # define RE_SYNTAX_POSIX_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP) /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this isn't minimal, since other operators, such as \`, aren't disabled. */ # define RE_SYNTAX_POSIX_MINIMAL_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) # define RE_SYNTAX_POSIX_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD) /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is removed and RE_NO_BK_REFS is added. */ # define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) /* [[[end syntaxes]]] */ /* Maximum number of duplicates an interval can allow. POSIX-conforming systems might define this in , but we want our value, so remove any previous define. */ # ifdef _REGEX_INCLUDE_LIMITS_H # include # endif # ifdef RE_DUP_MAX # undef RE_DUP_MAX # endif /* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored the counter as a 2-byte signed integer. This is no longer true, so RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to ((SIZE_MAX - 9) / 10) if _REGEX_LARGE_OFFSETS is defined. However, there would be a huge performance problem if someone actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains its historical value. */ # define RE_DUP_MAX (0x7fff) #endif /* POSIX 'cflags' bits (i.e., information for 'regcomp'). */ /* If this bit is set, then use extended regular expression syntax. If not set, then use basic regular expression syntax. */ #define REG_EXTENDED 1 /* If this bit is set, then ignore case when matching. If not set, then case is significant. */ #define REG_ICASE (1 << 1) /* If this bit is set, then anchors do not match at newline characters in the string. If not set, then anchors do match at newlines. */ #define REG_NEWLINE (1 << 2) /* If this bit is set, then report only success or fail in regexec. If not set, then returns differ between not matching and errors. */ #define REG_NOSUB (1 << 3) /* POSIX 'eflags' bits (i.e., information for regexec). */ /* If this bit is set, then the beginning-of-line operator doesn't match the beginning of the string (presumably because it's not the beginning of a line). If not set, then the beginning-of-line operator does match the beginning of the string. */ #define REG_NOTBOL 1 /* Like REG_NOTBOL, except for the end-of-line. */ #define REG_NOTEOL (1 << 1) /* Use PMATCH[0] to delimit the start and end of the search in the buffer. */ #define REG_STARTEND (1 << 2) /* If any error codes are removed, changed, or added, update the '__re_error_msgid' table in regcomp.c. */ typedef enum { _REG_ENOSYS = -1, /* This will never happen for this implementation. */ _REG_NOERROR = 0, /* Success. */ _REG_NOMATCH, /* Didn't find a match (for regexec). */ /* POSIX regcomp return error codes. (In the order listed in the standard.) */ _REG_BADPAT, /* Invalid pattern. */ _REG_ECOLLATE, /* Invalid collating element. */ _REG_ECTYPE, /* Invalid character class name. */ _REG_EESCAPE, /* Trailing backslash. */ _REG_ESUBREG, /* Invalid back reference. */ _REG_EBRACK, /* Unmatched left bracket. */ _REG_EPAREN, /* Parenthesis imbalance. */ _REG_EBRACE, /* Unmatched \{. */ _REG_BADBR, /* Invalid contents of \{\}. */ _REG_ERANGE, /* Invalid range end. */ _REG_ESPACE, /* Ran out of memory. */ _REG_BADRPT, /* No preceding re for repetition op. */ /* Error codes we've added. */ _REG_EEND, /* Premature end. */ _REG_ESIZE, /* Too large (e.g., repeat count too large). */ _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ } reg_errcode_t; #if defined _XOPEN_SOURCE || defined __USE_XOPEN2K # define REG_ENOSYS _REG_ENOSYS #endif #define REG_NOERROR _REG_NOERROR #define REG_NOMATCH _REG_NOMATCH #define REG_BADPAT _REG_BADPAT #define REG_ECOLLATE _REG_ECOLLATE #define REG_ECTYPE _REG_ECTYPE #define REG_EESCAPE _REG_EESCAPE #define REG_ESUBREG _REG_ESUBREG #define REG_EBRACK _REG_EBRACK #define REG_EPAREN _REG_EPAREN #define REG_EBRACE _REG_EBRACE #define REG_BADBR _REG_BADBR #define REG_ERANGE _REG_ERANGE #define REG_ESPACE _REG_ESPACE #define REG_BADRPT _REG_BADRPT #define REG_EEND _REG_EEND #define REG_ESIZE _REG_ESIZE #define REG_ERPAREN _REG_ERPAREN /* This data structure represents a compiled pattern. Before calling the pattern compiler, the fields 'buffer', 'allocated', 'fastmap', and 'translate' can be set. After the pattern has been compiled, the fields 're_nsub', 'not_bol' and 'not_eol' are available. All other fields are private to the regex routines. */ #ifndef RE_TRANSLATE_TYPE # define __RE_TRANSLATE_TYPE unsigned char * # ifdef __USE_GNU # define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE # endif #endif #ifdef __USE_GNU # define __REPB_PREFIX(name) name #else # define __REPB_PREFIX(name) __##name #endif struct re_pattern_buffer { /* Space that holds the compiled pattern. The type 'struct re_dfa_t' is private and is not declared here. */ struct re_dfa_t *__REPB_PREFIX(buffer); /* Number of bytes to which 'buffer' points. */ __re_long_size_t __REPB_PREFIX(allocated); /* Number of bytes actually used in 'buffer'. */ __re_long_size_t __REPB_PREFIX(used); /* Syntax setting with which the pattern was compiled. */ reg_syntax_t __REPB_PREFIX(syntax); /* Pointer to a fastmap, if any, otherwise zero. re_search uses the fastmap, if there is one, to skip over impossible starting points for matches. */ char *__REPB_PREFIX(fastmap); /* Either a translate table to apply to all characters before comparing them, or zero for no translation. The translation is applied to a pattern when it is compiled and to a string when it is matched. */ __RE_TRANSLATE_TYPE __REPB_PREFIX(translate); /* Number of subexpressions found by the compiler. */ size_t re_nsub; /* Zero if this pattern cannot match the empty string, one else. Well, in truth it's used only in 're_search_2', to see whether or not we should use the fastmap, so we don't set this absolutely perfectly; see 're_compile_fastmap' (the "duplicate" case). */ unsigned __REPB_PREFIX(can_be_null) : 1; /* If REGS_UNALLOCATED, allocate space in the 'regs' structure for 'max (RE_NREGS, re_nsub + 1)' groups. If REGS_REALLOCATE, reallocate space if necessary. If REGS_FIXED, use what's there. */ #ifdef __USE_GNU # define REGS_UNALLOCATED 0 # define REGS_REALLOCATE 1 # define REGS_FIXED 2 #endif unsigned __REPB_PREFIX(regs_allocated) : 2; /* Set to zero when 're_compile_pattern' compiles a pattern; set to one by 're_compile_fastmap' if it updates the fastmap. */ unsigned __REPB_PREFIX(fastmap_accurate) : 1; /* If set, 're_match_2' does not return information about subexpressions. */ unsigned __REPB_PREFIX(no_sub) : 1; /* If set, a beginning-of-line anchor doesn't match at the beginning of the string. */ unsigned __REPB_PREFIX(not_bol) : 1; /* Similarly for an end-of-line anchor. */ unsigned __REPB_PREFIX(not_eol) : 1; /* If true, an anchor at a newline matches. */ unsigned __REPB_PREFIX(newline_anchor) : 1; }; typedef struct re_pattern_buffer regex_t; /* Type for byte offsets within the string. POSIX mandates this. */ #ifdef _REGEX_LARGE_OFFSETS /* POSIX 1003.1-2008 requires that regoff_t be at least as wide as ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t is wider than ssize_t, so ssize_t is safe. */ typedef ssize_t regoff_t; #else /* The traditional GNU regex implementation mishandles strings longer than INT_MAX. */ typedef int regoff_t; #endif #ifdef __USE_GNU /* This is the structure we store register match data in. See regex.texinfo for a full description of what registers match. */ struct re_registers { __re_size_t num_regs; regoff_t *start; regoff_t *end; }; /* If 'regs_allocated' is REGS_UNALLOCATED in the pattern buffer, 're_match_2' returns information about at least this many registers the first time a 'regs' structure is passed. */ # ifndef RE_NREGS # define RE_NREGS 30 # endif #endif /* POSIX specification for registers. Aside from the different names than 're_registers', POSIX uses an array of structures, instead of a structure of arrays. */ typedef struct { regoff_t rm_so; /* Byte offset from string's start to substring's start. */ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ } regmatch_t; /* Declarations for routines. */ #ifdef __USE_GNU /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the 're_syntax_options' variable. */ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global 're_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. To free the allocated storage, you must call 'regfree' on BUFFER. Note that the translate table must either have been initialised by 'regcomp', with a malloc'ed value, or set to NULL before calling 'regfree'. */ extern const char *re_compile_pattern (const char *__pattern, size_t __length, struct re_pattern_buffer *__buffer); /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); /* Search in the string STRING (with length LENGTH) for the pattern compiled into BUFFER. Start searching at position START, for RANGE characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ extern regoff_t re_search (struct re_pattern_buffer *__buffer, const char *__string, __re_idx_t __length, __re_idx_t __start, regoff_t __range, struct re_registers *__regs); /* Like 're_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, const char *__string1, __re_idx_t __length1, const char *__string2, __re_idx_t __length2, __re_idx_t __start, regoff_t __range, struct re_registers *__regs, __re_idx_t __stop); /* Like 're_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ extern regoff_t re_match (struct re_pattern_buffer *__buffer, const char *__string, __re_idx_t __length, __re_idx_t __start, struct re_registers *__regs); /* Relates to 're_match' as 're_search_2' relates to 're_search'. */ extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, const char *__string1, __re_idx_t __length1, const char *__string2, __re_idx_t __length2, __re_idx_t __start, struct re_registers *__regs, __re_idx_t __stop); /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated with malloc, and must each be at least 'NUM_REGS * sizeof (regoff_t)' bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using BUFFER will allocate its own register data, without freeing the old data. */ extern void re_set_registers (struct re_pattern_buffer *__buffer, struct re_registers *__regs, __re_size_t __num_regs, regoff_t *__starts, regoff_t *__ends); #endif /* Use GNU */ #if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC) # ifndef _CRAY /* 4.2 bsd compatibility. */ extern char *re_comp (const char *); extern int re_exec (const char *); # endif #endif /* GCC 2.95 and later have "__restrict"; C99 compilers have "restrict", and "configure" may have defined "restrict". Other compilers use __restrict, __restrict__, and _Restrict, and 'configure' might #define 'restrict' to those words, so pick a different name. */ #ifndef _Restrict_ # if 199901L <= __STDC_VERSION__ # define _Restrict_ restrict # elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__) # define _Restrict_ __restrict # else # define _Restrict_ # endif #endif /* gcc 3.1 and up support the [restrict] syntax. Don't trust sys/cdefs.h's definition of __restrict_arr, though, as it mishandles gcc -ansi -pedantic. */ #ifndef _Restrict_arr_ # if ((199901L <= __STDC_VERSION__ \ || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ && !defined __STRICT_ANSI__)) \ && !defined __GNUG__) # define _Restrict_arr_ _Restrict_ # else # define _Restrict_arr_ # endif #endif /* POSIX compatibility. */ extern int regcomp (regex_t *_Restrict_ __preg, const char *_Restrict_ __pattern, int __cflags); extern int regexec (const regex_t *_Restrict_ __preg, const char *_Restrict_ __string, size_t __nmatch, regmatch_t __pmatch[_Restrict_arr_], int __eflags); extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, char *_Restrict_ __errbuf, size_t __errbuf_size); extern void regfree (regex_t *__preg); #ifdef __cplusplus } #endif /* C++ */ #endif /* regex.h */ lftp-4.6.3a/lib/lchown.c0000644000015000007670000000575612466374011012000 00000000000000/* Provide a stub lchown function for systems that lack it. Copyright (C) 1998-1999, 2002, 2004, 2006-2007, 2009-2015 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 . */ /* written by Jim Meyering */ #include #include #include #include #include #include #if !HAVE_LCHOWN /* If the system chown does not follow symlinks, we don't want it replaced by gnulib's chown, which does follow symlinks. */ # if CHOWN_MODIFIES_SYMLINK # undef chown # endif /* Work just like chown, except when FILE is a symbolic link. In that case, set errno to EOPNOTSUPP and return -1. But if autoconf tests determined that chown modifies symlinks, then just call chown. */ int lchown (const char *file, uid_t uid, gid_t gid) { # if HAVE_CHOWN # if ! CHOWN_MODIFIES_SYMLINK struct stat stats; if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode)) { errno = EOPNOTSUPP; return -1; } # endif return chown (file, uid, gid); # else /* !HAVE_CHOWN */ errno = ENOSYS; return -1; # endif } #else /* HAVE_LCHOWN */ # undef lchown /* Work around trailing slash bugs in lchown. */ int rpl_lchown (const char *file, uid_t uid, gid_t gid) { bool stat_valid = false; int result; # if CHOWN_CHANGE_TIME_BUG struct stat st; if (gid != (gid_t) -1 || uid != (uid_t) -1) { if (lstat (file, &st)) return -1; stat_valid = true; if (!S_ISLNK (st.st_mode)) return chown (file, uid, gid); } # endif # if CHOWN_TRAILING_SLASH_BUG if (!stat_valid) { size_t len = strlen (file); if (len && file[len - 1] == '/') return chown (file, uid, gid); } # endif result = lchown (file, uid, gid); # if CHOWN_CHANGE_TIME_BUG && HAVE_LCHMOD if (result == 0 && stat_valid && (uid == st.st_uid || uid == (uid_t) -1) && (gid == st.st_gid || gid == (gid_t) -1)) { /* No change in ownership, but at least one argument was not -1, so we are required to update ctime. Since lchown succeeded, we assume that lchmod will do likewise. But if the system lacks lchmod and lutimes, we are out of luck. Oh well. */ result = lchmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)); } # endif return result; } #endif /* HAVE_LCHOWN */ lftp-4.6.3a/lib/printf-frexpl.h0000644000015000007670000000210312466374011013272 00000000000000/* Split a 'long double' into fraction and mantissa, for hexadecimal printf. Copyright (C) 2007, 2009-2015 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 . */ /* Write a finite, positive number x as x = mantissa * 2^exp where exp >= LDBL_MIN_EXP - 1, mantissa < 2.0, if x is not a denormalized number then mantissa >= 1.0. Store exp in *EXPPTR and return mantissa. */ extern long double printf_frexpl (long double x, int *expptr); lftp-4.6.3a/lib/sockets.c0000644000015000007670000001001512466374012012142 00000000000000/* sockets.c --- wrappers for Windows socket functions Copyright (C) 2008-2015 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 . */ /* Written by Simon Josefsson */ #include /* Specification. */ #include "sockets.h" #if WINDOWS_SOCKETS /* This includes winsock2.h on MinGW. */ # include # include "fd-hook.h" # include "msvc-nothrow.h" /* Get set_winsock_errno, FD_TO_SOCKET etc. */ # include "w32sock.h" static int close_fd_maybe_socket (const struct fd_hook *remaining_list, gl_close_fn primary, int fd) { /* Note about multithread-safety: There is a race condition where, between our calls to closesocket() and the primary close(), some other thread could make system calls that allocate precisely the same HANDLE value as sock; then the primary close() would call CloseHandle() on it. */ SOCKET sock; WSANETWORKEVENTS ev; /* Test whether fd refers to a socket. */ sock = FD_TO_SOCKET (fd); ev.lNetworkEvents = 0xDEADBEEF; WSAEnumNetworkEvents (sock, NULL, &ev); if (ev.lNetworkEvents != 0xDEADBEEF) { /* fd refers to a socket. */ /* FIXME: other applications, like squid, use an undocumented _free_osfhnd free function. But this is not enough: The 'osfile' flags for fd also needs to be cleared, but it is hard to access it. Instead, here we just close twice the file descriptor. */ if (closesocket (sock)) { set_winsock_errno (); return -1; } else { /* This call frees the file descriptor and does a CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */ _close (fd); return 0; } } else /* Some other type of file descriptor. */ return execute_close_hooks (remaining_list, primary, fd); } static int ioctl_fd_maybe_socket (const struct fd_hook *remaining_list, gl_ioctl_fn primary, int fd, int request, void *arg) { SOCKET sock; WSANETWORKEVENTS ev; /* Test whether fd refers to a socket. */ sock = FD_TO_SOCKET (fd); ev.lNetworkEvents = 0xDEADBEEF; WSAEnumNetworkEvents (sock, NULL, &ev); if (ev.lNetworkEvents != 0xDEADBEEF) { /* fd refers to a socket. */ if (ioctlsocket (sock, request, arg) < 0) { set_winsock_errno (); return -1; } else return 0; } else /* Some other type of file descriptor. */ return execute_ioctl_hooks (remaining_list, primary, fd, request, arg); } static struct fd_hook fd_sockets_hook; static int initialized_sockets_version /* = 0 */; #endif /* WINDOWS_SOCKETS */ int gl_sockets_startup (int version _GL_UNUSED) { #if WINDOWS_SOCKETS if (version > initialized_sockets_version) { WSADATA data; int err; err = WSAStartup (version, &data); if (err != 0) return 1; if (data.wVersion < version) return 2; if (initialized_sockets_version == 0) register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket, &fd_sockets_hook); initialized_sockets_version = version; } #endif return 0; } int gl_sockets_cleanup (void) { #if WINDOWS_SOCKETS int err; initialized_sockets_version = 0; unregister_fd_hook (&fd_sockets_hook); err = WSACleanup (); if (err != 0) return 1; #endif return 0; } lftp-4.6.3a/lib/w32sock.h0000644000015000007670000000634112466374012011776 00000000000000/* w32sock.h --- internal auxiliary functions for Windows socket functions Copyright (C) 2008-2015 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 . */ /* Written by Paolo Bonzini */ #include /* Get O_RDWR and O_BINARY. */ #include /* Get _open_osfhandle(). */ #include /* Get _get_osfhandle(). */ #include "msvc-nothrow.h" #define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) #define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY)) static inline void set_winsock_errno (void) { int err = WSAGetLastError (); /* Map some WSAE* errors to the runtime library's error codes. */ switch (err) { case WSA_INVALID_HANDLE: errno = EBADF; break; case WSA_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; case WSA_INVALID_PARAMETER: errno = EINVAL; break; case WSAENAMETOOLONG: errno = ENAMETOOLONG; break; case WSAENOTEMPTY: errno = ENOTEMPTY; break; case WSAEWOULDBLOCK: errno = EWOULDBLOCK; break; case WSAEINPROGRESS: errno = EINPROGRESS; break; case WSAEALREADY: errno = EALREADY; break; case WSAENOTSOCK: errno = ENOTSOCK; break; case WSAEDESTADDRREQ: errno = EDESTADDRREQ; break; case WSAEMSGSIZE: errno = EMSGSIZE; break; case WSAEPROTOTYPE: errno = EPROTOTYPE; break; case WSAENOPROTOOPT: errno = ENOPROTOOPT; break; case WSAEPROTONOSUPPORT: errno = EPROTONOSUPPORT; break; case WSAEOPNOTSUPP: errno = EOPNOTSUPP; break; case WSAEAFNOSUPPORT: errno = EAFNOSUPPORT; break; case WSAEADDRINUSE: errno = EADDRINUSE; break; case WSAEADDRNOTAVAIL: errno = EADDRNOTAVAIL; break; case WSAENETDOWN: errno = ENETDOWN; break; case WSAENETUNREACH: errno = ENETUNREACH; break; case WSAENETRESET: errno = ENETRESET; break; case WSAECONNABORTED: errno = ECONNABORTED; break; case WSAECONNRESET: errno = ECONNRESET; break; case WSAENOBUFS: errno = ENOBUFS; break; case WSAEISCONN: errno = EISCONN; break; case WSAENOTCONN: errno = ENOTCONN; break; case WSAETIMEDOUT: errno = ETIMEDOUT; break; case WSAECONNREFUSED: errno = ECONNREFUSED; break; case WSAELOOP: errno = ELOOP; break; case WSAEHOSTUNREACH: errno = EHOSTUNREACH; break; default: errno = (err > 10000 && err < 10025) ? err - 10000 : err; break; } } lftp-4.6.3a/lib/stddef.in.h0000644000015000007670000000700012513711764012354 00000000000000/* A substitute for POSIX 2008 , for platforms that have issues. Copyright (C) 2009-2015 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 . */ /* Written by Eric Blake. */ /* * POSIX 2008 for platforms that have issues. * */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined __need_wchar_t || defined __need_size_t \ || defined __need_ptrdiff_t || defined __need_NULL \ || defined __need_wint_t /* Special invocation convention inside gcc header files. In particular, gcc provides a version of that blindly redefines NULL even when __need_wint_t was defined, even though wint_t is not normally provided by . Hence, we must remember if special invocation has ever been used to obtain wint_t, in which case we need to clean up NULL yet again. */ # if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) # ifdef __need_wint_t # define _GL_STDDEF_WINT_T # endif # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ # endif #else /* Normal invocation convention. */ # ifndef _@GUARD_PREFIX@_STDDEF_H /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ /* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ # if (@REPLACE_NULL@ \ && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T)) # undef NULL # ifdef __cplusplus /* ISO C++ says that the macro NULL must expand to an integer constant expression, hence '((void *) 0)' is not allowed in C++. */ # if __GNUG__ >= 3 /* GNU C++ has a __null macro that behaves like an integer ('int' or 'long') but has the same size as a pointer. Use that, to avoid warnings. */ # define NULL __null # else # define NULL 0L # endif # else # define NULL ((void *) 0) # endif # endif # ifndef _@GUARD_PREFIX@_STDDEF_H # define _@GUARD_PREFIX@_STDDEF_H /* Some platforms lack wchar_t. */ #if !@HAVE_WCHAR_T@ # define wchar_t int #endif /* Some platforms lack max_align_t. */ #if !@HAVE_MAX_ALIGN_T@ /* On the x86, the maximum storage alignment of double, long, etc. is 4, but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8, and the C11 standard allows this. Work around this problem by using __alignof__ (which returns 8 for double) rather than _Alignof (which returns 4), and align each union member accordingly. */ # ifdef __GNUC__ # define _GL_STDDEF_ALIGNAS(type) \ __attribute__ ((__aligned__ (__alignof__ (type)))) # else # define _GL_STDDEF_ALIGNAS(type) /* */ # endif typedef union { char *__p _GL_STDDEF_ALIGNAS (char *); double __d _GL_STDDEF_ALIGNAS (double); long double __ld _GL_STDDEF_ALIGNAS (long double); long int __i _GL_STDDEF_ALIGNAS (long int); } max_align_t; #endif # endif /* _@GUARD_PREFIX@_STDDEF_H */ # endif /* _@GUARD_PREFIX@_STDDEF_H */ #endif /* __need_XXX */ lftp-4.6.3a/lib/timespec.h0000644000015000007670000000722212466374012012313 00000000000000/* timespec -- System time interface Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2015 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 . */ #if ! defined TIMESPEC_H # define TIMESPEC_H # include #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_TIMESPEC_INLINE # define _GL_TIMESPEC_INLINE _GL_INLINE #endif /* Resolution of timespec time stamps (in units per second), and log base 10 of the resolution. */ enum { TIMESPEC_RESOLUTION = 1000000000 }; enum { LOG10_TIMESPEC_RESOLUTION = 9 }; /* Return a timespec with seconds S and nanoseconds NS. */ _GL_TIMESPEC_INLINE struct timespec make_timespec (time_t s, long int ns) { struct timespec r; r.tv_sec = s; r.tv_nsec = ns; return r; } /* Return negative, zero, positive if A < B, A == B, A > B, respectively. For each time stamp T, this code assumes that either: * T.tv_nsec is in the range 0..999999999; or * T.tv_sec corresponds to a valid leap second on a host that supports leap seconds, and T.tv_nsec is in the range 1000000000..1999999999; or * T.tv_sec is the minimum time_t value and T.tv_nsec is -1; or T.tv_sec is the maximum time_t value and T.tv_nsec is 2000000000. This allows for special struct timespec values that are less or greater than all possible valid time stamps. In all these cases, it is safe to subtract two tv_nsec values and convert the result to integer without worrying about overflow on any platform of interest to the GNU project, since all such platforms have 32-bit int or wider. Replacing "(int) (a.tv_nsec - b.tv_nsec)" with something like "a.tv_nsec < b.tv_nsec ? -1 : a.tv_nsec > b.tv_nsec" would cause this function to work in some cases where the above assumption is violated, but not in all cases (e.g., a.tv_sec==1, a.tv_nsec==-2, b.tv_sec==0, b.tv_nsec==999999999) and is arguably not worth the extra instructions. Using a subtraction has the advantage of detecting some invalid cases on platforms that detect integer overflow. The (int) cast avoids a gcc -Wconversion warning. */ _GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 : a.tv_sec > b.tv_sec ? 1 : (int) (a.tv_nsec - b.tv_nsec)); } /* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be nonnegative. */ _GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE timespec_sign (struct timespec a) { return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec; } struct timespec timespec_add (struct timespec, struct timespec) _GL_ATTRIBUTE_CONST; struct timespec timespec_sub (struct timespec, struct timespec) _GL_ATTRIBUTE_CONST; struct timespec dtotimespec (double) _GL_ATTRIBUTE_CONST; /* Return an approximation to A, of type 'double'. */ _GL_TIMESPEC_INLINE double timespectod (struct timespec a) { return a.tv_sec + a.tv_nsec / 1e9; } void gettime (struct timespec *); int settime (struct timespec const *); _GL_INLINE_HEADER_END #endif lftp-4.6.3a/lib/strnlen1.c0000644000015000007670000000236512466374012012246 00000000000000/* Find the length of STRING + 1, but scan at most MAXLEN bytes. Copyright (C) 2005-2006, 2009-2015 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 . */ #include /* Specification. */ #include "strnlen1.h" #include /* Find the length of STRING + 1, but scan at most MAXLEN bytes. If no '\0' terminator is found in that many characters, return MAXLEN. */ /* This is the same as strnlen (string, maxlen - 1) + 1. */ size_t strnlen1 (const char *string, size_t maxlen) { const char *end = (const char *) memchr (string, '\0', maxlen); if (end != NULL) return end - string + 1; else return maxlen; } lftp-4.6.3a/lib/strtoumax.c0000644000015000007670000000005212122621313012521 00000000000000#define UNSIGNED 1 #include "strtoimax.c" lftp-4.6.3a/lib/strtoimax.c0000644000015000007670000000417512466374012012533 00000000000000/* Convert string representation of a number into an intmax_t value. Copyright (C) 1999, 2001-2004, 2006, 2009-2015 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 . */ /* Written by Paul Eggert. */ #include /* Verify interface. */ #include #include #include "verify.h" #ifdef UNSIGNED # if HAVE_UNSIGNED_LONG_LONG_INT # ifndef HAVE_DECL_STRTOULL "this configure-time declaration test was not run" # endif # if !HAVE_DECL_STRTOULL unsigned long long int strtoull (char const *, char **, int); # endif # endif #else # if HAVE_LONG_LONG_INT # ifndef HAVE_DECL_STRTOLL "this configure-time declaration test was not run" # endif # if !HAVE_DECL_STRTOLL long long int strtoll (char const *, char **, int); # endif # endif #endif #ifdef UNSIGNED # define Have_long_long HAVE_UNSIGNED_LONG_LONG_INT # define Int uintmax_t # define Strtoimax strtoumax # define Strtol strtoul # define Strtoll strtoull # define Unsigned unsigned #else # define Have_long_long HAVE_LONG_LONG_INT # define Int intmax_t # define Strtoimax strtoimax # define Strtol strtol # define Strtoll strtoll # define Unsigned #endif Int Strtoimax (char const *ptr, char **endptr, int base) { #if Have_long_long verify (sizeof (Int) == sizeof (Unsigned long int) || sizeof (Int) == sizeof (Unsigned long long int)); if (sizeof (Int) != sizeof (Unsigned long int)) return Strtoll (ptr, endptr, base); #else verify (sizeof (Int) == sizeof (Unsigned long int)); #endif return Strtol (ptr, endptr, base); } lftp-4.6.3a/lib/quotearg.h0000644000015000007670000003707412466374011012340 00000000000000/* quotearg.h - quote arguments for output Copyright (C) 1998-2002, 2004, 2006, 2008-2015 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 . */ /* Written by Paul Eggert */ #ifndef QUOTEARG_H_ # define QUOTEARG_H_ 1 # include /* Basic quoting styles. For each style, an example is given on the input strings "simple", "\0 \t\n'\"\033?""?/\\", and "a:b", using quotearg_buffer, quotearg_mem, and quotearg_colon_mem with that style and the default flags and quoted characters. Note that the examples are shown here as valid C strings rather than what displays on a terminal (with "??/" as a trigraph for "\\"). */ enum quoting_style { /* Output names as-is (ls --quoting-style=literal). Can result in embedded null bytes if QA_ELIDE_NULL_BYTES is not in effect. quotearg_buffer: "simple", "\0 \t\n'\"\033??/\\", "a:b" quotearg: "simple", " \t\n'\"\033??/\\", "a:b" quotearg_colon: "simple", " \t\n'\"\033??/\\", "a:b" */ literal_quoting_style, /* Quote names for the shell if they contain shell metacharacters or would cause ambiguous output (ls --quoting-style=shell). Can result in embedded null bytes if QA_ELIDE_NULL_BYTES is not in effect. quotearg_buffer: "simple", "'\0 \t\n'\\''\"\033??/\\'", "a:b" quotearg: "simple", "' \t\n'\\''\"\033??/\\'", "a:b" quotearg_colon: "simple", "' \t\n'\\''\"\033??/\\'", "'a:b'" */ shell_quoting_style, /* Quote names for the shell, even if they would normally not require quoting (ls --quoting-style=shell-always). Can result in embedded null bytes if QA_ELIDE_NULL_BYTES is not in effect. Behaves like shell_quoting_style if QA_ELIDE_OUTER_QUOTES is in effect. quotearg_buffer: "'simple'", "'\0 \t\n'\\''\"\033??/\\'", "'a:b'" quotearg: "'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'" quotearg_colon: "'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'" */ shell_always_quoting_style, /* Quote names as for a C language string (ls --quoting-style=c). Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is in effect. Split into consecutive strings if QA_SPLIT_TRIGRAPHS. quotearg_buffer: "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" quotearg: "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" quotearg_colon: "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\"" */ c_quoting_style, /* Like c_quoting_style except omit the surrounding double-quote characters if no quoted characters are encountered. quotearg_buffer: "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b" quotearg: "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b" quotearg_colon: "simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" */ c_maybe_quoting_style, /* Like c_quoting_style except always omit the surrounding double-quote characters and ignore QA_SPLIT_TRIGRAPHS (ls --quoting-style=escape). quotearg_buffer: "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b" quotearg: "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b" quotearg_colon: "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a\\:b" */ escape_quoting_style, /* Like clocale_quoting_style, but use single quotes in the default C locale or if the program does not use gettext (ls --quoting-style=locale). For UTF-8 locales, quote characters will use Unicode. LC_MESSAGES=C quotearg_buffer: "`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'" quotearg: "`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'" quotearg_colon: "`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a\\:b'" LC_MESSAGES=pt_PT.utf8 quotearg_buffer: "\302\253simple\302\273", "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273" quotearg: "\302\253simple\302\273", "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273" quotearg_colon: "\302\253simple\302\273", "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273" */ locale_quoting_style, /* Like c_quoting_style except use quotation marks appropriate for the locale and ignore QA_SPLIT_TRIGRAPHS (ls --quoting-style=clocale). LC_MESSAGES=C quotearg_buffer: "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" quotearg: "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\"" quotearg_colon: "\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\"" LC_MESSAGES=pt_PT.utf8 quotearg_buffer: "\302\253simple\302\273", "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273" quotearg: "\302\253simple\302\273", "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273" quotearg_colon: "\302\253simple\302\273", "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273" */ clocale_quoting_style, /* Like clocale_quoting_style except use the custom quotation marks set by set_custom_quoting. If custom quotation marks are not set, the behavior is undefined. left_quote = right_quote = "'" quotearg_buffer: "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'" quotearg: "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'" quotearg_colon: "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a\\:b'" left_quote = "(" and right_quote = ")" quotearg_buffer: "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a:b)" quotearg: "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a:b)" quotearg_colon: "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a\\:b)" left_quote = ":" and right_quote = " " quotearg_buffer: ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a:b " quotearg: ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a:b " quotearg_colon: ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a\\:b " left_quote = "\"'" and right_quote = "'\"" Notice that this is treated as a single level of quotes or two levels where the outer quote need not be escaped within the inner quotes. For two levels where the outer quote must be escaped within the inner quotes, you must use separate quotearg invocations. quotearg_buffer: "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a:b'\"" quotearg: "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a:b'\"" quotearg_colon: "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a\\:b'\"" */ custom_quoting_style }; /* Flags for use in set_quoting_flags. */ enum quoting_flags { /* Always elide null bytes from styles that do not quote them, even when the length of the result is available to the caller. */ QA_ELIDE_NULL_BYTES = 0x01, /* Omit the surrounding quote characters if no escaped characters are encountered. Note that if no other character needs escaping, then neither does the escape character. */ QA_ELIDE_OUTER_QUOTES = 0x02, /* In the c_quoting_style and c_maybe_quoting_style, split ANSI trigraph sequences into concatenated strings (for example, "?""?/" rather than "??/", which could be confused with "\\"). */ QA_SPLIT_TRIGRAPHS = 0x04 }; /* For now, --quoting-style=literal is the default, but this may change. */ # ifndef DEFAULT_QUOTING_STYLE # define DEFAULT_QUOTING_STYLE literal_quoting_style # endif /* Names of quoting styles and their corresponding values. */ extern char const *const quoting_style_args[]; extern enum quoting_style const quoting_style_vals[]; struct quoting_options; /* The functions listed below set and use a hidden variable that contains the default quoting style options. */ /* Allocate a new set of quoting options, with contents initially identical to O if O is not null, or to the default if O is null. It is the caller's responsibility to free the result. */ struct quoting_options *clone_quoting_options (struct quoting_options *o); /* Get the value of O's quoting style. If O is null, use the default. */ enum quoting_style get_quoting_style (struct quoting_options *o); /* In O (or in the default if O is null), set the value of the quoting style to S. */ void set_quoting_style (struct quoting_options *o, enum quoting_style s); /* In O (or in the default if O is null), set the value of the quoting options for character C to I. Return the old value. Currently, the only values defined for I are 0 (the default) and 1 (which means to quote the character even if it would not otherwise be quoted). C must never be a digit or a letter that has special meaning after a backslash (for example, "\t" for tab). */ int set_char_quoting (struct quoting_options *o, char c, int i); /* In O (or in the default if O is null), set the value of the quoting options flag to I, which can be a bitwise combination of enum quoting_flags, or 0 for default behavior. Return the old value. */ int set_quoting_flags (struct quoting_options *o, int i); /* In O (or in the default if O is null), set the value of the quoting style to custom_quoting_style, set the left quote to LEFT_QUOTE, and set the right quote to RIGHT_QUOTE. Each of LEFT_QUOTE and RIGHT_QUOTE must be null-terminated and can be the empty string. Because backslashes are used for escaping, it does not make sense for RIGHT_QUOTE to contain a backslash. RIGHT_QUOTE must not begin with a digit or a letter that has special meaning after a backslash (for example, "\t" for tab). */ void set_custom_quoting (struct quoting_options *o, char const *left_quote, char const *right_quote); /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of argument ARG (of size ARGSIZE), using O to control quoting. If O is null, use the default. Terminate the output with a null character, and return the written size of the output, not counting the terminating null. If BUFFERSIZE is too small to store the output string, return the value that would have been returned had BUFFERSIZE been large enough. If ARGSIZE is -1, use the string length of the argument for ARGSIZE. On output, BUFFER might contain embedded null bytes if ARGSIZE was not -1, the style of O does not use backslash escapes, and the flags of O do not request elision of null bytes.*/ size_t quotearg_buffer (char *buffer, size_t buffersize, char const *arg, size_t argsize, struct quoting_options const *o); /* Like quotearg_buffer, except return the result in a newly allocated buffer. It is the caller's responsibility to free the result. The result will not contain embedded null bytes. */ char *quotearg_alloc (char const *arg, size_t argsize, struct quoting_options const *o); /* Like quotearg_alloc, except that the length of the result, excluding the terminating null byte, is stored into SIZE if it is non-NULL. The result might contain embedded null bytes if ARGSIZE was not -1, SIZE was not NULL, the style of O does not use backslash escapes, and the flags of O do not request elision of null bytes.*/ char *quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size, struct quoting_options const *o); /* Use storage slot N to return a quoted version of the string ARG. Use the default quoting options. The returned value points to static storage that can be reused by the next call to this function with the same value of N. N must be nonnegative. The output of all functions in the quotearg_n family are guaranteed to not contain embedded null bytes.*/ char *quotearg_n (int n, char const *arg); /* Equivalent to quotearg_n (0, ARG). */ char *quotearg (char const *arg); /* Use storage slot N to return a quoted version of the argument ARG of size ARGSIZE. This is like quotearg_n (N, ARG), except it can quote null bytes. */ char *quotearg_n_mem (int n, char const *arg, size_t argsize); /* Equivalent to quotearg_n_mem (0, ARG, ARGSIZE). */ char *quotearg_mem (char const *arg, size_t argsize); /* Use style S and storage slot N to return a quoted version of the string ARG. This is like quotearg_n (N, ARG), except that it uses S with no other options to specify the quoting method. */ char *quotearg_n_style (int n, enum quoting_style s, char const *arg); /* Use style S and storage slot N to return a quoted version of the argument ARG of size ARGSIZE. This is like quotearg_n_style (N, S, ARG), except it can quote null bytes. */ char *quotearg_n_style_mem (int n, enum quoting_style s, char const *arg, size_t argsize); /* Equivalent to quotearg_n_style (0, S, ARG). */ char *quotearg_style (enum quoting_style s, char const *arg); /* Equivalent to quotearg_n_style_mem (0, S, ARG, ARGSIZE). */ char *quotearg_style_mem (enum quoting_style s, char const *arg, size_t argsize); /* Like quotearg (ARG), except also quote any instances of CH. See set_char_quoting for a description of acceptable CH values. */ char *quotearg_char (char const *arg, char ch); /* Like quotearg_char (ARG, CH), except it can quote null bytes. */ char *quotearg_char_mem (char const *arg, size_t argsize, char ch); /* Equivalent to quotearg_char (ARG, ':'). */ char *quotearg_colon (char const *arg); /* Like quotearg_colon (ARG), except it can quote null bytes. */ char *quotearg_colon_mem (char const *arg, size_t argsize); /* Like quotearg_n_style (N, S, ARG) but with S as custom_quoting_style with left quote as LEFT_QUOTE and right quote as RIGHT_QUOTE. See set_custom_quoting for a description of acceptable LEFT_QUOTE and RIGHT_QUOTE values. */ char *quotearg_n_custom (int n, char const *left_quote, char const *right_quote, char const *arg); /* Like quotearg_n_custom (N, LEFT_QUOTE, RIGHT_QUOTE, ARG) except it can quote null bytes. */ char *quotearg_n_custom_mem (int n, char const *left_quote, char const *right_quote, char const *arg, size_t argsize); /* Equivalent to quotearg_n_custom (0, LEFT_QUOTE, RIGHT_QUOTE, ARG). */ char *quotearg_custom (char const *left_quote, char const *right_quote, char const *arg); /* Equivalent to quotearg_n_custom_mem (0, LEFT_QUOTE, RIGHT_QUOTE, ARG, ARGSIZE). */ char *quotearg_custom_mem (char const *left_quote, char const *right_quote, char const *arg, size_t argsize); /* Free any dynamically allocated memory. */ void quotearg_free (void); #endif /* !QUOTEARG_H_ */ lftp-4.6.3a/lib/getdtablesize.c0000644000015000007670000000643712477560611013336 00000000000000/* getdtablesize() function for platforms that don't have it. Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. 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 . */ #include /* Specification. */ #include #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # include # include "msvc-inval.h" # if HAVE_MSVC_INVALID_PARAMETER_HANDLER static int _setmaxstdio_nothrow (int newmax) { int result; TRY_MSVC_INVAL { result = _setmaxstdio (newmax); } CATCH_MSVC_INVAL { result = -1; } DONE_MSVC_INVAL; return result; } # define _setmaxstdio _setmaxstdio_nothrow # endif /* Cache for the previous getdtablesize () result. Safe to cache because Windows also lacks setrlimit. */ static int dtablesize; int getdtablesize (void) { if (dtablesize == 0) { /* We are looking for the number N such that the valid file descriptors are 0..N-1. It can be obtained through a loop as follows: { int fd; for (fd = 3; fd < 65536; fd++) if (dup2 (0, fd) == -1) break; return fd; } On Windows XP, the result is 2048. The drawback of this loop is that it allocates memory for a libc internal array that is never freed. The number N can also be obtained as the upper bound for _getmaxstdio (). _getmaxstdio () returns the maximum number of open FILE objects. The sanity check in _setmaxstdio reveals the maximum number of file descriptors. This too allocates memory, but it is freed when we call _setmaxstdio with the original value. */ int orig_max_stdio = _getmaxstdio (); unsigned int bound; for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2) ; _setmaxstdio (orig_max_stdio); dtablesize = bound; } return dtablesize; } #else # include # include # ifndef RLIM_SAVED_CUR # define RLIM_SAVED_CUR RLIM_INFINITY # endif # ifndef RLIM_SAVED_MAX # define RLIM_SAVED_MAX RLIM_INFINITY # endif # ifdef __CYGWIN__ /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it hits the compile-time constant hard limit of 3200. We might as well just report the hard limit. */ # define rlim_cur rlim_max # endif int getdtablesize (void) { struct rlimit lim; if (getrlimit (RLIMIT_NOFILE, &lim) == 0 && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX && lim.rlim_cur != RLIM_INFINITY && lim.rlim_cur != RLIM_SAVED_CUR && lim.rlim_cur != RLIM_SAVED_MAX) return lim.rlim_cur; return INT_MAX; } #endif lftp-4.6.3a/lib/signal.in.h0000644000015000007670000003462312477560612012376 00000000000000/* A GNU-like . Copyright (C) 2006-2015 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 . */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T) /* Special invocation convention: - Inside glibc header files. - On glibc systems we have a sequence of nested includes -> -> . In this situation, the functions are not yet declared, therefore we cannot provide the C++ aliases. - On glibc systems with GCC 4.3 we have a sequence of nested includes -> -> -> . In this situation, some of the functions are not yet declared, therefore we cannot provide the C++ aliases. */ # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@ #else /* Normal invocation convention. */ #ifndef _@GUARD_PREFIX@_SIGNAL_H #define _GL_ALREADY_INCLUDING_SIGNAL_H /* Define pid_t, uid_t. Also, mingw defines sigset_t not in , but in . On Solaris 10, includes , which eventually includes us; so include now, before the second inclusion guard. */ #include /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@ #undef _GL_ALREADY_INCLUDING_SIGNAL_H #ifndef _@GUARD_PREFIX@_SIGNAL_H #define _@GUARD_PREFIX@_SIGNAL_H /* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6, Android declare pthread_sigmask in , not in . But avoid namespace pollution on glibc systems.*/ #if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \ && ((defined __APPLE__ && defined __MACH__) \ || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ \ || defined __sun || defined __ANDROID__) \ && ! defined __GLIBC__ # include #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. */ /* On AIX, sig_atomic_t already includes volatile. C99 requires that 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not. Hence, redefine this to a non-volatile type as needed. */ #if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ # if !GNULIB_defined_sig_atomic_t typedef int rpl_sig_atomic_t; # undef sig_atomic_t # define sig_atomic_t rpl_sig_atomic_t # define GNULIB_defined_sig_atomic_t 1 # endif #endif /* A set or mask of signals. */ #if !@HAVE_SIGSET_T@ # if !GNULIB_defined_sigset_t typedef unsigned int sigset_t; # define GNULIB_defined_sigset_t 1 # endif #endif /* Define sighandler_t, the type of signal handlers. A GNU extension. */ #if !@HAVE_SIGHANDLER_T@ # ifdef __cplusplus extern "C" { # endif # if !GNULIB_defined_sighandler_t typedef void (*sighandler_t) (int); # define GNULIB_defined_sighandler_t 1 # endif # ifdef __cplusplus } # endif #endif #if @GNULIB_SIGNAL_H_SIGPIPE@ # ifndef SIGPIPE /* Define SIGPIPE to a value that does not overlap with other signals. */ # define SIGPIPE 13 # define GNULIB_defined_SIGPIPE 1 /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask', 'write', 'stdio'. */ # endif #endif /* Maximum signal number + 1. */ #ifndef NSIG # if defined __TANDEM # define NSIG 32 # endif #endif #if @GNULIB_PTHREAD_SIGMASK@ # if @REPLACE_PTHREAD_SIGMASK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef pthread_sigmask # define pthread_sigmask rpl_pthread_sigmask # endif _GL_FUNCDECL_RPL (pthread_sigmask, int, (int how, const sigset_t *new_mask, sigset_t *old_mask)); _GL_CXXALIAS_RPL (pthread_sigmask, int, (int how, const sigset_t *new_mask, sigset_t *old_mask)); # else # if !@HAVE_PTHREAD_SIGMASK@ _GL_FUNCDECL_SYS (pthread_sigmask, int, (int how, const sigset_t *new_mask, sigset_t *old_mask)); # endif _GL_CXXALIAS_SYS (pthread_sigmask, int, (int how, const sigset_t *new_mask, sigset_t *old_mask)); # endif _GL_CXXALIASWARN (pthread_sigmask); #elif defined GNULIB_POSIXCHECK # undef pthread_sigmask # if HAVE_RAW_DECL_PTHREAD_SIGMASK _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - " "use gnulib module pthread_sigmask for portability"); # endif #endif #if @GNULIB_RAISE@ # if @REPLACE_RAISE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef raise # define raise rpl_raise # endif _GL_FUNCDECL_RPL (raise, int, (int sig)); _GL_CXXALIAS_RPL (raise, int, (int sig)); # else # if !@HAVE_RAISE@ _GL_FUNCDECL_SYS (raise, int, (int sig)); # endif _GL_CXXALIAS_SYS (raise, int, (int sig)); # endif _GL_CXXALIASWARN (raise); #elif defined GNULIB_POSIXCHECK # undef raise /* Assume raise is always declared. */ _GL_WARN_ON_USE (raise, "raise can crash on native Windows - " "use gnulib module raise for portability"); #endif #if @GNULIB_SIGPROCMASK@ # if !@HAVE_POSIX_SIGNALBLOCKING@ # ifndef GNULIB_defined_signal_blocking # define GNULIB_defined_signal_blocking 1 # endif /* Maximum signal number + 1. */ # ifndef NSIG # define NSIG 32 # endif /* This code supports only 32 signals. */ # if !GNULIB_defined_verify_NSIG_constraint typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1]; # define GNULIB_defined_verify_NSIG_constraint 1 # endif # endif /* When also using extern inline, suppress the use of static inline in standard headers of problematic Apple configurations, as Libc at least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., . Perhaps Apple will fix this some day. */ #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ && (defined __i386__ || defined __x86_64__)) # undef sigaddset # undef sigdelset # undef sigemptyset # undef sigfillset # undef sigismember #endif /* Test whether a given signal is contained in a signal set. */ # if @HAVE_POSIX_SIGNALBLOCKING@ /* This function is defined as a macro on Mac OS X. */ # if defined __cplusplus && defined GNULIB_NAMESPACE # undef sigismember # endif # else _GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig)); _GL_CXXALIASWARN (sigismember); /* Initialize a signal set to the empty set. */ # if @HAVE_POSIX_SIGNALBLOCKING@ /* This function is defined as a macro on Mac OS X. */ # if defined __cplusplus && defined GNULIB_NAMESPACE # undef sigemptyset # endif # else _GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set)); _GL_CXXALIASWARN (sigemptyset); /* Add a signal to a signal set. */ # if @HAVE_POSIX_SIGNALBLOCKING@ /* This function is defined as a macro on Mac OS X. */ # if defined __cplusplus && defined GNULIB_NAMESPACE # undef sigaddset # endif # else _GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig)); _GL_CXXALIASWARN (sigaddset); /* Remove a signal from a signal set. */ # if @HAVE_POSIX_SIGNALBLOCKING@ /* This function is defined as a macro on Mac OS X. */ # if defined __cplusplus && defined GNULIB_NAMESPACE # undef sigdelset # endif # else _GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig)); _GL_CXXALIASWARN (sigdelset); /* Fill a signal set with all possible signals. */ # if @HAVE_POSIX_SIGNALBLOCKING@ /* This function is defined as a macro on Mac OS X. */ # if defined __cplusplus && defined GNULIB_NAMESPACE # undef sigfillset # endif # else _GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set)); _GL_CXXALIASWARN (sigfillset); /* Return the set of those blocked signals that are pending. */ # if !@HAVE_POSIX_SIGNALBLOCKING@ _GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set)); _GL_CXXALIASWARN (sigpending); /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET. Then, if SET is not NULL, affect the current set of blocked signals by combining it with *SET as indicated in OPERATION. In this implementation, you are not allowed to change a signal handler while the signal is blocked. */ # if !@HAVE_POSIX_SIGNALBLOCKING@ # define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */ # define SIG_SETMASK 1 /* blocked_set = *set; */ # define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */ _GL_FUNCDECL_SYS (sigprocmask, int, (int operation, const sigset_t *set, sigset_t *old_set)); # endif _GL_CXXALIAS_SYS (sigprocmask, int, (int operation, const sigset_t *set, sigset_t *old_set)); _GL_CXXALIASWARN (sigprocmask); /* Install the handler FUNC for signal SIG, and return the previous handler. */ # ifdef __cplusplus extern "C" { # endif # if !GNULIB_defined_function_taking_int_returning_void_t typedef void (*_gl_function_taking_int_returning_void_t) (int); # define GNULIB_defined_function_taking_int_returning_void_t 1 # endif # ifdef __cplusplus } # endif # if !@HAVE_POSIX_SIGNALBLOCKING@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define signal rpl_signal # endif _GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t, (int sig, _gl_function_taking_int_returning_void_t func)); _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t, (int sig, _gl_function_taking_int_returning_void_t func)); # else _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t, (int sig, _gl_function_taking_int_returning_void_t func)); # endif _GL_CXXALIASWARN (signal); # if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE /* Raise signal SIGPIPE. */ _GL_EXTERN_C int _gl_raise_SIGPIPE (void); # endif #elif defined GNULIB_POSIXCHECK # undef sigaddset # if HAVE_RAW_DECL_SIGADDSET _GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - " "use the gnulib module sigprocmask for portability"); # endif # undef sigdelset # if HAVE_RAW_DECL_SIGDELSET _GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - " "use the gnulib module sigprocmask for portability"); # endif # undef sigemptyset # if HAVE_RAW_DECL_SIGEMPTYSET _GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - " "use the gnulib module sigprocmask for portability"); # endif # undef sigfillset # if HAVE_RAW_DECL_SIGFILLSET _GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - " "use the gnulib module sigprocmask for portability"); # endif # undef sigismember # if HAVE_RAW_DECL_SIGISMEMBER _GL_WARN_ON_USE (sigismember, "sigismember is unportable - " "use the gnulib module sigprocmask for portability"); # endif # undef sigpending # if HAVE_RAW_DECL_SIGPENDING _GL_WARN_ON_USE (sigpending, "sigpending is unportable - " "use the gnulib module sigprocmask for portability"); # endif # undef sigprocmask # if HAVE_RAW_DECL_SIGPROCMASK _GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - " "use the gnulib module sigprocmask for portability"); # endif #endif /* @GNULIB_SIGPROCMASK@ */ #if @GNULIB_SIGACTION@ # if !@HAVE_SIGACTION@ # if !@HAVE_SIGINFO_T@ # if !GNULIB_defined_siginfo_types /* Present to allow compilation, but unsupported by gnulib. */ union sigval { int sival_int; void *sival_ptr; }; /* Present to allow compilation, but unsupported by gnulib. */ struct siginfo_t { int si_signo; int si_code; int si_errno; pid_t si_pid; uid_t si_uid; void *si_addr; int si_status; long si_band; union sigval si_value; }; typedef struct siginfo_t siginfo_t; # define GNULIB_defined_siginfo_types 1 # endif # endif /* !@HAVE_SIGINFO_T@ */ /* We assume that platforms which lack the sigaction() function also lack the 'struct sigaction' type, and vice versa. */ # if !GNULIB_defined_struct_sigaction struct sigaction { union { void (*_sa_handler) (int); /* Present to allow compilation, but unsupported by gnulib. POSIX says that implementations may, but not must, make sa_sigaction overlap with sa_handler, but we know of no implementation where they do not overlap. */ void (*_sa_sigaction) (int, siginfo_t *, void *); } _sa_func; sigset_t sa_mask; /* Not all POSIX flags are supported. */ int sa_flags; }; # define sa_handler _sa_func._sa_handler # define sa_sigaction _sa_func._sa_sigaction /* Unsupported flags are not present. */ # define SA_RESETHAND 1 # define SA_NODEFER 2 # define SA_RESTART 4 # define GNULIB_defined_struct_sigaction 1 # endif _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict, struct sigaction *restrict)); # elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ # define sa_sigaction sa_handler # endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */ _GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict, struct sigaction *restrict)); _GL_CXXALIASWARN (sigaction); #elif defined GNULIB_POSIXCHECK # undef sigaction # if HAVE_RAW_DECL_SIGACTION _GL_WARN_ON_USE (sigaction, "sigaction is unportable - " "use the gnulib module sigaction for portability"); # endif #endif /* Some systems don't have SA_NODEFER. */ #ifndef SA_NODEFER # define SA_NODEFER 0 #endif #endif /* _@GUARD_PREFIX@_SIGNAL_H */ #endif /* _@GUARD_PREFIX@_SIGNAL_H */ #endif lftp-4.6.3a/lib/itold.c0000644000015000007670000000201012466374011011575 00000000000000/* Replacement for 'int' to 'long double' conversion routine. Copyright (C) 2011-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2011. 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 . */ #include /* Specification. */ #include void _Qp_itoq (long double *result, int a) { /* Convert from 'int' to 'double', then from 'double' to 'long double'. */ *result = (double) a; } lftp-4.6.3a/lib/modechange.h0000644000015000007670000000212612466374011012571 00000000000000/* modechange.h -- definitions for file mode manipulation Copyright (C) 1989-1990, 1997, 2003-2006, 2009-2015 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 . */ #if ! defined MODECHANGE_H_ # define MODECHANGE_H_ # include # include struct mode_change *mode_compile (const char *); struct mode_change *mode_create_from_ref (const char *); mode_t mode_adjust (mode_t, bool, mode_t, struct mode_change const *, mode_t *); #endif lftp-4.6.3a/lib/md5.c0000644000015000007670000003577212466374011011174 00000000000000/* Functions to compute MD5 message digest of files or memory blocks. according to the definition of MD5 in RFC 1321 from April 1992. Copyright (C) 1995-1997, 1999-2001, 2005-2006, 2008-2015 Free Software Foundation, Inc. This file is part of 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, 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 . */ /* Written by Ulrich Drepper , 1995. */ #include #if HAVE_OPENSSL_MD5 # define GL_OPENSSL_INLINE _GL_EXTERN_INLINE #endif #include "md5.h" #include #include #include #include #include #if USE_UNLOCKED_IO # include "unlocked-io.h" #endif #ifdef _LIBC # include # if __BYTE_ORDER == __BIG_ENDIAN # define WORDS_BIGENDIAN 1 # endif /* We need to keep the namespace clean so define the MD5 function protected using leading __ . */ # define md5_init_ctx __md5_init_ctx # define md5_process_block __md5_process_block # define md5_process_bytes __md5_process_bytes # define md5_finish_ctx __md5_finish_ctx # define md5_read_ctx __md5_read_ctx # define md5_stream __md5_stream # define md5_buffer __md5_buffer #endif #ifdef WORDS_BIGENDIAN # define SWAP(n) \ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #else # define SWAP(n) (n) #endif #define BLOCKSIZE 32768 #if BLOCKSIZE % 64 != 0 # error "invalid BLOCKSIZE" #endif #if ! HAVE_OPENSSL_MD5 /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ void md5_init_ctx (struct md5_ctx *ctx) { ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; ctx->D = 0x10325476; ctx->total[0] = ctx->total[1] = 0; ctx->buflen = 0; } /* Copy the 4 byte value from v into the memory location pointed to by *cp, If your architecture allows unaligned access this is equivalent to * (uint32_t *) cp = v */ static void set_uint32 (char *cp, uint32_t v) { memcpy (cp, &v, sizeof v); } /* Put result from CTX in first 16 bytes following RESBUF. The result must be in little endian byte order. */ void * md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) { char *r = resbuf; set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A)); set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B)); set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C)); set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D)); return resbuf; } /* Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF. */ void * md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ uint32_t bytes = ctx->buflen; size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4; /* Now count remaining bytes. */ ctx->total[0] += bytes; if (ctx->total[0] < bytes) ++ctx->total[1]; /* Put the 64-bit file length in *bits* at the end of the buffer. */ ctx->buffer[size - 2] = SWAP (ctx->total[0] << 3); ctx->buffer[size - 1] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); /* Process last bytes. */ md5_process_block (ctx->buffer, size * 4, ctx); return md5_read_ctx (ctx, resbuf); } #endif /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ int md5_stream (FILE *stream, void *resblock) { struct md5_ctx ctx; size_t sum; char *buffer = malloc (BLOCKSIZE + 72); if (!buffer) return 1; /* Initialize the computation context. */ md5_init_ctx (&ctx); /* Iterate over full file contents. */ while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the computation function processes the whole buffer so that with the next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ while (1) { n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; if (sum == BLOCKSIZE) break; if (n == 0) { /* Check for the error flag IFF N == 0, so that we don't exit the loop after a partial read due to e.g., EAGAIN or EWOULDBLOCK. */ if (ferror (stream)) { free (buffer); return 1; } goto process_partial_block; } /* We've read at least one byte, so ignore errors. But always check for EOF, since feof may be true even though N > 0. Otherwise, we could end up calling fread after EOF. */ if (feof (stream)) goto process_partial_block; } /* Process buffer with BLOCKSIZE bytes. Note that BLOCKSIZE % 64 == 0 */ md5_process_block (buffer, BLOCKSIZE, &ctx); } process_partial_block: /* Process any remaining bytes. */ if (sum > 0) md5_process_bytes (buffer, sum, &ctx); /* Construct result in desired memory. */ md5_finish_ctx (&ctx, resblock); free (buffer); return 0; } #if ! HAVE_OPENSSL_MD5 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ void * md5_buffer (const char *buffer, size_t len, void *resblock) { struct md5_ctx ctx; /* Initialize the computation context. */ md5_init_ctx (&ctx); /* Process whole buffer but last len % 64 bytes. */ md5_process_bytes (buffer, len, &ctx); /* Put result in desired memory area. */ return md5_finish_ctx (&ctx, resblock); } void md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) { /* When we already have some bits in our internal buffer concatenate both inputs first. */ if (ctx->buflen != 0) { size_t left_over = ctx->buflen; size_t add = 128 - left_over > len ? len : 128 - left_over; memcpy (&((char *) ctx->buffer)[left_over], buffer, add); ctx->buflen += add; if (ctx->buflen > 64) { md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); ctx->buflen &= 63; /* The regions in the following copy operation cannot overlap. */ memcpy (ctx->buffer, &((char *) ctx->buffer)[(left_over + add) & ~63], ctx->buflen); } buffer = (const char *) buffer + add; len -= add; } /* Process available complete blocks. */ if (len >= 64) { #if !_STRING_ARCH_unaligned # define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); buffer = (const char *) buffer + 64; len -= 64; } else #endif { md5_process_block (buffer, len & ~63, ctx); buffer = (const char *) buffer + (len & ~63); len &= 63; } } /* Move remaining bytes in internal buffer. */ if (len > 0) { size_t left_over = ctx->buflen; memcpy (&((char *) ctx->buffer)[left_over], buffer, len); left_over += len; if (left_over >= 64) { md5_process_block (ctx->buffer, 64, ctx); left_over -= 64; memcpy (ctx->buffer, &ctx->buffer[16], left_over); } ctx->buflen = left_over; } } /* These are the four functions used in the four steps of the MD5 algorithm and defined in the RFC 1321. The first function is a little bit optimized (as found in Colin Plumbs public domain implementation). */ /* #define FF(b, c, d) ((b & c) | (~b & d)) */ #define FF(b, c, d) (d ^ (b & (c ^ d))) #define FG(b, c, d) FF (d, b, c) #define FH(b, c, d) (b ^ c ^ d) #define FI(b, c, d) (c ^ (b | ~d)) /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. */ void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) { uint32_t correct_words[16]; const uint32_t *words = buffer; size_t nwords = len / sizeof (uint32_t); const uint32_t *endp = words + nwords; uint32_t A = ctx->A; uint32_t B = ctx->B; uint32_t C = ctx->C; uint32_t D = ctx->D; uint32_t lolen = len; /* First increment the byte count. RFC 1321 specifies the possible length of the file up to 2^64 bits. Here we only compute the number of bytes. Do a double word increment. */ ctx->total[0] += lolen; ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen); /* Process all bytes in the buffer with 64 bytes in each round of the loop. */ while (words < endp) { uint32_t *cwp = correct_words; uint32_t A_save = A; uint32_t B_save = B; uint32_t C_save = C; uint32_t D_save = D; /* First round: using the given function, the context and a constant the next context is computed. Because the algorithms processing unit is a 32-bit word and it is determined to work on words in little endian byte order we perhaps have to change the byte order before the computation. To reduce the work for the next steps we store the swapped words in the array CORRECT_WORDS. */ #define OP(a, b, c, d, s, T) \ do \ { \ a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ ++words; \ CYCLIC (a, s); \ a += b; \ } \ while (0) /* It is unfortunate that C does not provide an operator for cyclic rotation. Hope the C compiler is smart enough. */ #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) /* Before we start, one word to the strange constants. They are defined in RFC 1321 as T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 Here is an equivalent invocation using Perl: perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin $_))}' */ /* Round 1. */ OP (A, B, C, D, 7, 0xd76aa478); OP (D, A, B, C, 12, 0xe8c7b756); OP (C, D, A, B, 17, 0x242070db); OP (B, C, D, A, 22, 0xc1bdceee); OP (A, B, C, D, 7, 0xf57c0faf); OP (D, A, B, C, 12, 0x4787c62a); OP (C, D, A, B, 17, 0xa8304613); OP (B, C, D, A, 22, 0xfd469501); OP (A, B, C, D, 7, 0x698098d8); OP (D, A, B, C, 12, 0x8b44f7af); OP (C, D, A, B, 17, 0xffff5bb1); OP (B, C, D, A, 22, 0x895cd7be); OP (A, B, C, D, 7, 0x6b901122); OP (D, A, B, C, 12, 0xfd987193); OP (C, D, A, B, 17, 0xa679438e); OP (B, C, D, A, 22, 0x49b40821); /* For the second to fourth round we have the possibly swapped words in CORRECT_WORDS. Redefine the macro to take an additional first argument specifying the function to use. */ #undef OP #define OP(f, a, b, c, d, k, s, T) \ do \ { \ a += f (b, c, d) + correct_words[k] + T; \ CYCLIC (a, s); \ a += b; \ } \ while (0) /* Round 2. */ OP (FG, A, B, C, D, 1, 5, 0xf61e2562); OP (FG, D, A, B, C, 6, 9, 0xc040b340); OP (FG, C, D, A, B, 11, 14, 0x265e5a51); OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); OP (FG, A, B, C, D, 5, 5, 0xd62f105d); OP (FG, D, A, B, C, 10, 9, 0x02441453); OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); OP (FG, D, A, B, C, 14, 9, 0xc33707d6); OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); OP (FG, B, C, D, A, 8, 20, 0x455a14ed); OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); OP (FG, C, D, A, B, 7, 14, 0x676f02d9); OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); /* Round 3. */ OP (FH, A, B, C, D, 5, 4, 0xfffa3942); OP (FH, D, A, B, C, 8, 11, 0x8771f681); OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); OP (FH, B, C, D, A, 14, 23, 0xfde5380c); OP (FH, A, B, C, D, 1, 4, 0xa4beea44); OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); OP (FH, B, C, D, A, 6, 23, 0x04881d05); OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); /* Round 4. */ OP (FI, A, B, C, D, 0, 6, 0xf4292244); OP (FI, D, A, B, C, 7, 10, 0x432aff97); OP (FI, C, D, A, B, 14, 15, 0xab9423a7); OP (FI, B, C, D, A, 5, 21, 0xfc93a039); OP (FI, A, B, C, D, 12, 6, 0x655b59c3); OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); OP (FI, C, D, A, B, 10, 15, 0xffeff47d); OP (FI, B, C, D, A, 1, 21, 0x85845dd1); OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); OP (FI, C, D, A, B, 6, 15, 0xa3014314); OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); OP (FI, A, B, C, D, 4, 6, 0xf7537e82); OP (FI, D, A, B, C, 11, 10, 0xbd3af235); OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); OP (FI, B, C, D, A, 9, 21, 0xeb86d391); /* Add the starting values of the context. */ A += A_save; B += B_save; C += C_save; D += D_save; } /* Put checksum in context given as argument. */ ctx->A = A; ctx->B = B; ctx->C = C; ctx->D = D; } #endif lftp-4.6.3a/lib/unistr/0000755000015000007670000000000012540300655011725 500000000000000lftp-4.6.3a/lib/unistr/u8-mbtoucr.c0000644000015000007670000002434412466374012014032 00000000000000/* Look at first character in UTF-8 string, returning an error code. Copyright (C) 1999-2002, 2006-2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2001. 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 . */ #include /* Specification. */ #include "unistr.h" int u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n) { uint8_t c = *s; if (c < 0x80) { *puc = c; return 1; } else if (c >= 0xc2) { if (c < 0xe0) { if (n >= 2) { if ((s[1] ^ 0x80) < 0x40) { *puc = ((unsigned int) (c & 0x1f) << 6) | (unsigned int) (s[1] ^ 0x80); return 2; } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } else if (c < 0xf0) { if (n >= 2) { if ((s[1] ^ 0x80) < 0x40 && (c >= 0xe1 || s[1] >= 0xa0) && (c != 0xed || s[1] < 0xa0)) { if (n >= 3) { if ((s[2] ^ 0x80) < 0x40) { *puc = ((unsigned int) (c & 0x0f) << 12) | ((unsigned int) (s[1] ^ 0x80) << 6) | (unsigned int) (s[2] ^ 0x80); return 3; } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } else if (c < 0xf8) { if (n >= 2) { if ((s[1] ^ 0x80) < 0x40 && (c >= 0xf1 || s[1] >= 0x90) #if 1 && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90)) #endif ) { if (n >= 3) { if ((s[2] ^ 0x80) < 0x40) { if (n >= 4) { if ((s[3] ^ 0x80) < 0x40) { *puc = ((unsigned int) (c & 0x07) << 18) | ((unsigned int) (s[1] ^ 0x80) << 12) | ((unsigned int) (s[2] ^ 0x80) << 6) | (unsigned int) (s[3] ^ 0x80); return 4; } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } #if 0 else if (c < 0xfc) { if (n >= 2) { if ((s[1] ^ 0x80) < 0x40 && (c >= 0xf9 || s[1] >= 0x88)) { if (n >= 3) { if ((s[2] ^ 0x80) < 0x40) { if (n >= 4) { if ((s[3] ^ 0x80) < 0x40) { if (n >= 5) { if ((s[4] ^ 0x80) < 0x40) { *puc = ((unsigned int) (c & 0x03) << 24) | ((unsigned int) (s[1] ^ 0x80) << 18) | ((unsigned int) (s[2] ^ 0x80) << 12) | ((unsigned int) (s[3] ^ 0x80) << 6) | (unsigned int) (s[4] ^ 0x80); return 5; } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } else if (c < 0xfe) { if (n >= 2) { if ((s[1] ^ 0x80) < 0x40 && (c >= 0xfd || s[1] >= 0x84)) { if (n >= 3) { if ((s[2] ^ 0x80) < 0x40) { if (n >= 4) { if ((s[3] ^ 0x80) < 0x40) { if (n >= 5) { if ((s[4] ^ 0x80) < 0x40) { if (n >= 6) { if ((s[5] ^ 0x80) < 0x40) { *puc = ((unsigned int) (c & 0x01) << 30) | ((unsigned int) (s[1] ^ 0x80) << 24) | ((unsigned int) (s[2] ^ 0x80) << 18) | ((unsigned int) (s[3] ^ 0x80) << 12) | ((unsigned int) (s[4] ^ 0x80) << 6) | (unsigned int) (s[5] ^ 0x80); return 6; } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } /* invalid multibyte character */ } else { /* incomplete multibyte character */ *puc = 0xfffd; return -2; } } #endif } /* invalid multibyte character */ *puc = 0xfffd; return -1; } lftp-4.6.3a/lib/unistr/u8-uctomb-aux.c0000644000015000007670000000354612466374012014444 00000000000000/* Conversion UCS-4 to UTF-8. Copyright (C) 2002, 2006-2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2002. 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 . */ #include /* Specification. */ #include "unistr.h" int u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n) { int count; if (uc < 0x80) /* The case n >= 1 is already handled by the caller. */ return -2; else if (uc < 0x800) count = 2; else if (uc < 0x10000) { if (uc < 0xd800 || uc >= 0xe000) count = 3; else return -1; } #if 0 else if (uc < 0x200000) count = 4; else if (uc < 0x4000000) count = 5; else if (uc <= 0x7fffffff) count = 6; #else else if (uc < 0x110000) count = 4; #endif else return -1; if (n < count) return -2; switch (count) /* note: code falls through cases! */ { #if 0 case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000; case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000; #endif case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000; case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800; case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0; /*case 1:*/ s[0] = uc; } return count; } lftp-4.6.3a/lib/unistr/u8-uctomb.c0000644000015000007670000000441412466374012013644 00000000000000/* Store a character in UTF-8 string. Copyright (C) 2002, 2005-2006, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2002. 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 . */ #include #if defined IN_LIBUNISTRING /* Tell unistr.h to declare u8_uctomb as 'extern', not 'static inline'. */ # include "unistring-notinline.h" #endif /* Specification. */ #include "unistr.h" #if !HAVE_INLINE int u8_uctomb (uint8_t *s, ucs4_t uc, int n) { if (uc < 0x80) { if (n > 0) { s[0] = uc; return 1; } /* else return -2, below. */ } else { int count; if (uc < 0x800) count = 2; else if (uc < 0x10000) { if (uc < 0xd800 || uc >= 0xe000) count = 3; else return -1; } #if 0 else if (uc < 0x200000) count = 4; else if (uc < 0x4000000) count = 5; else if (uc <= 0x7fffffff) count = 6; #else else if (uc < 0x110000) count = 4; #endif else return -1; if (n >= count) { switch (count) /* note: code falls through cases! */ { #if 0 case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000; case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000; #endif case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000; case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800; case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0; /*case 1:*/ s[0] = uc; } return count; } } return -2; } #endif lftp-4.6.3a/lib/math.in.h0000644000015000007670000017776612466374011012064 00000000000000/* A GNU-like . Copyright (C) 2002-2003, 2007-2015 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 . */ #ifndef _@GUARD_PREFIX@_MATH_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ #ifndef _@GUARD_PREFIX@_MATH_H #define _@GUARD_PREFIX@_MATH_H #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_MATH_INLINE # define _GL_MATH_INLINE _GL_INLINE #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 /* Helper macros to define type-generic function FUNC as overloaded functions, rather than as macros like in C. POSIX declares these with an argument of real-floating (that is, one of float, double, or long double). */ # define _GL_MATH_CXX_REAL_FLOATING_DECL_1(func) \ static inline int \ _gl_cxx_ ## func ## f (float f) \ { \ return func (f); \ } \ static inline int \ _gl_cxx_ ## func ## d (double d) \ { \ return func (d); \ } \ static inline int \ _gl_cxx_ ## func ## l (long double l) \ { \ return func (l); \ } # define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \ inline int \ func (float f) \ { \ return _gl_cxx_ ## func ## f (f); \ } \ inline int \ func (double d) \ { \ return _gl_cxx_ ## func ## d (d); \ } \ inline int \ func (long double l) \ { \ return _gl_cxx_ ## func ## l (l); \ } #endif /* Helper macros to define a portability warning for the classification macro FUNC called with VALUE. POSIX declares the classification macros with an argument of real-floating (that is, one of float, double, or long double). */ #define _GL_WARN_REAL_FLOATING_DECL(func) \ _GL_MATH_INLINE int \ rpl_ ## func ## f (float f) \ { \ return func (f); \ } \ _GL_MATH_INLINE int \ rpl_ ## func ## d (double d) \ { \ return func (d); \ } \ _GL_MATH_INLINE int \ rpl_ ## func ## l (long double l) \ { \ return func (l); \ } \ _GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \ "use gnulib module " #func " for portability"); \ _GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \ "use gnulib module " #func " for portability"); \ _GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \ "use gnulib module " #func " for portability") #define _GL_WARN_REAL_FLOATING_IMPL(func, value) \ (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \ : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \ : rpl_ ## func ## l (value)) #if @REPLACE_ITOLD@ /* Pull in a function that fixes the 'int' to 'long double' conversion of glibc 2.7. */ _GL_EXTERN_C void _Qp_itoq (long double *, int); static void (*_gl_math_fix_itold) (long double *, int) = _Qp_itoq; #endif /* POSIX allows platforms that don't support NAN. But all major machines in the past 15 years have supported something close to IEEE NaN, so we define this unconditionally. We also must define it on platforms like Solaris 10, where NAN is present but defined as a function pointer rather than a floating point constant. */ #if !defined NAN || @REPLACE_NAN@ # if !GNULIB_defined_NAN # undef NAN /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke on the expression 0.0 / 0.0. */ # if defined __DECC || defined _MSC_VER _GL_MATH_INLINE float _NaN () { static float zero = 0.0f; return zero / zero; } # define NAN (_NaN()) # else # define NAN (0.0f / 0.0f) # endif # define GNULIB_defined_NAN 1 # endif #endif /* Solaris 10 defines HUGE_VAL, but as a function pointer rather than a floating point constant. */ #if @REPLACE_HUGE_VAL@ # undef HUGE_VALF # define HUGE_VALF (1.0f / 0.0f) # undef HUGE_VAL # define HUGE_VAL (1.0 / 0.0) # undef HUGE_VALL # define HUGE_VALL (1.0L / 0.0L) #endif /* HUGE_VALF is a 'float' Infinity. */ #ifndef HUGE_VALF # if defined _MSC_VER /* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */ # define HUGE_VALF (1e25f * 1e25f) # else # define HUGE_VALF (1.0f / 0.0f) # endif #endif /* HUGE_VAL is a 'double' Infinity. */ #ifndef HUGE_VAL # if defined _MSC_VER /* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */ # define HUGE_VAL (1e250 * 1e250) # else # define HUGE_VAL (1.0 / 0.0) # endif #endif /* HUGE_VALL is a 'long double' Infinity. */ #ifndef HUGE_VALL # if defined _MSC_VER /* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */ # define HUGE_VALL (1e250L * 1e250L) # else # define HUGE_VALL (1.0L / 0.0L) # endif #endif /* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */ #if !(defined FP_ILOGB0 && defined FP_ILOGBNAN) # if defined __NetBSD__ || defined __sgi /* NetBSD, IRIX 6.5: match what ilogb() does */ # define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ # define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */ # elif defined _AIX /* AIX 5.1: match what ilogb() does in AIX >= 5.2 */ # define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ # define FP_ILOGBNAN 2147483647 /* INT_MAX */ # elif defined __sun /* Solaris 9: match what ilogb() does */ # define FP_ILOGB0 (- 2147483647) /* - INT_MAX */ # define FP_ILOGBNAN 2147483647 /* INT_MAX */ # else /* Gnulib defined values. */ # define FP_ILOGB0 (- 2147483647) /* - INT_MAX */ # define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */ # endif #endif #if @GNULIB_ACOSF@ # if !@HAVE_ACOSF@ # undef acosf _GL_FUNCDECL_SYS (acosf, float, (float x)); # endif _GL_CXXALIAS_SYS (acosf, float, (float x)); _GL_CXXALIASWARN (acosf); #elif defined GNULIB_POSIXCHECK # undef acosf # if HAVE_RAW_DECL_ACOSF _GL_WARN_ON_USE (acosf, "acosf is unportable - " "use gnulib module acosf for portability"); # endif #endif #if @GNULIB_ACOSL@ # if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@ # undef acosl _GL_FUNCDECL_SYS (acosl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (acosl, long double, (long double x)); _GL_CXXALIASWARN (acosl); #elif defined GNULIB_POSIXCHECK # undef acosl # if HAVE_RAW_DECL_ACOSL _GL_WARN_ON_USE (acosl, "acosl is unportable - " "use gnulib module acosl for portability"); # endif #endif #if @GNULIB_ASINF@ # if !@HAVE_ASINF@ # undef asinf _GL_FUNCDECL_SYS (asinf, float, (float x)); # endif _GL_CXXALIAS_SYS (asinf, float, (float x)); _GL_CXXALIASWARN (asinf); #elif defined GNULIB_POSIXCHECK # undef asinf # if HAVE_RAW_DECL_ASINF _GL_WARN_ON_USE (asinf, "asinf is unportable - " "use gnulib module asinf for portability"); # endif #endif #if @GNULIB_ASINL@ # if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@ # undef asinl _GL_FUNCDECL_SYS (asinl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (asinl, long double, (long double x)); _GL_CXXALIASWARN (asinl); #elif defined GNULIB_POSIXCHECK # undef asinl # if HAVE_RAW_DECL_ASINL _GL_WARN_ON_USE (asinl, "asinl is unportable - " "use gnulib module asinl for portability"); # endif #endif #if @GNULIB_ATANF@ # if !@HAVE_ATANF@ # undef atanf _GL_FUNCDECL_SYS (atanf, float, (float x)); # endif _GL_CXXALIAS_SYS (atanf, float, (float x)); _GL_CXXALIASWARN (atanf); #elif defined GNULIB_POSIXCHECK # undef atanf # if HAVE_RAW_DECL_ATANF _GL_WARN_ON_USE (atanf, "atanf is unportable - " "use gnulib module atanf for portability"); # endif #endif #if @GNULIB_ATANL@ # if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@ # undef atanl _GL_FUNCDECL_SYS (atanl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (atanl, long double, (long double x)); _GL_CXXALIASWARN (atanl); #elif defined GNULIB_POSIXCHECK # undef atanl # if HAVE_RAW_DECL_ATANL _GL_WARN_ON_USE (atanl, "atanl is unportable - " "use gnulib module atanl for portability"); # endif #endif #if @GNULIB_ATAN2F@ # if !@HAVE_ATAN2F@ # undef atan2f _GL_FUNCDECL_SYS (atan2f, float, (float y, float x)); # endif _GL_CXXALIAS_SYS (atan2f, float, (float y, float x)); _GL_CXXALIASWARN (atan2f); #elif defined GNULIB_POSIXCHECK # undef atan2f # if HAVE_RAW_DECL_ATAN2F _GL_WARN_ON_USE (atan2f, "atan2f is unportable - " "use gnulib module atan2f for portability"); # endif #endif #if @GNULIB_CBRTF@ # if @REPLACE_CBRTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef cbrtf # define cbrtf rpl_cbrtf # endif _GL_FUNCDECL_RPL (cbrtf, float, (float x)); _GL_CXXALIAS_RPL (cbrtf, float, (float x)); # else # if !@HAVE_DECL_CBRTF@ _GL_FUNCDECL_SYS (cbrtf, float, (float x)); # endif _GL_CXXALIAS_SYS (cbrtf, float, (float x)); # endif _GL_CXXALIASWARN (cbrtf); #elif defined GNULIB_POSIXCHECK # undef cbrtf # if HAVE_RAW_DECL_CBRTF _GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - " "use gnulib module cbrtf for portability"); # endif #endif #if @GNULIB_CBRT@ # if !@HAVE_CBRT@ _GL_FUNCDECL_SYS (cbrt, double, (double x)); # endif _GL_CXXALIAS_SYS (cbrt, double, (double x)); _GL_CXXALIASWARN (cbrt); #elif defined GNULIB_POSIXCHECK # undef cbrt # if HAVE_RAW_DECL_CBRT _GL_WARN_ON_USE (cbrt, "cbrt is unportable - " "use gnulib module cbrt for portability"); # endif #endif #if @GNULIB_CBRTL@ # if @REPLACE_CBRTL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef cbrtl # define cbrtl rpl_cbrtl # endif _GL_FUNCDECL_RPL (cbrtl, long double, (long double x)); _GL_CXXALIAS_RPL (cbrtl, long double, (long double x)); # else # if !@HAVE_DECL_CBRTL@ _GL_FUNCDECL_SYS (cbrtl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (cbrtl, long double, (long double x)); # endif _GL_CXXALIASWARN (cbrtl); #elif defined GNULIB_POSIXCHECK # undef cbrtl # if HAVE_RAW_DECL_CBRTL _GL_WARN_ON_USE (cbrtl, "cbrtl is unportable - " "use gnulib module cbrtl for portability"); # endif #endif #if @GNULIB_CEILF@ # if @REPLACE_CEILF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ceilf # define ceilf rpl_ceilf # endif _GL_FUNCDECL_RPL (ceilf, float, (float x)); _GL_CXXALIAS_RPL (ceilf, float, (float x)); # else # if !@HAVE_DECL_CEILF@ # undef ceilf _GL_FUNCDECL_SYS (ceilf, float, (float x)); # endif _GL_CXXALIAS_SYS (ceilf, float, (float x)); # endif _GL_CXXALIASWARN (ceilf); #elif defined GNULIB_POSIXCHECK # undef ceilf # if HAVE_RAW_DECL_CEILF _GL_WARN_ON_USE (ceilf, "ceilf is unportable - " "use gnulib module ceilf for portability"); # endif #endif #if @GNULIB_CEIL@ # if @REPLACE_CEIL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define ceil rpl_ceil # endif _GL_FUNCDECL_RPL (ceil, double, (double x)); _GL_CXXALIAS_RPL (ceil, double, (double x)); # else _GL_CXXALIAS_SYS (ceil, double, (double x)); # endif _GL_CXXALIASWARN (ceil); #endif #if @GNULIB_CEILL@ # if @REPLACE_CEILL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ceill # define ceill rpl_ceill # endif _GL_FUNCDECL_RPL (ceill, long double, (long double x)); _GL_CXXALIAS_RPL (ceill, long double, (long double x)); # else # if !@HAVE_DECL_CEILL@ # undef ceill _GL_FUNCDECL_SYS (ceill, long double, (long double x)); # endif _GL_CXXALIAS_SYS (ceill, long double, (long double x)); # endif _GL_CXXALIASWARN (ceill); #elif defined GNULIB_POSIXCHECK # undef ceill # if HAVE_RAW_DECL_CEILL _GL_WARN_ON_USE (ceill, "ceill is unportable - " "use gnulib module ceill for portability"); # endif #endif #if @GNULIB_COPYSIGNF@ # if !@HAVE_DECL_COPYSIGNF@ _GL_FUNCDECL_SYS (copysignf, float, (float x, float y)); # endif _GL_CXXALIAS_SYS (copysignf, float, (float x, float y)); _GL_CXXALIASWARN (copysignf); #elif defined GNULIB_POSIXCHECK # undef copysignf # if HAVE_RAW_DECL_COPYSIGNF _GL_WARN_ON_USE (copysignf, "copysignf is unportable - " "use gnulib module copysignf for portability"); # endif #endif #if @GNULIB_COPYSIGN@ # if !@HAVE_COPYSIGN@ _GL_FUNCDECL_SYS (copysign, double, (double x, double y)); # endif _GL_CXXALIAS_SYS (copysign, double, (double x, double y)); _GL_CXXALIASWARN (copysign); #elif defined GNULIB_POSIXCHECK # undef copysign # if HAVE_RAW_DECL_COPYSIGN _GL_WARN_ON_USE (copysign, "copysign is unportable - " "use gnulib module copysign for portability"); # endif #endif #if @GNULIB_COPYSIGNL@ # if !@HAVE_COPYSIGNL@ _GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y)); # endif _GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y)); _GL_CXXALIASWARN (copysignl); #elif defined GNULIB_POSIXCHECK # undef copysignl # if HAVE_RAW_DECL_COPYSIGNL _GL_WARN_ON_USE (copysign, "copysignl is unportable - " "use gnulib module copysignl for portability"); # endif #endif #if @GNULIB_COSF@ # if !@HAVE_COSF@ # undef cosf _GL_FUNCDECL_SYS (cosf, float, (float x)); # endif _GL_CXXALIAS_SYS (cosf, float, (float x)); _GL_CXXALIASWARN (cosf); #elif defined GNULIB_POSIXCHECK # undef cosf # if HAVE_RAW_DECL_COSF _GL_WARN_ON_USE (cosf, "cosf is unportable - " "use gnulib module cosf for portability"); # endif #endif #if @GNULIB_COSL@ # if !@HAVE_COSL@ || !@HAVE_DECL_COSL@ # undef cosl _GL_FUNCDECL_SYS (cosl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (cosl, long double, (long double x)); _GL_CXXALIASWARN (cosl); #elif defined GNULIB_POSIXCHECK # undef cosl # if HAVE_RAW_DECL_COSL _GL_WARN_ON_USE (cosl, "cosl is unportable - " "use gnulib module cosl for portability"); # endif #endif #if @GNULIB_COSHF@ # if !@HAVE_COSHF@ # undef coshf _GL_FUNCDECL_SYS (coshf, float, (float x)); # endif _GL_CXXALIAS_SYS (coshf, float, (float x)); _GL_CXXALIASWARN (coshf); #elif defined GNULIB_POSIXCHECK # undef coshf # if HAVE_RAW_DECL_COSHF _GL_WARN_ON_USE (coshf, "coshf is unportable - " "use gnulib module coshf for portability"); # endif #endif #if @GNULIB_EXPF@ # if !@HAVE_EXPF@ # undef expf _GL_FUNCDECL_SYS (expf, float, (float x)); # endif _GL_CXXALIAS_SYS (expf, float, (float x)); _GL_CXXALIASWARN (expf); #elif defined GNULIB_POSIXCHECK # undef expf # if HAVE_RAW_DECL_EXPF _GL_WARN_ON_USE (expf, "expf is unportable - " "use gnulib module expf for portability"); # endif #endif #if @GNULIB_EXPL@ # if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@ # undef expl _GL_FUNCDECL_SYS (expl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (expl, long double, (long double x)); _GL_CXXALIASWARN (expl); #elif defined GNULIB_POSIXCHECK # undef expl # if HAVE_RAW_DECL_EXPL _GL_WARN_ON_USE (expl, "expl is unportable - " "use gnulib module expl for portability"); # endif #endif #if @GNULIB_EXP2F@ # if !@HAVE_DECL_EXP2F@ _GL_FUNCDECL_SYS (exp2f, float, (float x)); # endif _GL_CXXALIAS_SYS (exp2f, float, (float x)); _GL_CXXALIASWARN (exp2f); #elif defined GNULIB_POSIXCHECK # undef exp2f # if HAVE_RAW_DECL_EXP2F _GL_WARN_ON_USE (exp2f, "exp2f is unportable - " "use gnulib module exp2f for portability"); # endif #endif #if @GNULIB_EXP2@ # if @REPLACE_EXP2@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef exp2 # define exp2 rpl_exp2 # endif _GL_FUNCDECL_RPL (exp2, double, (double x)); _GL_CXXALIAS_RPL (exp2, double, (double x)); # else # if !@HAVE_DECL_EXP2@ _GL_FUNCDECL_SYS (exp2, double, (double x)); # endif _GL_CXXALIAS_SYS (exp2, double, (double x)); # endif _GL_CXXALIASWARN (exp2); #elif defined GNULIB_POSIXCHECK # undef exp2 # if HAVE_RAW_DECL_EXP2 _GL_WARN_ON_USE (exp2, "exp2 is unportable - " "use gnulib module exp2 for portability"); # endif #endif #if @GNULIB_EXP2L@ # if @REPLACE_EXP2L@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef exp2l # define exp2l rpl_exp2l # endif _GL_FUNCDECL_RPL (exp2l, long double, (long double x)); _GL_CXXALIAS_RPL (exp2l, long double, (long double x)); # else # if !@HAVE_DECL_EXP2L@ # undef exp2l _GL_FUNCDECL_SYS (exp2l, long double, (long double x)); # endif _GL_CXXALIAS_SYS (exp2l, long double, (long double x)); # endif _GL_CXXALIASWARN (exp2l); #elif defined GNULIB_POSIXCHECK # undef exp2l # if HAVE_RAW_DECL_EXP2L _GL_WARN_ON_USE (exp2l, "exp2l is unportable - " "use gnulib module exp2l for portability"); # endif #endif #if @GNULIB_EXPM1F@ # if @REPLACE_EXPM1F@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef expm1f # define expm1f rpl_expm1f # endif _GL_FUNCDECL_RPL (expm1f, float, (float x)); _GL_CXXALIAS_RPL (expm1f, float, (float x)); # else # if !@HAVE_EXPM1F@ _GL_FUNCDECL_SYS (expm1f, float, (float x)); # endif _GL_CXXALIAS_SYS (expm1f, float, (float x)); # endif _GL_CXXALIASWARN (expm1f); #elif defined GNULIB_POSIXCHECK # undef expm1f # if HAVE_RAW_DECL_EXPM1F _GL_WARN_ON_USE (expm1f, "expm1f is unportable - " "use gnulib module expm1f for portability"); # endif #endif #if @GNULIB_EXPM1@ # if @REPLACE_EXPM1@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef expm1 # define expm1 rpl_expm1 # endif _GL_FUNCDECL_RPL (expm1, double, (double x)); _GL_CXXALIAS_RPL (expm1, double, (double x)); # else # if !@HAVE_EXPM1@ _GL_FUNCDECL_SYS (expm1, double, (double x)); # endif _GL_CXXALIAS_SYS (expm1, double, (double x)); # endif _GL_CXXALIASWARN (expm1); #elif defined GNULIB_POSIXCHECK # undef expm1 # if HAVE_RAW_DECL_EXPM1 _GL_WARN_ON_USE (expm1, "expm1 is unportable - " "use gnulib module expm1 for portability"); # endif #endif #if @GNULIB_EXPM1L@ # if !@HAVE_DECL_EXPM1L@ # undef expm1l _GL_FUNCDECL_SYS (expm1l, long double, (long double x)); # endif _GL_CXXALIAS_SYS (expm1l, long double, (long double x)); _GL_CXXALIASWARN (expm1l); #elif defined GNULIB_POSIXCHECK # undef expm1l # if HAVE_RAW_DECL_EXPM1L _GL_WARN_ON_USE (expm1l, "expm1l is unportable - " "use gnulib module expm1l for portability"); # endif #endif #if @GNULIB_FABSF@ # if !@HAVE_FABSF@ # undef fabsf _GL_FUNCDECL_SYS (fabsf, float, (float x)); # endif _GL_CXXALIAS_SYS (fabsf, float, (float x)); _GL_CXXALIASWARN (fabsf); #elif defined GNULIB_POSIXCHECK # undef fabsf # if HAVE_RAW_DECL_FABSF _GL_WARN_ON_USE (fabsf, "fabsf is unportable - " "use gnulib module fabsf for portability"); # endif #endif #if @GNULIB_FABSL@ # if @REPLACE_FABSL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fabsl # define fabsl rpl_fabsl # endif _GL_FUNCDECL_RPL (fabsl, long double, (long double x)); _GL_CXXALIAS_RPL (fabsl, long double, (long double x)); # else # if !@HAVE_FABSL@ # undef fabsl _GL_FUNCDECL_SYS (fabsl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (fabsl, long double, (long double x)); # endif _GL_CXXALIASWARN (fabsl); #elif defined GNULIB_POSIXCHECK # undef fabsl # if HAVE_RAW_DECL_FABSL _GL_WARN_ON_USE (fabsl, "fabsl is unportable - " "use gnulib module fabsl for portability"); # endif #endif #if @GNULIB_FLOORF@ # if @REPLACE_FLOORF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef floorf # define floorf rpl_floorf # endif _GL_FUNCDECL_RPL (floorf, float, (float x)); _GL_CXXALIAS_RPL (floorf, float, (float x)); # else # if !@HAVE_DECL_FLOORF@ # undef floorf _GL_FUNCDECL_SYS (floorf, float, (float x)); # endif _GL_CXXALIAS_SYS (floorf, float, (float x)); # endif _GL_CXXALIASWARN (floorf); #elif defined GNULIB_POSIXCHECK # undef floorf # if HAVE_RAW_DECL_FLOORF _GL_WARN_ON_USE (floorf, "floorf is unportable - " "use gnulib module floorf for portability"); # endif #endif #if @GNULIB_FLOOR@ # if @REPLACE_FLOOR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define floor rpl_floor # endif _GL_FUNCDECL_RPL (floor, double, (double x)); _GL_CXXALIAS_RPL (floor, double, (double x)); # else _GL_CXXALIAS_SYS (floor, double, (double x)); # endif _GL_CXXALIASWARN (floor); #endif #if @GNULIB_FLOORL@ # if @REPLACE_FLOORL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef floorl # define floorl rpl_floorl # endif _GL_FUNCDECL_RPL (floorl, long double, (long double x)); _GL_CXXALIAS_RPL (floorl, long double, (long double x)); # else # if !@HAVE_DECL_FLOORL@ # undef floorl _GL_FUNCDECL_SYS (floorl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (floorl, long double, (long double x)); # endif _GL_CXXALIASWARN (floorl); #elif defined GNULIB_POSIXCHECK # undef floorl # if HAVE_RAW_DECL_FLOORL _GL_WARN_ON_USE (floorl, "floorl is unportable - " "use gnulib module floorl for portability"); # endif #endif #if @GNULIB_FMAF@ # if @REPLACE_FMAF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fmaf # define fmaf rpl_fmaf # endif _GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z)); _GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z)); # else # if !@HAVE_FMAF@ _GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z)); # endif _GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z)); # endif _GL_CXXALIASWARN (fmaf); #elif defined GNULIB_POSIXCHECK # undef fmaf # if HAVE_RAW_DECL_FMAF _GL_WARN_ON_USE (fmaf, "fmaf is unportable - " "use gnulib module fmaf for portability"); # endif #endif #if @GNULIB_FMA@ # if @REPLACE_FMA@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fma # define fma rpl_fma # endif _GL_FUNCDECL_RPL (fma, double, (double x, double y, double z)); _GL_CXXALIAS_RPL (fma, double, (double x, double y, double z)); # else # if !@HAVE_FMA@ _GL_FUNCDECL_SYS (fma, double, (double x, double y, double z)); # endif _GL_CXXALIAS_SYS (fma, double, (double x, double y, double z)); # endif _GL_CXXALIASWARN (fma); #elif defined GNULIB_POSIXCHECK # undef fma # if HAVE_RAW_DECL_FMA _GL_WARN_ON_USE (fma, "fma is unportable - " "use gnulib module fma for portability"); # endif #endif #if @GNULIB_FMAL@ # if @REPLACE_FMAL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fmal # define fmal rpl_fmal # endif _GL_FUNCDECL_RPL (fmal, long double, (long double x, long double y, long double z)); _GL_CXXALIAS_RPL (fmal, long double, (long double x, long double y, long double z)); # else # if !@HAVE_FMAL@ # undef fmal _GL_FUNCDECL_SYS (fmal, long double, (long double x, long double y, long double z)); # endif _GL_CXXALIAS_SYS (fmal, long double, (long double x, long double y, long double z)); # endif _GL_CXXALIASWARN (fmal); #elif defined GNULIB_POSIXCHECK # undef fmal # if HAVE_RAW_DECL_FMAL _GL_WARN_ON_USE (fmal, "fmal is unportable - " "use gnulib module fmal for portability"); # endif #endif #if @GNULIB_FMODF@ # if @REPLACE_FMODF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fmodf # define fmodf rpl_fmodf # endif _GL_FUNCDECL_RPL (fmodf, float, (float x, float y)); _GL_CXXALIAS_RPL (fmodf, float, (float x, float y)); # else # if !@HAVE_FMODF@ # undef fmodf _GL_FUNCDECL_SYS (fmodf, float, (float x, float y)); # endif _GL_CXXALIAS_SYS (fmodf, float, (float x, float y)); # endif _GL_CXXALIASWARN (fmodf); #elif defined GNULIB_POSIXCHECK # undef fmodf # if HAVE_RAW_DECL_FMODF _GL_WARN_ON_USE (fmodf, "fmodf is unportable - " "use gnulib module fmodf for portability"); # endif #endif #if @GNULIB_FMOD@ # if @REPLACE_FMOD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fmod # define fmod rpl_fmod # endif _GL_FUNCDECL_RPL (fmod, double, (double x, double y)); _GL_CXXALIAS_RPL (fmod, double, (double x, double y)); # else _GL_CXXALIAS_SYS (fmod, double, (double x, double y)); # endif _GL_CXXALIASWARN (fmod); #elif defined GNULIB_POSIXCHECK # undef fmod # if HAVE_RAW_DECL_FMOD _GL_WARN_ON_USE (fmod, "fmod has portability problems - " "use gnulib module fmod for portability"); # endif #endif #if @GNULIB_FMODL@ # if @REPLACE_FMODL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fmodl # define fmodl rpl_fmodl # endif _GL_FUNCDECL_RPL (fmodl, long double, (long double x, long double y)); _GL_CXXALIAS_RPL (fmodl, long double, (long double x, long double y)); # else # if !@HAVE_FMODL@ # undef fmodl _GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y)); # endif _GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y)); # endif _GL_CXXALIASWARN (fmodl); #elif defined GNULIB_POSIXCHECK # undef fmodl # if HAVE_RAW_DECL_FMODL _GL_WARN_ON_USE (fmodl, "fmodl is unportable - " "use gnulib module fmodl for portability"); # endif #endif /* Write x as x = mantissa * 2^exp where If x finite and nonzero: 0.5 <= |mantissa| < 1.0. If x is zero: mantissa = x, exp = 0. If x is infinite or NaN: mantissa = x, exp unspecified. Store exp in *EXPPTR and return mantissa. */ #if @GNULIB_FREXPF@ # if @REPLACE_FREXPF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef frexpf # define frexpf rpl_frexpf # endif _GL_FUNCDECL_RPL (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (frexpf, float, (float x, int *expptr)); # else # if !@HAVE_FREXPF@ # undef frexpf _GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr)); # endif _GL_CXXALIASWARN (frexpf); #elif defined GNULIB_POSIXCHECK # undef frexpf # if HAVE_RAW_DECL_FREXPF _GL_WARN_ON_USE (frexpf, "frexpf is unportable - " "use gnulib module frexpf for portability"); # endif #endif /* Write x as x = mantissa * 2^exp where If x finite and nonzero: 0.5 <= |mantissa| < 1.0. If x is zero: mantissa = x, exp = 0. If x is infinite or NaN: mantissa = x, exp unspecified. Store exp in *EXPPTR and return mantissa. */ #if @GNULIB_FREXP@ # if @REPLACE_FREXP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define frexp rpl_frexp # endif _GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr)); # else _GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr)); # endif _GL_CXXALIASWARN (frexp); #elif defined GNULIB_POSIXCHECK # undef frexp /* Assume frexp is always declared. */ _GL_WARN_ON_USE (frexp, "frexp is unportable - " "use gnulib module frexp for portability"); #endif /* Write x as x = mantissa * 2^exp where If x finite and nonzero: 0.5 <= |mantissa| < 1.0. If x is zero: mantissa = x, exp = 0. If x is infinite or NaN: mantissa = x, exp unspecified. Store exp in *EXPPTR and return mantissa. */ #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef frexpl # define frexpl rpl_frexpl # endif _GL_FUNCDECL_RPL (frexpl, long double, (long double x, int *expptr) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (frexpl, long double, (long double x, int *expptr)); #else # if !@HAVE_DECL_FREXPL@ _GL_FUNCDECL_SYS (frexpl, long double, (long double x, int *expptr) _GL_ARG_NONNULL ((2))); # endif # if @GNULIB_FREXPL@ _GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr)); # endif #endif #if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@) _GL_CXXALIASWARN (frexpl); #endif #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK # undef frexpl # if HAVE_RAW_DECL_FREXPL _GL_WARN_ON_USE (frexpl, "frexpl is unportable - " "use gnulib module frexpl for portability"); # endif #endif /* Return sqrt(x^2+y^2). */ #if @GNULIB_HYPOTF@ # if @REPLACE_HYPOTF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef hypotf # define hypotf rpl_hypotf # endif _GL_FUNCDECL_RPL (hypotf, float, (float x, float y)); _GL_CXXALIAS_RPL (hypotf, float, (float x, float y)); # else # if !@HAVE_HYPOTF@ _GL_FUNCDECL_SYS (hypotf, float, (float x, float y)); # endif _GL_CXXALIAS_SYS (hypotf, float, (float x, float y)); # endif _GL_CXXALIASWARN (hypotf); #elif defined GNULIB_POSIXCHECK # undef hypotf # if HAVE_RAW_DECL_HYPOTF _GL_WARN_ON_USE (hypotf, "hypotf is unportable - " "use gnulib module hypotf for portability"); # endif #endif /* Return sqrt(x^2+y^2). */ #if @GNULIB_HYPOT@ # if @REPLACE_HYPOT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef hypot # define hypot rpl_hypot # endif _GL_FUNCDECL_RPL (hypot, double, (double x, double y)); _GL_CXXALIAS_RPL (hypot, double, (double x, double y)); # else _GL_CXXALIAS_SYS (hypot, double, (double x, double y)); # endif _GL_CXXALIASWARN (hypot); #elif defined GNULIB_POSIXCHECK # undef hypot # if HAVE_RAW_DECL_HYPOT _GL_WARN_ON_USE (hypotf, "hypot has portability problems - " "use gnulib module hypot for portability"); # endif #endif /* Return sqrt(x^2+y^2). */ #if @GNULIB_HYPOTL@ # if @REPLACE_HYPOTL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef hypotl # define hypotl rpl_hypotl # endif _GL_FUNCDECL_RPL (hypotl, long double, (long double x, long double y)); _GL_CXXALIAS_RPL (hypotl, long double, (long double x, long double y)); # else # if !@HAVE_HYPOTL@ _GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y)); # endif _GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y)); # endif _GL_CXXALIASWARN (hypotl); #elif defined GNULIB_POSIXCHECK # undef hypotl # if HAVE_RAW_DECL_HYPOTL _GL_WARN_ON_USE (hypotl, "hypotl is unportable - " "use gnulib module hypotl for portability"); # endif #endif #if @GNULIB_ILOGBF@ # if @REPLACE_ILOGBF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ilogbf # define ilogbf rpl_ilogbf # endif _GL_FUNCDECL_RPL (ilogbf, int, (float x)); _GL_CXXALIAS_RPL (ilogbf, int, (float x)); # else # if !@HAVE_ILOGBF@ _GL_FUNCDECL_SYS (ilogbf, int, (float x)); # endif _GL_CXXALIAS_SYS (ilogbf, int, (float x)); # endif _GL_CXXALIASWARN (ilogbf); #elif defined GNULIB_POSIXCHECK # undef ilogbf # if HAVE_RAW_DECL_ILOGBF _GL_WARN_ON_USE (ilogbf, "ilogbf is unportable - " "use gnulib module ilogbf for portability"); # endif #endif #if @GNULIB_ILOGB@ # if @REPLACE_ILOGB@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ilogb # define ilogb rpl_ilogb # endif _GL_FUNCDECL_RPL (ilogb, int, (double x)); _GL_CXXALIAS_RPL (ilogb, int, (double x)); # else # if !@HAVE_ILOGB@ _GL_FUNCDECL_SYS (ilogb, int, (double x)); # endif _GL_CXXALIAS_SYS (ilogb, int, (double x)); # endif _GL_CXXALIASWARN (ilogb); #elif defined GNULIB_POSIXCHECK # undef ilogb # if HAVE_RAW_DECL_ILOGB _GL_WARN_ON_USE (ilogb, "ilogb is unportable - " "use gnulib module ilogb for portability"); # endif #endif #if @GNULIB_ILOGBL@ # if !@HAVE_ILOGBL@ _GL_FUNCDECL_SYS (ilogbl, int, (long double x)); # endif _GL_CXXALIAS_SYS (ilogbl, int, (long double x)); _GL_CXXALIASWARN (ilogbl); #elif defined GNULIB_POSIXCHECK # undef ilogbl # if HAVE_RAW_DECL_ILOGBL _GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - " "use gnulib module ilogbl for portability"); # endif #endif /* Return x * 2^exp. */ #if @GNULIB_LDEXPF@ # if !@HAVE_LDEXPF@ # undef ldexpf _GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp)); # endif _GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp)); _GL_CXXALIASWARN (ldexpf); #elif defined GNULIB_POSIXCHECK # undef ldexpf # if HAVE_RAW_DECL_LDEXPF _GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - " "use gnulib module ldexpf for portability"); # endif #endif /* Return x * 2^exp. */ #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ldexpl # define ldexpl rpl_ldexpl # endif _GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp)); _GL_CXXALIAS_RPL (ldexpl, long double, (long double x, int exp)); #else # if !@HAVE_DECL_LDEXPL@ _GL_FUNCDECL_SYS (ldexpl, long double, (long double x, int exp)); # endif # if @GNULIB_LDEXPL@ _GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp)); # endif #endif #if @GNULIB_LDEXPL@ _GL_CXXALIASWARN (ldexpl); #endif #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK # undef ldexpl # if HAVE_RAW_DECL_LDEXPL _GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - " "use gnulib module ldexpl for portability"); # endif #endif #if @GNULIB_LOGF@ # if @REPLACE_LOGF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef logf # define logf rpl_logf # endif _GL_FUNCDECL_RPL (logf, float, (float x)); _GL_CXXALIAS_RPL (logf, float, (float x)); # else # if !@HAVE_LOGF@ # undef logf _GL_FUNCDECL_SYS (logf, float, (float x)); # endif _GL_CXXALIAS_SYS (logf, float, (float x)); # endif _GL_CXXALIASWARN (logf); #elif defined GNULIB_POSIXCHECK # undef logf # if HAVE_RAW_DECL_LOGF _GL_WARN_ON_USE (logf, "logf is unportable - " "use gnulib module logf for portability"); # endif #endif #if @GNULIB_LOG@ # if @REPLACE_LOG@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log # define log rpl_log # endif _GL_FUNCDECL_RPL (log, double, (double x)); _GL_CXXALIAS_RPL (log, double, (double x)); # else _GL_CXXALIAS_SYS (log, double, (double x)); # endif _GL_CXXALIASWARN (log); #elif defined GNULIB_POSIXCHECK # undef log # if HAVE_RAW_DECL_LOG _GL_WARN_ON_USE (log, "log has portability problems - " "use gnulib module log for portability"); # endif #endif #if @GNULIB_LOGL@ # if @REPLACE_LOGL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef logl # define logl rpl_logl # endif _GL_FUNCDECL_RPL (logl, long double, (long double x)); _GL_CXXALIAS_RPL (logl, long double, (long double x)); # else # if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@ # undef logl _GL_FUNCDECL_SYS (logl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (logl, long double, (long double x)); # endif _GL_CXXALIASWARN (logl); #elif defined GNULIB_POSIXCHECK # undef logl # if HAVE_RAW_DECL_LOGL _GL_WARN_ON_USE (logl, "logl is unportable - " "use gnulib module logl for portability"); # endif #endif #if @GNULIB_LOG10F@ # if @REPLACE_LOG10F@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log10f # define log10f rpl_log10f # endif _GL_FUNCDECL_RPL (log10f, float, (float x)); _GL_CXXALIAS_RPL (log10f, float, (float x)); # else # if !@HAVE_LOG10F@ # undef log10f _GL_FUNCDECL_SYS (log10f, float, (float x)); # endif _GL_CXXALIAS_SYS (log10f, float, (float x)); # endif _GL_CXXALIASWARN (log10f); #elif defined GNULIB_POSIXCHECK # undef log10f # if HAVE_RAW_DECL_LOG10F _GL_WARN_ON_USE (log10f, "log10f is unportable - " "use gnulib module log10f for portability"); # endif #endif #if @GNULIB_LOG10@ # if @REPLACE_LOG10@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log10 # define log10 rpl_log10 # endif _GL_FUNCDECL_RPL (log10, double, (double x)); _GL_CXXALIAS_RPL (log10, double, (double x)); # else _GL_CXXALIAS_SYS (log10, double, (double x)); # endif _GL_CXXALIASWARN (log10); #elif defined GNULIB_POSIXCHECK # undef log10 # if HAVE_RAW_DECL_LOG10 _GL_WARN_ON_USE (log10, "log10 has portability problems - " "use gnulib module log10 for portability"); # endif #endif #if @GNULIB_LOG10L@ # if @REPLACE_LOG10L@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log10l # define log10l rpl_log10l # endif _GL_FUNCDECL_RPL (log10l, long double, (long double x)); _GL_CXXALIAS_RPL (log10l, long double, (long double x)); # else # if !@HAVE_LOG10L@ || !@HAVE_DECL_LOG10L@ # undef log10l _GL_FUNCDECL_SYS (log10l, long double, (long double x)); # endif _GL_CXXALIAS_SYS (log10l, long double, (long double x)); # endif _GL_CXXALIASWARN (log10l); #elif defined GNULIB_POSIXCHECK # undef log10l # if HAVE_RAW_DECL_LOG10L _GL_WARN_ON_USE (log10l, "log10l is unportable - " "use gnulib module log10l for portability"); # endif #endif #if @GNULIB_LOG1PF@ # if @REPLACE_LOG1PF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log1pf # define log1pf rpl_log1pf # endif _GL_FUNCDECL_RPL (log1pf, float, (float x)); _GL_CXXALIAS_RPL (log1pf, float, (float x)); # else # if !@HAVE_LOG1PF@ _GL_FUNCDECL_SYS (log1pf, float, (float x)); # endif _GL_CXXALIAS_SYS (log1pf, float, (float x)); # endif _GL_CXXALIASWARN (log1pf); #elif defined GNULIB_POSIXCHECK # undef log1pf # if HAVE_RAW_DECL_LOG1PF _GL_WARN_ON_USE (log1pf, "log1pf is unportable - " "use gnulib module log1pf for portability"); # endif #endif #if @GNULIB_LOG1P@ # if @REPLACE_LOG1P@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log1p # define log1p rpl_log1p # endif _GL_FUNCDECL_RPL (log1p, double, (double x)); _GL_CXXALIAS_RPL (log1p, double, (double x)); # else # if !@HAVE_LOG1P@ _GL_FUNCDECL_SYS (log1p, double, (double x)); # endif _GL_CXXALIAS_SYS (log1p, double, (double x)); # endif _GL_CXXALIASWARN (log1p); #elif defined GNULIB_POSIXCHECK # undef log1p # if HAVE_RAW_DECL_LOG1P _GL_WARN_ON_USE (log1p, "log1p has portability problems - " "use gnulib module log1p for portability"); # endif #endif #if @GNULIB_LOG1PL@ # if @REPLACE_LOG1PL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log1pl # define log1pl rpl_log1pl # endif _GL_FUNCDECL_RPL (log1pl, long double, (long double x)); _GL_CXXALIAS_RPL (log1pl, long double, (long double x)); # else # if !@HAVE_LOG1PL@ _GL_FUNCDECL_SYS (log1pl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (log1pl, long double, (long double x)); # endif _GL_CXXALIASWARN (log1pl); #elif defined GNULIB_POSIXCHECK # undef log1pl # if HAVE_RAW_DECL_LOG1PL _GL_WARN_ON_USE (log1pl, "log1pl has portability problems - " "use gnulib module log1pl for portability"); # endif #endif #if @GNULIB_LOG2F@ # if @REPLACE_LOG2F@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log2f # define log2f rpl_log2f # endif _GL_FUNCDECL_RPL (log2f, float, (float x)); _GL_CXXALIAS_RPL (log2f, float, (float x)); # else # if !@HAVE_DECL_LOG2F@ # undef log2f _GL_FUNCDECL_SYS (log2f, float, (float x)); # endif _GL_CXXALIAS_SYS (log2f, float, (float x)); # endif _GL_CXXALIASWARN (log2f); #elif defined GNULIB_POSIXCHECK # undef log2f # if HAVE_RAW_DECL_LOG2F _GL_WARN_ON_USE (log2f, "log2f is unportable - " "use gnulib module log2f for portability"); # endif #endif #if @GNULIB_LOG2@ # if @REPLACE_LOG2@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log2 # define log2 rpl_log2 # endif _GL_FUNCDECL_RPL (log2, double, (double x)); _GL_CXXALIAS_RPL (log2, double, (double x)); # else # if !@HAVE_DECL_LOG2@ # undef log2 _GL_FUNCDECL_SYS (log2, double, (double x)); # endif _GL_CXXALIAS_SYS (log2, double, (double x)); # endif _GL_CXXALIASWARN (log2); #elif defined GNULIB_POSIXCHECK # undef log2 # if HAVE_RAW_DECL_LOG2 _GL_WARN_ON_USE (log2, "log2 is unportable - " "use gnulib module log2 for portability"); # endif #endif #if @GNULIB_LOG2L@ # if @REPLACE_LOG2L@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef log2l # define log2l rpl_log2l # endif _GL_FUNCDECL_RPL (log2l, long double, (long double x)); _GL_CXXALIAS_RPL (log2l, long double, (long double x)); # else # if !@HAVE_DECL_LOG2L@ _GL_FUNCDECL_SYS (log2l, long double, (long double x)); # endif _GL_CXXALIAS_SYS (log2l, long double, (long double x)); # endif _GL_CXXALIASWARN (log2l); #elif defined GNULIB_POSIXCHECK # undef log2l # if HAVE_RAW_DECL_LOG2L _GL_WARN_ON_USE (log2l, "log2l is unportable - " "use gnulib module log2l for portability"); # endif #endif #if @GNULIB_LOGBF@ # if @REPLACE_LOGBF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef logbf # define logbf rpl_logbf # endif _GL_FUNCDECL_RPL (logbf, float, (float x)); _GL_CXXALIAS_RPL (logbf, float, (float x)); # else # if !@HAVE_LOGBF@ _GL_FUNCDECL_SYS (logbf, float, (float x)); # endif _GL_CXXALIAS_SYS (logbf, float, (float x)); # endif _GL_CXXALIASWARN (logbf); #elif defined GNULIB_POSIXCHECK # undef logbf # if HAVE_RAW_DECL_LOGBF _GL_WARN_ON_USE (logbf, "logbf is unportable - " "use gnulib module logbf for portability"); # endif #endif #if @GNULIB_LOGB@ # if @REPLACE_LOGB@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef logb # define logb rpl_logb # endif _GL_FUNCDECL_RPL (logb, double, (double x)); _GL_CXXALIAS_RPL (logb, double, (double x)); # else # if !@HAVE_DECL_LOGB@ _GL_FUNCDECL_SYS (logb, double, (double x)); # endif _GL_CXXALIAS_SYS (logb, double, (double x)); # endif _GL_CXXALIASWARN (logb); #elif defined GNULIB_POSIXCHECK # undef logb # if HAVE_RAW_DECL_LOGB _GL_WARN_ON_USE (logb, "logb is unportable - " "use gnulib module logb for portability"); # endif #endif #if @GNULIB_LOGBL@ # if @REPLACE_LOGBL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef logbl # define logbl rpl_logbl # endif _GL_FUNCDECL_RPL (logbl, long double, (long double x)); _GL_CXXALIAS_RPL (logbl, long double, (long double x)); # else # if !@HAVE_LOGBL@ _GL_FUNCDECL_SYS (logbl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (logbl, long double, (long double x)); # endif _GL_CXXALIASWARN (logbl); #elif defined GNULIB_POSIXCHECK # undef logbl # if HAVE_RAW_DECL_LOGBL _GL_WARN_ON_USE (logbl, "logbl is unportable - " "use gnulib module logbl for portability"); # endif #endif #if @GNULIB_MODFF@ # if @REPLACE_MODFF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef modff # define modff rpl_modff # endif _GL_FUNCDECL_RPL (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (modff, float, (float x, float *iptr)); # else # if !@HAVE_MODFF@ # undef modff _GL_FUNCDECL_SYS (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (modff, float, (float x, float *iptr)); # endif _GL_CXXALIASWARN (modff); #elif defined GNULIB_POSIXCHECK # undef modff # if HAVE_RAW_DECL_MODFF _GL_WARN_ON_USE (modff, "modff is unportable - " "use gnulib module modff for portability"); # endif #endif #if @GNULIB_MODF@ # if @REPLACE_MODF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef modf # define modf rpl_modf # endif _GL_FUNCDECL_RPL (modf, double, (double x, double *iptr) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (modf, double, (double x, double *iptr)); # else _GL_CXXALIAS_SYS (modf, double, (double x, double *iptr)); # endif _GL_CXXALIASWARN (modf); #elif defined GNULIB_POSIXCHECK # undef modf # if HAVE_RAW_DECL_MODF _GL_WARN_ON_USE (modf, "modf has portability problems - " "use gnulib module modf for portability"); # endif #endif #if @GNULIB_MODFL@ # if @REPLACE_MODFL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef modfl # define modfl rpl_modfl # endif _GL_FUNCDECL_RPL (modfl, long double, (long double x, long double *iptr) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (modfl, long double, (long double x, long double *iptr)); # else # if !@HAVE_MODFL@ # undef modfl _GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr)); # endif _GL_CXXALIASWARN (modfl); #elif defined GNULIB_POSIXCHECK # undef modfl # if HAVE_RAW_DECL_MODFL _GL_WARN_ON_USE (modfl, "modfl is unportable - " "use gnulib module modfl for portability"); # endif #endif #if @GNULIB_POWF@ # if !@HAVE_POWF@ # undef powf _GL_FUNCDECL_SYS (powf, float, (float x, float y)); # endif _GL_CXXALIAS_SYS (powf, float, (float x, float y)); _GL_CXXALIASWARN (powf); #elif defined GNULIB_POSIXCHECK # undef powf # if HAVE_RAW_DECL_POWF _GL_WARN_ON_USE (powf, "powf is unportable - " "use gnulib module powf for portability"); # endif #endif #if @GNULIB_REMAINDERF@ # if @REPLACE_REMAINDERF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef remainderf # define remainderf rpl_remainderf # endif _GL_FUNCDECL_RPL (remainderf, float, (float x, float y)); _GL_CXXALIAS_RPL (remainderf, float, (float x, float y)); # else # if !@HAVE_REMAINDERF@ _GL_FUNCDECL_SYS (remainderf, float, (float x, float y)); # endif _GL_CXXALIAS_SYS (remainderf, float, (float x, float y)); # endif _GL_CXXALIASWARN (remainderf); #elif defined GNULIB_POSIXCHECK # undef remainderf # if HAVE_RAW_DECL_REMAINDERF _GL_WARN_ON_USE (remainderf, "remainderf is unportable - " "use gnulib module remainderf for portability"); # endif #endif #if @GNULIB_REMAINDER@ # if @REPLACE_REMAINDER@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef remainder # define remainder rpl_remainder # endif _GL_FUNCDECL_RPL (remainder, double, (double x, double y)); _GL_CXXALIAS_RPL (remainder, double, (double x, double y)); # else # if !@HAVE_REMAINDER@ || !@HAVE_DECL_REMAINDER@ _GL_FUNCDECL_SYS (remainder, double, (double x, double y)); # endif _GL_CXXALIAS_SYS (remainder, double, (double x, double y)); # endif _GL_CXXALIASWARN (remainder); #elif defined GNULIB_POSIXCHECK # undef remainder # if HAVE_RAW_DECL_REMAINDER _GL_WARN_ON_USE (remainder, "remainder is unportable - " "use gnulib module remainder for portability"); # endif #endif #if @GNULIB_REMAINDERL@ # if @REPLACE_REMAINDERL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef remainderl # define remainderl rpl_remainderl # endif _GL_FUNCDECL_RPL (remainderl, long double, (long double x, long double y)); _GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y)); # else # if !@HAVE_DECL_REMAINDERL@ # undef remainderl _GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y)); # endif _GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y)); # endif _GL_CXXALIASWARN (remainderl); #elif defined GNULIB_POSIXCHECK # undef remainderl # if HAVE_RAW_DECL_REMAINDERL _GL_WARN_ON_USE (remainderl, "remainderl is unportable - " "use gnulib module remainderl for portability"); # endif #endif #if @GNULIB_RINTF@ # if !@HAVE_DECL_RINTF@ _GL_FUNCDECL_SYS (rintf, float, (float x)); # endif _GL_CXXALIAS_SYS (rintf, float, (float x)); _GL_CXXALIASWARN (rintf); #elif defined GNULIB_POSIXCHECK # undef rintf # if HAVE_RAW_DECL_RINTF _GL_WARN_ON_USE (rintf, "rintf is unportable - " "use gnulib module rintf for portability"); # endif #endif #if @GNULIB_RINT@ # if !@HAVE_RINT@ _GL_FUNCDECL_SYS (rint, double, (double x)); # endif _GL_CXXALIAS_SYS (rint, double, (double x)); _GL_CXXALIASWARN (rint); #elif defined GNULIB_POSIXCHECK # undef rint # if HAVE_RAW_DECL_RINT _GL_WARN_ON_USE (rint, "rint is unportable - " "use gnulib module rint for portability"); # endif #endif #if @GNULIB_RINTL@ # if !@HAVE_RINTL@ _GL_FUNCDECL_SYS (rintl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (rintl, long double, (long double x)); _GL_CXXALIASWARN (rintl); #elif defined GNULIB_POSIXCHECK # undef rintl # if HAVE_RAW_DECL_RINTL _GL_WARN_ON_USE (rintl, "rintl is unportable - " "use gnulib module rintl for portability"); # endif #endif #if @GNULIB_ROUNDF@ # if @REPLACE_ROUNDF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef roundf # define roundf rpl_roundf # endif _GL_FUNCDECL_RPL (roundf, float, (float x)); _GL_CXXALIAS_RPL (roundf, float, (float x)); # else # if !@HAVE_DECL_ROUNDF@ _GL_FUNCDECL_SYS (roundf, float, (float x)); # endif _GL_CXXALIAS_SYS (roundf, float, (float x)); # endif _GL_CXXALIASWARN (roundf); #elif defined GNULIB_POSIXCHECK # undef roundf # if HAVE_RAW_DECL_ROUNDF _GL_WARN_ON_USE (roundf, "roundf is unportable - " "use gnulib module roundf for portability"); # endif #endif #if @GNULIB_ROUND@ # if @REPLACE_ROUND@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef round # define round rpl_round # endif _GL_FUNCDECL_RPL (round, double, (double x)); _GL_CXXALIAS_RPL (round, double, (double x)); # else # if !@HAVE_DECL_ROUND@ _GL_FUNCDECL_SYS (round, double, (double x)); # endif _GL_CXXALIAS_SYS (round, double, (double x)); # endif _GL_CXXALIASWARN (round); #elif defined GNULIB_POSIXCHECK # undef round # if HAVE_RAW_DECL_ROUND _GL_WARN_ON_USE (round, "round is unportable - " "use gnulib module round for portability"); # endif #endif #if @GNULIB_ROUNDL@ # if @REPLACE_ROUNDL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef roundl # define roundl rpl_roundl # endif _GL_FUNCDECL_RPL (roundl, long double, (long double x)); _GL_CXXALIAS_RPL (roundl, long double, (long double x)); # else # if !@HAVE_DECL_ROUNDL@ # undef roundl _GL_FUNCDECL_SYS (roundl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (roundl, long double, (long double x)); # endif _GL_CXXALIASWARN (roundl); #elif defined GNULIB_POSIXCHECK # undef roundl # if HAVE_RAW_DECL_ROUNDL _GL_WARN_ON_USE (roundl, "roundl is unportable - " "use gnulib module roundl for portability"); # endif #endif #if @GNULIB_SINF@ # if !@HAVE_SINF@ # undef sinf _GL_FUNCDECL_SYS (sinf, float, (float x)); # endif _GL_CXXALIAS_SYS (sinf, float, (float x)); _GL_CXXALIASWARN (sinf); #elif defined GNULIB_POSIXCHECK # undef sinf # if HAVE_RAW_DECL_SINF _GL_WARN_ON_USE (sinf, "sinf is unportable - " "use gnulib module sinf for portability"); # endif #endif #if @GNULIB_SINL@ # if !@HAVE_SINL@ || !@HAVE_DECL_SINL@ # undef sinl _GL_FUNCDECL_SYS (sinl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (sinl, long double, (long double x)); _GL_CXXALIASWARN (sinl); #elif defined GNULIB_POSIXCHECK # undef sinl # if HAVE_RAW_DECL_SINL _GL_WARN_ON_USE (sinl, "sinl is unportable - " "use gnulib module sinl for portability"); # endif #endif #if @GNULIB_SINHF@ # if !@HAVE_SINHF@ # undef sinhf _GL_FUNCDECL_SYS (sinhf, float, (float x)); # endif _GL_CXXALIAS_SYS (sinhf, float, (float x)); _GL_CXXALIASWARN (sinhf); #elif defined GNULIB_POSIXCHECK # undef sinhf # if HAVE_RAW_DECL_SINHF _GL_WARN_ON_USE (sinhf, "sinhf is unportable - " "use gnulib module sinhf for portability"); # endif #endif #if @GNULIB_SQRTF@ # if !@HAVE_SQRTF@ # undef sqrtf _GL_FUNCDECL_SYS (sqrtf, float, (float x)); # endif _GL_CXXALIAS_SYS (sqrtf, float, (float x)); _GL_CXXALIASWARN (sqrtf); #elif defined GNULIB_POSIXCHECK # undef sqrtf # if HAVE_RAW_DECL_SQRTF _GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - " "use gnulib module sqrtf for portability"); # endif #endif #if @GNULIB_SQRTL@ # if @REPLACE_SQRTL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef sqrtl # define sqrtl rpl_sqrtl # endif _GL_FUNCDECL_RPL (sqrtl, long double, (long double x)); _GL_CXXALIAS_RPL (sqrtl, long double, (long double x)); # else # if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@ # undef sqrtl _GL_FUNCDECL_SYS (sqrtl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (sqrtl, long double, (long double x)); # endif _GL_CXXALIASWARN (sqrtl); #elif defined GNULIB_POSIXCHECK # undef sqrtl # if HAVE_RAW_DECL_SQRTL _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - " "use gnulib module sqrtl for portability"); # endif #endif #if @GNULIB_TANF@ # if !@HAVE_TANF@ # undef tanf _GL_FUNCDECL_SYS (tanf, float, (float x)); # endif _GL_CXXALIAS_SYS (tanf, float, (float x)); _GL_CXXALIASWARN (tanf); #elif defined GNULIB_POSIXCHECK # undef tanf # if HAVE_RAW_DECL_TANF _GL_WARN_ON_USE (tanf, "tanf is unportable - " "use gnulib module tanf for portability"); # endif #endif #if @GNULIB_TANL@ # if !@HAVE_TANL@ || !@HAVE_DECL_TANL@ # undef tanl _GL_FUNCDECL_SYS (tanl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (tanl, long double, (long double x)); _GL_CXXALIASWARN (tanl); #elif defined GNULIB_POSIXCHECK # undef tanl # if HAVE_RAW_DECL_TANL _GL_WARN_ON_USE (tanl, "tanl is unportable - " "use gnulib module tanl for portability"); # endif #endif #if @GNULIB_TANHF@ # if !@HAVE_TANHF@ # undef tanhf _GL_FUNCDECL_SYS (tanhf, float, (float x)); # endif _GL_CXXALIAS_SYS (tanhf, float, (float x)); _GL_CXXALIASWARN (tanhf); #elif defined GNULIB_POSIXCHECK # undef tanhf # if HAVE_RAW_DECL_TANHF _GL_WARN_ON_USE (tanhf, "tanhf is unportable - " "use gnulib module tanhf for portability"); # endif #endif #if @GNULIB_TRUNCF@ # if @REPLACE_TRUNCF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define truncf rpl_truncf # endif _GL_FUNCDECL_RPL (truncf, float, (float x)); _GL_CXXALIAS_RPL (truncf, float, (float x)); # else # if !@HAVE_DECL_TRUNCF@ _GL_FUNCDECL_SYS (truncf, float, (float x)); # endif _GL_CXXALIAS_SYS (truncf, float, (float x)); # endif _GL_CXXALIASWARN (truncf); #elif defined GNULIB_POSIXCHECK # undef truncf # if HAVE_RAW_DECL_TRUNCF _GL_WARN_ON_USE (truncf, "truncf is unportable - " "use gnulib module truncf for portability"); # endif #endif #if @GNULIB_TRUNC@ # if @REPLACE_TRUNC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define trunc rpl_trunc # endif _GL_FUNCDECL_RPL (trunc, double, (double x)); _GL_CXXALIAS_RPL (trunc, double, (double x)); # else # if !@HAVE_DECL_TRUNC@ _GL_FUNCDECL_SYS (trunc, double, (double x)); # endif _GL_CXXALIAS_SYS (trunc, double, (double x)); # endif _GL_CXXALIASWARN (trunc); #elif defined GNULIB_POSIXCHECK # undef trunc # if HAVE_RAW_DECL_TRUNC _GL_WARN_ON_USE (trunc, "trunc is unportable - " "use gnulib module trunc for portability"); # endif #endif #if @GNULIB_TRUNCL@ # if @REPLACE_TRUNCL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef truncl # define truncl rpl_truncl # endif _GL_FUNCDECL_RPL (truncl, long double, (long double x)); _GL_CXXALIAS_RPL (truncl, long double, (long double x)); # else # if !@HAVE_DECL_TRUNCL@ _GL_FUNCDECL_SYS (truncl, long double, (long double x)); # endif _GL_CXXALIAS_SYS (truncl, long double, (long double x)); # endif _GL_CXXALIASWARN (truncl); #elif defined GNULIB_POSIXCHECK # undef truncl # if HAVE_RAW_DECL_TRUNCL _GL_WARN_ON_USE (truncl, "truncl is unportable - " "use gnulib module truncl for portability"); # endif #endif /* Definitions of function-like macros come here, after the function declarations. */ #if @GNULIB_ISFINITE@ # if @REPLACE_ISFINITE@ _GL_EXTERN_C int gl_isfinitef (float x); _GL_EXTERN_C int gl_isfinited (double x); _GL_EXTERN_C int gl_isfinitel (long double x); # undef isfinite # define isfinite(x) \ (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ gl_isfinitef (x)) # endif # ifdef __cplusplus # ifdef isfinite _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) # undef isfinite _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite) # endif # endif #elif defined GNULIB_POSIXCHECK # if defined isfinite _GL_WARN_REAL_FLOATING_DECL (isfinite); # undef isfinite # define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x) # endif #endif #if @GNULIB_ISINF@ # if @REPLACE_ISINF@ _GL_EXTERN_C int gl_isinff (float x); _GL_EXTERN_C int gl_isinfd (double x); _GL_EXTERN_C int gl_isinfl (long double x); # undef isinf # define isinf(x) \ (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ gl_isinff (x)) # endif # ifdef __cplusplus # ifdef isinf _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) # undef isinf _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf) # endif # endif #elif defined GNULIB_POSIXCHECK # if defined isinf _GL_WARN_REAL_FLOATING_DECL (isinf); # undef isinf # define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x) # endif #endif #if @GNULIB_ISNANF@ /* Test for NaN for 'float' numbers. */ # if @HAVE_ISNANF@ /* The original included above provides a declaration of isnan macro or (older) isnanf function. */ # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) # elif defined isnan # undef isnanf # define isnanf(x) isnan ((float)(x)) # endif # else /* Test whether X is a NaN. */ # undef isnanf # define isnanf rpl_isnanf _GL_EXTERN_C int isnanf (float x); # endif #endif #if @GNULIB_ISNAND@ /* Test for NaN for 'double' numbers. This function is a gnulib extension, unlike isnan() which applied only to 'double' numbers earlier but now is a type-generic macro. */ # if @HAVE_ISNAND@ /* The original included above provides a declaration of isnan macro. */ # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnand # define isnand(x) __builtin_isnan ((double)(x)) # else # undef isnand # define isnand(x) isnan ((double)(x)) # endif # else /* Test whether X is a NaN. */ # undef isnand # define isnand rpl_isnand _GL_EXTERN_C int isnand (double x); # endif #endif #if @GNULIB_ISNANL@ /* Test for NaN for 'long double' numbers. */ # if @HAVE_ISNANL@ /* The original included above provides a declaration of isnan macro or (older) isnanl function. */ # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) # elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) # endif # else /* Test whether X is a NaN. */ # undef isnanl # define isnanl rpl_isnanl _GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST; # endif #endif /* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */ #if @GNULIB_ISNAN@ # if @REPLACE_ISNAN@ /* We can't just use the isnanf macro (e.g.) as exposed by isnanf.h (e.g.) here, because those may end up being macros that recursively expand back to isnan. So use the gnulib replacements for them directly. */ # if @HAVE_ISNANF@ && __GNUC__ >= 4 # define gl_isnan_f(x) __builtin_isnanf ((float)(x)) # else _GL_EXTERN_C int rpl_isnanf (float x); # define gl_isnan_f(x) rpl_isnanf (x) # endif # if @HAVE_ISNAND@ && __GNUC__ >= 4 # define gl_isnan_d(x) __builtin_isnan ((double)(x)) # else _GL_EXTERN_C int rpl_isnand (double x); # define gl_isnan_d(x) rpl_isnand (x) # endif # if @HAVE_ISNANL@ && __GNUC__ >= 4 # define gl_isnan_l(x) __builtin_isnanl ((long double)(x)) # else _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; # define gl_isnan_l(x) rpl_isnanl (x) # endif # undef isnan # define isnan(x) \ (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ gl_isnan_f (x)) # elif __GNUC__ >= 4 # undef isnan # define isnan(x) \ (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : \ sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \ __builtin_isnanf ((float)(x))) # endif # ifdef __cplusplus # ifdef isnan _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) # undef isnan _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan) # endif # else /* Ensure isnan is a macro. */ # ifndef isnan # define isnan isnan # endif # endif #elif defined GNULIB_POSIXCHECK # if defined isnan _GL_WARN_REAL_FLOATING_DECL (isnan); # undef isnan # define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x) # endif #endif #if @GNULIB_SIGNBIT@ # if @REPLACE_SIGNBIT_USING_GCC@ # undef signbit /* GCC 4.0 and newer provides three built-ins for signbit. */ # define signbit(x) \ (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ __builtin_signbitf (x)) # endif # if @REPLACE_SIGNBIT@ # undef signbit _GL_EXTERN_C int gl_signbitf (float arg); _GL_EXTERN_C int gl_signbitd (double arg); _GL_EXTERN_C int gl_signbitl (long double arg); # if __GNUC__ >= 2 && !defined __STRICT_ANSI__ # define _GL_NUM_UINT_WORDS(type) \ ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf # define gl_signbitf_OPTIMIZED_MACRO # define gl_signbitf(arg) \ ({ union { float _value; \ unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \ } _m; \ _m._value = (arg); \ (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ }) # endif # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd # define gl_signbitd_OPTIMIZED_MACRO # define gl_signbitd(arg) \ ({ union { double _value; \ unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \ } _m; \ _m._value = (arg); \ (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ }) # endif # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl # define gl_signbitl_OPTIMIZED_MACRO # define gl_signbitl(arg) \ ({ union { long double _value; \ unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \ } _m; \ _m._value = (arg); \ (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ }) # endif # endif # define signbit(x) \ (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ gl_signbitf (x)) # endif # ifdef __cplusplus # ifdef signbit _GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) # undef signbit _GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit) # endif # endif #elif defined GNULIB_POSIXCHECK # if defined signbit _GL_WARN_REAL_FLOATING_DECL (signbit); # undef signbit # define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x) # endif #endif _GL_INLINE_HEADER_END #endif /* _@GUARD_PREFIX@_MATH_H */ #endif /* _@GUARD_PREFIX@_MATH_H */ lftp-4.6.3a/lib/fnmatch.in.h0000644000015000007670000000462212466374011012527 00000000000000/* Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2015 Free Software Foundation, Inc. This file is part of 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, 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 . */ #ifndef _FNMATCH_H #define _FNMATCH_H 1 /* The definition of _GL_ARG_NONNULL is copied here. */ #ifdef __cplusplus extern "C" { #endif /* We #undef these before defining them because some losing systems (HP-UX A.08.07 for example) define these in . */ #undef FNM_PATHNAME #undef FNM_NOESCAPE #undef FNM_PERIOD /* Bits set in the FLAGS argument to 'fnmatch'. */ #define FNM_PATHNAME (1 << 0) /* No wildcard can ever match '/'. */ #define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ #define FNM_PERIOD (1 << 2) /* Leading '.' is matched only explicitly. */ #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE # define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ # define FNM_LEADING_DIR (1 << 3) /* Ignore '/...' after a match. */ # define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ # define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ #endif /* Value returned by 'fnmatch' if STRING does not match PATTERN. */ #define FNM_NOMATCH 1 /* This value is returned if the implementation does not support 'fnmatch'. Since this is not the case here it will never be returned but the conformance test suites still require the symbol to be defined. */ #ifdef _XOPEN_SOURCE # define FNM_NOSYS (-1) #endif /* Match NAME against the file name pattern PATTERN, returning zero if it matches, FNM_NOMATCH if not. */ extern int fnmatch (const char *__pattern, const char *__name, int __flags) _GL_ARG_NONNULL ((1, 2)); #ifdef __cplusplus } #endif #endif /* fnmatch.h */ lftp-4.6.3a/lib/iconv_open.c0000644000015000007670000001267612466374011012644 00000000000000/* Character set conversion. Copyright (C) 2007, 2009-2015 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 . */ #include /* Specification. */ #include #include #include #include "c-ctype.h" #include "c-strcase.h" #define SIZEOF(a) (sizeof(a) / sizeof(a[0])) /* Namespace cleanliness. */ #define mapping_lookup rpl_iconv_open_mapping_lookup /* The macro ICONV_FLAVOR is defined to one of these or undefined. */ #define ICONV_FLAVOR_AIX "iconv_open-aix.h" #define ICONV_FLAVOR_HPUX "iconv_open-hpux.h" #define ICONV_FLAVOR_IRIX "iconv_open-irix.h" #define ICONV_FLAVOR_OSF "iconv_open-osf.h" #define ICONV_FLAVOR_SOLARIS "iconv_open-solaris.h" #ifdef ICONV_FLAVOR # include ICONV_FLAVOR #endif iconv_t rpl_iconv_open (const char *tocode, const char *fromcode) #undef iconv_open { char fromcode_upper[32]; char tocode_upper[32]; char *fromcode_upper_end; char *tocode_upper_end; #if REPLACE_ICONV_UTF /* Special handling of conversion between UTF-8 and UTF-{16,32}{BE,LE}. Do this here, before calling the real iconv_open(), because OSF/1 5.1 iconv() to these encoding inserts a BOM, which is wrong. We do not need to handle conversion between arbitrary encodings and UTF-{16,32}{BE,LE}, because the 'striconveh' module implements two-step conversion through UTF-8. The _ICONV_* constants are chosen to be disjoint from any iconv_t returned by the system's iconv_open() functions. Recall that iconv_t is a scalar type. */ if (c_toupper (fromcode[0]) == 'U' && c_toupper (fromcode[1]) == 'T' && c_toupper (fromcode[2]) == 'F' && fromcode[3] == '-') { if (c_toupper (tocode[0]) == 'U' && c_toupper (tocode[1]) == 'T' && c_toupper (tocode[2]) == 'F' && tocode[3] == '-') { if (strcmp (fromcode + 4, "8") == 0) { if (c_strcasecmp (tocode + 4, "16BE") == 0) return _ICONV_UTF8_UTF16BE; if (c_strcasecmp (tocode + 4, "16LE") == 0) return _ICONV_UTF8_UTF16LE; if (c_strcasecmp (tocode + 4, "32BE") == 0) return _ICONV_UTF8_UTF32BE; if (c_strcasecmp (tocode + 4, "32LE") == 0) return _ICONV_UTF8_UTF32LE; } else if (strcmp (tocode + 4, "8") == 0) { if (c_strcasecmp (fromcode + 4, "16BE") == 0) return _ICONV_UTF16BE_UTF8; if (c_strcasecmp (fromcode + 4, "16LE") == 0) return _ICONV_UTF16LE_UTF8; if (c_strcasecmp (fromcode + 4, "32BE") == 0) return _ICONV_UTF32BE_UTF8; if (c_strcasecmp (fromcode + 4, "32LE") == 0) return _ICONV_UTF32LE_UTF8; } } } #endif /* Do *not* add special support for 8-bit encodings like ASCII or ISO-8859-1 here. This would lead to programs that work in some locales (such as the "C" or "en_US" locales) but do not work in East Asian locales. It is better if programmers make their programs depend on GNU libiconv (except on glibc systems), e.g. by using the AM_ICONV macro and documenting the dependency in an INSTALL or DEPENDENCIES file. */ /* Try with the original names first. This covers the case when fromcode or tocode is a lowercase encoding name that is understood by the system's iconv_open but not listed in our mappings table. */ { iconv_t cd = iconv_open (tocode, fromcode); if (cd != (iconv_t)(-1)) return cd; } /* Convert the encodings to upper case, because 1. in the arguments of iconv_open() on AIX, HP-UX, and OSF/1 the case matters, 2. it makes searching in the table faster. */ { const char *p = fromcode; char *q = fromcode_upper; while ((*q = c_toupper (*p)) != '\0') { p++; q++; if (q == &fromcode_upper[SIZEOF (fromcode_upper)]) { errno = EINVAL; return (iconv_t)(-1); } } fromcode_upper_end = q; } { const char *p = tocode; char *q = tocode_upper; while ((*q = c_toupper (*p)) != '\0') { p++; q++; if (q == &tocode_upper[SIZEOF (tocode_upper)]) { errno = EINVAL; return (iconv_t)(-1); } } tocode_upper_end = q; } #ifdef ICONV_FLAVOR /* Apply the mappings. */ { const struct mapping *m = mapping_lookup (fromcode_upper, fromcode_upper_end - fromcode_upper); fromcode = (m != NULL ? m->vendor_name : fromcode_upper); } { const struct mapping *m = mapping_lookup (tocode_upper, tocode_upper_end - tocode_upper); tocode = (m != NULL ? m->vendor_name : tocode_upper); } #else fromcode = fromcode_upper; tocode = tocode_upper; #endif return iconv_open (tocode, fromcode); } lftp-4.6.3a/lib/dup2.c0000644000015000007670000000735512466374011011355 00000000000000/* Duplicate an open file descriptor to a specified file descriptor. Copyright (C) 1999, 2004-2007, 2009-2015 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 . */ /* written by Paul Eggert */ #include /* Specification. */ #include #include #include #if HAVE_DUP2 # undef dup2 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ # define WIN32_LEAN_AND_MEAN # include # include "msvc-inval.h" /* Get _get_osfhandle. */ # include "msvc-nothrow.h" static int ms_windows_dup2 (int fd, int desired_fd) { int result; /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open, dup2 (fd, fd) returns 0, but all further attempts to use fd in future dup2 calls will hang. */ if (fd == desired_fd) { if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE) { errno = EBADF; return -1; } return fd; } /* Wine 1.0.1 return 0 when desired_fd is negative but not -1: http://bugs.winehq.org/show_bug.cgi?id=21289 */ if (desired_fd < 0) { errno = EBADF; return -1; } TRY_MSVC_INVAL { result = dup2 (fd, desired_fd); } CATCH_MSVC_INVAL { errno = EBADF; result = -1; } DONE_MSVC_INVAL; if (result == 0) result = desired_fd; return result; } # define dup2 ms_windows_dup2 # endif int rpl_dup2 (int fd, int desired_fd) { int result; # ifdef F_GETFL /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF. On Cygwin 1.5.x, dup2 (1, 1) returns 0. On Cygwin 1.7.17, dup2 (1, -1) dumps core. On Cygwin 1.7.25, dup2 (1, 256) can dump core. On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ # if HAVE_SETDTABLESIZE setdtablesize (desired_fd + 1); # endif if (desired_fd < 0) fd = desired_fd; if (fd == desired_fd) return fcntl (fd, F_GETFL) == -1 ? -1 : fd; # endif result = dup2 (fd, desired_fd); /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */ if (result == -1 && errno == EMFILE) errno = EBADF; # if REPLACE_FCHDIR if (fd != desired_fd && result != -1) result = _gl_register_dup (fd, result); # endif return result; } #else /* !HAVE_DUP2 */ /* On older platforms, dup2 did not exist. */ # ifndef F_DUPFD static int dupfd (int fd, int desired_fd) { int duplicated_fd = dup (fd); if (duplicated_fd < 0 || duplicated_fd == desired_fd) return duplicated_fd; else { int r = dupfd (fd, desired_fd); int e = errno; close (duplicated_fd); errno = e; return r; } } # endif int dup2 (int fd, int desired_fd) { int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd; if (result == -1 || fd == desired_fd) return result; close (desired_fd); # ifdef F_DUPFD result = fcntl (fd, F_DUPFD, desired_fd); # if REPLACE_FCHDIR if (0 <= result) result = _gl_register_dup (fd, result); # endif # else result = dupfd (fd, desired_fd); # endif if (result == -1 && (errno == EMFILE || errno == EINVAL)) errno = EBADF; return result; } #endif /* !HAVE_DUP2 */ lftp-4.6.3a/lib/regex.c0000644000015000007670000000615312466374012011611 00000000000000/* Extended regular expression matching and search library. Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . The GNU C Library 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. The GNU C Library 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 the GNU C Library; if not, see . */ #ifndef _LIBC # include # if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" # endif # if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ # pragma GCC diagnostic ignored "-Wold-style-definition" # pragma GCC diagnostic ignored "-Wtype-limits" # endif #endif /* Make sure no one compiles this code with a C++ compiler. */ #if defined __cplusplus && defined _LIBC # error "This is C code, use a C compiler" #endif #ifdef _LIBC /* We have to keep the namespace clean. */ # define regfree(preg) __regfree (preg) # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef) # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags) # define regerror(errcode, preg, errbuf, errbuf_size) \ __regerror(errcode, preg, errbuf, errbuf_size) # define re_set_registers(bu, re, nu, st, en) \ __re_set_registers (bu, re, nu, st, en) # define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \ __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) # define re_match(bufp, string, size, pos, regs) \ __re_match (bufp, string, size, pos, regs) # define re_search(bufp, string, size, startpos, range, regs) \ __re_search (bufp, string, size, startpos, range, regs) # define re_compile_pattern(pattern, length, bufp) \ __re_compile_pattern (pattern, length, bufp) # define re_set_syntax(syntax) __re_set_syntax (syntax) # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \ __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop) # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp) # include "../locale/localeinfo.h" #endif /* On some systems, limits.h sets RE_DUP_MAX to a lower value than GNU regex allows. Include it before , which correctly #undefs RE_DUP_MAX and sets it to the right value. */ #include #include #include "regex_internal.h" #include "regex_internal.c" #include "regcomp.c" #include "regexec.c" /* Binary backward compatibility. */ #if _LIBC # include # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.") int re_max_failures = 2000; # endif #endif lftp-4.6.3a/lib/xstrtol.c0000644000015000007670000001404212466374012012212 00000000000000/* A more useful interface to strtol. Copyright (C) 1995-1996, 1998-2001, 2003-2007, 2009-2015 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 . */ /* Written by Jim Meyering. */ #ifndef __strtol # define __strtol strtol # define __strtol_t long int # define __xstrtol xstrtol # define STRTOL_T_MINIMUM LONG_MIN # define STRTOL_T_MAXIMUM LONG_MAX #endif #include #include "xstrtol.h" /* Some pre-ANSI implementations (e.g. SunOS 4) need stderr defined if assertion checking is enabled. */ #include #include #include #include #include #include #include "assure.h" #include "intprops.h" /* xstrtoll.c and xstrtoull.c, which include this file, require that ULLONG_MAX, LLONG_MAX, LLONG_MIN are defined, but does not define them on all platforms. */ #ifndef ULLONG_MAX # define ULLONG_MAX TYPE_MAXIMUM (unsigned long long) #endif #ifndef LLONG_MAX # define LLONG_MAX TYPE_MAXIMUM (long long int) #endif #ifndef LLONG_MIN # define LLONG_MIN TYPE_MINIMUM (long long int) #endif static strtol_error bkm_scale (__strtol_t *x, int scale_factor) { if (TYPE_SIGNED (__strtol_t) && *x < STRTOL_T_MINIMUM / scale_factor) { *x = STRTOL_T_MINIMUM; return LONGINT_OVERFLOW; } if (STRTOL_T_MAXIMUM / scale_factor < *x) { *x = STRTOL_T_MAXIMUM; return LONGINT_OVERFLOW; } *x *= scale_factor; return LONGINT_OK; } static strtol_error bkm_scale_by_power (__strtol_t *x, int base, int power) { strtol_error err = LONGINT_OK; while (power--) err |= bkm_scale (x, base); return err; } /* FIXME: comment. */ strtol_error __xstrtol (const char *s, char **ptr, int strtol_base, __strtol_t *val, const char *valid_suffixes) { char *t_ptr; char **p; __strtol_t tmp; strtol_error err = LONGINT_OK; assure (0 <= strtol_base && strtol_base <= 36); p = (ptr ? ptr : &t_ptr); errno = 0; if (! TYPE_SIGNED (__strtol_t)) { const char *q = s; unsigned char ch = *q; while (isspace (ch)) ch = *++q; if (ch == '-') return LONGINT_INVALID; } tmp = __strtol (s, p, strtol_base); if (*p == s) { /* If there is no number but there is a valid suffix, assume the number is 1. The string is invalid otherwise. */ if (valid_suffixes && **p && strchr (valid_suffixes, **p)) tmp = 1; else return LONGINT_INVALID; } else if (errno != 0) { if (errno != ERANGE) return LONGINT_INVALID; err = LONGINT_OVERFLOW; } /* Let valid_suffixes == NULL mean "allow any suffix". */ /* FIXME: update all callers except the ones that allow suffixes after the number, changing last parameter NULL to "". */ if (!valid_suffixes) { *val = tmp; return err; } if (**p != '\0') { int base = 1024; int suffixes = 1; strtol_error overflow; if (!strchr (valid_suffixes, **p)) { *val = tmp; return err | LONGINT_INVALID_SUFFIX_CHAR; } if (strchr (valid_suffixes, '0')) { /* The "valid suffix" '0' is a special flag meaning that an optional second suffix is allowed, which can change the base. A suffix "B" (e.g. "100MB") stands for a power of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for a power of 1024. If no suffix (e.g. "100M"), assume power-of-1024. */ switch (p[0][1]) { case 'i': if (p[0][2] == 'B') suffixes += 2; break; case 'B': case 'D': /* 'D' is obsolescent */ base = 1000; suffixes++; break; } } switch (**p) { case 'b': overflow = bkm_scale (&tmp, 512); break; case 'B': overflow = bkm_scale (&tmp, 1024); break; case 'c': overflow = LONGINT_OK; break; case 'E': /* exa or exbi */ overflow = bkm_scale_by_power (&tmp, base, 6); break; case 'G': /* giga or gibi */ case 'g': /* 'g' is undocumented; for compatibility only */ overflow = bkm_scale_by_power (&tmp, base, 3); break; case 'k': /* kilo */ case 'K': /* kibi */ overflow = bkm_scale_by_power (&tmp, base, 1); break; case 'M': /* mega or mebi */ case 'm': /* 'm' is undocumented; for compatibility only */ overflow = bkm_scale_by_power (&tmp, base, 2); break; case 'P': /* peta or pebi */ overflow = bkm_scale_by_power (&tmp, base, 5); break; case 'T': /* tera or tebi */ case 't': /* 't' is undocumented; for compatibility only */ overflow = bkm_scale_by_power (&tmp, base, 4); break; case 'w': overflow = bkm_scale (&tmp, 2); break; case 'Y': /* yotta or 2**80 */ overflow = bkm_scale_by_power (&tmp, base, 8); break; case 'Z': /* zetta or 2**70 */ overflow = bkm_scale_by_power (&tmp, base, 7); break; default: *val = tmp; return err | LONGINT_INVALID_SUFFIX_CHAR; } err |= overflow; *p += suffixes; if (**p) err |= LONGINT_INVALID_SUFFIX_CHAR; } *val = tmp; return err; } lftp-4.6.3a/lib/xalloc.h0000644000015000007670000001702112531301057011752 00000000000000/* xalloc.h -- malloc with out-of-memory checking Copyright (C) 1990-2000, 2003-2004, 2006-2015 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 . */ #ifndef XALLOC_H_ #define XALLOC_H_ #include #include "xalloc-oversized.h" #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif _GL_INLINE_HEADER_BEGIN #ifndef XALLOC_INLINE # define XALLOC_INLINE _GL_INLINE #endif #ifdef __cplusplus extern "C" { #endif #if __GNUC__ >= 3 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) #else # define _GL_ATTRIBUTE_MALLOC #endif #if ! defined __clang__ && \ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) #else # define _GL_ATTRIBUTE_ALLOC_SIZE(args) #endif /* This function is always triggered when memory is exhausted. It must be defined by the application, either explicitly or by using gnulib's xalloc-die module. This is the function to call when one wants the program to die because of a memory allocation failure. */ extern _Noreturn void xalloc_die (void); void *xmalloc (size_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); void *xzalloc (size_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); void *xcalloc (size_t n, size_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); void *xrealloc (void *p, size_t s) _GL_ATTRIBUTE_ALLOC_SIZE ((2)); void *x2realloc (void *p, size_t *pn); void *xmemdup (void const *p, size_t s) _GL_ATTRIBUTE_ALLOC_SIZE ((2)); char *xstrdup (char const *str) _GL_ATTRIBUTE_MALLOC; /* In the following macros, T must be an elementary or structure/union or typedef'ed type, or a pointer to such a type. To apply one of the following macros to a function pointer or array type, you need to typedef it first and use the typedef name. */ /* Allocate an object of type T dynamically, with error checking. */ /* extern t *XMALLOC (typename t); */ #define XMALLOC(t) ((t *) xmalloc (sizeof (t))) /* Allocate memory for N elements of type T, with error checking. */ /* extern t *XNMALLOC (size_t n, typename t); */ #define XNMALLOC(n, t) \ ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t)))) /* Allocate an object of type T dynamically, with error checking, and zero it. */ /* extern t *XZALLOC (typename t); */ #define XZALLOC(t) ((t *) xzalloc (sizeof (t))) /* Allocate memory for N elements of type T, with error checking, and zero it. */ /* extern t *XCALLOC (size_t n, typename t); */ #define XCALLOC(n, t) \ ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t)))) /* Allocate an array of N objects, each with S bytes of memory, dynamically, with error checking. S must be nonzero. */ XALLOC_INLINE void *xnmalloc (size_t n, size_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); XALLOC_INLINE void * xnmalloc (size_t n, size_t s) { if (xalloc_oversized (n, s)) xalloc_die (); return xmalloc (n * s); } /* Change the size of an allocated block of memory P to an array of N objects each of S bytes, with error checking. S must be nonzero. */ XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s) _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); XALLOC_INLINE void * xnrealloc (void *p, size_t n, size_t s) { if (xalloc_oversized (n, s)) xalloc_die (); return xrealloc (p, n * s); } /* If P is null, allocate a block of at least *PN such objects; otherwise, reallocate P so that it contains more than *PN objects each of S bytes. S must be nonzero. Set *PN to the new number of objects, and return the pointer to the new block. *PN is never set to zero, and the returned pointer is never null. Repeated reallocations are guaranteed to make progress, either by allocating an initial block with a nonzero size, or by allocating a larger block. In the following implementation, nonzero sizes are increased by a factor of approximately 1.5 so that repeated reallocations have O(N) overall cost rather than O(N**2) cost, but the specification for this function does not guarantee that rate. Here is an example of use: int *p = NULL; size_t used = 0; size_t allocated = 0; void append_int (int value) { if (used == allocated) p = x2nrealloc (p, &allocated, sizeof *p); p[used++] = value; } This causes x2nrealloc to allocate a block of some nonzero size the first time it is called. To have finer-grained control over the initial size, set *PN to a nonzero value before calling this function with P == NULL. For example: int *p = NULL; size_t used = 0; size_t allocated = 0; size_t allocated1 = 1000; void append_int (int value) { if (used == allocated) { p = x2nrealloc (p, &allocated1, sizeof *p); allocated = allocated1; } p[used++] = value; } */ XALLOC_INLINE void * x2nrealloc (void *p, size_t *pn, size_t s) { size_t n = *pn; if (! p) { if (! n) { /* The approximate size to use for initial small allocation requests, when the invoking code specifies an old size of zero. This is the largest "small" request for the GNU C library malloc. */ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; n = DEFAULT_MXFAST / s; n += !n; } } else { /* Set N = floor (1.5 * N) + 1 so that progress is made even if N == 0. Check for overflow, so that N * S stays in size_t range. The check may be slightly conservative, but an exact check isn't worth the trouble. */ if ((size_t) -1 / 3 * 2 / s <= n) xalloc_die (); n += n / 2 + 1; } *pn = n; return xrealloc (p, n * s); } /* Return a pointer to a new buffer of N bytes. This is like xmalloc, except it returns char *. */ XALLOC_INLINE char *xcharalloc (size_t n) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); XALLOC_INLINE char * xcharalloc (size_t n) { return XNMALLOC (n, char); } #ifdef __cplusplus } /* C++ does not allow conversions from void * to other pointer types without a cast. Use templates to work around the problem when possible. */ template inline T * xrealloc (T *p, size_t s) { return (T *) xrealloc ((void *) p, s); } template inline T * xnrealloc (T *p, size_t n, size_t s) { return (T *) xnrealloc ((void *) p, n, s); } template inline T * x2realloc (T *p, size_t *pn) { return (T *) x2realloc ((void *) p, pn); } template inline T * x2nrealloc (T *p, size_t *pn, size_t s) { return (T *) x2nrealloc ((void *) p, pn, s); } template inline T * xmemdup (T const *p, size_t s) { return (T *) xmemdup ((void const *) p, s); } #endif _GL_INLINE_HEADER_END #endif /* !XALLOC_H_ */ lftp-4.6.3a/lib/mbrtowc.c0000644000015000007670000002531212466374011012151 00000000000000/* Convert multibyte character to wide character. Copyright (C) 1999-2002, 2005-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. 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 . */ #include /* Specification. */ #include #if GNULIB_defined_mbstate_t /* Implement mbrtowc() on top of mbtowc(). */ # include # include # include "localcharset.h" # include "streq.h" # include "verify.h" verify (sizeof (mbstate_t) >= 4); static char internal_state[4]; size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) { char *pstate = (char *)ps; if (s == NULL) { pwc = NULL; s = ""; n = 1; } if (n == 0) return (size_t)(-2); /* Here n > 0. */ if (pstate == NULL) pstate = internal_state; { size_t nstate = pstate[0]; char buf[4]; const char *p; size_t m; switch (nstate) { case 0: p = s; m = n; break; case 3: buf[2] = pstate[3]; /*FALLTHROUGH*/ case 2: buf[1] = pstate[2]; /*FALLTHROUGH*/ case 1: buf[0] = pstate[1]; p = buf; m = nstate; buf[m++] = s[0]; if (n >= 2 && m < 4) { buf[m++] = s[1]; if (n >= 3 && m < 4) buf[m++] = s[2]; } break; default: errno = EINVAL; return (size_t)(-1); } /* Here m > 0. */ # if __GLIBC__ || defined __UCLIBC__ /* Work around bug */ mbtowc (NULL, NULL, 0); # endif { int res = mbtowc (pwc, p, m); if (res >= 0) { if (pwc != NULL && ((*pwc == 0) != (res == 0))) abort (); if (nstate >= (res > 0 ? res : 1)) abort (); res -= nstate; pstate[0] = 0; return res; } /* mbtowc does not distinguish between invalid and incomplete multibyte sequences. But mbrtowc needs to make this distinction. There are two possible approaches: - Use iconv() and its return value. - Use built-in knowledge about the possible encodings. Given the low quality of implementation of iconv() on the systems that lack mbrtowc(), we use the second approach. The possible encodings are: - 8-bit encodings, - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS, - UTF-8. Use specialized code for each. */ if (m >= 4 || m >= MB_CUR_MAX) goto invalid; /* Here MB_CUR_MAX > 1 and 0 < m < 4. */ { const char *encoding = locale_charset (); if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) { /* Cf. unistr/u8-mblen.c. */ unsigned char c = (unsigned char) p[0]; if (c >= 0xc2) { if (c < 0xe0) { if (m == 1) goto incomplete; } else if (c < 0xf0) { if (m == 1) goto incomplete; if (m == 2) { unsigned char c2 = (unsigned char) p[1]; if ((c2 ^ 0x80) < 0x40 && (c >= 0xe1 || c2 >= 0xa0) && (c != 0xed || c2 < 0xa0)) goto incomplete; } } else if (c <= 0xf4) { if (m == 1) goto incomplete; else /* m == 2 || m == 3 */ { unsigned char c2 = (unsigned char) p[1]; if ((c2 ^ 0x80) < 0x40 && (c >= 0xf1 || c2 >= 0x90) && (c < 0xf4 || (c == 0xf4 && c2 < 0x90))) { if (m == 2) goto incomplete; else /* m == 3 */ { unsigned char c3 = (unsigned char) p[2]; if ((c3 ^ 0x80) < 0x40) goto incomplete; } } } } } goto invalid; } /* As a reference for this code, you can use the GNU libiconv implementation. Look for uses of the RET_TOOFEW macro. */ if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)) { if (m == 1) { unsigned char c = (unsigned char) p[0]; if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f) goto incomplete; } if (m == 2) { unsigned char c = (unsigned char) p[0]; if (c == 0x8f) { unsigned char c2 = (unsigned char) p[1]; if (c2 >= 0xa1 && c2 < 0xff) goto incomplete; } } goto invalid; } if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)) { if (m == 1) { unsigned char c = (unsigned char) p[0]; if (c >= 0xa1 && c < 0xff) goto incomplete; } goto invalid; } if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)) { if (m == 1) { unsigned char c = (unsigned char) p[0]; if ((c >= 0xa1 && c < 0xff) || c == 0x8e) goto incomplete; } else /* m == 2 || m == 3 */ { unsigned char c = (unsigned char) p[0]; if (c == 0x8e) goto incomplete; } goto invalid; } if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) { if (m == 1) { unsigned char c = (unsigned char) p[0]; if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) goto incomplete; } else /* m == 2 || m == 3 */ { unsigned char c = (unsigned char) p[0]; if (c >= 0x90 && c <= 0xe3) { unsigned char c2 = (unsigned char) p[1]; if (c2 >= 0x30 && c2 <= 0x39) { if (m == 2) goto incomplete; else /* m == 3 */ { unsigned char c3 = (unsigned char) p[2]; if (c3 >= 0x81 && c3 <= 0xfe) goto incomplete; } } } } goto invalid; } if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0)) { if (m == 1) { unsigned char c = (unsigned char) p[0]; if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) || (c >= 0xf0 && c <= 0xf9)) goto incomplete; } goto invalid; } /* An unknown multibyte encoding. */ goto incomplete; } incomplete: { size_t k = nstate; /* Here 0 <= k < m < 4. */ pstate[++k] = s[0]; if (k < m) { pstate[++k] = s[1]; if (k < m) pstate[++k] = s[2]; } if (k != m) abort (); } pstate[0] = m; return (size_t)(-2); invalid: errno = EILSEQ; /* The conversion state is undefined, says POSIX. */ return (size_t)(-1); } } } #else /* Override the system's mbrtowc() function. */ # undef mbrtowc size_t rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) { # if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG if (s == NULL) { pwc = NULL; s = ""; n = 1; } # endif # if MBRTOWC_EMPTY_INPUT_BUG if (n == 0) return (size_t) -2; # endif # if MBRTOWC_RETVAL_BUG { static mbstate_t internal_state; /* Override mbrtowc's internal state. We cannot call mbsinit() on the hidden internal state, but we can call it on our variable. */ if (ps == NULL) ps = &internal_state; if (!mbsinit (ps)) { /* Parse the rest of the multibyte character byte for byte. */ size_t count = 0; for (; n > 0; s++, n--) { wchar_t wc; size_t ret = mbrtowc (&wc, s, 1, ps); if (ret == (size_t)(-1)) return (size_t)(-1); count++; if (ret != (size_t)(-2)) { /* The multibyte character has been completed. */ if (pwc != NULL) *pwc = wc; return (wc == 0 ? 0 : count); } } return (size_t)(-2); } } # endif # if MBRTOWC_NUL_RETVAL_BUG { wchar_t wc; size_t ret = mbrtowc (&wc, s, n, ps); if (ret != (size_t)(-1) && ret != (size_t)(-2)) { if (pwc != NULL) *pwc = wc; if (wc == 0) ret = 0; } return ret; } # else { # if MBRTOWC_NULL_ARG1_BUG wchar_t dummy; if (pwc == NULL) pwc = &dummy; # endif return mbrtowc (pwc, s, n, ps); } # endif } #endif lftp-4.6.3a/lib/cloexec.h0000644000015000007670000000273412466374011012126 00000000000000/* closexec.c - set or clear the close-on-exec descriptor flag Copyright (C) 2004, 2009-2015 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 . */ #include /* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true, or clear the flag if VALUE is false. Return 0 on success, or -1 on error with 'errno' set. Note that on MingW, this function does NOT protect DESC from being inherited into spawned children. Instead, either use dup_cloexec followed by closing the original DESC, or use interfaces such as open or pipe2 that accept flags like O_CLOEXEC to create DESC non-inheritable in the first place. */ int set_cloexec_flag (int desc, bool value); /* Duplicates a file handle FD, while marking the copy to be closed prior to exec or spawn. Returns -1 and sets errno if FD could not be duplicated. */ int dup_cloexec (int fd); lftp-4.6.3a/lib/streq.h0000644000015000007670000000763612466374012011651 00000000000000/* Optimized string comparison. Copyright (C) 2001-2002, 2007, 2009-2015 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 . */ /* Written by Bruno Haible . */ #ifndef _GL_STREQ_H #define _GL_STREQ_H #include /* STREQ_OPT allows to optimize string comparison with a small literal string. STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) is semantically equivalent to strcmp (s, "EUC-KR") == 0 just faster. */ /* Help GCC to generate good code for string comparisons with immediate strings. */ #if defined (__GNUC__) && defined (__OPTIMIZE__) static inline int streq9 (const char *s1, const char *s2) { return strcmp (s1 + 9, s2 + 9) == 0; } static inline int streq8 (const char *s1, const char *s2, char s28) { if (s1[8] == s28) { if (s28 == 0) return 1; else return streq9 (s1, s2); } else return 0; } static inline int streq7 (const char *s1, const char *s2, char s27, char s28) { if (s1[7] == s27) { if (s27 == 0) return 1; else return streq8 (s1, s2, s28); } else return 0; } static inline int streq6 (const char *s1, const char *s2, char s26, char s27, char s28) { if (s1[6] == s26) { if (s26 == 0) return 1; else return streq7 (s1, s2, s27, s28); } else return 0; } static inline int streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28) { if (s1[5] == s25) { if (s25 == 0) return 1; else return streq6 (s1, s2, s26, s27, s28); } else return 0; } static inline int streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28) { if (s1[4] == s24) { if (s24 == 0) return 1; else return streq5 (s1, s2, s25, s26, s27, s28); } else return 0; } static inline int streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28) { if (s1[3] == s23) { if (s23 == 0) return 1; else return streq4 (s1, s2, s24, s25, s26, s27, s28); } else return 0; } static inline int streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28) { if (s1[2] == s22) { if (s22 == 0) return 1; else return streq3 (s1, s2, s23, s24, s25, s26, s27, s28); } else return 0; } static inline int streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) { if (s1[1] == s21) { if (s21 == 0) return 1; else return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28); } else return 0; } static inline int streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) { if (s1[0] == s20) { if (s20 == 0) return 1; else return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28); } else return 0; } #define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28) #else #define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ (strcmp (s1, s2) == 0) #endif #endif /* _GL_STREQ_H */ lftp-4.6.3a/lib/gettext.h0000644000015000007670000002341612466374011012170 00000000000000/* Convenience header for conditional use of GNU . Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2015 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 . */ #ifndef _LIBGETTEXT_H #define _LIBGETTEXT_H 1 /* NLS can be disabled through the configure --disable-nls option. */ #if ENABLE_NLS /* Get declarations of GNU message catalog functions. */ # include /* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by the gettext() and ngettext() macros. This is an alternative to calling textdomain(), and is useful for libraries. */ # ifdef DEFAULT_TEXT_DOMAIN # undef gettext # define gettext(Msgid) \ dgettext (DEFAULT_TEXT_DOMAIN, Msgid) # undef ngettext # define ngettext(Msgid1, Msgid2, N) \ dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) # endif #else /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which chokes if dcgettext is defined as a macro. So include it now, to make later inclusions of a NOP. We don't include as well because people using "gettext.h" will not include , and also including would fail on SunOS 4, whereas is OK. */ #if defined(__sun) # include #endif /* Many header files from the libstdc++ coming with g++ 3.3 or newer include , which chokes if dcgettext is defined as a macro. So include it now, to make later inclusions of a NOP. */ #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) # include # if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H # include # endif #endif /* Disabled NLS. The casts to 'const char *' serve the purpose of producing warnings for invalid uses of the value returned from these functions. On pre-ANSI systems without 'const', the config.h file is supposed to contain "#define const". */ # undef gettext # define gettext(Msgid) ((const char *) (Msgid)) # undef dgettext # define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) # undef dcgettext # define dcgettext(Domainname, Msgid, Category) \ ((void) (Category), dgettext (Domainname, Msgid)) # undef ngettext # define ngettext(Msgid1, Msgid2, N) \ ((N) == 1 \ ? ((void) (Msgid2), (const char *) (Msgid1)) \ : ((void) (Msgid1), (const char *) (Msgid2))) # undef dngettext # define dngettext(Domainname, Msgid1, Msgid2, N) \ ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) # undef dcngettext # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N)) # undef textdomain # define textdomain(Domainname) ((const char *) (Domainname)) # undef bindtextdomain # define bindtextdomain(Domainname, Dirname) \ ((void) (Domainname), (const char *) (Dirname)) # undef bind_textdomain_codeset # define bind_textdomain_codeset(Domainname, Codeset) \ ((void) (Domainname), (const char *) (Codeset)) #endif /* Prefer gnulib's setlocale override over libintl's setlocale override. */ #ifdef GNULIB_defined_setlocale # undef setlocale # define setlocale rpl_setlocale #endif /* A pseudo function call that serves as a marker for the automated extraction of messages, but does not call gettext(). The run-time translation is done at a different place in the code. The argument, String, should be a literal string. Concatenated strings and other string expressions won't work. The macro's expansion is not parenthesized, so that it is suitable as initializer for static 'char[]' or 'const char[]' variables. */ #define gettext_noop(String) String /* The separator between msgctxt and msgid in a .mo file. */ #define GETTEXT_CONTEXT_GLUE "\004" /* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be short and rarely need to change. The letter 'p' stands for 'particular' or 'special'. */ #ifdef DEFAULT_TEXT_DOMAIN # define pgettext(Msgctxt, Msgid) \ pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) #else # define pgettext(Msgctxt, Msgid) \ pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) #endif #define dpgettext(Domainname, Msgctxt, Msgid) \ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) #ifdef DEFAULT_TEXT_DOMAIN # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) #else # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) #endif #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static const char * pgettext_aux (const char *domain, const char *msg_ctxt_id, const char *msgid, int category) { const char *translation = dcgettext (domain, msg_ctxt_id, category); if (translation == msg_ctxt_id) return msgid; else return translation; } #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static const char * npgettext_aux (const char *domain, const char *msg_ctxt_id, const char *msgid, const char *msgid_plural, unsigned long int n, int category) { const char *translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); if (translation == msg_ctxt_id || translation == msgid_plural) return (n == 1 ? msgid : msgid_plural); else return translation; } /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID can be arbitrary expressions. But for string literals these macros are less efficient than those above. */ #include #if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ /* || __STDC_VERSION__ >= 199901L */ ) # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 #else # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 #endif #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS #include #endif #define pgettext_expr(Msgctxt, Msgid) \ dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) #define dpgettext_expr(Domainname, Msgctxt, Msgid) \ dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static const char * dcpgettext_expr (const char *domain, const char *msgctxt, const char *msgid, int category) { size_t msgctxt_len = strlen (msgctxt) + 1; size_t msgid_len = strlen (msgid) + 1; const char *translation; #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS char msg_ctxt_id[msgctxt_len + msgid_len]; #else char buf[1024]; char *msg_ctxt_id = (msgctxt_len + msgid_len <= sizeof (buf) ? buf : (char *) malloc (msgctxt_len + msgid_len)); if (msg_ctxt_id != NULL) #endif { memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); msg_ctxt_id[msgctxt_len - 1] = '\004'; memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); translation = dcgettext (domain, msg_ctxt_id, category); #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS if (msg_ctxt_id != buf) free (msg_ctxt_id); #endif if (translation != msg_ctxt_id) return translation; } return msgid; } #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) #ifdef __GNUC__ __inline #else #ifdef __cplusplus inline #endif #endif static const char * dcnpgettext_expr (const char *domain, const char *msgctxt, const char *msgid, const char *msgid_plural, unsigned long int n, int category) { size_t msgctxt_len = strlen (msgctxt) + 1; size_t msgid_len = strlen (msgid) + 1; const char *translation; #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS char msg_ctxt_id[msgctxt_len + msgid_len]; #else char buf[1024]; char *msg_ctxt_id = (msgctxt_len + msgid_len <= sizeof (buf) ? buf : (char *) malloc (msgctxt_len + msgid_len)); if (msg_ctxt_id != NULL) #endif { memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); msg_ctxt_id[msgctxt_len - 1] = '\004'; memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS if (msg_ctxt_id != buf) free (msg_ctxt_id); #endif if (!(translation == msg_ctxt_id || translation == msgid_plural)) return translation; } return (n == 1 ? msgid : msgid_plural); } #endif /* _LIBGETTEXT_H */ lftp-4.6.3a/lib/c-ctype.h0000644000015000007670000002207312466374011012046 00000000000000/* Character handling in C locale. These functions work like the corresponding functions in , except that they have the C (POSIX) locale hardwired, whereas the functions' behaviour depends on the current locale set via setlocale. Copyright (C) 2000-2003, 2006, 2008-2015 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 . */ #ifndef C_CTYPE_H #define C_CTYPE_H #include #ifdef __cplusplus extern "C" { #endif /* The functions defined in this file assume the "C" locale and a character set without diacritics (ASCII-US or EBCDIC-US or something like that). Even if the "C" locale on a particular system is an extension of the ASCII character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it is ISO-8859-1), the functions in this file recognize only the ASCII characters. */ /* Check whether the ASCII optimizations apply. */ /* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that '0', '1', ..., '9' have consecutive integer values. */ #define C_CTYPE_CONSECUTIVE_DIGITS 1 #if ('A' <= 'Z') \ && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \ && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \ && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \ && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \ && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \ && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \ && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \ && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \ && ('Y' + 1 == 'Z') #define C_CTYPE_CONSECUTIVE_UPPERCASE 1 #endif #if ('a' <= 'z') \ && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \ && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \ && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \ && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \ && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \ && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \ && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \ && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \ && ('y' + 1 == 'z') #define C_CTYPE_CONSECUTIVE_LOWERCASE 1 #endif #if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126) /* The character set is ASCII or one of its variants or extensions, not EBCDIC. Testing the value of '\n' and '\r' is not relevant. */ #define C_CTYPE_ASCII 1 #endif /* Function declarations. */ /* Unlike the functions in , which require an argument in the range of the 'unsigned char' type, the functions here operate on values that are in the 'unsigned char' range or in the 'char' range. In other words, when you have a 'char' value, you need to cast it before using it as argument to a function: const char *s = ...; if (isalpha ((unsigned char) *s)) ... but you don't need to cast it for the functions defined in this file: const char *s = ...; if (c_isalpha (*s)) ... */ extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */ extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST; extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST; extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST; extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST; extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST; extern bool c_islower (int c) _GL_ATTRIBUTE_CONST; extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST; extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST; extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST; extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST; extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST; extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST; extern int c_tolower (int c) _GL_ATTRIBUTE_CONST; extern int c_toupper (int c) _GL_ATTRIBUTE_CONST; #if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS) /* ASCII optimizations. */ #undef c_isascii #define c_isascii(c) \ ({ int __c = (c); \ (__c >= 0x00 && __c <= 0x7f); \ }) #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII #undef c_isalnum #define c_isalnum(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \ }) #else #undef c_isalnum #define c_isalnum(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || (__c >= 'A' && __c <= 'Z') \ || (__c >= 'a' && __c <= 'z')); \ }) #endif #endif #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII #undef c_isalpha #define c_isalpha(c) \ ({ int __c = (c); \ ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \ }) #else #undef c_isalpha #define c_isalpha(c) \ ({ int __c = (c); \ ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \ }) #endif #endif #undef c_isblank #define c_isblank(c) \ ({ int __c = (c); \ (__c == ' ' || __c == '\t'); \ }) #if C_CTYPE_ASCII #undef c_iscntrl #define c_iscntrl(c) \ ({ int __c = (c); \ ((__c & ~0x1f) == 0 || __c == 0x7f); \ }) #endif #if C_CTYPE_CONSECUTIVE_DIGITS #undef c_isdigit #define c_isdigit(c) \ ({ int __c = (c); \ (__c >= '0' && __c <= '9'); \ }) #endif #if C_CTYPE_CONSECUTIVE_LOWERCASE #undef c_islower #define c_islower(c) \ ({ int __c = (c); \ (__c >= 'a' && __c <= 'z'); \ }) #endif #if C_CTYPE_ASCII #undef c_isgraph #define c_isgraph(c) \ ({ int __c = (c); \ (__c >= '!' && __c <= '~'); \ }) #endif #if C_CTYPE_ASCII #undef c_isprint #define c_isprint(c) \ ({ int __c = (c); \ (__c >= ' ' && __c <= '~'); \ }) #endif #if C_CTYPE_ASCII #undef c_ispunct #define c_ispunct(c) \ ({ int _c = (c); \ (c_isgraph (_c) && ! c_isalnum (_c)); \ }) #endif #undef c_isspace #define c_isspace(c) \ ({ int __c = (c); \ (__c == ' ' || __c == '\t' \ || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \ }) #if C_CTYPE_CONSECUTIVE_UPPERCASE #undef c_isupper #define c_isupper(c) \ ({ int __c = (c); \ (__c >= 'A' && __c <= 'Z'); \ }) #endif #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII #undef c_isxdigit #define c_isxdigit(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \ }) #else #undef c_isxdigit #define c_isxdigit(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || (__c >= 'A' && __c <= 'F') \ || (__c >= 'a' && __c <= 'f')); \ }) #endif #endif #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #undef c_tolower #define c_tolower(c) \ ({ int __c = (c); \ (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \ }) #undef c_toupper #define c_toupper(c) \ ({ int __c = (c); \ (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \ }) #endif #endif /* optimizing for speed */ #ifdef __cplusplus } #endif #endif /* C_CTYPE_H */ lftp-4.6.3a/lib/parse-datetime.h0000644000015000007670000000161712466374011013407 00000000000000/* Parse a string into an internal time stamp. Copyright (C) 1995, 1997-1998, 2003-2004, 2007, 2009-2015 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 . */ #include #include bool parse_datetime (struct timespec *, char const *, struct timespec const *); lftp-4.6.3a/lib/Makefile.in0000644000015000007670000055367412540277162012420 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Copyright (C) 2002-2015 Free Software Foundation, Inc. # # This file 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 file 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 file. If not, see . # # As a special exception to the GNU General Public License, # this file may be distributed as part of a program that # contains a configuration script generated by Autoconf, under # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --libtool --macro-prefix=gl alloca-opt arpa_inet crypto/md5 crypto/sha1 environ filemode fnmatch fnmatch-gnu getopt-gnu gettext gettimeofday glob human iconv_open inet_pton lchown longlong lstat mbswidth memmem mktime modechange parse-datetime passfd poll readlink regex sockets socklen strdup-posix strftime strptime strstr strtok_r unsetenv vsnprintf vsnprintf-posix wcwidth VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_TRUE@am__append_1 = unistr/u8-mbtoucr.c @LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_TRUE@am__append_2 = unistr/u8-uctomb.c unistr/u8-uctomb-aux.c @LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE@am__append_3 = uniwidth/width.c subdir = lib DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(srcdir)/config.h.in alloca.c parse-datetime.c \ $(top_srcdir)/build-aux/depcomp $(top_srcdir)/build-aux/ylwrap \ $(noinst_HEADERS) COPYING.LIB ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/arpa_inet_h.m4 $(top_srcdir)/m4/bison.m4 \ $(top_srcdir)/m4/btowc.m4 $(top_srcdir)/m4/chown.m4 \ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/close.m4 \ $(top_srcdir)/m4/closedir.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/configmake.m4 \ $(top_srcdir)/m4/cxx-dynamic-initializers.m4 \ $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirent_h.m4 \ $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dup2.m4 \ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/exponentf.m4 \ $(top_srcdir)/m4/exponentl.m4 $(top_srcdir)/m4/extensions.m4 \ $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fcntl-o.m4 \ $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/float_h.m4 \ $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fpieee.m4 \ $(top_srcdir)/m4/frexp.m4 $(top_srcdir)/m4/frexpl.m4 \ $(top_srcdir)/m4/fstat.m4 $(top_srcdir)/m4/getdtablesize.m4 \ $(top_srcdir)/m4/getlogin_r.m4 $(top_srcdir)/m4/getopt.m4 \ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gettime.m4 \ $(top_srcdir)/m4/gettimeofday.m4 \ $(top_srcdir)/m4/gl-openssl.m4 $(top_srcdir)/m4/glibc21.m4 \ $(top_srcdir)/m4/glob.m4 $(top_srcdir)/m4/gnulib-common.m4 \ $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/human.m4 \ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/iconv_h.m4 \ $(top_srcdir)/m4/iconv_open.m4 \ $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/inet_pton.m4 \ $(top_srcdir)/m4/inline.m4 $(top_srcdir)/m4/intlmacosx.m4 \ $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/isnand.m4 \ $(top_srcdir)/m4/isnanf.m4 $(top_srcdir)/m4/isnanl.m4 \ $(top_srcdir)/m4/langinfo_h.m4 $(top_srcdir)/m4/largefile.m4 \ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/ldexpl.m4 \ $(top_srcdir)/m4/lftp.m4 $(top_srcdir)/m4/lib-ld.m4 \ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/libunistring-base.m4 \ $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \ $(top_srcdir)/m4/locale_h.m4 $(top_srcdir)/m4/localeconv.m4 \ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/malloc.m4 \ $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/math_h.m4 \ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/mbtowc.m4 \ $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memchr.m4 \ $(top_srcdir)/m4/memmem.m4 $(top_srcdir)/m4/mempcpy.m4 \ $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/modechange.m4 \ $(top_srcdir)/m4/msvc-inval.m4 \ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/needtrio.m4 $(top_srcdir)/m4/netinet_in_h.m4 \ $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \ $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/opendir.m4 \ $(top_srcdir)/m4/parse-datetime.m4 $(top_srcdir)/m4/passfd.m4 \ $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/po.m4 \ $(top_srcdir)/m4/poll.m4 $(top_srcdir)/m4/poll_h.m4 \ $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/pty.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/readdir.m4 $(top_srcdir)/m4/readline.m4 \ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/regex.m4 \ $(top_srcdir)/m4/select.m4 $(top_srcdir)/m4/setenv.m4 \ $(top_srcdir)/m4/sha1.m4 $(top_srcdir)/m4/signal_h.m4 \ $(top_srcdir)/m4/signbit.m4 $(top_srcdir)/m4/size_max.m4 \ $(top_srcdir)/m4/socketlib.m4 $(top_srcdir)/m4/sockets.m4 \ $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/sockpfaf.m4 \ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/ssl.m4 \ $(top_srcdir)/m4/st_dm_mode.m4 $(top_srcdir)/m4/stat.m4 \ $(top_srcdir)/m4/stdalign.m4 $(top_srcdir)/m4/stdbool.m4 \ $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio_h.m4 \ $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strcase.m4 \ $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/string_h.m4 \ $(top_srcdir)/m4/strings_h.m4 $(top_srcdir)/m4/strptime.m4 \ $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtok_r.m4 \ $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ $(top_srcdir)/m4/sys_select_h.m4 \ $(top_srcdir)/m4/sys_socket_h.m4 \ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ $(top_srcdir)/m4/sys_types_h.m4 $(top_srcdir)/m4/sys_uio_h.m4 \ $(top_srcdir)/m4/terminfo.m4 $(top_srcdir)/m4/threadlib.m4 \ $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \ $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/va_copy.m4 \ $(top_srcdir)/m4/vasnprintf.m4 \ $(top_srcdir)/m4/vsnprintf-posix.m4 \ $(top_srcdir)/m4/vsnprintf.m4 $(top_srcdir)/m4/wchar_h.m4 \ $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wcrtomb.m4 \ $(top_srcdir)/m4/wctype_h.m4 $(top_srcdir)/m4/wcwidth.m4 \ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrtol.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) LTLIBRARIES = $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = am__libgnu_la_SOURCES_DIST = argmatch.c c-ctype.h c-ctype.c \ c-strcase.h c-strcasecmp.c c-strncasecmp.c cloexec.c md5.c \ sha1.c exitfail.c fd-hook.c filemode.c gettext.h gettime.c \ human.c localcharset.h localcharset.c glthread/lock.h \ glthread/lock.c malloca.c math.c mbswidth.h mbswidth.c \ modechange.c parse-datetime.y passfd.c printf-frexp.c \ printf-frexpl.c quotearg.c size_max.h sockets.h sockets.c \ strftime.c strnlen1.h strnlen1.c sys_socket.c \ glthread/threadlib.c timespec.c unistd.c unistr/u8-mbtoucr.c \ unistr/u8-uctomb.c unistr/u8-uctomb-aux.c uniwidth/width.c \ wctype-h.c xmalloc.c xalloc-die.c xsize.h xsize.c xstrtol.c \ xstrtoul.c xstrtol-error.c xstrtoumax.c am__dirstamp = $(am__leading_dot)dirstamp @LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_TRUE@am__objects_1 = unistr/u8-mbtoucr.lo @LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_TRUE@am__objects_2 = unistr/u8-uctomb.lo \ @LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_TRUE@ unistr/u8-uctomb-aux.lo @LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE@am__objects_3 = \ @LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE@ uniwidth/width.lo am_libgnu_la_OBJECTS = argmatch.lo c-ctype.lo c-strcasecmp.lo \ c-strncasecmp.lo cloexec.lo md5.lo sha1.lo exitfail.lo \ fd-hook.lo filemode.lo gettime.lo human.lo localcharset.lo \ glthread/lock.lo malloca.lo math.lo mbswidth.lo modechange.lo \ parse-datetime.lo passfd.lo printf-frexp.lo printf-frexpl.lo \ quotearg.lo sockets.lo strftime.lo strnlen1.lo sys_socket.lo \ glthread/threadlib.lo timespec.lo unistd.lo $(am__objects_1) \ $(am__objects_2) $(am__objects_3) wctype-h.lo xmalloc.lo \ xalloc-die.lo xsize.lo xstrtol.lo xstrtoul.lo xstrtol-error.lo \ xstrtoumax.lo libgnu_la_OBJECTS = $(am_libgnu_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libgnu_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libgnu_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = am__yacc_c2h = sed -e s/cc$$/hh/ -e s/cpp$$/hpp/ -e s/cxx$$/hxx/ \ -e s/c++$$/h++/ -e s/c$$/h/ YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS) LTYACCCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(YACC) $(AM_YFLAGS) $(YFLAGS) AM_V_YACC = $(am__v_YACC_@AM_V@) am__v_YACC_ = $(am__v_YACC_@AM_DEFAULT_V@) am__v_YACC_0 = @echo " YACC " $@; am__v_YACC_1 = YLWRAP = $(top_srcdir)/build-aux/ylwrap SOURCES = $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES) DIST_SOURCES = $(am__libgnu_la_SOURCES_DIST) \ $(EXTRA_libgnu_la_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(noinst_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" pkglibexecdir = @pkglibexecdir@ ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ ALLOCA_H = @ALLOCA_H@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ AR = @AR@ ARFLAGS = @ARFLAGS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@ BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@ BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@ BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@ BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ COMPILE_READLINE = @COMPILE_READLINE@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@ EMULTIHOP_VALUE = @EMULTIHOP_VALUE@ ENOLINK_HIDDEN = @ENOLINK_HIDDEN@ ENOLINK_VALUE = @ENOLINK_VALUE@ EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@ EOVERFLOW_VALUE = @EOVERFLOW_VALUE@ ERRNO_H = @ERRNO_H@ EXEEXT = @EXEEXT@ EXPAT_LIBS = @EXPAT_LIBS@ FGREP = @FGREP@ FLOAT_H = @FLOAT_H@ FNMATCH_H = @FNMATCH_H@ GETOPT_H = @GETOPT_H@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GLIBC21 = @GLIBC21@ GLOB_H = @GLOB_H@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNULIB_ACCEPT = @GNULIB_ACCEPT@ GNULIB_ACCEPT4 = @GNULIB_ACCEPT4@ GNULIB_ACOSF = @GNULIB_ACOSF@ GNULIB_ACOSL = @GNULIB_ACOSL@ GNULIB_ALPHASORT = @GNULIB_ALPHASORT@ GNULIB_ASINF = @GNULIB_ASINF@ GNULIB_ASINL = @GNULIB_ASINL@ GNULIB_ATAN2F = @GNULIB_ATAN2F@ GNULIB_ATANF = @GNULIB_ATANF@ GNULIB_ATANL = @GNULIB_ATANL@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ GNULIB_BTOWC = @GNULIB_BTOWC@ GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@ GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@ GNULIB_CBRT = @GNULIB_CBRT@ GNULIB_CBRTF = @GNULIB_CBRTF@ GNULIB_CBRTL = @GNULIB_CBRTL@ GNULIB_CEIL = @GNULIB_CEIL@ GNULIB_CEILF = @GNULIB_CEILF@ GNULIB_CEILL = @GNULIB_CEILL@ GNULIB_CHDIR = @GNULIB_CHDIR@ GNULIB_CHOWN = @GNULIB_CHOWN@ GNULIB_CLOSE = @GNULIB_CLOSE@ GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@ GNULIB_CONNECT = @GNULIB_CONNECT@ GNULIB_COPYSIGN = @GNULIB_COPYSIGN@ GNULIB_COPYSIGNF = @GNULIB_COPYSIGNF@ GNULIB_COPYSIGNL = @GNULIB_COPYSIGNL@ GNULIB_COSF = @GNULIB_COSF@ GNULIB_COSHF = @GNULIB_COSHF@ GNULIB_COSL = @GNULIB_COSL@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP = @GNULIB_DUP@ GNULIB_DUP2 = @GNULIB_DUP2@ GNULIB_DUP3 = @GNULIB_DUP3@ GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ GNULIB_EXP2 = @GNULIB_EXP2@ GNULIB_EXP2F = @GNULIB_EXP2F@ GNULIB_EXP2L = @GNULIB_EXP2L@ GNULIB_EXPF = @GNULIB_EXPF@ GNULIB_EXPL = @GNULIB_EXPL@ GNULIB_EXPM1 = @GNULIB_EXPM1@ GNULIB_EXPM1F = @GNULIB_EXPM1F@ GNULIB_EXPM1L = @GNULIB_EXPM1L@ GNULIB_FABSF = @GNULIB_FABSF@ GNULIB_FABSL = @GNULIB_FABSL@ GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ GNULIB_FCNTL = @GNULIB_FCNTL@ GNULIB_FDATASYNC = @GNULIB_FDATASYNC@ GNULIB_FDOPEN = @GNULIB_FDOPEN@ GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FFS = @GNULIB_FFS@ GNULIB_FFSL = @GNULIB_FFSL@ GNULIB_FFSLL = @GNULIB_FFSLL@ GNULIB_FGETC = @GNULIB_FGETC@ GNULIB_FGETS = @GNULIB_FGETS@ GNULIB_FLOOR = @GNULIB_FLOOR@ GNULIB_FLOORF = @GNULIB_FLOORF@ GNULIB_FLOORL = @GNULIB_FLOORL@ GNULIB_FMA = @GNULIB_FMA@ GNULIB_FMAF = @GNULIB_FMAF@ GNULIB_FMAL = @GNULIB_FMAL@ GNULIB_FMOD = @GNULIB_FMOD@ GNULIB_FMODF = @GNULIB_FMODF@ GNULIB_FMODL = @GNULIB_FMODL@ GNULIB_FOPEN = @GNULIB_FOPEN@ GNULIB_FPRINTF = @GNULIB_FPRINTF@ GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@ GNULIB_FPURGE = @GNULIB_FPURGE@ GNULIB_FPUTC = @GNULIB_FPUTC@ GNULIB_FPUTS = @GNULIB_FPUTS@ GNULIB_FREAD = @GNULIB_FREAD@ GNULIB_FREOPEN = @GNULIB_FREOPEN@ GNULIB_FREXP = @GNULIB_FREXP@ GNULIB_FREXPF = @GNULIB_FREXPF@ GNULIB_FREXPL = @GNULIB_FREXPL@ GNULIB_FSCANF = @GNULIB_FSCANF@ GNULIB_FSEEK = @GNULIB_FSEEK@ GNULIB_FSEEKO = @GNULIB_FSEEKO@ GNULIB_FSTAT = @GNULIB_FSTAT@ GNULIB_FSTATAT = @GNULIB_FSTATAT@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ GNULIB_FUTIMENS = @GNULIB_FUTIMENS@ GNULIB_FWRITE = @GNULIB_FWRITE@ GNULIB_GETC = @GNULIB_GETC@ GNULIB_GETCHAR = @GNULIB_GETCHAR@ GNULIB_GETCWD = @GNULIB_GETCWD@ GNULIB_GETDELIM = @GNULIB_GETDELIM@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ GNULIB_GETLINE = @GNULIB_GETLINE@ GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@ GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ GNULIB_GETPEERNAME = @GNULIB_GETPEERNAME@ GNULIB_GETSOCKNAME = @GNULIB_GETSOCKNAME@ GNULIB_GETSOCKOPT = @GNULIB_GETSOCKOPT@ GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@ GNULIB_GETTIMEOFDAY = @GNULIB_GETTIMEOFDAY@ GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@ GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@ GNULIB_GRANTPT = @GNULIB_GRANTPT@ GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@ GNULIB_HYPOT = @GNULIB_HYPOT@ GNULIB_HYPOTF = @GNULIB_HYPOTF@ GNULIB_HYPOTL = @GNULIB_HYPOTL@ GNULIB_ICONV = @GNULIB_ICONV@ GNULIB_ILOGB = @GNULIB_ILOGB@ GNULIB_ILOGBF = @GNULIB_ILOGBF@ GNULIB_ILOGBL = @GNULIB_ILOGBL@ GNULIB_IMAXABS = @GNULIB_IMAXABS@ GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ GNULIB_INET_NTOP = @GNULIB_INET_NTOP@ GNULIB_INET_PTON = @GNULIB_INET_PTON@ GNULIB_ISATTY = @GNULIB_ISATTY@ GNULIB_ISFINITE = @GNULIB_ISFINITE@ GNULIB_ISINF = @GNULIB_ISINF@ GNULIB_ISNAN = @GNULIB_ISNAN@ GNULIB_ISNAND = @GNULIB_ISNAND@ GNULIB_ISNANF = @GNULIB_ISNANF@ GNULIB_ISNANL = @GNULIB_ISNANL@ GNULIB_ISWBLANK = @GNULIB_ISWBLANK@ GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@ GNULIB_LCHMOD = @GNULIB_LCHMOD@ GNULIB_LCHOWN = @GNULIB_LCHOWN@ GNULIB_LDEXPF = @GNULIB_LDEXPF@ GNULIB_LDEXPL = @GNULIB_LDEXPL@ GNULIB_LINK = @GNULIB_LINK@ GNULIB_LINKAT = @GNULIB_LINKAT@ GNULIB_LISTEN = @GNULIB_LISTEN@ GNULIB_LOCALECONV = @GNULIB_LOCALECONV@ GNULIB_LOG = @GNULIB_LOG@ GNULIB_LOG10 = @GNULIB_LOG10@ GNULIB_LOG10F = @GNULIB_LOG10F@ GNULIB_LOG10L = @GNULIB_LOG10L@ GNULIB_LOG1P = @GNULIB_LOG1P@ GNULIB_LOG1PF = @GNULIB_LOG1PF@ GNULIB_LOG1PL = @GNULIB_LOG1PL@ GNULIB_LOG2 = @GNULIB_LOG2@ GNULIB_LOG2F = @GNULIB_LOG2F@ GNULIB_LOG2L = @GNULIB_LOG2L@ GNULIB_LOGB = @GNULIB_LOGB@ GNULIB_LOGBF = @GNULIB_LOGBF@ GNULIB_LOGBL = @GNULIB_LOGBL@ GNULIB_LOGF = @GNULIB_LOGF@ GNULIB_LOGL = @GNULIB_LOGL@ GNULIB_LSEEK = @GNULIB_LSEEK@ GNULIB_LSTAT = @GNULIB_LSTAT@ GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@ GNULIB_MBRLEN = @GNULIB_MBRLEN@ GNULIB_MBRTOWC = @GNULIB_MBRTOWC@ GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@ GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@ GNULIB_MBSCHR = @GNULIB_MBSCHR@ GNULIB_MBSCSPN = @GNULIB_MBSCSPN@ GNULIB_MBSINIT = @GNULIB_MBSINIT@ GNULIB_MBSLEN = @GNULIB_MBSLEN@ GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@ GNULIB_MBSNLEN = @GNULIB_MBSNLEN@ GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@ GNULIB_MBSPBRK = @GNULIB_MBSPBRK@ GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@ GNULIB_MBSRCHR = @GNULIB_MBSRCHR@ GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@ GNULIB_MBSSEP = @GNULIB_MBSSEP@ GNULIB_MBSSPN = @GNULIB_MBSSPN@ GNULIB_MBSSTR = @GNULIB_MBSSTR@ GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@ GNULIB_MBTOWC = @GNULIB_MBTOWC@ GNULIB_MEMCHR = @GNULIB_MEMCHR@ GNULIB_MEMMEM = @GNULIB_MEMMEM@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ GNULIB_MKFIFO = @GNULIB_MKFIFO@ GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ GNULIB_MKNOD = @GNULIB_MKNOD@ GNULIB_MKNODAT = @GNULIB_MKNODAT@ GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@ GNULIB_MKTIME = @GNULIB_MKTIME@ GNULIB_MODF = @GNULIB_MODF@ GNULIB_MODFF = @GNULIB_MODFF@ GNULIB_MODFL = @GNULIB_MODFL@ GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@ GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@ GNULIB_NONBLOCKING = @GNULIB_NONBLOCKING@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_OPENDIR = @GNULIB_OPENDIR@ GNULIB_PCLOSE = @GNULIB_PCLOSE@ GNULIB_PERROR = @GNULIB_PERROR@ GNULIB_PIPE = @GNULIB_PIPE@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POLL = @GNULIB_POLL@ GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@ GNULIB_POWF = @GNULIB_POWF@ GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PSELECT = @GNULIB_PSELECT@ GNULIB_PTHREAD_SIGMASK = @GNULIB_PTHREAD_SIGMASK@ GNULIB_PTSNAME = @GNULIB_PTSNAME@ GNULIB_PTSNAME_R = @GNULIB_PTSNAME_R@ GNULIB_PUTC = @GNULIB_PUTC@ GNULIB_PUTCHAR = @GNULIB_PUTCHAR@ GNULIB_PUTENV = @GNULIB_PUTENV@ GNULIB_PUTS = @GNULIB_PUTS@ GNULIB_PWRITE = @GNULIB_PWRITE@ GNULIB_QSORT_R = @GNULIB_QSORT_R@ GNULIB_RAISE = @GNULIB_RAISE@ GNULIB_RANDOM = @GNULIB_RANDOM@ GNULIB_RANDOM_R = @GNULIB_RANDOM_R@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READ = @GNULIB_READ@ GNULIB_READDIR = @GNULIB_READDIR@ GNULIB_READLINK = @GNULIB_READLINK@ GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ GNULIB_REALPATH = @GNULIB_REALPATH@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ GNULIB_REMAINDER = @GNULIB_REMAINDER@ GNULIB_REMAINDERF = @GNULIB_REMAINDERF@ GNULIB_REMAINDERL = @GNULIB_REMAINDERL@ GNULIB_REMOVE = @GNULIB_REMOVE@ GNULIB_RENAME = @GNULIB_RENAME@ GNULIB_RENAMEAT = @GNULIB_RENAMEAT@ GNULIB_REWINDDIR = @GNULIB_REWINDDIR@ GNULIB_RINT = @GNULIB_RINT@ GNULIB_RINTF = @GNULIB_RINTF@ GNULIB_RINTL = @GNULIB_RINTL@ GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ GNULIB_RPMATCH = @GNULIB_RPMATCH@ GNULIB_SCANDIR = @GNULIB_SCANDIR@ GNULIB_SCANF = @GNULIB_SCANF@ GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@ GNULIB_SELECT = @GNULIB_SELECT@ GNULIB_SEND = @GNULIB_SEND@ GNULIB_SENDTO = @GNULIB_SENDTO@ GNULIB_SETENV = @GNULIB_SETENV@ GNULIB_SETHOSTNAME = @GNULIB_SETHOSTNAME@ GNULIB_SETLOCALE = @GNULIB_SETLOCALE@ GNULIB_SETSOCKOPT = @GNULIB_SETSOCKOPT@ GNULIB_SHUTDOWN = @GNULIB_SHUTDOWN@ GNULIB_SIGACTION = @GNULIB_SIGACTION@ GNULIB_SIGNAL_H_SIGPIPE = @GNULIB_SIGNAL_H_SIGPIPE@ GNULIB_SIGNBIT = @GNULIB_SIGNBIT@ GNULIB_SIGPROCMASK = @GNULIB_SIGPROCMASK@ GNULIB_SINF = @GNULIB_SINF@ GNULIB_SINHF = @GNULIB_SINHF@ GNULIB_SINL = @GNULIB_SINL@ GNULIB_SLEEP = @GNULIB_SLEEP@ GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ GNULIB_SOCKET = @GNULIB_SOCKET@ GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ GNULIB_SQRTF = @GNULIB_SQRTF@ GNULIB_SQRTL = @GNULIB_SQRTL@ GNULIB_STAT = @GNULIB_STAT@ GNULIB_STDIO_H_NONBLOCKING = @GNULIB_STDIO_H_NONBLOCKING@ GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@ GNULIB_STPCPY = @GNULIB_STPCPY@ GNULIB_STPNCPY = @GNULIB_STPNCPY@ GNULIB_STRCASESTR = @GNULIB_STRCASESTR@ GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@ GNULIB_STRDUP = @GNULIB_STRDUP@ GNULIB_STRERROR = @GNULIB_STRERROR@ GNULIB_STRERROR_R = @GNULIB_STRERROR_R@ GNULIB_STRNCAT = @GNULIB_STRNCAT@ GNULIB_STRNDUP = @GNULIB_STRNDUP@ GNULIB_STRNLEN = @GNULIB_STRNLEN@ GNULIB_STRPBRK = @GNULIB_STRPBRK@ GNULIB_STRPTIME = @GNULIB_STRPTIME@ GNULIB_STRSEP = @GNULIB_STRSEP@ GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@ GNULIB_STRSTR = @GNULIB_STRSTR@ GNULIB_STRTOD = @GNULIB_STRTOD@ GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@ GNULIB_STRTOK_R = @GNULIB_STRTOK_R@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ GNULIB_SYMLINK = @GNULIB_SYMLINK@ GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@ GNULIB_TANF = @GNULIB_TANF@ GNULIB_TANHF = @GNULIB_TANHF@ GNULIB_TANL = @GNULIB_TANL@ GNULIB_TIMEGM = @GNULIB_TIMEGM@ GNULIB_TIME_R = @GNULIB_TIME_R@ GNULIB_TMPFILE = @GNULIB_TMPFILE@ GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@ GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ GNULIB_UNLINK = @GNULIB_UNLINK@ GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ GNULIB_USLEEP = @GNULIB_USLEEP@ GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ GNULIB_VFPRINTF = @GNULIB_VFPRINTF@ GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@ GNULIB_VFSCANF = @GNULIB_VFSCANF@ GNULIB_VPRINTF = @GNULIB_VPRINTF@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ GNULIB_VSCANF = @GNULIB_VSCANF@ GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ GNULIB_WCPCPY = @GNULIB_WCPCPY@ GNULIB_WCPNCPY = @GNULIB_WCPNCPY@ GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@ GNULIB_WCSCAT = @GNULIB_WCSCAT@ GNULIB_WCSCHR = @GNULIB_WCSCHR@ GNULIB_WCSCMP = @GNULIB_WCSCMP@ GNULIB_WCSCOLL = @GNULIB_WCSCOLL@ GNULIB_WCSCPY = @GNULIB_WCSCPY@ GNULIB_WCSCSPN = @GNULIB_WCSCSPN@ GNULIB_WCSDUP = @GNULIB_WCSDUP@ GNULIB_WCSLEN = @GNULIB_WCSLEN@ GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@ GNULIB_WCSNCAT = @GNULIB_WCSNCAT@ GNULIB_WCSNCMP = @GNULIB_WCSNCMP@ GNULIB_WCSNCPY = @GNULIB_WCSNCPY@ GNULIB_WCSNLEN = @GNULIB_WCSNLEN@ GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@ GNULIB_WCSPBRK = @GNULIB_WCSPBRK@ GNULIB_WCSRCHR = @GNULIB_WCSRCHR@ GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@ GNULIB_WCSSPN = @GNULIB_WCSSPN@ GNULIB_WCSSTR = @GNULIB_WCSSTR@ GNULIB_WCSTOK = @GNULIB_WCSTOK@ GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@ GNULIB_WCSXFRM = @GNULIB_WCSXFRM@ GNULIB_WCTOB = @GNULIB_WCTOB@ GNULIB_WCTOMB = @GNULIB_WCTOMB@ GNULIB_WCTRANS = @GNULIB_WCTRANS@ GNULIB_WCTYPE = @GNULIB_WCTYPE@ GNULIB_WCWIDTH = @GNULIB_WCWIDTH@ GNULIB_WMEMCHR = @GNULIB_WMEMCHR@ GNULIB_WMEMCMP = @GNULIB_WMEMCMP@ GNULIB_WMEMCPY = @GNULIB_WMEMCPY@ GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@ GNULIB_WMEMSET = @GNULIB_WMEMSET@ GNULIB_WRITE = @GNULIB_WRITE@ GNULIB__EXIT = @GNULIB__EXIT@ GREP = @GREP@ HAVE_ACCEPT4 = @HAVE_ACCEPT4@ HAVE_ACOSF = @HAVE_ACOSF@ HAVE_ACOSL = @HAVE_ACOSL@ HAVE_ALPHASORT = @HAVE_ALPHASORT@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ASINF = @HAVE_ASINF@ HAVE_ASINL = @HAVE_ASINL@ HAVE_ATAN2F = @HAVE_ATAN2F@ HAVE_ATANF = @HAVE_ATANF@ HAVE_ATANL = @HAVE_ATANL@ HAVE_ATOLL = @HAVE_ATOLL@ HAVE_BTOWC = @HAVE_BTOWC@ HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ HAVE_CBRT = @HAVE_CBRT@ HAVE_CBRTF = @HAVE_CBRTF@ HAVE_CBRTL = @HAVE_CBRTL@ HAVE_CHOWN = @HAVE_CHOWN@ HAVE_CLOSEDIR = @HAVE_CLOSEDIR@ HAVE_COPYSIGN = @HAVE_COPYSIGN@ HAVE_COPYSIGNL = @HAVE_COPYSIGNL@ HAVE_COSF = @HAVE_COSF@ HAVE_COSHF = @HAVE_COSHF@ HAVE_COSL = @HAVE_COSL@ HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@ HAVE_DECL_ASINL = @HAVE_DECL_ASINL@ HAVE_DECL_ATANL = @HAVE_DECL_ATANL@ HAVE_DECL_CBRTF = @HAVE_DECL_CBRTF@ HAVE_DECL_CBRTL = @HAVE_DECL_CBRTL@ HAVE_DECL_CEILF = @HAVE_DECL_CEILF@ HAVE_DECL_CEILL = @HAVE_DECL_CEILL@ HAVE_DECL_COPYSIGNF = @HAVE_DECL_COPYSIGNF@ HAVE_DECL_COSL = @HAVE_DECL_COSL@ HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@ HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@ HAVE_DECL_EXP2 = @HAVE_DECL_EXP2@ HAVE_DECL_EXP2F = @HAVE_DECL_EXP2F@ HAVE_DECL_EXP2L = @HAVE_DECL_EXP2L@ HAVE_DECL_EXPL = @HAVE_DECL_EXPL@ HAVE_DECL_EXPM1L = @HAVE_DECL_EXPM1L@ HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@ HAVE_DECL_FDATASYNC = @HAVE_DECL_FDATASYNC@ HAVE_DECL_FDOPENDIR = @HAVE_DECL_FDOPENDIR@ HAVE_DECL_FLOORF = @HAVE_DECL_FLOORF@ HAVE_DECL_FLOORL = @HAVE_DECL_FLOORL@ HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@ HAVE_DECL_FREXPL = @HAVE_DECL_FREXPL@ HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@ HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@ HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@ HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@ HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@ HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@ HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@ HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@ HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@ HAVE_DECL_IMAXABS = @HAVE_DECL_IMAXABS@ HAVE_DECL_IMAXDIV = @HAVE_DECL_IMAXDIV@ HAVE_DECL_INET_NTOP = @HAVE_DECL_INET_NTOP@ HAVE_DECL_INET_PTON = @HAVE_DECL_INET_PTON@ HAVE_DECL_LDEXPL = @HAVE_DECL_LDEXPL@ HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@ HAVE_DECL_LOG10L = @HAVE_DECL_LOG10L@ HAVE_DECL_LOG2 = @HAVE_DECL_LOG2@ HAVE_DECL_LOG2F = @HAVE_DECL_LOG2F@ HAVE_DECL_LOG2L = @HAVE_DECL_LOG2L@ HAVE_DECL_LOGB = @HAVE_DECL_LOGB@ HAVE_DECL_LOGL = @HAVE_DECL_LOGL@ HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@ HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@ HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@ HAVE_DECL_REMAINDER = @HAVE_DECL_REMAINDER@ HAVE_DECL_REMAINDERL = @HAVE_DECL_REMAINDERL@ HAVE_DECL_RINTF = @HAVE_DECL_RINTF@ HAVE_DECL_ROUND = @HAVE_DECL_ROUND@ HAVE_DECL_ROUNDF = @HAVE_DECL_ROUNDF@ HAVE_DECL_ROUNDL = @HAVE_DECL_ROUNDL@ HAVE_DECL_SETENV = @HAVE_DECL_SETENV@ HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@ HAVE_DECL_SINL = @HAVE_DECL_SINL@ 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@ HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@ HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@ HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@ HAVE_DECL_TANL = @HAVE_DECL_TANL@ HAVE_DECL_TRUNC = @HAVE_DECL_TRUNC@ HAVE_DECL_TRUNCF = @HAVE_DECL_TRUNCF@ HAVE_DECL_TRUNCL = @HAVE_DECL_TRUNCL@ HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@ HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@ HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@ HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@ HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@ HAVE_DIRENT_H = @HAVE_DIRENT_H@ HAVE_DPRINTF = @HAVE_DPRINTF@ HAVE_DUP2 = @HAVE_DUP2@ HAVE_DUP3 = @HAVE_DUP3@ HAVE_DUPLOCALE = @HAVE_DUPLOCALE@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ HAVE_EXPF = @HAVE_EXPF@ HAVE_EXPL = @HAVE_EXPL@ HAVE_EXPM1 = @HAVE_EXPM1@ HAVE_EXPM1F = @HAVE_EXPM1F@ HAVE_FABSF = @HAVE_FABSF@ HAVE_FABSL = @HAVE_FABSL@ HAVE_FACCESSAT = @HAVE_FACCESSAT@ HAVE_FCHDIR = @HAVE_FCHDIR@ HAVE_FCHMODAT = @HAVE_FCHMODAT@ HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ HAVE_FCNTL = @HAVE_FCNTL@ HAVE_FDATASYNC = @HAVE_FDATASYNC@ HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ HAVE_FEATURES_H = @HAVE_FEATURES_H@ HAVE_FFS = @HAVE_FFS@ HAVE_FFSL = @HAVE_FFSL@ HAVE_FFSLL = @HAVE_FFSLL@ HAVE_FMA = @HAVE_FMA@ HAVE_FMAF = @HAVE_FMAF@ HAVE_FMAL = @HAVE_FMAL@ HAVE_FMODF = @HAVE_FMODF@ HAVE_FMODL = @HAVE_FMODL@ HAVE_FREXPF = @HAVE_FREXPF@ HAVE_FSEEKO = @HAVE_FSEEKO@ HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ HAVE_FUTIMENS = @HAVE_FUTIMENS@ HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ HAVE_GETGROUPS = @HAVE_GETGROUPS@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ HAVE_GETLOGIN = @HAVE_GETLOGIN@ HAVE_GETOPT_H = @HAVE_GETOPT_H@ HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ HAVE_GETTIMEOFDAY = @HAVE_GETTIMEOFDAY@ HAVE_GRANTPT = @HAVE_GRANTPT@ HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@ HAVE_HYPOTF = @HAVE_HYPOTF@ HAVE_HYPOTL = @HAVE_HYPOTL@ HAVE_ILOGB = @HAVE_ILOGB@ HAVE_ILOGBF = @HAVE_ILOGBF@ HAVE_ILOGBL = @HAVE_ILOGBL@ HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ HAVE_ISNAND = @HAVE_ISNAND@ HAVE_ISNANF = @HAVE_ISNANF@ HAVE_ISNANL = @HAVE_ISNANL@ HAVE_ISWBLANK = @HAVE_ISWBLANK@ HAVE_ISWCNTRL = @HAVE_ISWCNTRL@ HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@ HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@ HAVE_LANGINFO_H = @HAVE_LANGINFO_H@ HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@ HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@ HAVE_LCHMOD = @HAVE_LCHMOD@ HAVE_LCHOWN = @HAVE_LCHOWN@ HAVE_LDEXPF = @HAVE_LDEXPF@ HAVE_LINK = @HAVE_LINK@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LOG10F = @HAVE_LOG10F@ HAVE_LOG10L = @HAVE_LOG10L@ HAVE_LOG1P = @HAVE_LOG1P@ HAVE_LOG1PF = @HAVE_LOG1PF@ HAVE_LOG1PL = @HAVE_LOG1PL@ HAVE_LOGBF = @HAVE_LOGBF@ HAVE_LOGBL = @HAVE_LOGBL@ HAVE_LOGF = @HAVE_LOGF@ HAVE_LOGL = @HAVE_LOGL@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ HAVE_MBSLEN = @HAVE_MBSLEN@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMCHR = @HAVE_MEMCHR@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ HAVE_MKFIFO = @HAVE_MKFIFO@ HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ HAVE_MKNOD = @HAVE_MKNOD@ HAVE_MKNODAT = @HAVE_MKNODAT@ HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@ HAVE_MKSTEMP = @HAVE_MKSTEMP@ HAVE_MKSTEMPS = @HAVE_MKSTEMPS@ HAVE_MODFF = @HAVE_MODFF@ HAVE_MODFL = @HAVE_MODFL@ HAVE_MSVC_INVALID_PARAMETER_HANDLER = @HAVE_MSVC_INVALID_PARAMETER_HANDLER@ HAVE_NANOSLEEP = @HAVE_NANOSLEEP@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@ HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OPENDIR = @HAVE_OPENDIR@ HAVE_OS_H = @HAVE_OS_H@ HAVE_PCLOSE = @HAVE_PCLOSE@ HAVE_PIPE = @HAVE_PIPE@ HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POLL = @HAVE_POLL@ HAVE_POLL_H = @HAVE_POLL_H@ HAVE_POPEN = @HAVE_POPEN@ HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ HAVE_POWF = @HAVE_POWF@ HAVE_PREAD = @HAVE_PREAD@ HAVE_PSELECT = @HAVE_PSELECT@ HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@ HAVE_PTSNAME = @HAVE_PTSNAME@ HAVE_PTSNAME_R = @HAVE_PTSNAME_R@ HAVE_PWRITE = @HAVE_PWRITE@ HAVE_RAISE = @HAVE_RAISE@ HAVE_RANDOM = @HAVE_RANDOM@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READDIR = @HAVE_READDIR@ HAVE_READLINK = @HAVE_READLINK@ HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALPATH = @HAVE_REALPATH@ HAVE_REMAINDER = @HAVE_REMAINDER@ HAVE_REMAINDERF = @HAVE_REMAINDERF@ HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_REWINDDIR = @HAVE_REWINDDIR@ HAVE_RINT = @HAVE_RINT@ HAVE_RINTL = @HAVE_RINTL@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = @HAVE_SAME_LONG_DOUBLE_AS_DOUBLE@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ HAVE_SCANDIR = @HAVE_SCANDIR@ HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@ HAVE_SETENV = @HAVE_SETENV@ HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@ HAVE_SIGACTION = @HAVE_SIGACTION@ HAVE_SIGHANDLER_T = @HAVE_SIGHANDLER_T@ HAVE_SIGINFO_T = @HAVE_SIGINFO_T@ HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@ HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@ HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@ HAVE_SIGSET_T = @HAVE_SIGSET_T@ HAVE_SINF = @HAVE_SINF@ HAVE_SINHF = @HAVE_SINHF@ HAVE_SINL = @HAVE_SINL@ HAVE_SLEEP = @HAVE_SLEEP@ HAVE_SQRTF = @HAVE_SQRTF@ 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@ HAVE_STRTOD = @HAVE_STRTOD@ HAVE_STRTOLL = @HAVE_STRTOLL@ HAVE_STRTOULL = @HAVE_STRTOULL@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = @HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ HAVE_SYMLINK = @HAVE_SYMLINK@ HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@ HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@ HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@ HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@ HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ HAVE_SYS_UIO_H = @HAVE_SYS_UIO_H@ HAVE_TANF = @HAVE_TANF@ HAVE_TANHF = @HAVE_TANHF@ HAVE_TANL = @HAVE_TANL@ HAVE_TIMEGM = @HAVE_TIMEGM@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNLOCKPT = @HAVE_UNLOCKPT@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ HAVE_USLEEP = @HAVE_USLEEP@ HAVE_UTIMENSAT = @HAVE_UTIMENSAT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ HAVE_VDPRINTF = @HAVE_VDPRINTF@ HAVE_WCHAR_H = @HAVE_WCHAR_H@ HAVE_WCHAR_T = @HAVE_WCHAR_T@ HAVE_WCPCPY = @HAVE_WCPCPY@ HAVE_WCPNCPY = @HAVE_WCPNCPY@ HAVE_WCRTOMB = @HAVE_WCRTOMB@ HAVE_WCSCASECMP = @HAVE_WCSCASECMP@ HAVE_WCSCAT = @HAVE_WCSCAT@ HAVE_WCSCHR = @HAVE_WCSCHR@ HAVE_WCSCMP = @HAVE_WCSCMP@ HAVE_WCSCOLL = @HAVE_WCSCOLL@ HAVE_WCSCPY = @HAVE_WCSCPY@ HAVE_WCSCSPN = @HAVE_WCSCSPN@ HAVE_WCSDUP = @HAVE_WCSDUP@ HAVE_WCSLEN = @HAVE_WCSLEN@ HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@ HAVE_WCSNCAT = @HAVE_WCSNCAT@ HAVE_WCSNCMP = @HAVE_WCSNCMP@ HAVE_WCSNCPY = @HAVE_WCSNCPY@ HAVE_WCSNLEN = @HAVE_WCSNLEN@ HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@ HAVE_WCSPBRK = @HAVE_WCSPBRK@ HAVE_WCSRCHR = @HAVE_WCSRCHR@ HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@ HAVE_WCSSPN = @HAVE_WCSSPN@ HAVE_WCSSTR = @HAVE_WCSSTR@ HAVE_WCSTOK = @HAVE_WCSTOK@ HAVE_WCSWIDTH = @HAVE_WCSWIDTH@ HAVE_WCSXFRM = @HAVE_WCSXFRM@ HAVE_WCTRANS_T = @HAVE_WCTRANS_T@ HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ HAVE_WCTYPE_T = @HAVE_WCTYPE_T@ HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ HAVE_WINT_T = @HAVE_WINT_T@ HAVE_WMEMCHR = @HAVE_WMEMCHR@ HAVE_WMEMCMP = @HAVE_WMEMCMP@ HAVE_WMEMCPY = @HAVE_WMEMCPY@ HAVE_WMEMMOVE = @HAVE_WMEMMOVE@ HAVE_WMEMSET = @HAVE_WMEMSET@ HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ HAVE_XLOCALE_H = @HAVE_XLOCALE_H@ HAVE__BOOL = @HAVE__BOOL@ HAVE__EXIT = @HAVE__EXIT@ ICONV_CONST = @ICONV_CONST@ ICONV_H = @ICONV_H@ INCLUDE_NEXT = @INCLUDE_NEXT@ INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ INET_PTON_LIB = @INET_PTON_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@ INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBMULTITHREAD = @LIBMULTITHREAD@ LIBOBJS = @LIBOBJS@ LIBPTH = @LIBPTH@ LIBPTH_PREFIX = @LIBPTH_PREFIX@ LIBS = @LIBS@ LIBSOCKET = @LIBSOCKET@ LIBTHREAD = @LIBTHREAD@ LIBTOOL = @LIBTOOL@ LIBUNISTRING_UNISTR_H = @LIBUNISTRING_UNISTR_H@ LIBUNISTRING_UNITYPES_H = @LIBUNISTRING_UNITYPES_H@ LIBUNISTRING_UNIWIDTH_H = @LIBUNISTRING_UNIWIDTH_H@ LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ LIB_CRYPTO = @LIB_CRYPTO@ LIB_POLL = @LIB_POLL@ LIB_SELECT = @LIB_SELECT@ LIPO = @LIPO@ LN_S = @LN_S@ LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@ LOCALE_FR = @LOCALE_FR@ LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@ LOCALE_JA = @LOCALE_JA@ LOCALE_ZH_CN = @LOCALE_ZH_CN@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ LTLIBOBJS = @LTLIBOBJS@ LTLIBPTH = @LTLIBPTH@ LTLIBTHREAD = @LTLIBTHREAD@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NETINET_IN_H = @NETINET_IN_H@ NEXT_ARPA_INET_H = @NEXT_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H = @NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@ NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@ NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@ NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@ NEXT_AS_FIRST_DIRECTIVE_POLL_H = @NEXT_AS_FIRST_DIRECTIVE_POLL_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ 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_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H@ NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@ NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@ NEXT_DIRENT_H = @NEXT_DIRENT_H@ NEXT_ERRNO_H = @NEXT_ERRNO_H@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_FLOAT_H = @NEXT_FLOAT_H@ NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_ICONV_H = @NEXT_ICONV_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ NEXT_LANGINFO_H = @NEXT_LANGINFO_H@ NEXT_LOCALE_H = @NEXT_LOCALE_H@ NEXT_MATH_H = @NEXT_MATH_H@ NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@ NEXT_POLL_H = @NEXT_POLL_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ 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_SELECT_H = @NEXT_SYS_SELECT_H@ NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@ NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@ NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@ NEXT_SYS_UIO_H = @NEXT_SYS_UIO_H@ NEXT_TIME_H = @NEXT_TIME_H@ NEXT_UNISTD_H = @NEXT_UNISTD_H@ NEXT_WCHAR_H = @NEXT_WCHAR_H@ NEXT_WCTYPE_H = @NEXT_WCTYPE_H@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POSUB = @POSUB@ PRAGMA_COLUMNS = @PRAGMA_COLUMNS@ PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@ PRIPTR_PREFIX = @PRIPTR_PREFIX@ PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ RANLIB = @RANLIB@ READLINE = @READLINE@ READLINE_DEPEND = @READLINE_DEPEND@ READLINE_DIR = @READLINE_DIR@ REPLACE_BTOWC = @REPLACE_BTOWC@ REPLACE_CALLOC = @REPLACE_CALLOC@ REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ REPLACE_CBRTF = @REPLACE_CBRTF@ REPLACE_CBRTL = @REPLACE_CBRTL@ REPLACE_CEIL = @REPLACE_CEIL@ REPLACE_CEILF = @REPLACE_CEILF@ REPLACE_CEILL = @REPLACE_CEILL@ REPLACE_CHOWN = @REPLACE_CHOWN@ REPLACE_CLOSE = @REPLACE_CLOSE@ REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ REPLACE_DIRFD = @REPLACE_DIRFD@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ REPLACE_DUP = @REPLACE_DUP@ REPLACE_DUP2 = @REPLACE_DUP2@ REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@ REPLACE_EXP2 = @REPLACE_EXP2@ REPLACE_EXP2L = @REPLACE_EXP2L@ REPLACE_EXPM1 = @REPLACE_EXPM1@ REPLACE_EXPM1F = @REPLACE_EXPM1F@ REPLACE_FABSL = @REPLACE_FABSL@ REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ REPLACE_FCNTL = @REPLACE_FCNTL@ REPLACE_FDOPEN = @REPLACE_FDOPEN@ REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOOR = @REPLACE_FLOOR@ REPLACE_FLOORF = @REPLACE_FLOORF@ REPLACE_FLOORL = @REPLACE_FLOORL@ REPLACE_FMA = @REPLACE_FMA@ REPLACE_FMAF = @REPLACE_FMAF@ REPLACE_FMAL = @REPLACE_FMAL@ REPLACE_FMOD = @REPLACE_FMOD@ REPLACE_FMODF = @REPLACE_FMODF@ REPLACE_FMODL = @REPLACE_FMODL@ REPLACE_FOPEN = @REPLACE_FOPEN@ REPLACE_FPRINTF = @REPLACE_FPRINTF@ REPLACE_FPURGE = @REPLACE_FPURGE@ REPLACE_FREOPEN = @REPLACE_FREOPEN@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPF = @REPLACE_FREXPF@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ REPLACE_FSTAT = @REPLACE_FSTAT@ REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ REPLACE_FTRUNCATE = @REPLACE_FTRUNCATE@ REPLACE_FUTIMENS = @REPLACE_FUTIMENS@ REPLACE_GETCWD = @REPLACE_GETCWD@ REPLACE_GETDELIM = @REPLACE_GETDELIM@ REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@ REPLACE_GETDTABLESIZE = @REPLACE_GETDTABLESIZE@ REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ REPLACE_GETLINE = @REPLACE_GETLINE@ REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ REPLACE_GMTIME = @REPLACE_GMTIME@ REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@ REPLACE_HYPOT = @REPLACE_HYPOT@ REPLACE_HYPOTF = @REPLACE_HYPOTF@ REPLACE_HYPOTL = @REPLACE_HYPOTL@ REPLACE_ICONV = @REPLACE_ICONV@ REPLACE_ICONV_OPEN = @REPLACE_ICONV_OPEN@ REPLACE_ICONV_UTF = @REPLACE_ICONV_UTF@ REPLACE_ILOGB = @REPLACE_ILOGB@ REPLACE_ILOGBF = @REPLACE_ILOGBF@ REPLACE_INET_NTOP = @REPLACE_INET_NTOP@ REPLACE_INET_PTON = @REPLACE_INET_PTON@ REPLACE_ISATTY = @REPLACE_ISATTY@ REPLACE_ISFINITE = @REPLACE_ISFINITE@ REPLACE_ISINF = @REPLACE_ISINF@ REPLACE_ISNAN = @REPLACE_ISNAN@ REPLACE_ISWBLANK = @REPLACE_ISWBLANK@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_ITOLD = @REPLACE_ITOLD@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ REPLACE_LINK = @REPLACE_LINK@ REPLACE_LINKAT = @REPLACE_LINKAT@ REPLACE_LOCALECONV = @REPLACE_LOCALECONV@ REPLACE_LOCALTIME = @REPLACE_LOCALTIME@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LOG = @REPLACE_LOG@ REPLACE_LOG10 = @REPLACE_LOG10@ REPLACE_LOG10F = @REPLACE_LOG10F@ REPLACE_LOG10L = @REPLACE_LOG10L@ REPLACE_LOG1P = @REPLACE_LOG1P@ REPLACE_LOG1PF = @REPLACE_LOG1PF@ REPLACE_LOG1PL = @REPLACE_LOG1PL@ REPLACE_LOG2 = @REPLACE_LOG2@ REPLACE_LOG2F = @REPLACE_LOG2F@ REPLACE_LOG2L = @REPLACE_LOG2L@ REPLACE_LOGB = @REPLACE_LOGB@ REPLACE_LOGBF = @REPLACE_LOGBF@ REPLACE_LOGBL = @REPLACE_LOGBL@ REPLACE_LOGF = @REPLACE_LOGF@ REPLACE_LOGL = @REPLACE_LOGL@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ REPLACE_MALLOC = @REPLACE_MALLOC@ REPLACE_MBRLEN = @REPLACE_MBRLEN@ REPLACE_MBRTOWC = @REPLACE_MBRTOWC@ REPLACE_MBSINIT = @REPLACE_MBSINIT@ REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@ REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@ REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@ REPLACE_MBTOWC = @REPLACE_MBTOWC@ REPLACE_MEMCHR = @REPLACE_MEMCHR@ REPLACE_MEMMEM = @REPLACE_MEMMEM@ REPLACE_MKDIR = @REPLACE_MKDIR@ REPLACE_MKFIFO = @REPLACE_MKFIFO@ REPLACE_MKNOD = @REPLACE_MKNOD@ REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ REPLACE_MKTIME = @REPLACE_MKTIME@ REPLACE_MODF = @REPLACE_MODF@ REPLACE_MODFF = @REPLACE_MODFF@ REPLACE_MODFL = @REPLACE_MODFL@ REPLACE_NAN = @REPLACE_NAN@ REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ REPLACE_OPENAT = @REPLACE_OPENAT@ REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POLL = @REPLACE_POLL@ REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PSELECT = @REPLACE_PSELECT@ REPLACE_PTHREAD_SIGMASK = @REPLACE_PTHREAD_SIGMASK@ REPLACE_PTSNAME = @REPLACE_PTSNAME@ REPLACE_PTSNAME_R = @REPLACE_PTSNAME_R@ REPLACE_PUTENV = @REPLACE_PUTENV@ REPLACE_PWRITE = @REPLACE_PWRITE@ REPLACE_QSORT_R = @REPLACE_QSORT_R@ REPLACE_RAISE = @REPLACE_RAISE@ REPLACE_RANDOM_R = @REPLACE_RANDOM_R@ REPLACE_READ = @REPLACE_READ@ REPLACE_READLINK = @REPLACE_READLINK@ REPLACE_READLINKAT = @REPLACE_READLINKAT@ REPLACE_REALLOC = @REPLACE_REALLOC@ REPLACE_REALPATH = @REPLACE_REALPATH@ REPLACE_REMAINDER = @REPLACE_REMAINDER@ REPLACE_REMAINDERF = @REPLACE_REMAINDERF@ REPLACE_REMAINDERL = @REPLACE_REMAINDERL@ REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ REPLACE_SELECT = @REPLACE_SELECT@ REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SETLOCALE = @REPLACE_SETLOCALE@ REPLACE_SIGNBIT = @REPLACE_SIGNBIT@ REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@ REPLACE_SLEEP = @REPLACE_SLEEP@ REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ REPLACE_SPRINTF = @REPLACE_SPRINTF@ REPLACE_SQRTL = @REPLACE_SQRTL@ REPLACE_STAT = @REPLACE_STAT@ REPLACE_STDIO_READ_FUNCS = @REPLACE_STDIO_READ_FUNCS@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STPNCPY = @REPLACE_STPNCPY@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@ REPLACE_STRDUP = @REPLACE_STRDUP@ REPLACE_STRERROR = @REPLACE_STRERROR@ REPLACE_STRERROR_R = @REPLACE_STRERROR_R@ REPLACE_STRNCAT = @REPLACE_STRNCAT@ REPLACE_STRNDUP = @REPLACE_STRNDUP@ REPLACE_STRNLEN = @REPLACE_STRNLEN@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ REPLACE_STRTOIMAX = @REPLACE_STRTOIMAX@ REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ REPLACE_STRTOUMAX = @REPLACE_STRTOUMAX@ REPLACE_STRUCT_LCONV = @REPLACE_STRUCT_LCONV@ REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@ REPLACE_SYMLINK = @REPLACE_SYMLINK@ REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TMPFILE = @REPLACE_TMPFILE@ REPLACE_TOWLOWER = @REPLACE_TOWLOWER@ REPLACE_TRUNC = @REPLACE_TRUNC@ REPLACE_TRUNCF = @REPLACE_TRUNCF@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@ REPLACE_UNLINK = @REPLACE_UNLINK@ REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ REPLACE_UNSETENV = @REPLACE_UNSETENV@ REPLACE_USLEEP = @REPLACE_USLEEP@ REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ REPLACE_VDPRINTF = @REPLACE_VDPRINTF@ REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ REPLACE_VPRINTF = @REPLACE_VPRINTF@ REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@ REPLACE_VSPRINTF = @REPLACE_VSPRINTF@ REPLACE_WCRTOMB = @REPLACE_WCRTOMB@ REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@ REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@ REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@ REPLACE_WCTOB = @REPLACE_WCTOB@ REPLACE_WCTOMB = @REPLACE_WCTOMB@ REPLACE_WCWIDTH = @REPLACE_WCWIDTH@ REPLACE_WRITE = @REPLACE_WRITE@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@ SIZE_T_SUFFIX = @SIZE_T_SUFFIX@ SOCKSLIBS = @SOCKSLIBS@ STDALIGN_H = @STDALIGN_H@ STDBOOL_H = @STDBOOL_H@ STDDEF_H = @STDDEF_H@ STDINT_H = @STDINT_H@ STRIP = @STRIP@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@ UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@ UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@ UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@ WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@ WINT_T_SUFFIX = @WINT_T_SUFFIX@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ YACC = @YACC@ YFLAGS = @YFLAGS@ ZLIB = @ZLIB@ ZLIB_CPPFLAGS = @ZLIB_CPPFLAGS@ ZLIB_LDFLAGS = @ZLIB_LDFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ gl_LIBOBJS = @gl_LIBOBJS@ gl_LTLIBOBJS = @gl_LTLIBOBJS@ gltests_LIBOBJS = @gltests_LIBOBJS@ gltests_LTLIBOBJS = @gltests_LTLIBOBJS@ gltests_WITNESS = @gltests_WITNESS@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ lispdir = @lispdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects SUBDIRS = noinst_HEADERS = noinst_LIBRARIES = noinst_LTLIBRARIES = libgnu.la # If your project uses "gettextize --intl" to put a source-code # copy of libintl into the package, every Makefile.am needs # -I$(top_builddir)/intl, so that can be found in this directory. # Here's one way to do this: #AM_CPPFLAGS += -I$(top_builddir)/intl # This option has no effect when the user disables NLS (because then # the intl directory contains no libintl.h file). This option is not # enabled by default because the intl directory might not exist if # your project does not use "gettext --intl", and some compilers # complain about -I options applied to nonexistent directories. EXTRA_DIST = alloca.c alloca.in.h argmatch.h arpa_inet.in.h assure.h \ btowc.c c-strcaseeq.h chown.c fchown-stub.c cloexec.h close.c \ closedir.c dirent-private.h gl_openssl.h md5.h gl_openssl.h \ sha1.h dirent.in.h dirfd.c dosname.h dup2.c errno.in.h error.c \ error.h exitfail.h fcntl.c fcntl.in.h fd-hook.h filemode.h \ filename.h float.c float.in.h itold.c fnmatch.c fnmatch.in.h \ fnmatch_loop.c fpucw.h frexp.c frexp.c frexpl.c fstat.c \ getdtablesize.c getlogin_r.c getopt.c getopt.in.h getopt1.c \ getopt_int.h $(top_srcdir)/build-aux/config.rpath \ gettimeofday.c glob-libc.h glob.c glob.in.h \ $(top_srcdir)/build-aux/config.rpath human.h iconv.in.h \ iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h \ iconv_open-osf.h iconv_open-solaris.h iconv.c iconv_close.c \ iconv_open-aix.gperf iconv_open-hpux.gperf \ iconv_open-irix.gperf iconv_open-osf.gperf \ iconv_open-solaris.gperf iconv_open.c inet_pton.c intprops.h \ inttypes.in.h float+.h isnan.c isnand-nolibm.h isnand.c \ float+.h isnan.c isnanf-nolibm.h isnanf.c float+.h isnan.c \ isnanl-nolibm.h isnanl.c langinfo.in.h lchown.c config.charset \ ref-add.sin ref-del.sin locale.in.h localeconv.c lstat.c \ malloc.c malloca.h malloca.valgrind math.in.h mbrtowc.c \ mbsinit.c mbsrtowcs-impl.h mbsrtowcs-state.c mbsrtowcs.c \ mbtowc-impl.h mbtowc.c memchr.c memchr.valgrind memmem.c \ str-two-way.h mempcpy.c mktime-internal.h mktime.c \ modechange.h msvc-inval.c msvc-inval.h msvc-nothrow.c \ msvc-nothrow.h netinet_in.in.h nl_langinfo.c open.c \ dirent-private.h opendir.c parse-datetime.c parse-datetime.h \ passfd.h pathmax.h poll.c poll.in.h printf-frexp.h \ printf-frexp.c printf-frexpl.h quote.h quote.h quotearg.h \ dirent-private.h readdir.c readlink.c regcomp.c regex.c \ regex.h regex_internal.c regex_internal.h regexec.c select.c \ setenv.c signal.in.h float+.h signbitd.c signbitf.c signbitl.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/unused-parameter.h \ $(top_srcdir)/build-aux/snippet/warn-on-use.h w32sock.h stat.c \ stat-macros.h stdalign.in.h stdbool.in.h stddef.in.h \ stdint.in.h stdio.in.h stdlib.in.h strcasecmp.c strncasecmp.c \ strdup.c streq.h strerror.c strerror-override.c \ strerror-override.h strftime.h string.in.h strings.in.h \ strptime.c str-two-way.h strstr.c strtok_r.c strtol.c \ strtoul.c strtoull.c strtoimax.c strtoumax.c sys_select.in.h \ sys_socket.in.h sys_stat.in.h sys_time.in.h sys_types.in.h \ sys_uio.in.h $(top_srcdir)/build-aux/config.rpath time.in.h \ time_r.c timespec.h unistd.in.h unistr.in.h unitypes.in.h \ localcharset.h uniwidth.in.h uniwidth/cjk.h unsetenv.c \ asnprintf.c float+.h printf-args.c printf-args.h \ printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h \ verify.h vsnprintf.c wchar.in.h wcrtomb.c wctype.in.h \ wcwidth.c xalloc.h xalloc-oversized.h xstrtol.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 # present in all Makefile.am that need it. This is ensured by the applicability # 'all' defined above. # The BUILT_SOURCES created by this Makefile snippet are not used via #include # statements but through direct file reference. Therefore this snippet must be # present in all Makefile.am that need it. This is ensured by the applicability # 'all' defined above. # The BUILT_SOURCES created by this Makefile snippet are not used via #include # statements but through direct file reference. Therefore this snippet must be # present in all Makefile.am that need it. This is ensured by the applicability # 'all' defined above. BUILT_SOURCES = $(ALLOCA_H) arpa/inet.h configmake.h dirent.h \ $(ERRNO_H) fcntl.h $(FLOAT_H) $(FNMATCH_H) $(GETOPT_H) \ $(GLOB_H) $(ICONV_H) iconv_open-aix.h iconv_open-hpux.h \ iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h \ inttypes.h langinfo.h locale.h math.h $(NETINET_IN_H) \ parse-datetime.c poll.h signal.h arg-nonnull.h c++defs.h \ unused-parameter.h warn-on-use.h $(STDALIGN_H) $(STDBOOL_H) \ $(STDDEF_H) $(STDINT_H) stdio.h stdlib.h string.h strings.h \ sys/select.h sys/socket.h sys/stat.h sys/time.h sys/types.h \ sys/uio.h time.h unistd.h $(LIBUNISTRING_UNISTR_H) \ $(LIBUNISTRING_UNITYPES_H) $(LIBUNISTRING_UNIWIDTH_H) wchar.h \ wctype.h SUFFIXES = .sed .sin MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \ arpa/inet.h-t dirent.h dirent.h-t errno.h errno.h-t fcntl.h \ fcntl.h-t float.h float.h-t fnmatch.h fnmatch.h-t getopt.h \ getopt.h-t glob.h glob.h-t iconv.h iconv.h-t \ iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h-t \ iconv_open-osf.h-t iconv_open-solaris.h-t inttypes.h \ inttypes.h-t langinfo.h langinfo.h-t locale.h locale.h-t \ math.h math.h-t netinet/in.h netinet/in.h-t parse-datetime.c-t \ poll.h poll.h-t signal.h signal.h-t arg-nonnull.h \ arg-nonnull.h-t c++defs.h c++defs.h-t unused-parameter.h \ unused-parameter.h-t 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 strings.h strings.h-t sys/select.h \ sys/select.h-t sys/socket.h sys/socket.h-t sys/stat.h \ sys/stat.h-t sys/time.h sys/time.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 \ unistr.h unistr.h-t unitypes.h unitypes.h-t uniwidth.h \ uniwidth.h-t wchar.h wchar.h-t wctype.h wctype.h-t MOSTLYCLEANDIRS = arpa netinet sys sys sys sys CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \ ref-del.sed DISTCLEANFILES = MAINTAINERCLEANFILES = iconv_open-aix.h iconv_open-hpux.h \ iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h \ parse-datetime.c AM_CPPFLAGS = AM_CFLAGS = libgnu_la_SOURCES = argmatch.c c-ctype.h c-ctype.c c-strcase.h \ c-strcasecmp.c c-strncasecmp.c cloexec.c md5.c sha1.c \ exitfail.c fd-hook.c filemode.c gettext.h gettime.c human.c \ localcharset.h localcharset.c glthread/lock.h glthread/lock.c \ malloca.c math.c mbswidth.h mbswidth.c modechange.c \ parse-datetime.y passfd.c printf-frexp.c printf-frexpl.c \ quotearg.c size_max.h sockets.h sockets.c strftime.c \ strnlen1.h strnlen1.c sys_socket.c glthread/threadlib.c \ timespec.c unistd.c $(am__append_1) $(am__append_2) \ $(am__append_3) wctype-h.c xmalloc.c xalloc-die.c xsize.h \ xsize.c xstrtol.c xstrtoul.c xstrtol-error.c xstrtoumax.c libgnu_la_LIBADD = $(gl_LTLIBOBJS) @LTALLOCA@ libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS) @LTALLOCA@ EXTRA_libgnu_la_SOURCES = alloca.c btowc.c chown.c fchown-stub.c \ close.c closedir.c dirfd.c dup2.c error.c fcntl.c float.c \ itold.c fnmatch.c fnmatch_loop.c frexp.c frexp.c frexpl.c \ fstat.c getdtablesize.c getlogin_r.c getopt.c getopt1.c \ gettimeofday.c glob.c iconv.c iconv_close.c iconv_open.c \ inet_pton.c isnan.c isnand.c isnan.c isnanf.c isnan.c isnanl.c \ lchown.c localeconv.c lstat.c malloc.c mbrtowc.c mbsinit.c \ mbsrtowcs-state.c mbsrtowcs.c mbtowc.c memchr.c memmem.c \ mempcpy.c mktime.c msvc-inval.c msvc-nothrow.c nl_langinfo.c \ open.c opendir.c poll.c printf-frexp.c readdir.c readlink.c \ regcomp.c regex.c regex_internal.c regexec.c select.c setenv.c \ signbitd.c signbitf.c signbitl.c stat.c strcasecmp.c \ strncasecmp.c strdup.c strerror.c strerror-override.c \ strptime.c strstr.c strtok_r.c strtol.c strtoul.c strtoull.c \ strtoimax.c strtoumax.c time_r.c unsetenv.c asnprintf.c \ printf-args.c printf-parse.c vasnprintf.c vsnprintf.c \ wcrtomb.c wcwidth.c libgnu_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(INET_PTON_LIB) \ $(LIBSOCKET) $(LIB_CLOCK_GETTIME) $(LIB_CRYPTO) $(LIB_POLL) \ $(LIB_SELECT) $(LTLIBICONV) $(LTLIBINTL) $(LTLIBTHREAD) # Use this preprocessor expression to decide whether #include_next works. # Do not rely on a 'configure'-time test for this, since the expression # might appear in an installed header, which is used by some other compiler. HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER) GPERF = gperf charset_alias = $(DESTDIR)$(libdir)/charset.alias charset_tmp = $(DESTDIR)$(libdir)/charset.tmp # Because this Makefile snippet defines a variable used by other # gnulib Makefile snippets, it must be present in all Makefile.am that # need it. This is ensured by the applicability 'all' defined above. _NORETURN_H = $(top_srcdir)/build-aux/snippet/_Noreturn.h ARG_NONNULL_H = arg-nonnull.h CXXDEFS_H = c++defs.h UNUSED_PARAMETER_H = unused-parameter.h WARN_ON_USE_H = warn-on-use.h all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .sed .sin .c .lo .o .obj .y $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits lib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnits lib/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status lib/config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } glthread/$(am__dirstamp): @$(MKDIR_P) glthread @: > glthread/$(am__dirstamp) glthread/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) glthread/$(DEPDIR) @: > glthread/$(DEPDIR)/$(am__dirstamp) glthread/lock.lo: glthread/$(am__dirstamp) \ glthread/$(DEPDIR)/$(am__dirstamp) glthread/threadlib.lo: glthread/$(am__dirstamp) \ glthread/$(DEPDIR)/$(am__dirstamp) unistr/$(am__dirstamp): @$(MKDIR_P) unistr @: > unistr/$(am__dirstamp) unistr/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) unistr/$(DEPDIR) @: > unistr/$(DEPDIR)/$(am__dirstamp) unistr/u8-mbtoucr.lo: unistr/$(am__dirstamp) \ unistr/$(DEPDIR)/$(am__dirstamp) unistr/u8-uctomb.lo: unistr/$(am__dirstamp) \ unistr/$(DEPDIR)/$(am__dirstamp) unistr/u8-uctomb-aux.lo: unistr/$(am__dirstamp) \ unistr/$(DEPDIR)/$(am__dirstamp) uniwidth/$(am__dirstamp): @$(MKDIR_P) uniwidth @: > uniwidth/$(am__dirstamp) uniwidth/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) uniwidth/$(DEPDIR) @: > uniwidth/$(DEPDIR)/$(am__dirstamp) uniwidth/width.lo: uniwidth/$(am__dirstamp) \ uniwidth/$(DEPDIR)/$(am__dirstamp) libgnu.la: $(libgnu_la_OBJECTS) $(libgnu_la_DEPENDENCIES) $(EXTRA_libgnu_la_DEPENDENCIES) $(AM_V_CCLD)$(libgnu_la_LINK) $(libgnu_la_OBJECTS) $(libgnu_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f glthread/*.$(OBJEXT) -rm -f glthread/*.lo -rm -f unistr/*.$(OBJEXT) -rm -f unistr/*.lo -rm -f uniwidth/*.$(OBJEXT) -rm -f uniwidth/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloca.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argmatch.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asnprintf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btowc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-ctype.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strcasecmp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strncasecmp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chown.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cloexec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/close.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/closedir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirfd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exitfail.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchown-stub.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcntl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-hook.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filemode.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/float.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch_loop.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frexp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frexpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdtablesize.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getlogin_r.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gettime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gettimeofday.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glob.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/human.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iconv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iconv_close.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iconv_open.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_pton.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnan.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnand.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnanf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnanl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/itold.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localeconv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloca.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/math.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbrtowc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsinit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsrtowcs-state.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsrtowcs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbswidth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbtowc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memchr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memmem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempcpy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modechange.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-inval.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-nothrow.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nl_langinfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opendir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse-datetime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passfd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-args.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-frexp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-frexpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-parse.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quotearg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readdir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readlink.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regcomp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex_internal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regexec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/select.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setenv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signbitd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signbitf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signbitl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockets.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strcasecmp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror-override.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strftime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strncasecmp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strptime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strstr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoimax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtok_r.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtol.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoul.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoull.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoumax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sys_socket.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time_r.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timespec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unistd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unsetenv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vasnprintf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vsnprintf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcrtomb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctype-h.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcwidth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xalloc-die.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xsize.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtol-error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtol.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtoul.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtoumax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/lock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/threadlib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unistr/$(DEPDIR)/u8-mbtoucr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unistr/$(DEPDIR)/u8-uctomb-aux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unistr/$(DEPDIR)/u8-uctomb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@uniwidth/$(DEPDIR)/width.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< .y.c: $(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h `echo $@ | $(am__yacc_c2h)` y.output $*.output -- $(YACCCOMPILE) mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf glthread/.libs glthread/_libs -rm -rf unistr/.libs unistr/_libs -rm -rf uniwidth/.libs uniwidth/_libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) config.h \ all-local installdirs: installdirs-recursive installdirs-am: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f glthread/$(DEPDIR)/$(am__dirstamp) -rm -f glthread/$(am__dirstamp) -rm -f unistr/$(DEPDIR)/$(am__dirstamp) -rm -f unistr/$(am__dirstamp) -rm -f uniwidth/$(DEPDIR)/$(am__dirstamp) -rm -f uniwidth/$(am__dirstamp) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -rm -f parse-datetime.c -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-recursive -rm -rf $(DEPDIR) ./$(DEPDIR) glthread/$(DEPDIR) unistr/$(DEPDIR) uniwidth/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-exec-local install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf $(DEPDIR) ./$(DEPDIR) glthread/$(DEPDIR) unistr/$(DEPDIR) uniwidth/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-local .MAKE: $(am__recursive_targets) all check install install-am \ install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am all-local \ check check-am clean clean-generic clean-libtool \ clean-noinstLIBRARIES clean-noinstLTLIBRARIES cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-exec-local install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool mostlyclean-local pdf pdf-am ps ps-am tags \ tags-am uninstall uninstall-am uninstall-local # We need the following in order to create when the system # doesn't have one that works with the given compiler. @GL_GENERATE_ALLOCA_H_TRUE@alloca.h: alloca.in.h $(top_builddir)/config.status @GL_GENERATE_ALLOCA_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_ALLOCA_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @GL_GENERATE_ALLOCA_H_TRUE@ cat $(srcdir)/alloca.in.h; \ @GL_GENERATE_ALLOCA_H_TRUE@ } > $@-t && \ @GL_GENERATE_ALLOCA_H_TRUE@ mv -f $@-t $@ @GL_GENERATE_ALLOCA_H_FALSE@alloca.h: $(top_builddir)/config.status @GL_GENERATE_ALLOCA_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one. arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) arpa $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ -e 's/@''GNULIB_INET_NTOP''@/$(GNULIB_INET_NTOP)/g' \ -e 's/@''GNULIB_INET_PTON''@/$(GNULIB_INET_PTON)/g' \ -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \ -e 's|@''REPLACE_INET_PTON''@|$(REPLACE_INET_PTON)|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)/arpa_inet.in.h; \ } > $@-t && \ mv $@-t $@ # Listed in the same order as the GNU makefile conventions, and # provided by autoconf 2.59c+ or 2.70. # The Automake-defined pkg* macros are appended, in the order # listed in the Automake 1.10a+ documentation. configmake.h: Makefile $(AM_V_GEN)rm -f $@-t && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ echo '#define PREFIX "$(prefix)"'; \ echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ echo '#define BINDIR "$(bindir)"'; \ echo '#define SBINDIR "$(sbindir)"'; \ echo '#define LIBEXECDIR "$(libexecdir)"'; \ echo '#define DATAROOTDIR "$(datarootdir)"'; \ echo '#define DATADIR "$(datadir)"'; \ echo '#define SYSCONFDIR "$(sysconfdir)"'; \ echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \ echo '#define LOCALSTATEDIR "$(localstatedir)"'; \ echo '#define RUNSTATEDIR "$(runstatedir)"'; \ echo '#define INCLUDEDIR "$(includedir)"'; \ echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \ echo '#define DOCDIR "$(docdir)"'; \ echo '#define INFODIR "$(infodir)"'; \ echo '#define HTMLDIR "$(htmldir)"'; \ echo '#define DVIDIR "$(dvidir)"'; \ echo '#define PDFDIR "$(pdfdir)"'; \ echo '#define PSDIR "$(psdir)"'; \ echo '#define LIBDIR "$(libdir)"'; \ echo '#define LISPDIR "$(lispdir)"'; \ echo '#define LOCALEDIR "$(localedir)"'; \ echo '#define MANDIR "$(mandir)"'; \ echo '#define MANEXT "$(manext)"'; \ echo '#define PKGDATADIR "$(pkgdatadir)"'; \ echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \ echo '#define PKGLIBDIR "$(pkglibdir)"'; \ echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ } | sed '/""/d' > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_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_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \ -e 's/@''GNULIB_OPENDIR''@/$(GNULIB_OPENDIR)/g' \ -e 's/@''GNULIB_READDIR''@/$(GNULIB_READDIR)/g' \ -e 's/@''GNULIB_REWINDDIR''@/$(GNULIB_REWINDDIR)/g' \ -e 's/@''GNULIB_CLOSEDIR''@/$(GNULIB_CLOSEDIR)/g' \ -e 's/@''GNULIB_DIRFD''@/$(GNULIB_DIRFD)/g' \ -e 's/@''GNULIB_FDOPENDIR''@/$(GNULIB_FDOPENDIR)/g' \ -e 's/@''GNULIB_SCANDIR''@/$(GNULIB_SCANDIR)/g' \ -e 's/@''GNULIB_ALPHASORT''@/$(GNULIB_ALPHASORT)/g' \ -e 's/@''HAVE_OPENDIR''@/$(HAVE_OPENDIR)/g' \ -e 's/@''HAVE_READDIR''@/$(HAVE_READDIR)/g' \ -e 's/@''HAVE_REWINDDIR''@/$(HAVE_REWINDDIR)/g' \ -e 's/@''HAVE_CLOSEDIR''@/$(HAVE_CLOSEDIR)/g' \ -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \ -e 's|@''HAVE_DECL_FDOPENDIR''@|$(HAVE_DECL_FDOPENDIR)|g' \ -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \ -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \ -e 's|@''REPLACE_DIRFD''@|$(REPLACE_DIRFD)|g' \ -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|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)/dirent.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that is POSIX compliant. @GL_GENERATE_ERRNO_H_TRUE@errno.h: errno.in.h $(top_builddir)/config.status @GL_GENERATE_ERRNO_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_ERRNO_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ @GL_GENERATE_ERRNO_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \ @GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \ @GL_GENERATE_ERRNO_H_TRUE@ < $(srcdir)/errno.in.h; \ @GL_GENERATE_ERRNO_H_TRUE@ } > $@-t && \ @GL_GENERATE_ERRNO_H_TRUE@ mv $@-t $@ @GL_GENERATE_ERRNO_H_FALSE@errno.h: $(top_builddir)/config.status @GL_GENERATE_ERRNO_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ -e 's/@''GNULIB_FCNTL''@/$(GNULIB_FCNTL)/g' \ -e 's/@''GNULIB_NONBLOCKING''@/$(GNULIB_NONBLOCKING)/g' \ -e 's/@''GNULIB_OPEN''@/$(GNULIB_OPEN)/g' \ -e 's/@''GNULIB_OPENAT''@/$(GNULIB_OPENAT)/g' \ -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \ -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \ -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \ -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|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)/fcntl.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. @GL_GENERATE_FLOAT_H_TRUE@float.h: float.in.h $(top_builddir)/config.status @GL_GENERATE_FLOAT_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_FLOAT_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ @GL_GENERATE_FLOAT_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ @GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ @GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ @GL_GENERATE_FLOAT_H_TRUE@ -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ @GL_GENERATE_FLOAT_H_TRUE@ < $(srcdir)/float.in.h; \ @GL_GENERATE_FLOAT_H_TRUE@ } > $@-t && \ @GL_GENERATE_FLOAT_H_TRUE@ mv $@-t $@ @GL_GENERATE_FLOAT_H_FALSE@float.h: $(top_builddir)/config.status @GL_GENERATE_FLOAT_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one that supports the required API. @GL_GENERATE_FNMATCH_H_TRUE@fnmatch.h: fnmatch.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) @GL_GENERATE_FNMATCH_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_FNMATCH_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @GL_GENERATE_FNMATCH_H_TRUE@ sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ @GL_GENERATE_FNMATCH_H_TRUE@ < $(srcdir)/fnmatch.in.h; \ @GL_GENERATE_FNMATCH_H_TRUE@ } > $@-t && \ @GL_GENERATE_FNMATCH_H_TRUE@ mv -f $@-t $@ @GL_GENERATE_FNMATCH_H_FALSE@fnmatch.h: $(top_builddir)/config.status @GL_GENERATE_FNMATCH_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. getopt.h: getopt.in.h $(top_builddir)/config.status $(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_GETOPT_H''@|$(HAVE_GETOPT_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_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/getopt.in.h; \ } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. @GL_GENERATE_GLOB_H_TRUE@glob.h: glob.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) @GL_GENERATE_GLOB_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_GLOB_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @GL_GENERATE_GLOB_H_TRUE@ sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \ @GL_GENERATE_GLOB_H_TRUE@ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ @GL_GENERATE_GLOB_H_TRUE@ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ @GL_GENERATE_GLOB_H_TRUE@ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ @GL_GENERATE_GLOB_H_TRUE@ < $(srcdir)/glob.in.h; \ @GL_GENERATE_GLOB_H_TRUE@ } > $@-t && \ @GL_GENERATE_GLOB_H_TRUE@ mv -f $@-t $@ @GL_GENERATE_GLOB_H_FALSE@glob.h: $(top_builddir)/config.status @GL_GENERATE_GLOB_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. @GL_GENERATE_ICONV_H_TRUE@iconv.h: iconv.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) @GL_GENERATE_ICONV_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_ICONV_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ @GL_GENERATE_ICONV_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's|@''NEXT_ICONV_H''@|$(NEXT_ICONV_H)|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's/@''GNULIB_ICONV''@/$(GNULIB_ICONV)/g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's|@''ICONV_CONST''@|$(ICONV_CONST)|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \ @GL_GENERATE_ICONV_H_TRUE@ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ @GL_GENERATE_ICONV_H_TRUE@ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ @GL_GENERATE_ICONV_H_TRUE@ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ @GL_GENERATE_ICONV_H_TRUE@ < $(srcdir)/iconv.in.h; \ @GL_GENERATE_ICONV_H_TRUE@ } > $@-t && \ @GL_GENERATE_ICONV_H_TRUE@ mv $@-t $@ @GL_GENERATE_ICONV_H_FALSE@iconv.h: $(top_builddir)/config.status @GL_GENERATE_ICONV_H_FALSE@ rm -f $@ iconv_open-aix.h: iconv_open-aix.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-aix.gperf > $(srcdir)/iconv_open-aix.h-t mv $(srcdir)/iconv_open-aix.h-t $(srcdir)/iconv_open-aix.h iconv_open-hpux.h: iconv_open-hpux.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-hpux.gperf > $(srcdir)/iconv_open-hpux.h-t mv $(srcdir)/iconv_open-hpux.h-t $(srcdir)/iconv_open-hpux.h iconv_open-irix.h: iconv_open-irix.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-irix.gperf > $(srcdir)/iconv_open-irix.h-t mv $(srcdir)/iconv_open-irix.h-t $(srcdir)/iconv_open-irix.h iconv_open-osf.h: iconv_open-osf.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t mv $(srcdir)/iconv_open-osf.h-t $(srcdir)/iconv_open-osf.h iconv_open-solaris.h: iconv_open-solaris.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t mv $(srcdir)/iconv_open-solaris.h-t $(srcdir)/iconv_open-solaris.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. inttypes.h: inttypes.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/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_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_INTTYPES_H''@|$(NEXT_INTTYPES_H)|g' \ -e 's/@''PRI_MACROS_BROKEN''@/$(PRI_MACROS_BROKEN)/g' \ -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ -e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \ -e 's/@''GNULIB_IMAXABS''@/$(GNULIB_IMAXABS)/g' \ -e 's/@''GNULIB_IMAXDIV''@/$(GNULIB_IMAXDIV)/g' \ -e 's/@''GNULIB_STRTOIMAX''@/$(GNULIB_STRTOIMAX)/g' \ -e 's/@''GNULIB_STRTOUMAX''@/$(GNULIB_STRTOUMAX)/g' \ -e 's/@''HAVE_DECL_IMAXABS''@/$(HAVE_DECL_IMAXABS)/g' \ -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \ -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \ -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \ -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \ -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \ -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \ -e 's/@''INT64_MAX_EQ_LONG_MAX''@/$(INT64_MAX_EQ_LONG_MAX)/g' \ -e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \ -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/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)/inttypes.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create an empty placeholder for # when the system doesn't have one. langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_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_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ -e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \ -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \ -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \ -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/langinfo.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to install a simple file in $(libdir) # which is shared with other installed packages. We use a list of referencing # packages so that "make uninstall" will remove the file if and only if it # is not used by another installed package. # On systems with glibc-2.1 or newer, the file is redundant, therefore we # avoid installing it. all-local: charset.alias ref-add.sed ref-del.sed install-exec-local: install-exec-localcharset install-exec-localcharset: all-local if test $(GLIBC21) = no; then \ case '$(host_os)' in \ darwin[56]*) \ need_charset_alias=true ;; \ darwin* | cygwin* | mingw* | pw32* | cegcc*) \ need_charset_alias=false ;; \ *) \ need_charset_alias=true ;; \ esac ; \ else \ need_charset_alias=false ; \ fi ; \ if $$need_charset_alias; then \ $(mkinstalldirs) $(DESTDIR)$(libdir) ; \ fi ; \ if test -f $(charset_alias); then \ sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \ $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \ rm -f $(charset_tmp) ; \ else \ if $$need_charset_alias; then \ sed -f ref-add.sed charset.alias > $(charset_tmp) ; \ $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \ rm -f $(charset_tmp) ; \ fi ; \ fi uninstall-local: uninstall-localcharset uninstall-localcharset: all-local if test -f $(charset_alias); then \ sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \ if grep '^# Packages using this file: $$' $(charset_tmp) \ > /dev/null; then \ rm -f $(charset_alias); \ else \ $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \ fi; \ rm -f $(charset_tmp); \ fi charset.alias: config.charset $(AM_V_GEN)rm -f t-$@ $@ && \ $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \ mv t-$@ $@ .sin.sed: $(AM_V_GEN)rm -f t-$@ $@ && \ sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \ mv t-$@ $@ # We need the following in order to create when the system # doesn't have one that provides all definitions. locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \ -e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \ -e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \ -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \ -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \ -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|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)/locale.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \ -e 's/@''GNULIB_ACOSF''@/$(GNULIB_ACOSF)/g' \ -e 's/@''GNULIB_ACOSL''@/$(GNULIB_ACOSL)/g' \ -e 's/@''GNULIB_ASINF''@/$(GNULIB_ASINF)/g' \ -e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \ -e 's/@''GNULIB_ATANF''@/$(GNULIB_ATANF)/g' \ -e 's/@''GNULIB_ATANL''@/$(GNULIB_ATANL)/g' \ -e 's/@''GNULIB_ATAN2F''@/$(GNULIB_ATAN2F)/g' \ -e 's/@''GNULIB_CBRT''@/$(GNULIB_CBRT)/g' \ -e 's/@''GNULIB_CBRTF''@/$(GNULIB_CBRTF)/g' \ -e 's/@''GNULIB_CBRTL''@/$(GNULIB_CBRTL)/g' \ -e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \ -e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \ -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \ -e 's/@''GNULIB_COPYSIGN''@/$(GNULIB_COPYSIGN)/g' \ -e 's/@''GNULIB_COPYSIGNF''@/$(GNULIB_COPYSIGNF)/g' \ -e 's/@''GNULIB_COPYSIGNL''@/$(GNULIB_COPYSIGNL)/g' \ -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \ -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \ -e 's/@''GNULIB_COSHF''@/$(GNULIB_COSHF)/g' \ -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \ -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \ -e 's/@''GNULIB_EXP2''@/$(GNULIB_EXP2)/g' \ -e 's/@''GNULIB_EXP2F''@/$(GNULIB_EXP2F)/g' \ -e 's/@''GNULIB_EXP2L''@/$(GNULIB_EXP2L)/g' \ -e 's/@''GNULIB_EXPM1''@/$(GNULIB_EXPM1)/g' \ -e 's/@''GNULIB_EXPM1F''@/$(GNULIB_EXPM1F)/g' \ -e 's/@''GNULIB_EXPM1L''@/$(GNULIB_EXPM1L)/g' \ -e 's/@''GNULIB_FABSF''@/$(GNULIB_FABSF)/g' \ -e 's/@''GNULIB_FABSL''@/$(GNULIB_FABSL)/g' \ -e 's/@''GNULIB_FLOOR''@/$(GNULIB_FLOOR)/g' \ -e 's/@''GNULIB_FLOORF''@/$(GNULIB_FLOORF)/g' \ -e 's/@''GNULIB_FLOORL''@/$(GNULIB_FLOORL)/g' \ -e 's/@''GNULIB_FMA''@/$(GNULIB_FMA)/g' \ -e 's/@''GNULIB_FMAF''@/$(GNULIB_FMAF)/g' \ -e 's/@''GNULIB_FMAL''@/$(GNULIB_FMAL)/g' \ -e 's/@''GNULIB_FMOD''@/$(GNULIB_FMOD)/g' \ -e 's/@''GNULIB_FMODF''@/$(GNULIB_FMODF)/g' \ -e 's/@''GNULIB_FMODL''@/$(GNULIB_FMODL)/g' \ -e 's/@''GNULIB_FREXPF''@/$(GNULIB_FREXPF)/g' \ -e 's/@''GNULIB_FREXP''@/$(GNULIB_FREXP)/g' \ -e 's/@''GNULIB_FREXPL''@/$(GNULIB_FREXPL)/g' \ -e 's/@''GNULIB_HYPOT''@/$(GNULIB_HYPOT)/g' \ -e 's/@''GNULIB_HYPOTF''@/$(GNULIB_HYPOTF)/g' \ -e 's/@''GNULIB_HYPOTL''@/$(GNULIB_HYPOTL)/g' \ < $(srcdir)/math.in.h | \ sed -e 's/@''GNULIB_ILOGB''@/$(GNULIB_ILOGB)/g' \ -e 's/@''GNULIB_ILOGBF''@/$(GNULIB_ILOGBF)/g' \ -e 's/@''GNULIB_ILOGBL''@/$(GNULIB_ILOGBL)/g' \ -e 's/@''GNULIB_ISFINITE''@/$(GNULIB_ISFINITE)/g' \ -e 's/@''GNULIB_ISINF''@/$(GNULIB_ISINF)/g' \ -e 's/@''GNULIB_ISNAN''@/$(GNULIB_ISNAN)/g' \ -e 's/@''GNULIB_ISNANF''@/$(GNULIB_ISNANF)/g' \ -e 's/@''GNULIB_ISNAND''@/$(GNULIB_ISNAND)/g' \ -e 's/@''GNULIB_ISNANL''@/$(GNULIB_ISNANL)/g' \ -e 's/@''GNULIB_LDEXPF''@/$(GNULIB_LDEXPF)/g' \ -e 's/@''GNULIB_LDEXPL''@/$(GNULIB_LDEXPL)/g' \ -e 's/@''GNULIB_LOG''@/$(GNULIB_LOG)/g' \ -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \ -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \ -e 's/@''GNULIB_LOG10''@/$(GNULIB_LOG10)/g' \ -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \ -e 's/@''GNULIB_LOG10L''@/$(GNULIB_LOG10L)/g' \ -e 's/@''GNULIB_LOG1P''@/$(GNULIB_LOG1P)/g' \ -e 's/@''GNULIB_LOG1PF''@/$(GNULIB_LOG1PF)/g' \ -e 's/@''GNULIB_LOG1PL''@/$(GNULIB_LOG1PL)/g' \ -e 's/@''GNULIB_LOG2''@/$(GNULIB_LOG2)/g' \ -e 's/@''GNULIB_LOG2F''@/$(GNULIB_LOG2F)/g' \ -e 's/@''GNULIB_LOG2L''@/$(GNULIB_LOG2L)/g' \ -e 's/@''GNULIB_LOGB''@/$(GNULIB_LOGB)/g' \ -e 's/@''GNULIB_LOGBF''@/$(GNULIB_LOGBF)/g' \ -e 's/@''GNULIB_LOGBL''@/$(GNULIB_LOGBL)/g' \ -e 's/@''GNULIB_MODF''@/$(GNULIB_MODF)/g' \ -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \ -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \ -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \ -e 's/@''GNULIB_REMAINDER''@/$(GNULIB_REMAINDER)/g' \ -e 's/@''GNULIB_REMAINDERF''@/$(GNULIB_REMAINDERF)/g' \ -e 's/@''GNULIB_REMAINDERL''@/$(GNULIB_REMAINDERL)/g' \ -e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \ -e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \ -e 's/@''GNULIB_RINTL''@/$(GNULIB_RINTL)/g' \ -e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \ -e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \ -e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \ -e 's/@''GNULIB_SIGNBIT''@/$(GNULIB_SIGNBIT)/g' \ -e 's/@''GNULIB_SINF''@/$(GNULIB_SINF)/g' \ -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \ -e 's/@''GNULIB_SINHF''@/$(GNULIB_SINHF)/g' \ -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \ -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \ -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \ -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \ -e 's/@''GNULIB_TANHF''@/$(GNULIB_TANHF)/g' \ -e 's/@''GNULIB_TRUNC''@/$(GNULIB_TRUNC)/g' \ -e 's/@''GNULIB_TRUNCF''@/$(GNULIB_TRUNCF)/g' \ -e 's/@''GNULIB_TRUNCL''@/$(GNULIB_TRUNCL)/g' \ | \ sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \ -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \ -e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \ -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \ -e 's|@''HAVE_ATANF''@|$(HAVE_ATANF)|g' \ -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \ -e 's|@''HAVE_ATAN2F''@|$(HAVE_ATAN2F)|g' \ -e 's|@''HAVE_CBRT''@|$(HAVE_CBRT)|g' \ -e 's|@''HAVE_CBRTF''@|$(HAVE_CBRTF)|g' \ -e 's|@''HAVE_CBRTL''@|$(HAVE_CBRTL)|g' \ -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \ -e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \ -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \ -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \ -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \ -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \ -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \ -e 's|@''HAVE_EXPM1''@|$(HAVE_EXPM1)|g' \ -e 's|@''HAVE_EXPM1F''@|$(HAVE_EXPM1F)|g' \ -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \ -e 's|@''HAVE_FABSL''@|$(HAVE_FABSL)|g' \ -e 's|@''HAVE_FMA''@|$(HAVE_FMA)|g' \ -e 's|@''HAVE_FMAF''@|$(HAVE_FMAF)|g' \ -e 's|@''HAVE_FMAL''@|$(HAVE_FMAL)|g' \ -e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \ -e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \ -e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \ -e 's|@''HAVE_HYPOTF''@|$(HAVE_HYPOTF)|g' \ -e 's|@''HAVE_HYPOTL''@|$(HAVE_HYPOTL)|g' \ -e 's|@''HAVE_ILOGB''@|$(HAVE_ILOGB)|g' \ -e 's|@''HAVE_ILOGBF''@|$(HAVE_ILOGBF)|g' \ -e 's|@''HAVE_ILOGBL''@|$(HAVE_ILOGBL)|g' \ -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \ -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \ -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \ -e 's|@''HAVE_LDEXPF''@|$(HAVE_LDEXPF)|g' \ -e 's|@''HAVE_LOGF''@|$(HAVE_LOGF)|g' \ -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \ -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \ -e 's|@''HAVE_LOG10L''@|$(HAVE_LOG10L)|g' \ -e 's|@''HAVE_LOG1P''@|$(HAVE_LOG1P)|g' \ -e 's|@''HAVE_LOG1PF''@|$(HAVE_LOG1PF)|g' \ -e 's|@''HAVE_LOG1PL''@|$(HAVE_LOG1PL)|g' \ -e 's|@''HAVE_LOGBF''@|$(HAVE_LOGBF)|g' \ -e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \ -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \ -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \ -e 's|@''HAVE_REMAINDER''@|$(HAVE_REMAINDER)|g' \ -e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \ -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \ -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \ -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \ -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \ -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \ -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \ -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \ -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \ -e 's|@''HAVE_TANHF''@|$(HAVE_TANHF)|g' \ -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ -e 's|@''HAVE_DECL_CBRTF''@|$(HAVE_DECL_CBRTF)|g' \ -e 's|@''HAVE_DECL_CBRTL''@|$(HAVE_DECL_CBRTL)|g' \ -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \ -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \ -e 's|@''HAVE_DECL_COPYSIGNF''@|$(HAVE_DECL_COPYSIGNF)|g' \ -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ -e 's|@''HAVE_DECL_EXP2''@|$(HAVE_DECL_EXP2)|g' \ -e 's|@''HAVE_DECL_EXP2F''@|$(HAVE_DECL_EXP2F)|g' \ -e 's|@''HAVE_DECL_EXP2L''@|$(HAVE_DECL_EXP2L)|g' \ -e 's|@''HAVE_DECL_EXPM1L''@|$(HAVE_DECL_EXPM1L)|g' \ -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \ -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \ -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ -e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \ -e 's|@''HAVE_DECL_LOG2''@|$(HAVE_DECL_LOG2)|g' \ -e 's|@''HAVE_DECL_LOG2F''@|$(HAVE_DECL_LOG2F)|g' \ -e 's|@''HAVE_DECL_LOG2L''@|$(HAVE_DECL_LOG2L)|g' \ -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \ -e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \ -e 's|@''HAVE_DECL_REMAINDERL''@|$(HAVE_DECL_REMAINDERL)|g' \ -e 's|@''HAVE_DECL_RINTF''@|$(HAVE_DECL_RINTF)|g' \ -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \ -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \ -e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \ -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \ -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \ -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ | \ sed -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \ -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \ -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \ -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \ -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \ -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \ -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \ -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \ -e 's|@''REPLACE_FLOOR''@|$(REPLACE_FLOOR)|g' \ -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \ -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \ -e 's|@''REPLACE_FMA''@|$(REPLACE_FMA)|g' \ -e 's|@''REPLACE_FMAF''@|$(REPLACE_FMAF)|g' \ -e 's|@''REPLACE_FMAL''@|$(REPLACE_FMAL)|g' \ -e 's|@''REPLACE_FMOD''@|$(REPLACE_FMOD)|g' \ -e 's|@''REPLACE_FMODF''@|$(REPLACE_FMODF)|g' \ -e 's|@''REPLACE_FMODL''@|$(REPLACE_FMODL)|g' \ -e 's|@''REPLACE_FREXPF''@|$(REPLACE_FREXPF)|g' \ -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \ -e 's|@''REPLACE_HYPOT''@|$(REPLACE_HYPOT)|g' \ -e 's|@''REPLACE_HYPOTF''@|$(REPLACE_HYPOTF)|g' \ -e 's|@''REPLACE_HYPOTL''@|$(REPLACE_HYPOTL)|g' \ -e 's|@''REPLACE_ILOGB''@|$(REPLACE_ILOGB)|g' \ -e 's|@''REPLACE_ILOGBF''@|$(REPLACE_ILOGBF)|g' \ -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \ -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \ -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \ -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \ -e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \ -e 's|@''REPLACE_LOG10''@|$(REPLACE_LOG10)|g' \ -e 's|@''REPLACE_LOG10F''@|$(REPLACE_LOG10F)|g' \ -e 's|@''REPLACE_LOG10L''@|$(REPLACE_LOG10L)|g' \ -e 's|@''REPLACE_LOG1P''@|$(REPLACE_LOG1P)|g' \ -e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \ -e 's|@''REPLACE_LOG1PL''@|$(REPLACE_LOG1PL)|g' \ -e 's|@''REPLACE_LOG2''@|$(REPLACE_LOG2)|g' \ -e 's|@''REPLACE_LOG2F''@|$(REPLACE_LOG2F)|g' \ -e 's|@''REPLACE_LOG2L''@|$(REPLACE_LOG2L)|g' \ -e 's|@''REPLACE_LOGB''@|$(REPLACE_LOGB)|g' \ -e 's|@''REPLACE_LOGBF''@|$(REPLACE_LOGBF)|g' \ -e 's|@''REPLACE_LOGBL''@|$(REPLACE_LOGBL)|g' \ -e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \ -e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \ -e 's|@''REPLACE_MODFL''@|$(REPLACE_MODFL)|g' \ -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \ -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \ -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \ -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \ -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|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)'; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one. @GL_GENERATE_NETINET_IN_H_TRUE@netinet/in.h: netinet_in.in.h $(top_builddir)/config.status @GL_GENERATE_NETINET_IN_H_TRUE@ $(AM_V_at)$(MKDIR_P) netinet @GL_GENERATE_NETINET_IN_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_NETINET_IN_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @GL_GENERATE_NETINET_IN_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ @GL_GENERATE_NETINET_IN_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @GL_GENERATE_NETINET_IN_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @GL_GENERATE_NETINET_IN_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ @GL_GENERATE_NETINET_IN_H_TRUE@ -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ @GL_GENERATE_NETINET_IN_H_TRUE@ -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ @GL_GENERATE_NETINET_IN_H_TRUE@ < $(srcdir)/netinet_in.in.h; \ @GL_GENERATE_NETINET_IN_H_TRUE@ } > $@-t && \ @GL_GENERATE_NETINET_IN_H_TRUE@ mv $@-t $@ @GL_GENERATE_NETINET_IN_H_FALSE@netinet/in.h: $(top_builddir)/config.status @GL_GENERATE_NETINET_IN_H_FALSE@ rm -f $@ # This rule overrides the Automake generated .y.c rule, to ensure that the # parse-datetime.c file gets generated in the source directory, not in the # build directory. parse-datetime.c: parse-datetime.y $(AM_V_GEN)$(SHELL) $(YLWRAP) $(srcdir)/parse-datetime.y \ y.tab.c parse-datetime.c \ y.tab.h parse-datetime.h \ y.output parse-datetime.output \ -- $(YACC) $(YFLAGS) $(AM_YFLAGS) && \ mv parse-datetime.c parse-datetime.c-t && \ mv parse-datetime.c-t $(srcdir)/parse-datetime.c # We need the following in order to create when the system # doesn't have one. poll.h: poll.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''HAVE_POLL_H''@|$(HAVE_POLL_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_POLL_H''@|$(NEXT_POLL_H)|g' \ -e 's/@''GNULIB_POLL''@/$(GNULIB_POLL)/g' \ -e 's|@''HAVE_POLL''@|$(HAVE_POLL)|g' \ -e 's|@''REPLACE_POLL''@|$(REPLACE_POLL)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/poll.in.h; \ } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # doesn't have a complete one. signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \ -e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \ -e 's|@''GNULIB_RAISE''@|$(GNULIB_RAISE)|g' \ -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \ -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \ -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \ -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \ -e 's|@''HAVE_RAISE''@|$(HAVE_RAISE)|g' \ -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \ -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \ -e 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g' \ -e 's|@''REPLACE_RAISE''@|$(REPLACE_RAISE)|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)/signal.in.h; \ } > $@-t && \ mv $@-t $@ # The arg-nonnull.h that gets inserted into generated .h files is the same as # build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut # off. arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h $(AM_V_GEN)rm -f $@-t $@ && \ sed -n -e '/GL_ARG_NONNULL/,$$p' \ < $(top_srcdir)/build-aux/snippet/arg-nonnull.h \ > $@-t && \ mv $@-t $@ # The c++defs.h that gets inserted into generated .h files is the same as # build-aux/snippet/c++defs.h, except that it has the copyright header cut off. c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h $(AM_V_GEN)rm -f $@-t $@ && \ sed -n -e '/_GL_CXXDEFS/,$$p' \ < $(top_srcdir)/build-aux/snippet/c++defs.h \ > $@-t && \ mv $@-t $@ # The unused-parameter.h that gets inserted into generated .h files is the same # as build-aux/snippet/unused-parameter.h, except that it has the copyright # header cut off. unused-parameter.h: $(top_srcdir)/build-aux/snippet/unused-parameter.h $(AM_V_GEN)rm -f $@-t $@ && \ sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \ < $(top_srcdir)/build-aux/snippet/unused-parameter.h \ > $@-t && \ mv $@-t $@ # The warn-on-use.h that gets inserted into generated .h files is the same as # build-aux/snippet/warn-on-use.h, except that it has the copyright header cut # off. warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h $(AM_V_GEN)rm -f $@-t $@ && \ sed -n -e '/^.ifndef/,$$p' \ < $(top_srcdir)/build-aux/snippet/warn-on-use.h \ > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works. @GL_GENERATE_STDALIGN_H_TRUE@stdalign.h: stdalign.in.h $(top_builddir)/config.status @GL_GENERATE_STDALIGN_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_STDALIGN_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @GL_GENERATE_STDALIGN_H_TRUE@ cat $(srcdir)/stdalign.in.h; \ @GL_GENERATE_STDALIGN_H_TRUE@ } > $@-t && \ @GL_GENERATE_STDALIGN_H_TRUE@ mv $@-t $@ @GL_GENERATE_STDALIGN_H_FALSE@stdalign.h: $(top_builddir)/config.status @GL_GENERATE_STDALIGN_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one that works. @GL_GENERATE_STDBOOL_H_TRUE@stdbool.h: stdbool.in.h $(top_builddir)/config.status @GL_GENERATE_STDBOOL_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_STDBOOL_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @GL_GENERATE_STDBOOL_H_TRUE@ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ @GL_GENERATE_STDBOOL_H_TRUE@ } > $@-t && \ @GL_GENERATE_STDBOOL_H_TRUE@ mv $@-t $@ @GL_GENERATE_STDBOOL_H_FALSE@stdbool.h: $(top_builddir)/config.status @GL_GENERATE_STDBOOL_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. @GL_GENERATE_STDDEF_H_TRUE@stddef.h: stddef.in.h $(top_builddir)/config.status @GL_GENERATE_STDDEF_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_STDDEF_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ @GL_GENERATE_STDDEF_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ @GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ @GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ @GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \ @GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ @GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ @GL_GENERATE_STDDEF_H_TRUE@ < $(srcdir)/stddef.in.h; \ @GL_GENERATE_STDDEF_H_TRUE@ } > $@-t && \ @GL_GENERATE_STDDEF_H_TRUE@ mv $@-t $@ @GL_GENERATE_STDDEF_H_FALSE@stddef.h: $(top_builddir)/config.status @GL_GENERATE_STDDEF_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. @GL_GENERATE_STDINT_H_TRUE@stdint.h: stdint.in.h $(top_builddir)/config.status @GL_GENERATE_STDINT_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \ @GL_GENERATE_STDINT_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @GL_GENERATE_STDINT_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ @GL_GENERATE_STDINT_H_TRUE@ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ @GL_GENERATE_STDINT_H_TRUE@ < $(srcdir)/stdint.in.h; \ @GL_GENERATE_STDINT_H_TRUE@ } > $@-t && \ @GL_GENERATE_STDINT_H_TRUE@ mv $@-t $@ @GL_GENERATE_STDINT_H_FALSE@stdint.h: $(top_builddir)/config.status @GL_GENERATE_STDINT_H_FALSE@ rm -f $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_STDIO_H''@|$(NEXT_STDIO_H)|g' \ -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \ -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \ -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \ -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \ -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \ -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \ -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \ -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \ -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \ -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \ -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \ -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \ -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \ -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \ -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \ -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \ -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \ -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \ -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \ -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \ -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \ -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \ -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \ -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \ -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \ -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \ -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \ -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \ -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \ -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \ -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \ -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \ -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \ -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \ -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \ -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \ -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \ -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \ -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \ -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \ -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \ -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \ -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \ -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \ -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \ -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \ -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \ -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \ -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \ -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \ -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \ < $(srcdir)/stdio.in.h | \ sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \ -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \ -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \ -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \ -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \ -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \ -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ -e 's|@''REPLACE_STDIO_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|g' \ -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \ -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|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)'; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \ -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \ -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \ -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \ -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \ -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \ -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \ -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \ -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/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_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \ -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \ -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \ -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \ -e 's/@''GNULIB_QSORT_R''@/$(GNULIB_QSORT_R)/g' \ -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \ -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \ -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \ -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \ -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \ -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \ -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \ -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \ -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \ -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \ -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \ -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \ -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \ -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \ < $(srcdir)/stdlib.in.h | \ sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|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_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \ -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \ -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \ -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \ -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _Noreturn/r $(_NORETURN_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_STRING_H''@|$(NEXT_STRING_H)|g' \ -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \ -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \ -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \ -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \ -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \ -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \ -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \ -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \ -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \ -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \ -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \ -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \ -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \ -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \ -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \ -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \ -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \ -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \ -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \ -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \ -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \ -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \ -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \ -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \ -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \ -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \ -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \ -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \ -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \ -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \ -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \ -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \ -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \ -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \ -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \ -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \ -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \ < $(srcdir)/string.in.h | \ sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \ -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|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)/string.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create 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 when the system # doesn't have one that works with the given compiler. sys/select.h: sys_select.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \ -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \ -e 's/@''GNULIB_PSELECT''@/$(GNULIB_PSELECT)/g' \ -e 's/@''GNULIB_SELECT''@/$(GNULIB_SELECT)/g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_PSELECT''@|$(HAVE_PSELECT)|g' \ -e 's|@''REPLACE_PSELECT''@|$(REPLACE_PSELECT)|g' \ -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/sys_select.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create 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) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ -e 's/@''GNULIB_SOCKET''@/$(GNULIB_SOCKET)/g' \ -e 's/@''GNULIB_CONNECT''@/$(GNULIB_CONNECT)/g' \ -e 's/@''GNULIB_ACCEPT''@/$(GNULIB_ACCEPT)/g' \ -e 's/@''GNULIB_BIND''@/$(GNULIB_BIND)/g' \ -e 's/@''GNULIB_GETPEERNAME''@/$(GNULIB_GETPEERNAME)/g' \ -e 's/@''GNULIB_GETSOCKNAME''@/$(GNULIB_GETSOCKNAME)/g' \ -e 's/@''GNULIB_GETSOCKOPT''@/$(GNULIB_GETSOCKOPT)/g' \ -e 's/@''GNULIB_LISTEN''@/$(GNULIB_LISTEN)/g' \ -e 's/@''GNULIB_RECV''@/$(GNULIB_RECV)/g' \ -e 's/@''GNULIB_SEND''@/$(GNULIB_SEND)/g' \ -e 's/@''GNULIB_RECVFROM''@/$(GNULIB_RECVFROM)/g' \ -e 's/@''GNULIB_SENDTO''@/$(GNULIB_SENDTO)/g' \ -e 's/@''GNULIB_SETSOCKOPT''@/$(GNULIB_SETSOCKOPT)/g' \ -e 's/@''GNULIB_SHUTDOWN''@/$(GNULIB_SHUTDOWN)/g' \ -e 's/@''GNULIB_ACCEPT4''@/$(GNULIB_ACCEPT4)/g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY''@|$(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)|g' \ -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|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)/sys_socket.in.h; \ } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # has one that is incomplete. sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \ -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \ -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \ -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \ -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \ -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \ -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \ -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \ -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \ -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \ -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \ -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \ -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \ -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|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)/sys_stat.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_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_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/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)/sys_time.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/types.h: sys_types.in.h $(top_builddir)/config.status $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ < $(srcdir)/sys_types.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/uio.h: sys_uio.in.h $(top_builddir)/config.status $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \ -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \ < $(srcdir)/sys_uio.in.h; \ } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''GUARD_PREFIX''@|GL|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_TIME_H''@|$(NEXT_TIME_H)|g' \ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|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)/time.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create an empty placeholder for # when the system doesn't have one. unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_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_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \ -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \ -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \ -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \ -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \ -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \ -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \ -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \ -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \ -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \ -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \ -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \ -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \ -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \ -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \ -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \ -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \ -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \ -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \ -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \ -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \ -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \ -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \ -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \ -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \ -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \ -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \ -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \ -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \ -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \ -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \ -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \ -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \ -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \ -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \ -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \ -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \ -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \ -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \ -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \ -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \ -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \ -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \ -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \ -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \ -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \ -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \ -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \ < $(srcdir)/unistd.in.h | \ sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \ -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \ -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \ -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \ -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ | \ sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \ -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \ -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \ -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|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)'; \ } > $@-t && \ mv $@-t $@ unistr.h: unistr.in.h $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/unistr.in.h; \ } > $@-t && \ mv -f $@-t $@ unitypes.h: unitypes.in.h $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/unitypes.in.h; \ } > $@-t && \ mv -f $@-t $@ uniwidth.h: uniwidth.in.h $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/uniwidth.in.h; \ } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # version does not work standalone. wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|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|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ -e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \ -e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \ -e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \ -e 's/@''GNULIB_MBRTOWC''@/$(GNULIB_MBRTOWC)/g' \ -e 's/@''GNULIB_MBRLEN''@/$(GNULIB_MBRLEN)/g' \ -e 's/@''GNULIB_MBSRTOWCS''@/$(GNULIB_MBSRTOWCS)/g' \ -e 's/@''GNULIB_MBSNRTOWCS''@/$(GNULIB_MBSNRTOWCS)/g' \ -e 's/@''GNULIB_WCRTOMB''@/$(GNULIB_WCRTOMB)/g' \ -e 's/@''GNULIB_WCSRTOMBS''@/$(GNULIB_WCSRTOMBS)/g' \ -e 's/@''GNULIB_WCSNRTOMBS''@/$(GNULIB_WCSNRTOMBS)/g' \ -e 's/@''GNULIB_WCWIDTH''@/$(GNULIB_WCWIDTH)/g' \ -e 's/@''GNULIB_WMEMCHR''@/$(GNULIB_WMEMCHR)/g' \ -e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \ -e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \ -e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \ -e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \ -e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \ -e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \ -e 's/@''GNULIB_WCSCPY''@/$(GNULIB_WCSCPY)/g' \ -e 's/@''GNULIB_WCPCPY''@/$(GNULIB_WCPCPY)/g' \ -e 's/@''GNULIB_WCSNCPY''@/$(GNULIB_WCSNCPY)/g' \ -e 's/@''GNULIB_WCPNCPY''@/$(GNULIB_WCPNCPY)/g' \ -e 's/@''GNULIB_WCSCAT''@/$(GNULIB_WCSCAT)/g' \ -e 's/@''GNULIB_WCSNCAT''@/$(GNULIB_WCSNCAT)/g' \ -e 's/@''GNULIB_WCSCMP''@/$(GNULIB_WCSCMP)/g' \ -e 's/@''GNULIB_WCSNCMP''@/$(GNULIB_WCSNCMP)/g' \ -e 's/@''GNULIB_WCSCASECMP''@/$(GNULIB_WCSCASECMP)/g' \ -e 's/@''GNULIB_WCSNCASECMP''@/$(GNULIB_WCSNCASECMP)/g' \ -e 's/@''GNULIB_WCSCOLL''@/$(GNULIB_WCSCOLL)/g' \ -e 's/@''GNULIB_WCSXFRM''@/$(GNULIB_WCSXFRM)/g' \ -e 's/@''GNULIB_WCSDUP''@/$(GNULIB_WCSDUP)/g' \ -e 's/@''GNULIB_WCSCHR''@/$(GNULIB_WCSCHR)/g' \ -e 's/@''GNULIB_WCSRCHR''@/$(GNULIB_WCSRCHR)/g' \ -e 's/@''GNULIB_WCSCSPN''@/$(GNULIB_WCSCSPN)/g' \ -e 's/@''GNULIB_WCSSPN''@/$(GNULIB_WCSSPN)/g' \ -e 's/@''GNULIB_WCSPBRK''@/$(GNULIB_WCSPBRK)/g' \ -e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \ -e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \ -e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \ < $(srcdir)/wchar.in.h | \ sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \ -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \ -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \ -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \ -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \ -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \ -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \ -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \ -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \ -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \ -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \ -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \ -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \ -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \ -e 's|@''HAVE_WCSCPY''@|$(HAVE_WCSCPY)|g' \ -e 's|@''HAVE_WCPCPY''@|$(HAVE_WCPCPY)|g' \ -e 's|@''HAVE_WCSNCPY''@|$(HAVE_WCSNCPY)|g' \ -e 's|@''HAVE_WCPNCPY''@|$(HAVE_WCPNCPY)|g' \ -e 's|@''HAVE_WCSCAT''@|$(HAVE_WCSCAT)|g' \ -e 's|@''HAVE_WCSNCAT''@|$(HAVE_WCSNCAT)|g' \ -e 's|@''HAVE_WCSCMP''@|$(HAVE_WCSCMP)|g' \ -e 's|@''HAVE_WCSNCMP''@|$(HAVE_WCSNCMP)|g' \ -e 's|@''HAVE_WCSCASECMP''@|$(HAVE_WCSCASECMP)|g' \ -e 's|@''HAVE_WCSNCASECMP''@|$(HAVE_WCSNCASECMP)|g' \ -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \ -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \ -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \ -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \ -e 's|@''HAVE_WCSRCHR''@|$(HAVE_WCSRCHR)|g' \ -e 's|@''HAVE_WCSCSPN''@|$(HAVE_WCSCSPN)|g' \ -e 's|@''HAVE_WCSSPN''@|$(HAVE_WCSSPN)|g' \ -e 's|@''HAVE_WCSPBRK''@|$(HAVE_WCSPBRK)|g' \ -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \ -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \ -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \ -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ | \ sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \ -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \ -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \ -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \ -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \ -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \ -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \ -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|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)'; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_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_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \ -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \ -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \ -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \ -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \ -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \ -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \ -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/wctype.in.h; \ } > $@-t && \ mv $@-t $@ mostlyclean-local: mostlyclean-generic @for dir in '' $(MOSTLYCLEANDIRS); do \ if test -n "$$dir" && test -d $$dir; then \ echo "rmdir $$dir"; rmdir $$dir; \ fi; \ done; \ : # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: lftp-4.6.3a/lib/strftime.h0000644000015000007670000000230612466374012012335 00000000000000/* declarations for strftime.c Copyright (C) 2002, 2004, 2008-2015 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 . */ #include #ifdef __cplusplus extern "C" { #endif /* Just like strftime, but with two more arguments: POSIX requires that strftime use the local timezone information. When __UTC is nonzero and tm->tm_zone is NULL or the empty string, use UTC instead. Use __NS as the number of nanoseconds in the %N directive. */ size_t nstrftime (char *, size_t, char const *, struct tm const *, int __utc, int __ns); #ifdef __cplusplus } #endif lftp-4.6.3a/lib/intprops.h0000644000015000007670000003507112466374011012362 00000000000000/* intprops.h -- properties of integer types Copyright (C) 2001-2005, 2009-2015 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 . */ /* Written by Paul Eggert. */ #ifndef _GL_INTPROPS_H #define _GL_INTPROPS_H #include /* Return an integer value, converted to the same type as the integer expression E after integer type promotion. V is the unconverted value. */ #define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) /* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see . */ #define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v)) /* The extra casts in the following macros work around compiler bugs, e.g., in Cray C 5.0.3.0. */ /* True if the arithmetic type T is an integer type. bool counts as an integer. */ #define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) /* True if negative values of the signed integer type T use two's complement, ones' complement, or signed magnitude representation, respectively. Much GNU code assumes two's complement, but some people like to be portable to all possible C hosts. */ #define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) #define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) #define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) /* True if the signed integer expression E uses two's complement. */ #define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1) /* True if the arithmetic type T is signed. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* Return 1 if the integer expression E, after integer promotion, has a signed type. */ #define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) /* Minimum and maximum values for integer types and expressions. These macros have undefined behavior if T is signed and has padding bits. If this is a problem for you, please let us know how to fix it for your host. */ /* The maximum and minimum values for the integer type T. */ #define TYPE_MINIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ ? (t) 0 \ : TYPE_SIGNED_MAGNITUDE (t) \ ? ~ (t) 0 \ : ~ TYPE_MAXIMUM (t))) #define TYPE_MAXIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ ? (t) -1 \ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) /* The maximum and minimum values for the type of the expression E, after integer promotion. E should not have side effects. */ #define _GL_INT_MINIMUM(e) \ (_GL_INT_SIGNED (e) \ ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \ : _GL_INT_CONVERT (e, 0)) #define _GL_INT_MAXIMUM(e) \ (_GL_INT_SIGNED (e) \ ? _GL_SIGNED_INT_MAXIMUM (e) \ : _GL_INT_NEGATE_CONVERT (e, 1)) #define _GL_SIGNED_INT_MAXIMUM(e) \ (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1) /* Return 1 if the __typeof__ keyword works. This could be done by 'configure', but for now it's easier to do it by hand. */ #if (2 <= __GNUC__ || defined __IBM__TYPEOF__ \ || (0x5110 <= __SUNPRO_C && !__STDC__)) # define _GL_HAVE___TYPEOF__ 1 #else # define _GL_HAVE___TYPEOF__ 0 #endif /* Return 1 if the integer type or expression T might be signed. Return 0 if it is definitely unsigned. This macro does not evaluate its argument, and expands to an integer constant expression. */ #if _GL_HAVE___TYPEOF__ # define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t)) #else # define _GL_SIGNED_TYPE_OR_EXPR(t) 1 #endif /* Bound on length of the string representing an unsigned integer value representable in B bits. log10 (2.0) < 146/485. The smallest value of B where this bound is not tight is 2621. */ #define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) /* Bound on length of the string representing an integer type or expression T. Subtract 1 for the sign bit if T is signed, and then add 1 more for a minus sign if needed. Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is signed, this macro may overestimate the true bound by one byte when applied to unsigned types of size 2, 4, 16, ... bytes. */ #define INT_STRLEN_BOUND(t) \ (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \ - _GL_SIGNED_TYPE_OR_EXPR (t)) \ + _GL_SIGNED_TYPE_OR_EXPR (t)) /* Bound on buffer size needed to represent an integer type or expression T, including the terminating null. */ #define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) /* Range overflow checks. The INT__RANGE_OVERFLOW macros return 1 if the corresponding C operators might not yield numerically correct answers due to arithmetic overflow. They do not rely on undefined or implementation-defined behavior. Their implementations are simple and straightforward, but they are a bit harder to use than the INT__OVERFLOW macros described below. Example usage: long int i = ...; long int j = ...; if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX)) printf ("multiply would overflow"); else printf ("product is %ld", i * j); Restrictions on *_RANGE_OVERFLOW macros: These macros do not check for all possible numerical problems or undefined or unspecified behavior: they do not check for division by zero, for bad shift counts, or for shifting negative numbers. These macros may evaluate their arguments zero or multiple times, so the arguments should not have side effects. The arithmetic arguments (including the MIN and MAX arguments) must be of the same integer type after the usual arithmetic conversions, and the type must have minimum value MIN and maximum MAX. Unsigned types should use a zero MIN of the proper type. These macros are tuned for constant MIN and MAX. For commutative operations such as A + B, they are also tuned for constant B. */ /* Return 1 if A + B would overflow in [MIN,MAX] arithmetic. See above for restrictions. */ #define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \ ((b) < 0 \ ? (a) < (min) - (b) \ : (max) - (b) < (a)) /* Return 1 if A - B would overflow in [MIN,MAX] arithmetic. See above for restrictions. */ #define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \ ((b) < 0 \ ? (max) + (b) < (a) \ : (a) < (min) + (b)) /* Return 1 if - A would overflow in [MIN,MAX] arithmetic. See above for restrictions. */ #define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ ((min) < 0 \ ? (a) < - (max) \ : 0 < (a)) /* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. See above for restrictions. Avoid && and || as they tickle bugs in Sun C 5.11 2010/08/13 and other compilers; see . */ #define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ ((b) < 0 \ ? ((a) < 0 \ ? (a) < (max) / (b) \ : (b) == -1 \ ? 0 \ : (min) / (b) < (a)) \ : (b) == 0 \ ? 0 \ : ((a) < 0 \ ? (a) < (min) / (b) \ : (max) / (b) < (a))) /* Return 1 if A / B would overflow in [MIN,MAX] arithmetic. See above for restrictions. Do not check for division by zero. */ #define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \ ((min) < 0 && (b) == -1 && (a) < - (max)) /* Return 1 if A % B would overflow in [MIN,MAX] arithmetic. See above for restrictions. Do not check for division by zero. Mathematically, % should never overflow, but on x86-like hosts INT_MIN % -1 traps, and the C standard permits this, so treat this as an overflow too. */ #define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \ INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max) /* Return 1 if A << B would overflow in [MIN,MAX] arithmetic. See above for restrictions. Here, MIN and MAX are for A only, and B need not be of the same type as the other arguments. The C standard says that behavior is undefined for shifts unless 0 <= B < wordwidth, and that when A is negative then A << B has undefined behavior and A >> B has implementation-defined behavior, but do not check these other restrictions. */ #define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \ ((a) < 0 \ ? (a) < (min) >> (b) \ : (max) >> (b) < (a)) /* The _GL*_OVERFLOW macros have the same restrictions as the *_RANGE_OVERFLOW macros, except that they do not assume that operands (e.g., A and B) have the same type as MIN and MAX. Instead, they assume that the result (e.g., A + B) has that type. */ #define _GL_ADD_OVERFLOW(a, b, min, max) \ ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ : (a) < 0 ? (b) <= (a) + (b) \ : (b) < 0 ? (a) <= (a) + (b) \ : (a) + (b) < (b)) #define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \ : (a) < 0 ? 1 \ : (b) < 0 ? (a) - (b) <= (a) \ : (a) < (b)) #define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) #define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ : (a) < 0 ? (b) <= (a) + (b) - 1 \ : (b) < 0 && (a) + (b) <= (a)) #define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) /* Return a nonzero value if A is a mathematical multiple of B, where A is unsigned, B is negative, and MAX is the maximum value of A's type. A's type must be the same as (A % B)'s type. Normally (A % -B == 0) suffices, but things get tricky if -B would overflow. */ #define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \ (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \ ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \ ? (a) \ : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \ : (a) % - (b)) \ == 0) /* Integer overflow checks. The INT__OVERFLOW macros return 1 if the corresponding C operators might not yield numerically correct answers due to arithmetic overflow. They work correctly on all known practical hosts, and do not rely on undefined behavior due to signed arithmetic overflow. Example usage: long int i = ...; long int j = ...; if (INT_MULTIPLY_OVERFLOW (i, j)) printf ("multiply would overflow"); else printf ("product is %ld", i * j); These macros do not check for all possible numerical problems or undefined or unspecified behavior: they do not check for division by zero, for bad shift counts, or for shifting negative numbers. These macros may evaluate their arguments zero or multiple times, so the arguments should not have side effects. These macros are tuned for their last argument being a constant. Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, A % B, and A << B would overflow, respectively. */ #define INT_ADD_OVERFLOW(a, b) \ _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) #define INT_SUBTRACT_OVERFLOW(a, b) \ _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) #define INT_NEGATE_OVERFLOW(a) \ INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) #define INT_MULTIPLY_OVERFLOW(a, b) \ _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) #define INT_DIVIDE_OVERFLOW(a, b) \ _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW) #define INT_REMAINDER_OVERFLOW(a, b) \ _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW) #define INT_LEFT_SHIFT_OVERFLOW(a, b) \ INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \ _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) /* Return 1 if the expression A B would overflow, where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test, assuming MIN and MAX are the minimum and maximum for the result type. Arguments should be free of side effects. */ #define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ op_result_overflow (a, b, \ _GL_INT_MINIMUM (0 * (b) + (a)), \ _GL_INT_MAXIMUM (0 * (b) + (a))) #endif /* _GL_INTPROPS_H */ lftp-4.6.3a/lib/strtoull.c0000644000015000007670000000201612466374012012361 00000000000000/* Function to parse an 'unsigned long long int' from text. Copyright (C) 1995-1997, 1999, 2009-2015 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. 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 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 . */ #define QUAD 1 #include "strtoul.c" #ifdef _LIBC strong_alias (__strtoull_internal, __strtouq_internal) weak_alias (strtoull, strtouq) #endif lftp-4.6.3a/lib/stdbool.in.h0000644000015000007670000001177212466374012012562 00000000000000/* Copyright (C) 2001-2003, 2006-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2001. 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 . */ #ifndef _GL_STDBOOL_H #define _GL_STDBOOL_H /* ISO C 99 for platforms that lack it. */ /* Usage suggestions: Programs that use should be aware of some limitations and standards compliance issues. Standards compliance: - must be #included before 'bool', 'false', 'true' can be used. - You cannot assume that sizeof (bool) == 1. - Programs should not undefine the macros bool, true, and false, as C99 lists that as an "obsolescent feature". Limitations of this substitute, when used in a C89 environment: - must be #included before the '_Bool' type can be used. - You cannot assume that _Bool is a typedef; it might be a macro. - Bit-fields of type 'bool' are not supported. Portable code should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. - In C99, casts and automatic conversions to '_Bool' or 'bool' are performed in such a way that every nonzero value gets converted to 'true', and zero gets converted to 'false'. This doesn't work with this substitute. With this substitute, only the values 0 and 1 give the expected result when converted to _Bool' or 'bool'. - C99 allows the use of (_Bool)0.0 in constant expressions, but this substitute cannot always provide this property. Also, it is suggested that programs use 'bool' rather than '_Bool'; this isn't required, but 'bool' is more common. */ /* 7.16. Boolean type and values */ /* BeOS already #defines false 0, true 1. We use the same definitions below, but temporarily we have to #undef them. */ #if defined __BEOS__ && !defined __HAIKU__ # include /* defines bool but not _Bool */ # undef false # undef true #endif #ifdef __cplusplus # define _Bool bool # define bool bool #else # if defined __BEOS__ && !defined __HAIKU__ /* A compiler known to have 'bool'. */ /* If the compiler already has both 'bool' and '_Bool', we can assume they are the same types. */ # if !@HAVE__BOOL@ typedef bool _Bool; # endif # else # if !defined __GNUC__ /* If @HAVE__BOOL@: Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when the built-in _Bool type is used. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html Similar bugs are likely with other compilers as well; this file wouldn't be used if was working. So we override the _Bool type. If !@HAVE__BOOL@: Need to define _Bool ourselves. As 'signed char' or as an enum type? Use of a typedef, with SunPRO C, leads to a stupid "warning: _Bool is a keyword in ISO C99". Use of an enum type, with IRIX cc, leads to a stupid "warning(1185): enumerated type mixed with another type". Even the existence of an enum type, without a typedef, "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. The only benefit of the enum, debuggability, is not important with these compilers. So use 'signed char' and no enum. */ # define _Bool signed char # else /* With this compiler, trust the _Bool type if the compiler has it. */ # if !@HAVE__BOOL@ /* For the sake of symbolic names in gdb, define true and false as enum constants, not only as macros. It is tempting to write typedef enum { false = 0, true = 1 } _Bool; so that gdb prints values of type 'bool' symbolically. But then values of type '_Bool' might promote to 'int' or 'unsigned int' (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' (see ISO C 99 6.3.1.1.(2)). So add a negative value to the enum; this ensures that '_Bool' promotes to 'int'. */ typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; # endif # endif # endif # define bool _Bool #endif /* The other macros must be usable in preprocessor directives. */ #ifdef __cplusplus # define false false # define true true #else # define false 0 # define true 1 #endif #define __bool_true_false_are_defined 1 #endif /* _GL_STDBOOL_H */ lftp-4.6.3a/lib/sys_select.in.h0000644000015000007670000002711412466374012013266 00000000000000/* Substitute for . Copyright (C) 2007-2015 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 . */ # if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ # endif @PRAGMA_COLUMNS@ /* On OSF/1 and Solaris 2.6, and both include . On Cygwin, includes . Simply delegate to the system's header in this case. */ #if (@HAVE_SYS_SELECT_H@ \ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H \ && ((defined __osf__ && defined _SYS_TYPES_H_ \ && defined _OSF_SOURCE) \ || (defined __sun && defined _SYS_TYPES_H \ && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE) \ || defined __EXTENSIONS__)))) # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ #elif (@HAVE_SYS_SELECT_H@ \ && (defined _CYGWIN_SYS_TIME_H \ || (!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H \ && ((defined __osf__ && defined _SYS_TIME_H_ \ && defined _OSF_SOURCE) \ || (defined __sun && defined _SYS_TIME_H \ && (! (defined _XOPEN_SOURCE \ || defined _POSIX_C_SOURCE) \ || defined __EXTENSIONS__)))))) # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ /* On IRIX 6.5, includes , which includes , which includes . At this point we cannot include , because that includes , which gives a syntax error because has not been completely processed. Simply delegate to the system's header in this case. */ #elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H) # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ /* On OpenBSD 5.0, includes , which includes . At this point we cannot include , because that includes gnulib's pthread.h override, which gives a syntax error because /usr/include/pthread.h has not been completely processed. Simply delegate to the system's header in this case. */ #elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && !defined PTHREAD_MUTEX_INITIALIZER) # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ #else #ifndef _@GUARD_PREFIX@_SYS_SELECT_H /* On many platforms, assumes prior inclusion of . Also, mingw defines sigset_t there, instead of in where it belongs. */ #include #if @HAVE_SYS_SELECT_H@ /* On OSF/1 4.0, provides only a forward declaration of 'struct timeval', and no definition of this type. Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select() in . But avoid namespace pollution on glibc systems. */ # ifndef __GLIBC__ # include # endif /* On AIX 7 and Solaris 10, provides an FD_ZERO implementation that relies on memset(), but without including . But in any case avoid namespace pollution on glibc systems. */ # if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \ && ! defined __GLIBC__ # include # endif /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ #endif /* Get definition of 'sigset_t'. But avoid namespace pollution on glibc systems. Do this after the include_next (for the sake of OpenBSD 5.0) but before the split double-inclusion guard (for the sake of Solaris). */ #if !(defined __GLIBC__ && !defined __UCLIBC__) # include #endif #ifndef _@GUARD_PREFIX@_SYS_SELECT_H #define _@GUARD_PREFIX@_SYS_SELECT_H #if !@HAVE_SYS_SELECT_H@ /* A platform that lacks . */ /* Get the 'struct timeval' and 'fd_set' types and the FD_* macros on most platforms. */ # include /* On HP-UX 11, provides an FD_ZERO implementation that relies on memset(), but without including . */ # if defined __hpux # include # endif /* On native Windows platforms: Get the 'fd_set' type. Get the close() declaration before we override it. */ # if @HAVE_WINSOCK2_H@ # if !defined _GL_INCLUDING_WINSOCK2_H # define _GL_INCLUDING_WINSOCK2_H # include # undef _GL_INCLUDING_WINSOCK2_H # endif # include # endif #endif /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_WARN_ON_USE is copied here. */ /* Fix some definitions from . */ #if @HAVE_WINSOCK2_H@ # if !GNULIB_defined_rpl_fd_isset /* Re-define FD_ISSET to avoid a WSA call while we are not using network sockets. */ static int rpl_fd_isset (SOCKET fd, fd_set * set) { u_int i; if (set == NULL) return 0; for (i = 0; i < set->fd_count; i++) if (set->fd_array[i] == fd) return 1; return 0; } # define GNULIB_defined_rpl_fd_isset 1 # endif # undef FD_ISSET # define FD_ISSET(fd, set) rpl_fd_isset(fd, set) #endif /* Hide some function declarations from . */ #if @HAVE_WINSOCK2_H@ # if !defined _@GUARD_PREFIX@_UNISTD_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef close # define close close_used_without_including_unistd_h # else _GL_WARN_ON_USE (close, "close() used without including "); # endif # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef gethostname # define gethostname gethostname_used_without_including_unistd_h # else _GL_WARN_ON_USE (gethostname, "gethostname() used without including "); # endif # endif # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef socket # define socket socket_used_without_including_sys_socket_h # undef connect # define connect connect_used_without_including_sys_socket_h # undef accept # define accept accept_used_without_including_sys_socket_h # undef bind # define bind bind_used_without_including_sys_socket_h # undef getpeername # define getpeername getpeername_used_without_including_sys_socket_h # undef getsockname # define getsockname getsockname_used_without_including_sys_socket_h # undef getsockopt # define getsockopt getsockopt_used_without_including_sys_socket_h # undef listen # define listen listen_used_without_including_sys_socket_h # undef recv # define recv recv_used_without_including_sys_socket_h # undef send # define send send_used_without_including_sys_socket_h # undef recvfrom # define recvfrom recvfrom_used_without_including_sys_socket_h # undef sendto # define sendto sendto_used_without_including_sys_socket_h # undef setsockopt # define setsockopt setsockopt_used_without_including_sys_socket_h # undef shutdown # define shutdown shutdown_used_without_including_sys_socket_h # else _GL_WARN_ON_USE (socket, "socket() used without including "); _GL_WARN_ON_USE (connect, "connect() used without including "); _GL_WARN_ON_USE (accept, "accept() used without including "); _GL_WARN_ON_USE (bind, "bind() used without including "); _GL_WARN_ON_USE (getpeername, "getpeername() used without including "); _GL_WARN_ON_USE (getsockname, "getsockname() used without including "); _GL_WARN_ON_USE (getsockopt, "getsockopt() used without including "); _GL_WARN_ON_USE (listen, "listen() used without including "); _GL_WARN_ON_USE (recv, "recv() used without including "); _GL_WARN_ON_USE (send, "send() used without including "); _GL_WARN_ON_USE (recvfrom, "recvfrom() used without including "); _GL_WARN_ON_USE (sendto, "sendto() used without including "); _GL_WARN_ON_USE (setsockopt, "setsockopt() used without including "); _GL_WARN_ON_USE (shutdown, "shutdown() used without including "); # endif # endif #endif #if @GNULIB_PSELECT@ # if @REPLACE_PSELECT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef pselect # define pselect rpl_pselect # endif _GL_FUNCDECL_RPL (pselect, int, (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, struct timespec const *restrict, const sigset_t *restrict)); _GL_CXXALIAS_RPL (pselect, int, (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, struct timespec const *restrict, const sigset_t *restrict)); # else # if !@HAVE_PSELECT@ _GL_FUNCDECL_SYS (pselect, int, (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, struct timespec const *restrict, const sigset_t *restrict)); # endif _GL_CXXALIAS_SYS (pselect, int, (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, struct timespec const *restrict, const sigset_t *restrict)); # endif _GL_CXXALIASWARN (pselect); #elif defined GNULIB_POSIXCHECK # undef pselect # if HAVE_RAW_DECL_PSELECT _GL_WARN_ON_USE (pselect, "pselect is not portable - " "use gnulib module pselect for portability"); # endif #endif #if @GNULIB_SELECT@ # if @REPLACE_SELECT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef select # define select rpl_select # endif _GL_FUNCDECL_RPL (select, int, (int, fd_set *, fd_set *, fd_set *, struct timeval *)); _GL_CXXALIAS_RPL (select, int, (int, fd_set *, fd_set *, fd_set *, struct timeval *)); # else _GL_CXXALIAS_SYS (select, int, (int, fd_set *, fd_set *, fd_set *, struct timeval *)); # endif _GL_CXXALIASWARN (select); #elif @HAVE_WINSOCK2_H@ # undef select # define select select_used_without_requesting_gnulib_module_select #elif defined GNULIB_POSIXCHECK # undef select # if HAVE_RAW_DECL_SELECT _GL_WARN_ON_USE (select, "select is not always POSIX compliant - " "use gnulib module select for portability"); # endif #endif #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */ #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */ #endif /* OSF/1 */ lftp-4.6.3a/lib/poll.c0000644000015000007670000003775012477560612011461 00000000000000/* Emulation for poll(2) Contributed by Paolo Bonzini. Copyright 2001-2003, 2006-2015 Free Software Foundation, Inc. This file is part of gnulib. 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 . */ /* Tell gcc not to warn about the (nfd < 0) tests, below. */ #if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ # pragma GCC diagnostic ignored "-Wtype-limits" #endif #include #include #include /* Specification. */ #include #include #include #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WINDOWS_NATIVE # include # include # include # include # include # include "msvc-nothrow.h" #else # include # include #endif #include #include #ifdef HAVE_SYS_IOCTL_H # include #endif #ifdef HAVE_SYS_FILIO_H # include #endif #include #include "assure.h" #ifndef INFTIM # define INFTIM (-1) #endif /* BeOS does not have MSG_PEEK. */ #ifndef MSG_PEEK # define MSG_PEEK 0 #endif #ifdef WINDOWS_NATIVE static BOOL IsConsoleHandle (HANDLE h) { DWORD mode; return GetConsoleMode (h, &mode) != 0; } static BOOL IsSocketHandle (HANDLE h) { WSANETWORKEVENTS ev; if (IsConsoleHandle (h)) return FALSE; /* Under Wine, it seems that getsockopt returns 0 for pipes too. WSAEnumNetworkEvents instead distinguishes the two correctly. */ ev.lNetworkEvents = 0xDEADBEEF; WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev); return ev.lNetworkEvents != 0xDEADBEEF; } /* Declare data structures for ntdll functions. */ typedef struct _FILE_PIPE_LOCAL_INFORMATION { ULONG NamedPipeType; ULONG NamedPipeConfiguration; ULONG MaximumInstances; ULONG CurrentInstances; ULONG InboundQuota; ULONG ReadDataAvailable; ULONG OutboundQuota; ULONG WriteQuotaAvailable; ULONG NamedPipeState; ULONG NamedPipeEnd; } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; typedef struct _IO_STATUS_BLOCK { union { DWORD Status; PVOID Pointer; } u; ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; typedef enum _FILE_INFORMATION_CLASS { FilePipeLocalInformation = 24 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; typedef DWORD (WINAPI *PNtQueryInformationFile) (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS); # ifndef PIPE_BUF # define PIPE_BUF 512 # endif /* Compute revents values for file handle H. If some events cannot happen for the handle, eliminate them from *P_SOUGHT. */ static int windows_compute_revents (HANDLE h, int *p_sought) { int i, ret, happened; INPUT_RECORD *irbuffer; DWORD avail, nbuffer; BOOL bRet; IO_STATUS_BLOCK iosb; FILE_PIPE_LOCAL_INFORMATION fpli; static PNtQueryInformationFile NtQueryInformationFile; static BOOL once_only; switch (GetFileType (h)) { case FILE_TYPE_PIPE: if (!once_only) { NtQueryInformationFile = (PNtQueryInformationFile) GetProcAddress (GetModuleHandle ("ntdll.dll"), "NtQueryInformationFile"); once_only = TRUE; } happened = 0; if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0) { if (avail) happened |= *p_sought & (POLLIN | POLLRDNORM); } else if (GetLastError () == ERROR_BROKEN_PIPE) happened |= POLLHUP; else { /* It was the write-end of the pipe. Check if it is writable. If NtQueryInformationFile fails, optimistically assume the pipe is writable. This could happen on Windows 9x, where NtQueryInformationFile is not available, or if we inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES access on the write end (I think this should not happen since Windows XP SP2; WINE seems fine too). Otherwise, ensure that enough space is available for atomic writes. */ memset (&iosb, 0, sizeof (iosb)); memset (&fpli, 0, sizeof (fpli)); if (!NtQueryInformationFile || NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli), FilePipeLocalInformation) || fpli.WriteQuotaAvailable >= PIPE_BUF || (fpli.OutboundQuota < PIPE_BUF && fpli.WriteQuotaAvailable == fpli.OutboundQuota)) happened |= *p_sought & (POLLOUT | POLLWRNORM | POLLWRBAND); } return happened; case FILE_TYPE_CHAR: ret = WaitForSingleObject (h, 0); if (!IsConsoleHandle (h)) return ret == WAIT_OBJECT_0 ? *p_sought & ~(POLLPRI | POLLRDBAND) : 0; nbuffer = avail = 0; bRet = GetNumberOfConsoleInputEvents (h, &nbuffer); if (bRet) { /* Input buffer. */ *p_sought &= POLLIN | POLLRDNORM; if (nbuffer == 0) return POLLHUP; if (!*p_sought) return 0; irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD)); bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail); if (!bRet || avail == 0) return POLLHUP; for (i = 0; i < avail; i++) if (irbuffer[i].EventType == KEY_EVENT) return *p_sought; return 0; } else { /* Screen buffer. */ *p_sought &= POLLOUT | POLLWRNORM | POLLWRBAND; return *p_sought; } default: ret = WaitForSingleObject (h, 0); if (ret == WAIT_OBJECT_0) return *p_sought & ~(POLLPRI | POLLRDBAND); return *p_sought & (POLLOUT | POLLWRNORM | POLLWRBAND); } } /* Convert fd_sets returned by select into revents values. */ static int windows_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents) { int happened = 0; if ((lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) == FD_ACCEPT) happened |= (POLLIN | POLLRDNORM) & sought; else if (lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) { int r, error; char data[64]; WSASetLastError (0); r = recv (h, data, sizeof (data), MSG_PEEK); error = WSAGetLastError (); WSASetLastError (0); if (r > 0 || error == WSAENOTCONN) happened |= (POLLIN | POLLRDNORM) & sought; /* Distinguish hung-up sockets from other errors. */ else if (r == 0 || error == WSAESHUTDOWN || error == WSAECONNRESET || error == WSAECONNABORTED || error == WSAENETRESET) happened |= POLLHUP; else happened |= POLLERR; } if (lNetworkEvents & (FD_WRITE | FD_CONNECT)) happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought; if (lNetworkEvents & FD_OOB) happened |= (POLLPRI | POLLRDBAND) & sought; return happened; } #else /* !MinGW */ /* Convert select(2) returned fd_sets into poll(2) revents values. */ static int compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds) { int happened = 0; if (FD_ISSET (fd, rfds)) { int r; int socket_errno; # if defined __MACH__ && defined __APPLE__ /* There is a bug in Mac OS X that causes it to ignore MSG_PEEK for some kinds of descriptors. Detect if this descriptor is a connected socket, a server socket, or something else using a 0-byte recv, and use ioctl(2) to detect POLLHUP. */ r = recv (fd, NULL, 0, MSG_PEEK); socket_errno = (r < 0) ? errno : 0; if (r == 0 || socket_errno == ENOTSOCK) ioctl (fd, FIONREAD, &r); # else char data[64]; r = recv (fd, data, sizeof (data), MSG_PEEK); socket_errno = (r < 0) ? errno : 0; # endif if (r == 0) happened |= POLLHUP; /* If the event happened on an unconnected server socket, that's fine. */ else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN)) happened |= (POLLIN | POLLRDNORM) & sought; /* Distinguish hung-up sockets from other errors. */ else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET || socket_errno == ECONNABORTED || socket_errno == ENETRESET) happened |= POLLHUP; /* some systems can't use recv() on non-socket, including HP NonStop */ else if (socket_errno == ENOTSOCK) happened |= (POLLIN | POLLRDNORM) & sought; else happened |= POLLERR; } if (FD_ISSET (fd, wfds)) happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought; if (FD_ISSET (fd, efds)) happened |= (POLLPRI | POLLRDBAND) & sought; return happened; } #endif /* !MinGW */ int poll (struct pollfd *pfd, nfds_t nfd, int timeout) { #ifndef WINDOWS_NATIVE fd_set rfds, wfds, efds; struct timeval tv; struct timeval *ptv; int maxfd, rc; nfds_t i; if (nfd < 0) { errno = EINVAL; return -1; } /* Don't check directly for NFD too large. Any practical use of a too-large NFD is caught by one of the other checks below, and checking directly for getdtablesize is too much of a portability and/or performance and/or correctness hassle. */ /* EFAULT is not necessary to implement, but let's do it in the simplest case. */ if (!pfd && nfd) { errno = EFAULT; return -1; } /* convert timeout number into a timeval structure */ if (timeout == 0) { ptv = &tv; ptv->tv_sec = 0; ptv->tv_usec = 0; } else if (timeout > 0) { ptv = &tv; ptv->tv_sec = timeout / 1000; ptv->tv_usec = (timeout % 1000) * 1000; } else if (timeout == INFTIM) /* wait forever */ ptv = NULL; else { errno = EINVAL; return -1; } /* create fd sets and determine max fd */ maxfd = -1; FD_ZERO (&rfds); FD_ZERO (&wfds); FD_ZERO (&efds); for (i = 0; i < nfd; i++) { if (pfd[i].fd < 0) continue; if (maxfd < pfd[i].fd) { maxfd = pfd[i].fd; if (FD_SETSIZE <= maxfd) { errno = EINVAL; return -1; } } if (pfd[i].events & (POLLIN | POLLRDNORM)) FD_SET (pfd[i].fd, &rfds); /* see select(2): "the only exceptional condition detectable is out-of-band data received on a socket", hence we push POLLWRBAND events onto wfds instead of efds. */ if (pfd[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND)) FD_SET (pfd[i].fd, &wfds); if (pfd[i].events & (POLLPRI | POLLRDBAND)) FD_SET (pfd[i].fd, &efds); } /* examine fd sets */ rc = select (maxfd + 1, &rfds, &wfds, &efds, ptv); if (rc < 0) return rc; /* establish results */ rc = 0; for (i = 0; i < nfd; i++) { pfd[i].revents = (pfd[i].fd < 0 ? 0 : compute_revents (pfd[i].fd, pfd[i].events, &rfds, &wfds, &efds)); rc += pfd[i].revents != 0; } return rc; #else static struct timeval tv0; static HANDLE hEvent; WSANETWORKEVENTS ev; HANDLE h, handle_array[FD_SETSIZE + 2]; DWORD ret, wait_timeout, nhandles; fd_set rfds, wfds, xfds; BOOL poll_again; MSG msg; int rc = 0; nfds_t i; if (nfd < 0 || timeout < -1) { errno = EINVAL; return -1; } if (!hEvent) hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); restart: handle_array[0] = hEvent; nhandles = 1; FD_ZERO (&rfds); FD_ZERO (&wfds); FD_ZERO (&xfds); /* Classify socket handles and create fd sets. */ for (i = 0; i < nfd; i++) { int sought = pfd[i].events; pfd[i].revents = 0; if (pfd[i].fd < 0) continue; if (!(sought & (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM | POLLWRBAND | POLLPRI | POLLRDBAND))) continue; h = (HANDLE) _get_osfhandle (pfd[i].fd); assure (h != NULL); if (IsSocketHandle (h)) { int requested = FD_CLOSE; /* see above; socket handles are mapped onto select. */ if (sought & (POLLIN | POLLRDNORM)) { requested |= FD_READ | FD_ACCEPT; FD_SET ((SOCKET) h, &rfds); } if (sought & (POLLOUT | POLLWRNORM | POLLWRBAND)) { requested |= FD_WRITE | FD_CONNECT; FD_SET ((SOCKET) h, &wfds); } if (sought & (POLLPRI | POLLRDBAND)) { requested |= FD_OOB; FD_SET ((SOCKET) h, &xfds); } if (requested) WSAEventSelect ((SOCKET) h, hEvent, requested); } else { /* Poll now. If we get an event, do not poll again. Also, screen buffer handles are waitable, and they'll block until a character is available. windows_compute_revents eliminates bits for the "wrong" direction. */ pfd[i].revents = windows_compute_revents (h, &sought); if (sought) handle_array[nhandles++] = h; if (pfd[i].revents) timeout = 0; } } if (select (0, &rfds, &wfds, &xfds, &tv0) > 0) { /* Do MsgWaitForMultipleObjects anyway to dispatch messages, but no need to call select again. */ poll_again = FALSE; wait_timeout = 0; } else { poll_again = TRUE; if (timeout == INFTIM) wait_timeout = INFINITE; else wait_timeout = timeout; } for (;;) { ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE, wait_timeout, QS_ALLINPUT); if (ret == WAIT_OBJECT_0 + nhandles) { /* new input of some other kind */ BOOL bRet; while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0) { TranslateMessage (&msg); DispatchMessage (&msg); } } else break; } if (poll_again) select (0, &rfds, &wfds, &xfds, &tv0); /* Place a sentinel at the end of the array. */ handle_array[nhandles] = NULL; nhandles = 1; for (i = 0; i < nfd; i++) { int happened; if (pfd[i].fd < 0) continue; if (!(pfd[i].events & (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM | POLLWRBAND))) continue; h = (HANDLE) _get_osfhandle (pfd[i].fd); if (h != handle_array[nhandles]) { /* It's a socket. */ WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev); WSAEventSelect ((SOCKET) h, 0, 0); /* If we're lucky, WSAEnumNetworkEvents already provided a way to distinguish FD_READ and FD_ACCEPT; this saves a recv later. */ if (FD_ISSET ((SOCKET) h, &rfds) && !(ev.lNetworkEvents & (FD_READ | FD_ACCEPT))) ev.lNetworkEvents |= FD_READ | FD_ACCEPT; if (FD_ISSET ((SOCKET) h, &wfds)) ev.lNetworkEvents |= FD_WRITE | FD_CONNECT; if (FD_ISSET ((SOCKET) h, &xfds)) ev.lNetworkEvents |= FD_OOB; happened = windows_compute_revents_socket ((SOCKET) h, pfd[i].events, ev.lNetworkEvents); } else { /* Not a socket. */ int sought = pfd[i].events; happened = windows_compute_revents (h, &sought); nhandles++; } if ((pfd[i].revents |= happened) != 0) rc++; } if (!rc && timeout == INFTIM) { SleepEx (1, TRUE); goto restart; } return rc; #endif } lftp-4.6.3a/lib/str-two-way.h0000644000015000007670000004216512466374012012724 00000000000000/* Byte-wise substring search, using the Two-Way algorithm. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Eric Blake , 2008. 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 . */ /* Before including this file, you need to include and , and define: RESULT_TYPE A macro that expands to the return type. AVAILABLE(h, h_l, j, n_l) A macro that returns nonzero if there are at least N_L bytes left starting at H[J]. H is 'unsigned char *', H_L, J, and N_L are 'size_t'; H_L is an lvalue. For NUL-terminated searches, H_L can be modified each iteration to avoid having to compute the end of H up front. For case-insensitivity, you may optionally define: CMP_FUNC(p1, p2, l) A macro that returns 0 iff the first L characters of P1 and P2 are equal. CANON_ELEMENT(c) A macro that canonicalizes an element right after it has been fetched from one of the two strings. The argument is an 'unsigned char'; the result must be an 'unsigned char' as well. This file undefines the macros documented above, and defines LONG_NEEDLE_THRESHOLD. */ #include #include /* We use the Two-Way string matching algorithm (also known as Chrochemore-Perrin), which guarantees linear complexity with constant space. Additionally, for long needles, we also use a bad character shift table similar to the Boyer-Moore algorithm to achieve improved (potentially sub-linear) performance. See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260, http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm, http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf */ /* Point at which computing a bad-byte shift table is likely to be worthwhile. Small needles should not compute a table, since it adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a speedup no greater than a factor of NEEDLE_LEN. The larger the needle, the better the potential performance gain. On the other hand, on non-POSIX systems with CHAR_BIT larger than eight, the memory required for the table is prohibitive. */ #if CHAR_BIT < 10 # define LONG_NEEDLE_THRESHOLD 32U #else # define LONG_NEEDLE_THRESHOLD SIZE_MAX #endif #ifndef MAX # define MAX(a, b) ((a < b) ? (b) : (a)) #endif #ifndef CANON_ELEMENT # define CANON_ELEMENT(c) c #endif #ifndef CMP_FUNC # define CMP_FUNC memcmp #endif /* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN. Return the index of the first byte in the right half, and set *PERIOD to the global period of the right half. The global period of a string is the smallest index (possibly its length) at which all remaining bytes in the string are repetitions of the prefix (the last repetition may be a subset of the prefix). When NEEDLE is factored into two halves, a local period is the length of the smallest word that shares a suffix with the left half and shares a prefix with the right half. All factorizations of a non-empty NEEDLE have a local period of at least 1 and no greater than NEEDLE_LEN. A critical factorization has the property that the local period equals the global period. All strings have at least one critical factorization with the left half smaller than the global period. And while some strings have more than one critical factorization, it is provable that with an ordered alphabet, at least one of the critical factorizations corresponds to a maximal suffix. Given an ordered alphabet, a critical factorization can be computed in linear time, with 2 * NEEDLE_LEN comparisons, by computing the shorter of two ordered maximal suffixes. The ordered maximal suffixes are determined by lexicographic comparison while tracking periodicity. */ static size_t critical_factorization (const unsigned char *needle, size_t needle_len, size_t *period) { /* Index of last byte of left half, or SIZE_MAX. */ size_t max_suffix, max_suffix_rev; size_t j; /* Index into NEEDLE for current candidate suffix. */ size_t k; /* Offset into current period. */ size_t p; /* Intermediate period. */ unsigned char a, b; /* Current comparison bytes. */ /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered out 0-length needles. */ if (needle_len < 3) { *period = 1; return needle_len - 1; } /* Invariants: 0 <= j < NEEDLE_LEN - 1 -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed) min(max_suffix, max_suffix_rev) < global period of NEEDLE 1 <= p <= global period of NEEDLE p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] 1 <= k <= p */ /* Perform lexicographic search. */ max_suffix = SIZE_MAX; j = 0; k = p = 1; while (j + k < needle_len) { a = CANON_ELEMENT (needle[j + k]); b = CANON_ELEMENT (needle[max_suffix + k]); if (a < b) { /* Suffix is smaller, period is entire prefix so far. */ j += k; k = 1; p = j - max_suffix; } else if (a == b) { /* Advance through repetition of the current period. */ if (k != p) ++k; else { j += p; k = 1; } } else /* b < a */ { /* Suffix is larger, start over from current location. */ max_suffix = j++; k = p = 1; } } *period = p; /* Perform reverse lexicographic search. */ max_suffix_rev = SIZE_MAX; j = 0; k = p = 1; while (j + k < needle_len) { a = CANON_ELEMENT (needle[j + k]); b = CANON_ELEMENT (needle[max_suffix_rev + k]); if (b < a) { /* Suffix is smaller, period is entire prefix so far. */ j += k; k = 1; p = j - max_suffix_rev; } else if (a == b) { /* Advance through repetition of the current period. */ if (k != p) ++k; else { j += p; k = 1; } } else /* a < b */ { /* Suffix is larger, start over from current location. */ max_suffix_rev = j++; k = p = 1; } } /* Choose the shorter suffix. Return the index of the first byte of the right half, rather than the last byte of the left half. For some examples, 'banana' has two critical factorizations, both exposed by the two lexicographic extreme suffixes of 'anana' and 'nana', where both suffixes have a period of 2. On the other hand, with 'aab' and 'bba', both strings have a single critical factorization of the last byte, with the suffix having a period of 1. While the maximal lexicographic suffix of 'aab' is 'b', the maximal lexicographic suffix of 'bba' is 'ba', which is not a critical factorization. Conversely, the maximal reverse lexicographic suffix of 'a' works for 'bba', but not 'ab' for 'aab'. The shorter suffix of the two will always be a critical factorization. */ if (max_suffix_rev + 1 < max_suffix + 1) return max_suffix + 1; *period = p; return max_suffix_rev + 1; } /* Return the first location of non-empty NEEDLE within HAYSTACK, or NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD. Performance is guaranteed to be linear, with an initialization cost of 2 * NEEDLE_LEN comparisons. If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ static RETURN_TYPE two_way_short_needle (const unsigned char *haystack, size_t haystack_len, const unsigned char *needle, size_t needle_len) { size_t i; /* Index into current byte of NEEDLE. */ size_t j; /* Index into current window of HAYSTACK. */ size_t period; /* The period of the right half of needle. */ size_t suffix; /* The index of the right half of needle. */ /* Factor the needle into two halves, such that the left half is smaller than the global period, and the right half is periodic (with a period as large as NEEDLE_LEN - suffix). */ suffix = critical_factorization (needle, needle_len, &period); /* Perform the search. Each iteration compares the right half first. */ if (CMP_FUNC (needle, needle + period, suffix) == 0) { /* Entire needle is periodic; a mismatch in the left half can only advance by the period, so use memory to avoid rescanning known occurrences of the period in the right half. */ size_t memory = 0; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) { /* Scan for matches in right half. */ i = MAX (suffix, memory); while (i < needle_len && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i + j]))) ++i; if (needle_len <= i) { /* Scan for matches in left half. */ i = suffix - 1; while (memory < i + 1 && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i + j]))) --i; if (i + 1 < memory + 1) return (RETURN_TYPE) (haystack + j); /* No match, so remember how many repetitions of period on the right half were scanned. */ j += period; memory = needle_len - period; } else { j += i - suffix + 1; memory = 0; } } } else { /* The two halves of needle are distinct; no extra memory is required, and any mismatch results in a maximal shift. */ period = MAX (suffix, needle_len - suffix) + 1; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) { /* Scan for matches in right half. */ i = suffix; while (i < needle_len && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i + j]))) ++i; if (needle_len <= i) { /* Scan for matches in left half. */ i = suffix - 1; while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i + j]))) --i; if (i == SIZE_MAX) return (RETURN_TYPE) (haystack + j); j += period; } else j += i - suffix + 1; } } return NULL; } /* Return the first location of non-empty NEEDLE within HAYSTACK, or NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN. Performance is guaranteed to be linear, with an initialization cost of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations. If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible. If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and sublinear performance is not possible. */ static RETURN_TYPE two_way_long_needle (const unsigned char *haystack, size_t haystack_len, const unsigned char *needle, size_t needle_len) { size_t i; /* Index into current byte of NEEDLE. */ size_t j; /* Index into current window of HAYSTACK. */ size_t period; /* The period of the right half of needle. */ size_t suffix; /* The index of the right half of needle. */ size_t shift_table[1U << CHAR_BIT]; /* See below. */ /* Factor the needle into two halves, such that the left half is smaller than the global period, and the right half is periodic (with a period as large as NEEDLE_LEN - suffix). */ suffix = critical_factorization (needle, needle_len, &period); /* Populate shift_table. For each possible byte value c, shift_table[c] is the distance from the last occurrence of c to the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ for (i = 0; i < 1U << CHAR_BIT; i++) shift_table[i] = needle_len; for (i = 0; i < needle_len; i++) shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; /* Perform the search. Each iteration compares the right half first. */ if (CMP_FUNC (needle, needle + period, suffix) == 0) { /* Entire needle is periodic; a mismatch in the left half can only advance by the period, so use memory to avoid rescanning known occurrences of the period in the right half. */ size_t memory = 0; size_t shift; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) { /* Check the last byte first; if it does not match, then shift to the next possible match location. */ shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; if (0 < shift) { if (memory && shift < period) { /* Since needle is periodic, but the last period has a byte out of place, there can be no match until after the mismatch. */ shift = needle_len - period; } memory = 0; j += shift; continue; } /* Scan for matches in right half. The last byte has already been matched, by virtue of the shift table. */ i = MAX (suffix, memory); while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i + j]))) ++i; if (needle_len - 1 <= i) { /* Scan for matches in left half. */ i = suffix - 1; while (memory < i + 1 && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i + j]))) --i; if (i + 1 < memory + 1) return (RETURN_TYPE) (haystack + j); /* No match, so remember how many repetitions of period on the right half were scanned. */ j += period; memory = needle_len - period; } else { j += i - suffix + 1; memory = 0; } } } else { /* The two halves of needle are distinct; no extra memory is required, and any mismatch results in a maximal shift. */ size_t shift; period = MAX (suffix, needle_len - suffix) + 1; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) { /* Check the last byte first; if it does not match, then shift to the next possible match location. */ shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; if (0 < shift) { j += shift; continue; } /* Scan for matches in right half. The last byte has already been matched, by virtue of the shift table. */ i = suffix; while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i + j]))) ++i; if (needle_len - 1 <= i) { /* Scan for matches in left half. */ i = suffix - 1; while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i + j]))) --i; if (i == SIZE_MAX) return (RETURN_TYPE) (haystack + j); j += period; } else j += i - suffix + 1; } } return NULL; } #undef AVAILABLE #undef CANON_ELEMENT #undef CMP_FUNC #undef MAX #undef RETURN_TYPE lftp-4.6.3a/lib/unistd.in.h0000644000015000007670000015100012466374012012407 00000000000000/* Substitute for and wrapper around . Copyright (C) 2003-2015 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 . */ #ifndef _@GUARD_PREFIX@_UNISTD_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ #ifdef _GL_INCLUDING_UNISTD_H /* Special invocation convention: - On Mac OS X 10.3.9 we have a sequence of nested includes -> -> -> In this situation, the functions are not yet declared, therefore we cannot provide the C++ aliases. */ #@INCLUDE_NEXT@ @NEXT_UNISTD_H@ #else /* Normal invocation convention. */ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_UNISTD_H@ # define _GL_INCLUDING_UNISTD_H # @INCLUDE_NEXT@ @NEXT_UNISTD_H@ # undef _GL_INCLUDING_UNISTD_H #endif /* Get all possible declarations of gethostname(). */ #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ && !defined _GL_INCLUDING_WINSOCK2_H # define _GL_INCLUDING_WINSOCK2_H # include # undef _GL_INCLUDING_WINSOCK2_H #endif #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H #define _@GUARD_PREFIX@_UNISTD_H /* NetBSD 5.0 mis-defines NULL. Also get size_t. */ #include /* mingw doesn't define the SEEK_* or *_FILENO macros in . */ /* Cygwin 1.7.1 declares symlinkat in , not in . */ /* But avoid namespace pollution on glibc systems. */ #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ && defined __CYGWIN__)) \ && ! defined __GLIBC__ # include #endif /* Cygwin 1.7.1 declares unlinkat in , not in . */ /* But avoid namespace pollution on glibc systems. */ #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ && ! defined __GLIBC__ # include #endif /* mingw fails to declare _exit in . */ /* mingw, MSVC, BeOS, Haiku declare environ in , not in . */ /* Solaris declares getcwd not only in but also in . */ /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system is included here. */ /* But avoid namespace pollution on glibc systems. */ #if !defined __GLIBC__ && !defined __osf__ # define __need_system_stdlib_h # include # undef __need_system_stdlib_h #endif /* Native Windows platforms declare chdir, getcwd, rmdir in and/or , not in . They also declare access(), chmod(), close(), dup(), dup2(), isatty(), lseek(), read(), unlink(), write() in . */ #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \ || defined GNULIB_POSIXCHECK) \ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) # include /* mingw32, mingw64 */ # include /* mingw64, MSVC 9 */ #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \ || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \ || defined GNULIB_POSIXCHECK) \ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) # include #endif /* AIX and OSF/1 5.1 declare getdomainname in , not in . NonStop Kernel declares gethostname in , not in . */ /* But avoid namespace pollution on glibc systems. */ #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \ || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \ && !defined __GLIBC__ # include #endif /* MSVC defines off_t in . May also define off_t to a 64-bit type on native Windows. */ #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@ /* Get off_t. */ # include #endif #if (@GNULIB_READ@ || @GNULIB_WRITE@ \ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) /* Get ssize_t. */ # include #endif /* Get getopt(), optarg, optind, opterr, optopt. But avoid namespace pollution on glibc systems. */ #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT # define __need_getopt # include #endif #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif _GL_INLINE_HEADER_BEGIN #ifndef _GL_UNISTD_INLINE # define _GL_UNISTD_INLINE _GL_INLINE #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. */ /* Hide some function declarations from . */ #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef socket # define socket socket_used_without_including_sys_socket_h # undef connect # define connect connect_used_without_including_sys_socket_h # undef accept # define accept accept_used_without_including_sys_socket_h # undef bind # define bind bind_used_without_including_sys_socket_h # undef getpeername # define getpeername getpeername_used_without_including_sys_socket_h # undef getsockname # define getsockname getsockname_used_without_including_sys_socket_h # undef getsockopt # define getsockopt getsockopt_used_without_including_sys_socket_h # undef listen # define listen listen_used_without_including_sys_socket_h # undef recv # define recv recv_used_without_including_sys_socket_h # undef send # define send send_used_without_including_sys_socket_h # undef recvfrom # define recvfrom recvfrom_used_without_including_sys_socket_h # undef sendto # define sendto sendto_used_without_including_sys_socket_h # undef setsockopt # define setsockopt setsockopt_used_without_including_sys_socket_h # undef shutdown # define shutdown shutdown_used_without_including_sys_socket_h # else _GL_WARN_ON_USE (socket, "socket() used without including "); _GL_WARN_ON_USE (connect, "connect() used without including "); _GL_WARN_ON_USE (accept, "accept() used without including "); _GL_WARN_ON_USE (bind, "bind() used without including "); _GL_WARN_ON_USE (getpeername, "getpeername() used without including "); _GL_WARN_ON_USE (getsockname, "getsockname() used without including "); _GL_WARN_ON_USE (getsockopt, "getsockopt() used without including "); _GL_WARN_ON_USE (listen, "listen() used without including "); _GL_WARN_ON_USE (recv, "recv() used without including "); _GL_WARN_ON_USE (send, "send() used without including "); _GL_WARN_ON_USE (recvfrom, "recvfrom() used without including "); _GL_WARN_ON_USE (sendto, "sendto() used without including "); _GL_WARN_ON_USE (setsockopt, "setsockopt() used without including "); _GL_WARN_ON_USE (shutdown, "shutdown() used without including "); # endif # endif # if !defined _@GUARD_PREFIX@_SYS_SELECT_H # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef select # define select select_used_without_including_sys_select_h # else _GL_WARN_ON_USE (select, "select() used without including "); # endif # endif #endif /* OS/2 EMX lacks these macros. */ #ifndef STDIN_FILENO # define STDIN_FILENO 0 #endif #ifndef STDOUT_FILENO # define STDOUT_FILENO 1 #endif #ifndef STDERR_FILENO # define STDERR_FILENO 2 #endif /* Ensure *_OK macros exist. */ #ifndef F_OK # define F_OK 0 # define X_OK 1 # define W_OK 2 # define R_OK 4 #endif /* Declare overridden functions. */ #if defined GNULIB_POSIXCHECK /* The access() function is a security risk. */ _GL_WARN_ON_USE (access, "the access function is a security risk - " "use the gnulib module faccessat instead"); #endif #if @GNULIB_CHDIR@ _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); _GL_CXXALIASWARN (chdir); #elif defined GNULIB_POSIXCHECK # undef chdir # if HAVE_RAW_DECL_CHDIR _GL_WARN_ON_USE (chown, "chdir is not always in - " "use gnulib module chdir for portability"); # endif #endif #if @GNULIB_CHOWN@ /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE to GID (if GID is not -1). Follow symbolic links. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification . */ # if @REPLACE_DUP2@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define dup2 rpl_dup2 # endif _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); # else # if !@HAVE_DUP2@ _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd)); # endif _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); # endif _GL_CXXALIASWARN (dup2); #elif defined GNULIB_POSIXCHECK # undef dup2 # if HAVE_RAW_DECL_DUP2 _GL_WARN_ON_USE (dup2, "dup2 is unportable - " "use gnulib module dup2 for portability"); # endif #endif #if @GNULIB_DUP3@ /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the specified flags. The flags are a bitmask, possibly including O_CLOEXEC (defined in ) and O_TEXT, O_BINARY (defined in "binary-io.h"). Close NEWFD first if it is open. Return newfd if successful, otherwise -1 and errno set. See the Linux man page at . */ # if @HAVE_DUP3@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define dup3 rpl_dup3 # endif _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags)); _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags)); # else _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags)); # endif _GL_CXXALIASWARN (dup3); #elif defined GNULIB_POSIXCHECK # undef dup3 # if HAVE_RAW_DECL_DUP3 _GL_WARN_ON_USE (dup3, "dup3 is unportable - " "use gnulib module dup3 for portability"); # endif #endif #if @GNULIB_ENVIRON@ # if !@HAVE_DECL_ENVIRON@ /* Set of environment variables and values. An array of strings of the form "VARIABLE=VALUE", terminated with a NULL. */ # if defined __APPLE__ && defined __MACH__ # include # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR # define _GL_USE_CRT_EXTERNS # endif # endif # ifdef _GL_USE_CRT_EXTERNS # include # define environ (*_NSGetEnviron ()) # else # ifdef __cplusplus extern "C" { # endif extern char **environ; # ifdef __cplusplus } # endif # endif # endif #elif defined GNULIB_POSIXCHECK # if HAVE_RAW_DECL_ENVIRON _GL_UNISTD_INLINE char *** rpl_environ (void) { return &environ; } _GL_WARN_ON_USE (rpl_environ, "environ is unportable - " "use gnulib module environ for portability"); # undef environ # define environ (*rpl_environ ()) # endif #endif #if @GNULIB_EUIDACCESS@ /* Like access(), except that it uses the effective user id and group id of the current process. */ # if !@HAVE_EUIDACCESS@ _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode)); _GL_CXXALIASWARN (euidaccess); # if defined GNULIB_POSIXCHECK /* Like access(), this function is a security risk. */ _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - " "use the gnulib module faccessat instead"); # endif #elif defined GNULIB_POSIXCHECK # undef euidaccess # if HAVE_RAW_DECL_EUIDACCESS _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - " "use gnulib module euidaccess for portability"); # endif #endif #if @GNULIB_FACCESSAT@ # if !@HAVE_FACCESSAT@ _GL_FUNCDECL_SYS (faccessat, int, (int fd, char const *file, int mode, int flag) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (faccessat, int, (int fd, char const *file, int mode, int flag)); _GL_CXXALIASWARN (faccessat); #elif defined GNULIB_POSIXCHECK # undef faccessat # if HAVE_RAW_DECL_FACCESSAT _GL_WARN_ON_USE (faccessat, "faccessat is not portable - " "use gnulib module faccessat for portability"); # endif #endif #if @GNULIB_FCHDIR@ /* Change the process' current working directory to the directory on which the given file descriptor is open. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification . */ # if ! @HAVE_FCHDIR@ _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); /* Gnulib internal hooks needed to maintain the fchdir metadata. */ _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename) _GL_ARG_NONNULL ((2)); _GL_EXTERN_C void _gl_unregister_fd (int fd); _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); _GL_EXTERN_C const char *_gl_directory_name (int fd); # else # if !@HAVE_DECL_FCHDIR@ _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); # endif # endif _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); _GL_CXXALIASWARN (fchdir); #elif defined GNULIB_POSIXCHECK # undef fchdir # if HAVE_RAW_DECL_FCHDIR _GL_WARN_ON_USE (fchdir, "fchdir is unportable - " "use gnulib module fchdir for portability"); # endif #endif #if @GNULIB_FCHOWNAT@ # if @REPLACE_FCHOWNAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fchownat # define fchownat rpl_fchownat # endif _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file, uid_t owner, gid_t group, int flag) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file, uid_t owner, gid_t group, int flag)); # else # if !@HAVE_FCHOWNAT@ _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file, uid_t owner, gid_t group, int flag) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file, uid_t owner, gid_t group, int flag)); # endif _GL_CXXALIASWARN (fchownat); #elif defined GNULIB_POSIXCHECK # undef fchownat # if HAVE_RAW_DECL_FCHOWNAT _GL_WARN_ON_USE (fchownat, "fchownat is not portable - " "use gnulib module openat for portability"); # endif #endif #if @GNULIB_FDATASYNC@ /* Synchronize changes to a file. Return 0 if successful, otherwise -1 and errno set. See POSIX:2008 specification . */ # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ _GL_FUNCDECL_SYS (fdatasync, int, (int fd)); # endif _GL_CXXALIAS_SYS (fdatasync, int, (int fd)); _GL_CXXALIASWARN (fdatasync); #elif defined GNULIB_POSIXCHECK # undef fdatasync # if HAVE_RAW_DECL_FDATASYNC _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - " "use gnulib module fdatasync for portability"); # endif #endif #if @GNULIB_FSYNC@ /* Synchronize changes, including metadata, to a file. Return 0 if successful, otherwise -1 and errno set. See POSIX:2008 specification . */ # if !@HAVE_FSYNC@ _GL_FUNCDECL_SYS (fsync, int, (int fd)); # endif _GL_CXXALIAS_SYS (fsync, int, (int fd)); _GL_CXXALIASWARN (fsync); #elif defined GNULIB_POSIXCHECK # undef fsync # if HAVE_RAW_DECL_FSYNC _GL_WARN_ON_USE (fsync, "fsync is unportable - " "use gnulib module fsync for portability"); # endif #endif #if @GNULIB_FTRUNCATE@ /* Change the size of the file to which FD is opened to become equal to LENGTH. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification . */ # if @REPLACE_FTRUNCATE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ftruncate # define ftruncate rpl_ftruncate # endif _GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length)); _GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length)); # else # if !@HAVE_FTRUNCATE@ _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); # endif _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); # endif _GL_CXXALIASWARN (ftruncate); #elif defined GNULIB_POSIXCHECK # undef ftruncate # if HAVE_RAW_DECL_FTRUNCATE _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " "use gnulib module ftruncate for portability"); # endif #endif #if @GNULIB_GETCWD@ /* Get the name of the current working directory, and put it in SIZE bytes of BUF. Return BUF if successful, or NULL if the directory couldn't be determined or SIZE was too small. See the POSIX:2008 specification . Additionally, the gnulib module 'getcwd' guarantees the following GNU extension: If BUF is NULL, an array is allocated with 'malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case it is as big as necessary. */ # if @REPLACE_GETCWD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define getcwd rpl_getcwd # endif _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); # else /* Need to cast, because on mingw, the second parameter is int size. */ _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size)); # endif _GL_CXXALIASWARN (getcwd); #elif defined GNULIB_POSIXCHECK # undef getcwd # if HAVE_RAW_DECL_GETCWD _GL_WARN_ON_USE (getcwd, "getcwd is unportable - " "use gnulib module getcwd for portability"); # endif #endif #if @GNULIB_GETDOMAINNAME@ /* Return the NIS domain name of the machine. WARNING! The NIS domain name is unrelated to the fully qualified host name of the machine. It is also unrelated to email addresses. WARNING! The NIS domain name is usually the empty string or "(none)" when not using NIS. Put up to LEN bytes of the NIS domain name into NAME. Null terminate it if the name is shorter than LEN. If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. Return 0 if successful, otherwise set errno and return -1. */ # if @REPLACE_GETDOMAINNAME@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getdomainname # define getdomainname rpl_getdomainname # endif _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len)); # else # if !@HAVE_DECL_GETDOMAINNAME@ _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); # endif _GL_CXXALIASWARN (getdomainname); #elif defined GNULIB_POSIXCHECK # undef getdomainname # if HAVE_RAW_DECL_GETDOMAINNAME _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - " "use gnulib module getdomainname for portability"); # endif #endif #if @GNULIB_GETDTABLESIZE@ /* Return the maximum number of file descriptors in the current process. In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ # if @REPLACE_GETDTABLESIZE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getdtablesize # define getdtablesize rpl_getdtablesize # endif _GL_FUNCDECL_RPL (getdtablesize, int, (void)); _GL_CXXALIAS_RPL (getdtablesize, int, (void)); # else # if !@HAVE_GETDTABLESIZE@ _GL_FUNCDECL_SYS (getdtablesize, int, (void)); # endif _GL_CXXALIAS_SYS (getdtablesize, int, (void)); # endif _GL_CXXALIASWARN (getdtablesize); #elif defined GNULIB_POSIXCHECK # undef getdtablesize # if HAVE_RAW_DECL_GETDTABLESIZE _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " "use gnulib module getdtablesize for portability"); # endif #endif #if @GNULIB_GETGROUPS@ /* Return the supplemental groups that the current process belongs to. It is unspecified whether the effective group id is in the list. If N is 0, return the group count; otherwise, N describes how many entries are available in GROUPS. Return -1 and set errno if N is not 0 and not large enough. Fails with ENOSYS on some systems. */ # if @REPLACE_GETGROUPS@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef getgroups # define getgroups rpl_getgroups # endif _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups)); _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups)); # else # if !@HAVE_GETGROUPS@ _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups)); # endif _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups)); # endif _GL_CXXALIASWARN (getgroups); #elif defined GNULIB_POSIXCHECK # undef getgroups # if HAVE_RAW_DECL_GETGROUPS _GL_WARN_ON_USE (getgroups, "getgroups is unportable - " "use gnulib module getgroups for portability"); # endif #endif #if @GNULIB_GETHOSTNAME@ /* Return the standard host name of the machine. WARNING! The host name may or may not be fully qualified. Put up to LEN bytes of the host name into NAME. Null terminate it if the name is shorter than LEN. If the host name is longer than LEN, set errno = EINVAL and return -1. Return 0 if successful, otherwise set errno and return -1. */ # if @UNISTD_H_HAVE_WINSOCK2_H@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef gethostname # define gethostname rpl_gethostname # endif _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len)); # else # if !@HAVE_GETHOSTNAME@ _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len) _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second parameter is int len. */ _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len)); # endif _GL_CXXALIASWARN (gethostname); #elif @UNISTD_H_HAVE_WINSOCK2_H@ # undef gethostname # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname #elif defined GNULIB_POSIXCHECK # undef gethostname # if HAVE_RAW_DECL_GETHOSTNAME _GL_WARN_ON_USE (gethostname, "gethostname is unportable - " "use gnulib module gethostname for portability"); # endif #endif #if @GNULIB_GETLOGIN@ /* Returns the user's login name, or NULL if it cannot be found. Upon error, returns NULL with errno set. See . Most programs don't need to use this function, because the information is available through environment variables: ${LOGNAME-$USER} on Unix platforms, $USERNAME on native Windows platforms. */ # if !@HAVE_GETLOGIN@ _GL_FUNCDECL_SYS (getlogin, char *, (void)); # endif _GL_CXXALIAS_SYS (getlogin, char *, (void)); _GL_CXXALIASWARN (getlogin); #elif defined GNULIB_POSIXCHECK # undef getlogin # if HAVE_RAW_DECL_GETLOGIN _GL_WARN_ON_USE (getlogin, "getlogin is unportable - " "use gnulib module getlogin for portability"); # endif #endif #if @GNULIB_GETLOGIN_R@ /* Copies the user's login name to NAME. The array pointed to by NAME has room for SIZE bytes. Returns 0 if successful. Upon error, an error number is returned, or -1 in the case that the login name cannot be found but no specific error is provided (this case is hopefully rare but is left open by the POSIX spec). See . Most programs don't need to use this function, because the information is available through environment variables: ${LOGNAME-$USER} on Unix platforms, $USERNAME on native Windows platforms. */ # if @REPLACE_GETLOGIN_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define getlogin_r rpl_getlogin_r # endif _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size)); # else # if !@HAVE_DECL_GETLOGIN_R@ _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on Solaris 10 systems, the second argument is int size. */ _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size)); # endif _GL_CXXALIASWARN (getlogin_r); #elif defined GNULIB_POSIXCHECK # undef getlogin_r # if HAVE_RAW_DECL_GETLOGIN_R _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - " "use gnulib module getlogin_r for portability"); # endif #endif #if @GNULIB_GETPAGESIZE@ # if @REPLACE_GETPAGESIZE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define getpagesize rpl_getpagesize # endif _GL_FUNCDECL_RPL (getpagesize, int, (void)); _GL_CXXALIAS_RPL (getpagesize, int, (void)); # else # if !@HAVE_GETPAGESIZE@ # if !defined getpagesize /* This is for POSIX systems. */ # if !defined _gl_getpagesize && defined _SC_PAGESIZE # if ! (defined __VMS && __VMS_VER < 70000000) # define _gl_getpagesize() sysconf (_SC_PAGESIZE) # endif # endif /* This is for older VMS. */ # if !defined _gl_getpagesize && defined __VMS # ifdef __ALPHA # define _gl_getpagesize() 8192 # else # define _gl_getpagesize() 512 # endif # endif /* This is for BeOS. */ # if !defined _gl_getpagesize && @HAVE_OS_H@ # include # if defined B_PAGE_SIZE # define _gl_getpagesize() B_PAGE_SIZE # endif # endif /* This is for AmigaOS4.0. */ # if !defined _gl_getpagesize && defined __amigaos4__ # define _gl_getpagesize() 2048 # endif /* This is for older Unix systems. */ # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@ # include # ifdef EXEC_PAGESIZE # define _gl_getpagesize() EXEC_PAGESIZE # else # ifdef NBPG # ifndef CLSIZE # define CLSIZE 1 # endif # define _gl_getpagesize() (NBPG * CLSIZE) # else # ifdef NBPC # define _gl_getpagesize() NBPC # endif # endif # endif # endif # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define getpagesize() _gl_getpagesize () # else # if !GNULIB_defined_getpagesize_function _GL_UNISTD_INLINE int getpagesize () { return _gl_getpagesize (); } # define GNULIB_defined_getpagesize_function 1 # endif # endif # endif # endif /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */ _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void)); # endif # if @HAVE_DECL_GETPAGESIZE@ _GL_CXXALIASWARN (getpagesize); # endif #elif defined GNULIB_POSIXCHECK # undef getpagesize # if HAVE_RAW_DECL_GETPAGESIZE _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - " "use gnulib module getpagesize for portability"); # endif #endif #if @GNULIB_GETUSERSHELL@ /* Return the next valid login shell on the system, or NULL when the end of the list has been reached. */ # if !@HAVE_DECL_GETUSERSHELL@ _GL_FUNCDECL_SYS (getusershell, char *, (void)); # endif _GL_CXXALIAS_SYS (getusershell, char *, (void)); _GL_CXXALIASWARN (getusershell); #elif defined GNULIB_POSIXCHECK # undef getusershell # if HAVE_RAW_DECL_GETUSERSHELL _GL_WARN_ON_USE (getusershell, "getusershell is unportable - " "use gnulib module getusershell for portability"); # endif #endif #if @GNULIB_GETUSERSHELL@ /* Rewind to pointer that is advanced at each getusershell() call. */ # if !@HAVE_DECL_GETUSERSHELL@ _GL_FUNCDECL_SYS (setusershell, void, (void)); # endif _GL_CXXALIAS_SYS (setusershell, void, (void)); _GL_CXXALIASWARN (setusershell); #elif defined GNULIB_POSIXCHECK # undef setusershell # if HAVE_RAW_DECL_SETUSERSHELL _GL_WARN_ON_USE (setusershell, "setusershell is unportable - " "use gnulib module getusershell for portability"); # endif #endif #if @GNULIB_GETUSERSHELL@ /* Free the pointer that is advanced at each getusershell() call and associated resources. */ # if !@HAVE_DECL_GETUSERSHELL@ _GL_FUNCDECL_SYS (endusershell, void, (void)); # endif _GL_CXXALIAS_SYS (endusershell, void, (void)); _GL_CXXALIASWARN (endusershell); #elif defined GNULIB_POSIXCHECK # undef endusershell # if HAVE_RAW_DECL_ENDUSERSHELL _GL_WARN_ON_USE (endusershell, "endusershell is unportable - " "use gnulib module getusershell for portability"); # endif #endif #if @GNULIB_GROUP_MEMBER@ /* Determine whether group id is in calling user's group list. */ # if !@HAVE_GROUP_MEMBER@ _GL_FUNCDECL_SYS (group_member, int, (gid_t gid)); # endif _GL_CXXALIAS_SYS (group_member, int, (gid_t gid)); _GL_CXXALIASWARN (group_member); #elif defined GNULIB_POSIXCHECK # undef group_member # if HAVE_RAW_DECL_GROUP_MEMBER _GL_WARN_ON_USE (group_member, "group_member is unportable - " "use gnulib module group-member for portability"); # endif #endif #if @GNULIB_ISATTY@ # if @REPLACE_ISATTY@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef isatty # define isatty rpl_isatty # endif _GL_FUNCDECL_RPL (isatty, int, (int fd)); _GL_CXXALIAS_RPL (isatty, int, (int fd)); # else _GL_CXXALIAS_SYS (isatty, int, (int fd)); # endif _GL_CXXALIASWARN (isatty); #elif defined GNULIB_POSIXCHECK # undef isatty # if HAVE_RAW_DECL_ISATTY _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " "use gnulib module isatty for portability"); # endif #endif #if @GNULIB_LCHOWN@ /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE to GID (if GID is not -1). Do not follow symbolic links. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2008 specification . */ # if @REPLACE_LCHOWN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef lchown # define lchown rpl_lchown # endif _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)); # else # if !@HAVE_LCHOWN@ _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)); # endif _GL_CXXALIASWARN (lchown); #elif defined GNULIB_POSIXCHECK # undef lchown # if HAVE_RAW_DECL_LCHOWN _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " "use gnulib module lchown for portability"); # endif #endif #if @GNULIB_LINK@ /* Create a new hard link for an existing file. Return 0 if successful, otherwise -1 and errno set. See POSIX:2008 specification . */ # if @REPLACE_LINK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define link rpl_link # endif _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2)); # else # if !@HAVE_LINK@ _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2)); # endif _GL_CXXALIASWARN (link); #elif defined GNULIB_POSIXCHECK # undef link # if HAVE_RAW_DECL_LINK _GL_WARN_ON_USE (link, "link is unportable - " "use gnulib module link for portability"); # endif #endif #if @GNULIB_LINKAT@ /* Create a new hard link for an existing file, relative to two directories. FLAG controls whether symlinks are followed. Return 0 if successful, otherwise -1 and errno set. */ # if @REPLACE_LINKAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef linkat # define linkat rpl_linkat # endif _GL_FUNCDECL_RPL (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, int flag) _GL_ARG_NONNULL ((2, 4))); _GL_CXXALIAS_RPL (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, int flag)); # else # if !@HAVE_LINKAT@ _GL_FUNCDECL_SYS (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, int flag) _GL_ARG_NONNULL ((2, 4))); # endif _GL_CXXALIAS_SYS (linkat, int, (int fd1, const char *path1, int fd2, const char *path2, int flag)); # endif _GL_CXXALIASWARN (linkat); #elif defined GNULIB_POSIXCHECK # undef linkat # if HAVE_RAW_DECL_LINKAT _GL_WARN_ON_USE (linkat, "linkat is unportable - " "use gnulib module linkat for portability"); # endif #endif #if @GNULIB_LSEEK@ /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. Return the new offset if successful, otherwise -1 and errno set. See the POSIX:2008 specification . */ # if @REPLACE_LSEEK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define lseek rpl_lseek # endif _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); # else _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); # endif _GL_CXXALIASWARN (lseek); #elif defined GNULIB_POSIXCHECK # undef lseek # if HAVE_RAW_DECL_LSEEK _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " "systems - use gnulib module lseek for portability"); # endif #endif #if @GNULIB_PIPE@ /* Create a pipe, defaulting to O_BINARY mode. Store the read-end as fd[0] and the write-end as fd[1]. Return 0 upon success, or -1 with errno set upon failure. */ # if !@HAVE_PIPE@ _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (pipe, int, (int fd[2])); _GL_CXXALIASWARN (pipe); #elif defined GNULIB_POSIXCHECK # undef pipe # if HAVE_RAW_DECL_PIPE _GL_WARN_ON_USE (pipe, "pipe is unportable - " "use gnulib module pipe-posix for portability"); # endif #endif #if @GNULIB_PIPE2@ /* Create a pipe, applying the given flags when opening the read-end of the pipe and the write-end of the pipe. The flags are a bitmask, possibly including O_CLOEXEC (defined in ) and O_TEXT, O_BINARY (defined in "binary-io.h"). Store the read-end as fd[0] and the write-end as fd[1]. Return 0 upon success, or -1 with errno set upon failure. See also the Linux man page at . */ # if @HAVE_PIPE2@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define pipe2 rpl_pipe2 # endif _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags)); # else _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags)); # endif _GL_CXXALIASWARN (pipe2); #elif defined GNULIB_POSIXCHECK # undef pipe2 # if HAVE_RAW_DECL_PIPE2 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " "use gnulib module pipe2 for portability"); # endif #endif #if @GNULIB_PREAD@ /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. Return the number of bytes placed into BUF if successful, otherwise set errno and return -1. 0 indicates EOF. See the POSIX:2008 specification . */ # if @REPLACE_PREAD@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef pread # define pread rpl_pread # endif _GL_FUNCDECL_RPL (pread, ssize_t, (int fd, void *buf, size_t bufsize, off_t offset) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (pread, ssize_t, (int fd, void *buf, size_t bufsize, off_t offset)); # else # if !@HAVE_PREAD@ _GL_FUNCDECL_SYS (pread, ssize_t, (int fd, void *buf, size_t bufsize, off_t offset) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (pread, ssize_t, (int fd, void *buf, size_t bufsize, off_t offset)); # endif _GL_CXXALIASWARN (pread); #elif defined GNULIB_POSIXCHECK # undef pread # if HAVE_RAW_DECL_PREAD _GL_WARN_ON_USE (pread, "pread is unportable - " "use gnulib module pread for portability"); # endif #endif #if @GNULIB_PWRITE@ /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. Return the number of bytes written if successful, otherwise set errno and return -1. 0 indicates nothing written. See the POSIX:2008 specification . */ # if @REPLACE_PWRITE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef pwrite # define pwrite rpl_pwrite # endif _GL_FUNCDECL_RPL (pwrite, ssize_t, (int fd, const void *buf, size_t bufsize, off_t offset) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (pwrite, ssize_t, (int fd, const void *buf, size_t bufsize, off_t offset)); # else # if !@HAVE_PWRITE@ _GL_FUNCDECL_SYS (pwrite, ssize_t, (int fd, const void *buf, size_t bufsize, off_t offset) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (pwrite, ssize_t, (int fd, const void *buf, size_t bufsize, off_t offset)); # endif _GL_CXXALIASWARN (pwrite); #elif defined GNULIB_POSIXCHECK # undef pwrite # if HAVE_RAW_DECL_PWRITE _GL_WARN_ON_USE (pwrite, "pwrite is unportable - " "use gnulib module pwrite for portability"); # endif #endif #if @GNULIB_READ@ /* Read up to COUNT bytes from file descriptor FD into the buffer starting at BUF. See the POSIX:2008 specification . */ # if @REPLACE_READ@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef read # define read rpl_read # endif _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); # else /* Need to cast, because on mingw, the third parameter is unsigned int count and the return type is 'int'. */ _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count)); # endif _GL_CXXALIASWARN (read); #endif #if @GNULIB_READLINK@ /* Read the contents of the symbolic link FILE and place the first BUFSIZE bytes of it into BUF. Return the number of bytes placed into BUF if successful, otherwise -1 and errno set. See the POSIX:2008 specification . */ # if @REPLACE_READLINK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define readlink rpl_readlink # endif _GL_FUNCDECL_RPL (readlink, ssize_t, (const char *file, char *buf, size_t bufsize) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (readlink, ssize_t, (const char *file, char *buf, size_t bufsize)); # else # if !@HAVE_READLINK@ _GL_FUNCDECL_SYS (readlink, ssize_t, (const char *file, char *buf, size_t bufsize) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (readlink, ssize_t, (const char *file, char *buf, size_t bufsize)); # endif _GL_CXXALIASWARN (readlink); #elif defined GNULIB_POSIXCHECK # undef readlink # if HAVE_RAW_DECL_READLINK _GL_WARN_ON_USE (readlink, "readlink is unportable - " "use gnulib module readlink for portability"); # endif #endif #if @GNULIB_READLINKAT@ # if @REPLACE_READLINKAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define readlinkat rpl_readlinkat # endif _GL_FUNCDECL_RPL (readlinkat, ssize_t, (int fd, char const *file, char *buf, size_t len) _GL_ARG_NONNULL ((2, 3))); _GL_CXXALIAS_RPL (readlinkat, ssize_t, (int fd, char const *file, char *buf, size_t len)); # else # if !@HAVE_READLINKAT@ _GL_FUNCDECL_SYS (readlinkat, ssize_t, (int fd, char const *file, char *buf, size_t len) _GL_ARG_NONNULL ((2, 3))); # endif _GL_CXXALIAS_SYS (readlinkat, ssize_t, (int fd, char const *file, char *buf, size_t len)); # endif _GL_CXXALIASWARN (readlinkat); #elif defined GNULIB_POSIXCHECK # undef readlinkat # if HAVE_RAW_DECL_READLINKAT _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " "use gnulib module readlinkat for portability"); # endif #endif #if @GNULIB_RMDIR@ /* Remove the directory DIR. */ # if @REPLACE_RMDIR@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define rmdir rpl_rmdir # endif _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (rmdir, int, (char const *name)); # else _GL_CXXALIAS_SYS (rmdir, int, (char const *name)); # endif _GL_CXXALIASWARN (rmdir); #elif defined GNULIB_POSIXCHECK # undef rmdir # if HAVE_RAW_DECL_RMDIR _GL_WARN_ON_USE (rmdir, "rmdir is unportable - " "use gnulib module rmdir for portability"); # endif #endif #if @GNULIB_SETHOSTNAME@ /* Set the host name of the machine. The host name may or may not be fully qualified. Put LEN bytes of NAME into the host name. Return 0 if successful, otherwise, set errno and return -1. Platforms with no ability to set the hostname return -1 and set errno = ENOSYS. */ # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) _GL_ARG_NONNULL ((1))); # endif /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5 and FreeBSD 6.4 the second parameter is int. On Solaris 11 2011-10, the first parameter is not const. */ _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); _GL_CXXALIASWARN (sethostname); #elif defined GNULIB_POSIXCHECK # undef sethostname # if HAVE_RAW_DECL_SETHOSTNAME _GL_WARN_ON_USE (sethostname, "sethostname is unportable - " "use gnulib module sethostname for portability"); # endif #endif #if @GNULIB_SLEEP@ /* Pause the execution of the current thread for N seconds. Returns the number of seconds left to sleep. See the POSIX:2008 specification . */ # if @REPLACE_SLEEP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef sleep # define sleep rpl_sleep # endif _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n)); _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n)); # else # if !@HAVE_SLEEP@ _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n)); # endif _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n)); # endif _GL_CXXALIASWARN (sleep); #elif defined GNULIB_POSIXCHECK # undef sleep # if HAVE_RAW_DECL_SLEEP _GL_WARN_ON_USE (sleep, "sleep is unportable - " "use gnulib module sleep for portability"); # endif #endif #if @GNULIB_SYMLINK@ # if @REPLACE_SYMLINK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef symlink # define symlink rpl_symlink # endif _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file)); # else # if !@HAVE_SYMLINK@ _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file) _GL_ARG_NONNULL ((1, 2))); # endif _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file)); # endif _GL_CXXALIASWARN (symlink); #elif defined GNULIB_POSIXCHECK # undef symlink # if HAVE_RAW_DECL_SYMLINK _GL_WARN_ON_USE (symlink, "symlink is not portable - " "use gnulib module symlink for portability"); # endif #endif #if @GNULIB_SYMLINKAT@ # if @REPLACE_SYMLINKAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef symlinkat # define symlinkat rpl_symlinkat # endif _GL_FUNCDECL_RPL (symlinkat, int, (char const *contents, int fd, char const *file) _GL_ARG_NONNULL ((1, 3))); _GL_CXXALIAS_RPL (symlinkat, int, (char const *contents, int fd, char const *file)); # else # if !@HAVE_SYMLINKAT@ _GL_FUNCDECL_SYS (symlinkat, int, (char const *contents, int fd, char const *file) _GL_ARG_NONNULL ((1, 3))); # endif _GL_CXXALIAS_SYS (symlinkat, int, (char const *contents, int fd, char const *file)); # endif _GL_CXXALIASWARN (symlinkat); #elif defined GNULIB_POSIXCHECK # undef symlinkat # if HAVE_RAW_DECL_SYMLINKAT _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " "use gnulib module symlinkat for portability"); # endif #endif #if @GNULIB_TTYNAME_R@ /* Store at most BUFLEN characters of the pathname of the terminal FD is open on in BUF. Return 0 on success, otherwise an error number. */ # if @REPLACE_TTYNAME_R@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef ttyname_r # define ttyname_r rpl_ttyname_r # endif _GL_FUNCDECL_RPL (ttyname_r, int, (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (ttyname_r, int, (int fd, char *buf, size_t buflen)); # else # if !@HAVE_DECL_TTYNAME_R@ _GL_FUNCDECL_SYS (ttyname_r, int, (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (ttyname_r, int, (int fd, char *buf, size_t buflen)); # endif _GL_CXXALIASWARN (ttyname_r); #elif defined GNULIB_POSIXCHECK # undef ttyname_r # if HAVE_RAW_DECL_TTYNAME_R _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " "use gnulib module ttyname_r for portability"); # endif #endif #if @GNULIB_UNLINK@ # if @REPLACE_UNLINK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef unlink # define unlink rpl_unlink # endif _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (unlink, int, (char const *file)); # else _GL_CXXALIAS_SYS (unlink, int, (char const *file)); # endif _GL_CXXALIASWARN (unlink); #elif defined GNULIB_POSIXCHECK # undef unlink # if HAVE_RAW_DECL_UNLINK _GL_WARN_ON_USE (unlink, "unlink is not portable - " "use gnulib module unlink for portability"); # endif #endif #if @GNULIB_UNLINKAT@ # if @REPLACE_UNLINKAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef unlinkat # define unlinkat rpl_unlinkat # endif _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag)); # else # if !@HAVE_UNLINKAT@ _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2))); # endif _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag)); # endif _GL_CXXALIASWARN (unlinkat); #elif defined GNULIB_POSIXCHECK # undef unlinkat # if HAVE_RAW_DECL_UNLINKAT _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " "use gnulib module openat for portability"); # endif #endif #if @GNULIB_USLEEP@ /* Pause the execution of the current thread for N microseconds. Returns 0 on completion, or -1 on range error. See the POSIX:2001 specification . */ # if @REPLACE_USLEEP@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef usleep # define usleep rpl_usleep # endif _GL_FUNCDECL_RPL (usleep, int, (useconds_t n)); _GL_CXXALIAS_RPL (usleep, int, (useconds_t n)); # else # if !@HAVE_USLEEP@ _GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); # endif _GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); # endif _GL_CXXALIASWARN (usleep); #elif defined GNULIB_POSIXCHECK # undef usleep # if HAVE_RAW_DECL_USLEEP _GL_WARN_ON_USE (usleep, "usleep is unportable - " "use gnulib module usleep for portability"); # endif #endif #if @GNULIB_WRITE@ /* Write up to COUNT bytes starting at BUF to file descriptor FD. See the POSIX:2008 specification . */ # if @REPLACE_WRITE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef write # define write rpl_write # endif _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); # else /* Need to cast, because on mingw, the third parameter is unsigned int count and the return type is 'int'. */ _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count)); # endif _GL_CXXALIASWARN (write); #endif _GL_INLINE_HEADER_END #endif /* _@GUARD_PREFIX@_UNISTD_H */ #endif /* _GL_INCLUDING_UNISTD_H */ #endif /* _@GUARD_PREFIX@_UNISTD_H */ lftp-4.6.3a/lib/strtoul.c0000644000015000007670000000145012466374012012206 00000000000000/* Copyright (C) 1991, 1997, 2009-2015 Free Software Foundation, Inc. This file is part of 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 . */ #define UNSIGNED 1 #include "strtol.c" lftp-4.6.3a/lib/signbitd.c0000644000015000007670000000406612466374012012303 00000000000000/* signbit() macro: Determine the sign bit of a floating-point number. Copyright (C) 2007-2015 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 . */ #include /* Specification. */ #include #include #include "isnand-nolibm.h" #include "float+.h" #ifdef gl_signbitd_OPTIMIZED_MACRO # undef gl_signbitd #endif int gl_signbitd (double arg) { #if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT /* The use of a union to extract the bits of the representation of a 'long double' is safe in practice, despite of the "aliasing rules" of C99, because the GCC docs say "Even with '-fstrict-aliasing', type-punning is allowed, provided the memory is accessed through the union type." and similarly for other compilers. */ # define NWORDS \ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) union { double value; unsigned int word[NWORDS]; } m; m.value = arg; return (m.word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; #elif HAVE_COPYSIGN_IN_LIBC return copysign (1.0, arg) < 0; #else /* This does not do the right thing for NaN, but this is irrelevant for most use cases. */ if (isnand (arg)) return 0; if (arg < 0.0) return 1; else if (arg == 0.0) { /* Distinguish 0.0 and -0.0. */ static double plus_zero = 0.0; double arg_mem = arg; return (memcmp (&plus_zero, &arg_mem, SIZEOF_DBL) != 0); } else return 0; #endif } lftp-4.6.3a/lib/c-strcase.h0000644000015000007670000000401412466374011012361 00000000000000/* Case-insensitive string comparison functions in C locale. Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2015 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 . */ #ifndef C_STRCASE_H #define C_STRCASE_H #include /* The functions defined in this file assume the "C" locale and a character set without diacritics (ASCII-US or EBCDIC-US or something like that). Even if the "C" locale on a particular system is an extension of the ASCII character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it is ISO-8859-1), the functions in this file recognize only the ASCII characters. More precisely, one of the string arguments must be an ASCII string; the other one can also contain non-ASCII characters (but then the comparison result will be nonzero). */ #ifdef __cplusplus extern "C" { #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. */ extern int c_strcasecmp (const char *s1, const char *s2) _GL_ATTRIBUTE_PURE; /* Compare no more than N characters 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. */ extern int c_strncasecmp (const char *s1, const char *s2, size_t n) _GL_ATTRIBUTE_PURE; #ifdef __cplusplus } #endif #endif /* C_STRCASE_H */ lftp-4.6.3a/lib/errno.in.h0000644000015000007670000001646312466374011012242 00000000000000/* A POSIX-like . Copyright (C) 2008-2015 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 . */ #ifndef _@GUARD_PREFIX@_ERRNO_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_ERRNO_H@ #ifndef _@GUARD_PREFIX@_ERRNO_H #define _@GUARD_PREFIX@_ERRNO_H /* On native Windows platforms, many macros are not defined. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* These are the same values as defined by MSVC 10, for interoperability. */ # ifndef ENOMSG # define ENOMSG 122 # define GNULIB_defined_ENOMSG 1 # endif # ifndef EIDRM # define EIDRM 111 # define GNULIB_defined_EIDRM 1 # endif # ifndef ENOLINK # define ENOLINK 121 # define GNULIB_defined_ENOLINK 1 # endif # ifndef EPROTO # define EPROTO 134 # define GNULIB_defined_EPROTO 1 # endif # ifndef EBADMSG # define EBADMSG 104 # define GNULIB_defined_EBADMSG 1 # endif # ifndef EOVERFLOW # define EOVERFLOW 132 # define GNULIB_defined_EOVERFLOW 1 # endif # ifndef ENOTSUP # define ENOTSUP 129 # define GNULIB_defined_ENOTSUP 1 # endif # ifndef ENETRESET # define ENETRESET 117 # define GNULIB_defined_ENETRESET 1 # endif # ifndef ECONNABORTED # define ECONNABORTED 106 # define GNULIB_defined_ECONNABORTED 1 # endif # ifndef ECANCELED # define ECANCELED 105 # define GNULIB_defined_ECANCELED 1 # endif # ifndef EOWNERDEAD # define EOWNERDEAD 133 # define GNULIB_defined_EOWNERDEAD 1 # endif # ifndef ENOTRECOVERABLE # define ENOTRECOVERABLE 127 # define GNULIB_defined_ENOTRECOVERABLE 1 # endif # ifndef EINPROGRESS # define EINPROGRESS 112 # define EALREADY 103 # define ENOTSOCK 128 # define EDESTADDRREQ 109 # define EMSGSIZE 115 # define EPROTOTYPE 136 # define ENOPROTOOPT 123 # define EPROTONOSUPPORT 135 # define EOPNOTSUPP 130 # define EAFNOSUPPORT 102 # define EADDRINUSE 100 # define EADDRNOTAVAIL 101 # define ENETDOWN 116 # define ENETUNREACH 118 # define ECONNRESET 108 # define ENOBUFS 119 # define EISCONN 113 # define ENOTCONN 126 # define ETIMEDOUT 138 # define ECONNREFUSED 107 # define ELOOP 114 # define EHOSTUNREACH 110 # define EWOULDBLOCK 140 # define GNULIB_defined_ESOCK 1 # endif # ifndef ETXTBSY # define ETXTBSY 139 # define ENODATA 120 /* not required by POSIX */ # define ENOSR 124 /* not required by POSIX */ # define ENOSTR 125 /* not required by POSIX */ # define ETIME 137 /* not required by POSIX */ # define EOTHER 131 /* not required by POSIX */ # define GNULIB_defined_ESTREAMS 1 # endif /* These are intentionally the same values as the WSA* error numbers, defined in . */ # define ESOCKTNOSUPPORT 10044 /* not required by POSIX */ # define EPFNOSUPPORT 10046 /* not required by POSIX */ # define ESHUTDOWN 10058 /* not required by POSIX */ # define ETOOMANYREFS 10059 /* not required by POSIX */ # define EHOSTDOWN 10064 /* not required by POSIX */ # define EPROCLIM 10067 /* not required by POSIX */ # define EUSERS 10068 /* not required by POSIX */ # define EDQUOT 10069 # define ESTALE 10070 # define EREMOTE 10071 /* not required by POSIX */ # define GNULIB_defined_EWINSOCK 1 # endif /* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */ # if @EMULTIHOP_HIDDEN@ # define EMULTIHOP @EMULTIHOP_VALUE@ # define GNULIB_defined_EMULTIHOP 1 # endif # if @ENOLINK_HIDDEN@ # define ENOLINK @ENOLINK_VALUE@ # define GNULIB_defined_ENOLINK 1 # endif # if @EOVERFLOW_HIDDEN@ # define EOVERFLOW @EOVERFLOW_VALUE@ # define GNULIB_defined_EOVERFLOW 1 # endif /* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK, EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined. Likewise, on NonStop Kernel, EDQUOT is not defined. Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151, HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133. Note: When one of these systems defines some of these macros some day, binaries will have to be recompiled so that they recognizes the new errno values from the system. */ # ifndef ENOMSG # define ENOMSG 2000 # define GNULIB_defined_ENOMSG 1 # endif # ifndef EIDRM # define EIDRM 2001 # define GNULIB_defined_EIDRM 1 # endif # ifndef ENOLINK # define ENOLINK 2002 # define GNULIB_defined_ENOLINK 1 # endif # ifndef EPROTO # define EPROTO 2003 # define GNULIB_defined_EPROTO 1 # endif # ifndef EMULTIHOP # define EMULTIHOP 2004 # define GNULIB_defined_EMULTIHOP 1 # endif # ifndef EBADMSG # define EBADMSG 2005 # define GNULIB_defined_EBADMSG 1 # endif # ifndef EOVERFLOW # define EOVERFLOW 2006 # define GNULIB_defined_EOVERFLOW 1 # endif # ifndef ENOTSUP # define ENOTSUP 2007 # define GNULIB_defined_ENOTSUP 1 # endif # ifndef ENETRESET # define ENETRESET 2011 # define GNULIB_defined_ENETRESET 1 # endif # ifndef ECONNABORTED # define ECONNABORTED 2012 # define GNULIB_defined_ECONNABORTED 1 # endif # ifndef ESTALE # define ESTALE 2009 # define GNULIB_defined_ESTALE 1 # endif # ifndef EDQUOT # define EDQUOT 2010 # define GNULIB_defined_EDQUOT 1 # endif # ifndef ECANCELED # define ECANCELED 2008 # define GNULIB_defined_ECANCELED 1 # endif /* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not defined. */ # ifndef EOWNERDEAD # if defined __sun /* Use the same values as defined for Solaris >= 8, for interoperability. */ # define EOWNERDEAD 58 # define ENOTRECOVERABLE 59 # elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* We have a conflict here: pthreads-win32 defines these values differently than MSVC 10. It's hairy to decide which one to use. */ # if defined __MINGW32__ && !defined USE_WINDOWS_THREADS /* Use the same values as defined by pthreads-win32, for interoperability. */ # define EOWNERDEAD 43 # define ENOTRECOVERABLE 44 # else /* Use the same values as defined by MSVC 10, for interoperability. */ # define EOWNERDEAD 133 # define ENOTRECOVERABLE 127 # endif # else # define EOWNERDEAD 2013 # define ENOTRECOVERABLE 2014 # endif # define GNULIB_defined_EOWNERDEAD 1 # define GNULIB_defined_ENOTRECOVERABLE 1 # endif # ifndef EILSEQ # define EILSEQ 2015 # define GNULIB_defined_EILSEQ 1 # endif #endif /* _@GUARD_PREFIX@_ERRNO_H */ #endif /* _@GUARD_PREFIX@_ERRNO_H */ lftp-4.6.3a/lib/strnlen1.h0000644000015000007670000000230712466374012012247 00000000000000/* Find the length of STRING + 1, but scan at most MAXLEN bytes. Copyright (C) 2005, 2009-2015 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 . */ #ifndef _STRNLEN1_H #define _STRNLEN1_H #include #ifdef __cplusplus extern "C" { #endif /* Find the length of STRING + 1, but scan at most MAXLEN bytes. If no '\0' terminator is found in that many characters, return MAXLEN. */ /* This is the same as strnlen (string, maxlen - 1) + 1. */ extern size_t strnlen1 (const char *string, size_t maxlen) _GL_ATTRIBUTE_PURE; #ifdef __cplusplus } #endif #endif /* _STRNLEN1_H */ lftp-4.6.3a/lib/mktime.c0000644000015000007670000005566412466374011011777 00000000000000/* Convert a 'struct tm' to a time_t value. Copyright (C) 1993-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Eggert . The GNU C Library 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. The GNU C Library 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 the GNU C Library; if not, see . */ /* Define this to have a standalone program to test this implementation of mktime. */ /* #define DEBUG 1 */ #ifndef _LIBC # include #endif /* Assume that leap seconds are possible, unless told otherwise. If the host has a 'zic' command with a '-L leapsecondfilename' option, then it supports leap seconds; otherwise it probably doesn't. */ #ifndef LEAP_SECONDS_POSSIBLE # define LEAP_SECONDS_POSSIBLE 1 #endif #include #include #include /* For the real memcpy prototype. */ #if defined DEBUG && DEBUG # include # include /* Make it work even if the system's libc has its own mktime routine. */ # undef mktime # define mktime my_mktime #endif /* DEBUG */ /* Some of the code in this file assumes that signed integer overflow silently wraps around. This assumption can't easily be programmed around, nor can it be checked for portably at compile-time or easily eliminated at run-time. Define WRAPV to 1 if the assumption is valid and if #pragma GCC optimize ("wrapv") does not trigger GCC bug 51793 . Otherwise, define it to 0; this forces the use of slower code that, while not guaranteed by the C Standard, works on all production platforms that we know about. */ #ifndef WRAPV # if (((__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__) \ && defined __GLIBC__) # pragma GCC optimize ("wrapv") # define WRAPV 1 # else # define WRAPV 0 # endif #endif /* Verify a requirement at compile-time (unlike assert, which is runtime). */ #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } /* A signed type that is at least one bit wider than int. */ #if INT_MAX <= LONG_MAX / 2 typedef long int long_int; #else typedef long long int long_int; #endif verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2); /* Shift A right by B bits portably, by dividing A by 2**B and truncating towards minus infinity. A and B should be free of side effects, and B should be in the range 0 <= B <= INT_BITS - 2, where INT_BITS is the number of useful bits in an int. GNU code can assume that INT_BITS is at least 32. ISO C99 says that A >> B is implementation-defined if A < 0. Some implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ #define SHR(a, b) \ ((-1 >> 1 == -1 \ && (long_int) -1 >> 1 == -1 \ && ((time_t) -1 >> 1 == -1 || ! TYPE_SIGNED (time_t))) \ ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) /* The extra casts in the following macros work around compiler bugs, e.g., in Cray C 5.0.3.0. */ /* True if the arithmetic type T is an integer type. bool counts as an integer. */ #define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) /* True if negative values of the signed integer type T use two's complement, or if T is an unsigned integer type. */ #define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) /* True if the arithmetic type T is signed. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* The maximum and minimum values for the integer type T. These macros have undefined behavior if T is signed and has padding bits. If this is a problem for you, please let us know how to fix it for your host. */ #define TYPE_MINIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ ? (t) 0 \ : ~ TYPE_MAXIMUM (t))) #define TYPE_MAXIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ ? (t) -1 \ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) #ifndef TIME_T_MIN # define TIME_T_MIN TYPE_MINIMUM (time_t) #endif #ifndef TIME_T_MAX # define TIME_T_MAX TYPE_MAXIMUM (time_t) #endif #define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1) verify (time_t_is_integer, TYPE_IS_INTEGER (time_t)); verify (twos_complement_arithmetic, (TYPE_TWOS_COMPLEMENT (int) && TYPE_TWOS_COMPLEMENT (long_int) && TYPE_TWOS_COMPLEMENT (time_t))); #define EPOCH_YEAR 1970 #define TM_YEAR_BASE 1900 verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0); /* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */ static int leapyear (long_int year) { /* Don't add YEAR to TM_YEAR_BASE, as that might overflow. Also, work even if YEAR is negative. */ return ((year & 3) == 0 && (year % 100 != 0 || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3))); } /* How many days come before each month (0-12). */ #ifndef _LIBC static #endif const unsigned short int __mon_yday[2][13] = { /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, /* Leap years. */ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; #ifndef _LIBC /* Portable standalone applications should supply a that declares a POSIX-compliant localtime_r, for the benefit of older implementations that lack localtime_r or have a nonstandard one. See the gnulib time_r module for one way to implement this. */ # undef __localtime_r # define __localtime_r localtime_r # define __mktime_internal mktime_internal # include "mktime-internal.h" #endif /* Return 1 if the values A and B differ according to the rules for tm_isdst: A and B differ if one is zero and the other positive. */ static int isdst_differ (int a, int b) { return (!a != !b) && (0 <= a) && (0 <= b); } /* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks were not adjusted between the time stamps. The YEAR values uses the same numbering as TP->tm_year. Values need not be in the usual range. However, YEAR1 must not be less than 2 * INT_MIN or greater than 2 * INT_MAX. The result may overflow. It is the caller's responsibility to detect overflow. */ static time_t ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1, int year0, int yday0, int hour0, int min0, int sec0) { verify (C99_integer_division, -1 / 2 == 0); /* Compute intervening leap days correctly even if year is negative. Take care to avoid integer overflow here. */ int a4 = SHR (year1, 2) + SHR (TM_YEAR_BASE, 2) - ! (year1 & 3); int b4 = SHR (year0, 2) + SHR (TM_YEAR_BASE, 2) - ! (year0 & 3); int a100 = a4 / 25 - (a4 % 25 < 0); int b100 = b4 / 25 - (b4 % 25 < 0); int a400 = SHR (a100, 2); int b400 = SHR (b100, 2); int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); /* Compute the desired time in time_t precision. Overflow might occur here. */ time_t tyear1 = year1; time_t years = tyear1 - year0; time_t days = 365 * years + yday1 - yday0 + intervening_leap_days; time_t hours = 24 * days + hour1 - hour0; time_t minutes = 60 * hours + min1 - min0; time_t seconds = 60 * minutes + sec1 - sec0; return seconds; } /* Return the average of A and B, even if A + B would overflow. */ static time_t time_t_avg (time_t a, time_t b) { return SHR (a, 1) + SHR (b, 1) + (a & b & 1); } /* Return 1 if A + B does not overflow. If time_t is unsigned and if B's top bit is set, assume that the sum represents A - -B, and return 1 if the subtraction does not wrap around. */ static int time_t_add_ok (time_t a, time_t b) { if (! TYPE_SIGNED (time_t)) { time_t sum = a + b; return (sum < a) == (TIME_T_MIDPOINT <= b); } else if (WRAPV) { time_t sum = a + b; return (sum < a) == (b < 0); } else { time_t avg = time_t_avg (a, b); return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2; } } /* Return 1 if A + B does not overflow. */ static int time_t_int_add_ok (time_t a, int b) { verify (int_no_wider_than_time_t, INT_MAX <= TIME_T_MAX); if (WRAPV) { time_t sum = a + b; return (sum < a) == (b < 0); } else { int a_odd = a & 1; time_t avg = SHR (a, 1) + (SHR (b, 1) + (a_odd & b)); return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2; } } /* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC), assuming that *T corresponds to *TP and that no clock adjustments occurred between *TP and the desired time. If TP is null, return a value not equal to *T; this avoids false matches. If overflow occurs, yield the minimal or maximal value, except do not yield a value equal to *T. */ static time_t guess_time_tm (long_int year, long_int yday, int hour, int min, int sec, const time_t *t, const struct tm *tp) { if (tp) { time_t d = ydhms_diff (year, yday, hour, min, sec, tp->tm_year, tp->tm_yday, tp->tm_hour, tp->tm_min, tp->tm_sec); if (time_t_add_ok (*t, d)) return *t + d; } /* Overflow occurred one way or another. Return the nearest result that is actually in range, except don't report a zero difference if the actual difference is nonzero, as that would cause a false match; and don't oscillate between two values, as that would confuse the spring-forward gap detector. */ return (*t < TIME_T_MIDPOINT ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN) : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX)); } /* Use CONVERT to convert *T to a broken down time in *TP. If *T is out of range for conversion, adjust it so that it is the nearest in-range value and then convert that. */ static struct tm * ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), time_t *t, struct tm *tp) { struct tm *r = convert (t, tp); if (!r && *t) { time_t bad = *t; time_t ok = 0; /* BAD is a known unconvertible time_t, and OK is a known good one. Use binary search to narrow the range between BAD and OK until they differ by 1. */ while (bad != ok + (bad < 0 ? -1 : 1)) { time_t mid = *t = time_t_avg (ok, bad); r = convert (t, tp); if (r) ok = mid; else bad = mid; } if (!r && ok) { /* The last conversion attempt failed; revert to the most recent successful attempt. */ *t = ok; r = convert (t, tp); } } return r; } /* Convert *TP to a time_t value, inverting the monotonic and mostly-unit-linear conversion function CONVERT. Use *OFFSET to keep track of a guess at the offset of the result, compared to what the result would be for UTC without leap seconds. If *OFFSET's guess is correct, only one CONVERT call is needed. This function is external because it is used also by timegm.c. */ time_t __mktime_internal (struct tm *tp, struct tm *(*convert) (const time_t *, struct tm *), time_t *offset) { time_t t, gt, t0, t1, t2; struct tm tm; /* The maximum number of probes (calls to CONVERT) should be enough to handle any combinations of time zone rule changes, solar time, leap seconds, and oscillations around a spring-forward gap. POSIX.1 prohibits leap seconds, but some hosts have them anyway. */ int remaining_probes = 6; /* Time requested. Copy it in case CONVERT modifies *TP; this can occur if TP is localtime's returned value and CONVERT is localtime. */ int sec = tp->tm_sec; int min = tp->tm_min; int hour = tp->tm_hour; int mday = tp->tm_mday; int mon = tp->tm_mon; int year_requested = tp->tm_year; int isdst = tp->tm_isdst; /* 1 if the previous probe was DST. */ int dst2; /* Ensure that mon is in range, and set year accordingly. */ int mon_remainder = mon % 12; int negative_mon_remainder = mon_remainder < 0; int mon_years = mon / 12 - negative_mon_remainder; long_int lyear_requested = year_requested; long_int year = lyear_requested + mon_years; /* The other values need not be in range: the remaining code handles minor overflows correctly, assuming int and time_t arithmetic wraps around. Major overflows are caught at the end. */ /* Calculate day of year from year, month, and day of month. The result need not be in range. */ int mon_yday = ((__mon_yday[leapyear (year)] [mon_remainder + 12 * negative_mon_remainder]) - 1); long_int lmday = mday; long_int yday = mon_yday + lmday; time_t guessed_offset = *offset; int sec_requested = sec; if (LEAP_SECONDS_POSSIBLE) { /* Handle out-of-range seconds specially, since ydhms_tm_diff assumes every minute has 60 seconds. */ if (sec < 0) sec = 0; if (59 < sec) sec = 59; } /* Invert CONVERT by probing. First assume the same offset as last time. */ t0 = ydhms_diff (year, yday, hour, min, sec, EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset); if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3) { /* time_t isn't large enough to rule out overflows, so check for major overflows. A gross check suffices, since if t0 has overflowed, it is off by a multiple of TIME_T_MAX - TIME_T_MIN + 1. So ignore any component of the difference that is bounded by a small value. */ /* Approximate log base 2 of the number of time units per biennium. A biennium is 2 years; use this unit instead of years to avoid integer overflow. For example, 2 average Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds, which is 63113904 seconds, and rint (log2 (63113904)) is 26. */ int ALOG2_SECONDS_PER_BIENNIUM = 26; int ALOG2_MINUTES_PER_BIENNIUM = 20; int ALOG2_HOURS_PER_BIENNIUM = 14; int ALOG2_DAYS_PER_BIENNIUM = 10; int LOG2_YEARS_PER_BIENNIUM = 1; int approx_requested_biennia = (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM) - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM) + SHR (mday, ALOG2_DAYS_PER_BIENNIUM) + SHR (hour, ALOG2_HOURS_PER_BIENNIUM) + SHR (min, ALOG2_MINUTES_PER_BIENNIUM) + (LEAP_SECONDS_POSSIBLE ? 0 : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM))); int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM); int diff = approx_biennia - approx_requested_biennia; int approx_abs_diff = diff < 0 ? -1 - diff : diff; /* IRIX 4.0.5 cc miscalculates TIME_T_MIN / 3: it erroneously gives a positive value of 715827882. Setting a variable first then doing math on it seems to work. (ghazi@caip.rutgers.edu) */ time_t time_t_max = TIME_T_MAX; time_t time_t_min = TIME_T_MIN; time_t overflow_threshold = (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM; if (overflow_threshold < approx_abs_diff) { /* Overflow occurred. Try repairing it; this might work if the time zone offset is enough to undo the overflow. */ time_t repaired_t0 = -1 - t0; approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM); diff = approx_biennia - approx_requested_biennia; approx_abs_diff = diff < 0 ? -1 - diff : diff; if (overflow_threshold < approx_abs_diff) return -1; guessed_offset += repaired_t0 - t0; t0 = repaired_t0; } } /* Repeatedly use the error to improve the guess. */ for (t = t1 = t2 = t0, dst2 = 0; (gt = guess_time_tm (year, yday, hour, min, sec, &t, ranged_convert (convert, &t, &tm)), t != gt); t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0) if (t == t1 && t != t2 && (tm.tm_isdst < 0 || (isdst < 0 ? dst2 <= (tm.tm_isdst != 0) : (isdst != 0) != (tm.tm_isdst != 0)))) /* We can't possibly find a match, as we are oscillating between two values. The requested time probably falls within a spring-forward gap of size GT - T. Follow the common practice in this case, which is to return a time that is GT - T away from the requested time, preferring a time whose tm_isdst differs from the requested value. (If no tm_isdst was requested and only one of the two values has a nonzero tm_isdst, prefer that value.) In practice, this is more useful than returning -1. */ goto offset_found; else if (--remaining_probes == 0) return -1; /* We have a match. Check whether tm.tm_isdst has the requested value, if any. */ if (isdst_differ (isdst, tm.tm_isdst)) { /* tm.tm_isdst has the wrong value. Look for a neighboring time with the right value, and use its UTC offset. Heuristic: probe the adjacent timestamps in both directions, looking for the desired isdst. This should work for all real time zone histories in the tz database. */ /* Distance between probes when looking for a DST boundary. In tzdata2003a, the shortest period of DST is 601200 seconds (e.g., America/Recife starting 2000-10-08 01:00), and the shortest period of non-DST surrounded by DST is 694800 seconds (Africa/Tunis starting 1943-04-17 01:00). Use the minimum of these two values, so we don't miss these short periods when probing. */ int stride = 601200; /* The longest period of DST in tzdata2003a is 536454000 seconds (e.g., America/Jujuy starting 1946-10-01 01:00). The longest period of non-DST is much longer, but it makes no real sense to search for more than a year of non-DST, so use the DST max. */ int duration_max = 536454000; /* Search in both directions, so the maximum distance is half the duration; add the stride to avoid off-by-1 problems. */ int delta_bound = duration_max / 2 + stride; int delta, direction; for (delta = stride; delta < delta_bound; delta += stride) for (direction = -1; direction <= 1; direction += 2) if (time_t_int_add_ok (t, delta * direction)) { time_t ot = t + delta * direction; struct tm otm; ranged_convert (convert, &ot, &otm); if (! isdst_differ (isdst, otm.tm_isdst)) { /* We found the desired tm_isdst. Extrapolate back to the desired time. */ t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm); ranged_convert (convert, &t, &tm); goto offset_found; } } } offset_found: *offset = guessed_offset + t - t0; if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) { /* Adjust time to reflect the tm_sec requested, not the normalized value. Also, repair any damage from a false match due to a leap second. */ int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec; if (! time_t_int_add_ok (t, sec_requested)) return -1; t1 = t + sec_requested; if (! time_t_int_add_ok (t1, sec_adjustment)) return -1; t2 = t1 + sec_adjustment; if (! convert (&t2, &tm)) return -1; t = t2; } *tp = tm; return t; } /* FIXME: This should use a signed type wide enough to hold any UTC offset in seconds. 'int' should be good enough for GNU code. We can't fix this unilaterally though, as other modules invoke __mktime_internal. */ static time_t localtime_offset; /* Convert *TP to a time_t value. */ time_t mktime (struct tm *tp) { #ifdef _LIBC /* POSIX.1 8.1.1 requires that whenever mktime() is called, the time zone names contained in the external variable 'tzname' shall be set as if the tzset() function had been called. */ __tzset (); #endif return __mktime_internal (tp, __localtime_r, &localtime_offset); } #ifdef weak_alias weak_alias (mktime, timelocal) #endif #ifdef _LIBC libc_hidden_def (mktime) libc_hidden_weak (timelocal) #endif #if defined DEBUG && DEBUG static int not_equal_tm (const struct tm *a, const struct tm *b) { return ((a->tm_sec ^ b->tm_sec) | (a->tm_min ^ b->tm_min) | (a->tm_hour ^ b->tm_hour) | (a->tm_mday ^ b->tm_mday) | (a->tm_mon ^ b->tm_mon) | (a->tm_year ^ b->tm_year) | (a->tm_yday ^ b->tm_yday) | isdst_differ (a->tm_isdst, b->tm_isdst)); } static void print_tm (const struct tm *tp) { if (tp) printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d", tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, tp->tm_yday, tp->tm_wday, tp->tm_isdst); else printf ("0"); } static int check_result (time_t tk, struct tm tmk, time_t tl, const struct tm *lt) { if (tk != tl || !lt || not_equal_tm (&tmk, lt)) { printf ("mktime ("); print_tm (lt); printf (")\nyields ("); print_tm (&tmk); printf (") == %ld, should be %ld\n", (long int) tk, (long int) tl); return 1; } return 0; } int main (int argc, char **argv) { int status = 0; struct tm tm, tmk, tml; struct tm *lt; time_t tk, tl, tl1; char trailer; if ((argc == 3 || argc == 4) && (sscanf (argv[1], "%d-%d-%d%c", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer) == 3) && (sscanf (argv[2], "%d:%d:%d%c", &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer) == 3)) { tm.tm_year -= TM_YEAR_BASE; tm.tm_mon--; tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]); tmk = tm; tl = mktime (&tmk); lt = localtime (&tl); if (lt) { tml = *lt; lt = &tml; } printf ("mktime returns %ld == ", (long int) tl); print_tm (&tmk); printf ("\n"); status = check_result (tl, tmk, tl, lt); } else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0)) { time_t from = atol (argv[1]); time_t by = atol (argv[2]); time_t to = atol (argv[3]); if (argc == 4) for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1) { lt = localtime (&tl); if (lt) { tmk = tml = *lt; tk = mktime (&tmk); status |= check_result (tk, tmk, tl, &tml); } else { printf ("localtime (%ld) yields 0\n", (long int) tl); status = 1; } tl1 = tl + by; if ((tl1 < tl) != (by < 0)) break; } else for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1) { /* Null benchmark. */ lt = localtime (&tl); if (lt) { tmk = tml = *lt; tk = tl; status |= check_result (tk, tmk, tl, &tml); } else { printf ("localtime (%ld) yields 0\n", (long int) tl); status = 1; } tl1 = tl + by; if ((tl1 < tl) != (by < 0)) break; } } else printf ("Usage:\ \t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\ \t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\ \t%s FROM BY TO - # Do not test those values (for benchmark).\n", argv[0], argv[0], argv[0]); return status; } #endif /* DEBUG */ /* Local Variables: compile-command: "gcc -DDEBUG -I. -Wall -W -O2 -g mktime.c -o mktime" End: */ lftp-4.6.3a/lib/passfd.c0000644000015000007670000001146112477560612011762 00000000000000/* Copyright (C) 2011-2015 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 . */ #include /* Specification. */ #include "passfd.h" #include #include #include #include #include #include #include #include #include "cloexec.h" /* The code that uses CMSG_FIRSTHDR is enabled on Linux, Mac OS X, FreeBSD, OpenBSD, NetBSD, AIX, OSF/1, Cygwin. The code that uses HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS is enabled on HP-UX, IRIX, Solaris. */ /* MSG_CMSG_CLOEXEC is defined only on Linux, as of 2011. */ #ifndef MSG_CMSG_CLOEXEC # define MSG_CMSG_CLOEXEC 0 #endif #if HAVE_SENDMSG /* sendfd sends the file descriptor fd along the socket to a process calling recvfd on the other end. Return 0 on success, or -1 with errno set in case of error. */ int sendfd (int sock, int fd) { char byte = 0; struct iovec iov; struct msghdr msg; # ifdef CMSG_FIRSTHDR struct cmsghdr *cmsg; char buf[CMSG_SPACE (sizeof fd)]; # endif /* send at least one char */ memset (&msg, 0, sizeof msg); iov.iov_base = &byte; iov.iov_len = 1; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_name = NULL; msg.msg_namelen = 0; # ifdef CMSG_FIRSTHDR msg.msg_control = buf; msg.msg_controllen = sizeof buf; cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN (sizeof fd); /* Initialize the payload: */ memcpy (CMSG_DATA (cmsg), &fd, sizeof fd); msg.msg_controllen = cmsg->cmsg_len; # elif HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS msg.msg_accrights = &fd; msg.msg_accrightslen = sizeof fd; # else errno = ENOSYS; return -1; # endif if (sendmsg (sock, &msg, 0) != iov.iov_len) return -1; return 0; } #else int sendfd (int sock _GL_UNUSED, int fd _GL_UNUSED) { errno = ENOSYS; return -1; } #endif #if HAVE_RECVMSG /* recvfd receives a file descriptor through the socket. The flags are a bitmask, possibly including O_CLOEXEC (defined in ). Return the fd on success, or -1 with errno set in case of error. */ int recvfd (int sock, int flags) { char byte = 0; struct iovec iov; struct msghdr msg; int fd = -1; ssize_t len; # ifdef CMSG_FIRSTHDR struct cmsghdr *cmsg; char buf[CMSG_SPACE (sizeof fd)]; int flags_recvmsg = flags & O_CLOEXEC ? MSG_CMSG_CLOEXEC : 0; # endif if ((flags & ~O_CLOEXEC) != 0) { errno = EINVAL; return -1; } /* send at least one char */ memset (&msg, 0, sizeof msg); iov.iov_base = &byte; iov.iov_len = 1; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_name = NULL; msg.msg_namelen = 0; # ifdef CMSG_FIRSTHDR msg.msg_control = buf; msg.msg_controllen = sizeof buf; cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN (sizeof fd); /* Initialize the payload: */ memcpy (CMSG_DATA (cmsg), &fd, sizeof fd); msg.msg_controllen = cmsg->cmsg_len; len = recvmsg (sock, &msg, flags_recvmsg); if (len < 0) return -1; cmsg = CMSG_FIRSTHDR (&msg); /* be paranoiac */ if (len == 0 || cmsg == NULL || cmsg->cmsg_len != CMSG_LEN (sizeof fd) || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { /* fake errno: at end the file is not available */ errno = len ? EACCES : ENOTCONN; return -1; } memcpy (&fd, CMSG_DATA (cmsg), sizeof fd); /* set close-on-exec flag */ if (!MSG_CMSG_CLOEXEC && (flags & O_CLOEXEC)) { if (set_cloexec_flag (fd, true) < 0) { int saved_errno = errno; (void) close (fd); errno = saved_errno; return -1; } } # elif HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS msg.msg_accrights = &fd; msg.msg_accrightslen = sizeof fd; if (recvmsg (sock, &msg, 0) < 0) return -1; /* set close-on-exec flag */ if (flags & O_CLOEXEC) { if (set_cloexec_flag (fd, true) < 0) { int saved_errno = errno; close (fd); errno = saved_errno; return -1; } } # else errno = ENOSYS; # endif return fd; } #else int recvfd (int sock _GL_UNUSED, int flags _GL_UNUSED) { errno = ENOSYS; return -1; } #endif lftp-4.6.3a/lib/msvc-nothrow.h0000644000015000007670000000301012466374011013136 00000000000000/* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. Copyright (C) 2011-2015 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 . */ #ifndef _MSVC_NOTHROW_H #define _MSVC_NOTHROW_H /* With MSVC runtime libraries with the "invalid parameter handler" concept, functions like fprintf(), dup2(), or close() crash when the caller passes an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF) instead. This file defines wrappers that turn such an invalid parameter notification into an error code. */ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Get original declaration of _get_osfhandle. */ # include # if HAVE_MSVC_INVALID_PARAMETER_HANDLER /* Override _get_osfhandle. */ extern intptr_t _gl_nothrow_get_osfhandle (int fd); # define _get_osfhandle _gl_nothrow_get_osfhandle # endif #endif #endif /* _MSVC_NOTHROW_H */ lftp-4.6.3a/lib/verify.h0000644000015000007670000002536412466374012012015 00000000000000/* Compile-time assert-like macros. Copyright (C) 2005-2006, 2009-2015 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 . */ /* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ #ifndef _GL_VERIFY_H #define _GL_VERIFY_H /* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. This is supported by GCC 4.6.0 and later, in C mode, and its use here generates easier-to-read diagnostics when verify (R) fails. Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11. This will likely be supported by future GCC versions, in C++ mode. Use this only with GCC. If we were willing to slow 'configure' down we could also use it with other compilers, but since this affects only the quality of diagnostics, why bother? */ #if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ && !defined __cplusplus) # define _GL_HAVE__STATIC_ASSERT 1 #endif /* The condition (99 < __GNUC__) is temporary, until we know about the first G++ release that supports static_assert. */ #if (99 < __GNUC__) && defined __cplusplus # define _GL_HAVE_STATIC_ASSERT 1 #endif /* FreeBSD 9.1 , included by and lots of other system headers, defines a conflicting _Static_assert that is no better than ours; override it. */ #ifndef _GL_HAVE_STATIC_ASSERT # include # undef _Static_assert #endif /* Each of these macros verifies that its argument R is nonzero. To be portable, R should be an integer constant expression. Unlike assert (R), there is no run-time overhead. If _Static_assert works, verify (R) uses it directly. Similarly, _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct that is an operand of sizeof. The code below uses several ideas for C++ compilers, and for C compilers that do not support _Static_assert: * The first step is ((R) ? 1 : -1). Given an expression R, of integral or boolean or floating-point type, this yields an expression of integral type, whose value is later verified to be constant and nonnegative. * Next this expression W is wrapped in a type struct _gl_verify_type { unsigned int _gl_verify_error_if_negative: W; }. If W is negative, this yields a compile-time error. No compiler can deal with a bit-field of negative size. One might think that an array size check would have the same effect, that is, that the type struct { unsigned int dummy[W]; } would work as well. However, inside a function, some compilers (such as C++ compilers and GNU C) allow local parameters and variables inside array size expressions. With these compilers, an array size check would not properly diagnose this misuse of the verify macro: void function (int n) { verify (n < 0); } * For the verify macro, the struct _gl_verify_type will need to somehow be embedded into a declaration. To be portable, this declaration must declare an object, a constant, a function, or a typedef name. If the declared entity uses the type directly, such as in struct dummy {...}; typedef struct {...} dummy; extern struct {...} *dummy; extern void dummy (struct {...} *); extern struct {...} *dummy (void); two uses of the verify macro would yield colliding declarations if the entity names are not disambiguated. A workaround is to attach the current line number to the entity name: #define _GL_CONCAT0(x, y) x##y #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) extern struct {...} * _GL_CONCAT (dummy, __LINE__); But this has the problem that two invocations of verify from within the same macro would collide, since the __LINE__ value would be the same for both invocations. (The GCC __COUNTER__ macro solves this problem, but is not portable.) A solution is to use the sizeof operator. It yields a number, getting rid of the identity of the type. Declarations like extern int dummy [sizeof (struct {...})]; extern void dummy (int [sizeof (struct {...})]); extern int (*dummy (void)) [sizeof (struct {...})]; can be repeated. * Should the implementation use a named struct or an unnamed struct? Which of the following alternatives can be used? extern int dummy [sizeof (struct {...})]; extern int dummy [sizeof (struct _gl_verify_type {...})]; extern void dummy (int [sizeof (struct {...})]); extern void dummy (int [sizeof (struct _gl_verify_type {...})]); extern int (*dummy (void)) [sizeof (struct {...})]; extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})]; In the second and sixth case, the struct type is exported to the outer scope; two such declarations therefore collide. GCC warns about the first, third, and fourth cases. So the only remaining possibility is the fifth case: extern int (*dummy (void)) [sizeof (struct {...})]; * GCC warns about duplicate declarations of the dummy function if -Wredundant-decls is used. GCC 4.3 and later have a builtin __COUNTER__ macro that can let us generate unique identifiers for each dummy function, to suppress this warning. * This implementation exploits the fact that older versions of GCC, which do not support _Static_assert, also do not warn about the last declaration mentioned above. * GCC warns if -Wnested-externs is enabled and verify() is used within a function body; but inside a function, you can always arrange to use verify_expr() instead. * In C++, any struct definition inside sizeof is invalid. Use a template type to work around the problem. */ /* Concatenate two preprocessor tokens. */ #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) #define _GL_CONCAT0(x, y) x##y /* _GL_COUNTER is an integer, preferably one that changes each time we use it. Use __COUNTER__ if it works, falling back on __LINE__ otherwise. __LINE__ isn't perfect, but it's better than a constant. */ #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ # define _GL_COUNTER __COUNTER__ #else # define _GL_COUNTER __LINE__ #endif /* Generate a symbol with the given prefix, making it unique if possible. */ #define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) /* Verify requirement R at compile-time, as an integer constant expression that returns 1. If R is false, fail at compile-time, preferably with a diagnostic that includes the string-literal DIAGNOSTIC. */ #define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) #ifdef __cplusplus # if !GNULIB_defined_struct__gl_verify_type template struct _gl_verify_type { unsigned int _gl_verify_error_if_negative: w; }; # define GNULIB_defined_struct__gl_verify_type 1 # endif # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ _gl_verify_type<(R) ? 1 : -1> #elif defined _GL_HAVE__STATIC_ASSERT # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ struct { \ _Static_assert (R, DIAGNOSTIC); \ int _gl_dummy; \ } #else # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; } #endif /* Verify requirement R at compile-time, as a declaration without a trailing ';'. If R is false, fail at compile-time, preferably with a diagnostic that includes the string-literal DIAGNOSTIC. Unfortunately, unlike C11, this implementation must appear as an ordinary declaration, and cannot appear inside struct { ... }. */ #ifdef _GL_HAVE__STATIC_ASSERT # define _GL_VERIFY _Static_assert #else # define _GL_VERIFY(R, DIAGNOSTIC) \ extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] #endif /* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ #ifdef _GL_STATIC_ASSERT_H # if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert # define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) # endif # if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert # define static_assert _Static_assert /* C11 requires this #define. */ # endif #endif /* @assert.h omit start@ */ /* Each of these macros verifies that its argument R is nonzero. To be portable, R should be an integer constant expression. Unlike assert (R), there is no run-time overhead. There are two macros, since no single macro can be used in all contexts in C. verify_true (R) is for scalar contexts, including integer constant expression contexts. verify (R) is for declaration contexts, e.g., the top level. */ /* Verify requirement R at compile-time, as an integer constant expression. Return 1. This is equivalent to verify_expr (R, 1). verify_true is obsolescent; please use verify_expr instead. */ #define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") /* Verify requirement R at compile-time. Return the value of the expression E. */ #define verify_expr(R, E) \ (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) /* Verify requirement R at compile-time, as a declaration without a trailing ';'. */ #define verify(R) _GL_VERIFY (R, "verify (" #R ")") #ifndef __has_builtin # define __has_builtin(x) 0 #endif /* Assume that R always holds. This lets the compiler optimize accordingly. R should not have side-effects; it may or may not be evaluated. Behavior is undefined if R is false. */ #if (__has_builtin (__builtin_unreachable) \ || 4 < __GNUC__ + (5 <= __GNUC_MINOR__)) # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) #elif 1200 <= _MSC_VER # define assume(R) __assume (R) #elif (defined lint \ && (__has_builtin (__builtin_trap) \ || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)))) /* Doing it this way helps various packages when configured with --enable-gcc-warnings, which compiles with -Dlint. It's nicer when 'assume' silences warnings even with older GCCs. */ # define assume(R) ((R) ? (void) 0 : __builtin_trap ()) #else # define assume(R) ((void) (0 && (R))) #endif /* @assert.h omit end@ */ #endif lftp-4.6.3a/lib/argmatch.c0000644000015000007670000001724612466374011012271 00000000000000/* argmatch.c -- find a match for a string in an array Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2015 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 . */ /* Written by David MacKenzie Modified by Akim Demaille */ #include /* Specification. */ #include "argmatch.h" #include #include #include #include #include "gettext.h" #define _(msgid) gettext (msgid) #include "error.h" #include "quotearg.h" #include "quote.h" #if USE_UNLOCKED_IO # include "unlocked-io.h" #endif /* When reporting an invalid argument, show nonprinting characters by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use literal_quoting_style. */ #ifndef ARGMATCH_QUOTING_STYLE # define ARGMATCH_QUOTING_STYLE locale_quoting_style #endif /* Non failing version of argmatch call this function after failing. */ #ifndef ARGMATCH_DIE # include "exitfail.h" # define ARGMATCH_DIE exit (exit_failure) #endif #ifdef ARGMATCH_DIE_DECL ARGMATCH_DIE_DECL; #endif static void __argmatch_die (void) { ARGMATCH_DIE; } /* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h. Default to __argmatch_die, but allow caller to change this at run-time. */ argmatch_exit_fn argmatch_die = __argmatch_die; /* If ARG is an unambiguous match for an element of the NULL-terminated array ARGLIST, return the index in ARGLIST of the matched element, else -1 if it does not match any element or -2 if it is ambiguous (is a prefix of more than one element). If VALLIST is none null, use it to resolve ambiguities limited to synonyms, i.e., for "yes", "yop" -> 0 "no", "nope" -> 1 "y" is a valid argument, for 0, and "n" for 1. */ ptrdiff_t argmatch (const char *arg, const char *const *arglist, const char *vallist, size_t valsize) { size_t i; /* Temporary index in ARGLIST. */ size_t arglen; /* Length of ARG. */ ptrdiff_t matchind = -1; /* Index of first nonexact match. */ bool ambiguous = false; /* If true, multiple nonexact match(es). */ arglen = strlen (arg); /* Test all elements for either exact match or abbreviated matches. */ for (i = 0; arglist[i]; i++) { if (!strncmp (arglist[i], arg, arglen)) { if (strlen (arglist[i]) == arglen) /* Exact match found. */ return i; else if (matchind == -1) /* First nonexact match found. */ matchind = i; else { /* Second nonexact match found. */ if (vallist == NULL || memcmp (vallist + valsize * matchind, vallist + valsize * i, valsize)) { /* There is a real ambiguity, or we could not disambiguate. */ ambiguous = true; } } } } if (ambiguous) return -2; else return matchind; } /* Error reporting for argmatch. CONTEXT is a description of the type of entity that was being matched. VALUE is the invalid value that was given. PROBLEM is the return value from argmatch. */ void argmatch_invalid (const char *context, const char *value, ptrdiff_t problem) { char const *format = (problem == -1 ? _("invalid argument %s for %s") : _("ambiguous argument %s for %s")); error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value), quote_n (1, context)); } /* List the valid arguments for argmatch. ARGLIST is the same as in argmatch. VALLIST is a pointer to an array of values. VALSIZE is the size of the elements of VALLIST */ void argmatch_valid (const char *const *arglist, const char *vallist, size_t valsize) { size_t i; const char *last_val = NULL; /* We try to put synonyms on the same line. The assumption is that synonyms follow each other */ fputs (_("Valid arguments are:"), stderr); for (i = 0; arglist[i]; i++) if ((i == 0) || memcmp (last_val, vallist + valsize * i, valsize)) { fprintf (stderr, "\n - %s", quote (arglist[i])); last_val = vallist + valsize * i; } else { fprintf (stderr, ", %s", quote (arglist[i])); } putc ('\n', stderr); } /* Never failing versions of the previous functions. CONTEXT is the context for which argmatch is called (e.g., "--version-control", or "$VERSION_CONTROL" etc.). Upon failure, calls the (supposed never to return) function EXIT_FN. */ ptrdiff_t __xargmatch_internal (const char *context, const char *arg, const char *const *arglist, const char *vallist, size_t valsize, argmatch_exit_fn exit_fn) { ptrdiff_t res = argmatch (arg, arglist, vallist, valsize); if (res >= 0) /* Success. */ return res; /* We failed. Explain why. */ argmatch_invalid (context, arg, res); argmatch_valid (arglist, vallist, valsize); (*exit_fn) (); return -1; /* To please the compilers. */ } /* Look for VALUE in VALLIST, an array of objects of size VALSIZE and return the first corresponding argument in ARGLIST */ const char * argmatch_to_argument (const char *value, const char *const *arglist, const char *vallist, size_t valsize) { size_t i; for (i = 0; arglist[i]; i++) if (!memcmp (value, vallist + valsize * i, valsize)) return arglist[i]; return NULL; } #ifdef TEST /* * Based on "getversion.c" by David MacKenzie */ char *program_name; /* When to make backup files. */ enum backup_type { /* Never make backups. */ no_backups, /* Make simple backups of every file. */ simple_backups, /* Make numbered backups of files that already have numbered backups, and simple backups of the others. */ numbered_existing_backups, /* Make numbered backups of every file. */ numbered_backups }; /* Two tables describing arguments (keys) and their corresponding values */ static const char *const backup_args[] = { "no", "none", "off", "simple", "never", "existing", "nil", "numbered", "t", 0 }; static const enum backup_type backup_vals[] = { no_backups, no_backups, no_backups, simple_backups, simple_backups, numbered_existing_backups, numbered_existing_backups, numbered_backups, numbered_backups }; int main (int argc, const char *const *argv) { const char *cp; enum backup_type backup_type = no_backups; program_name = (char *) argv[0]; if (argc > 2) { fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name); exit (1); } if ((cp = getenv ("VERSION_CONTROL"))) backup_type = XARGMATCH ("$VERSION_CONTROL", cp, backup_args, backup_vals); if (argc == 2) backup_type = XARGMATCH (program_name, argv[1], backup_args, backup_vals); printf ("The version control is '%s'\n", ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals)); return 0; } #endif lftp-4.6.3a/lib/xsize.h0000644000015000007670000000705612466374012011651 00000000000000/* xsize.h -- Checked size_t computations. Copyright (C) 2003, 2008-2015 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 . */ #ifndef _XSIZE_H #define _XSIZE_H /* Get size_t. */ #include /* Get SIZE_MAX. */ #include #if HAVE_STDINT_H # include #endif #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." #endif _GL_INLINE_HEADER_BEGIN #ifndef XSIZE_INLINE # define XSIZE_INLINE _GL_INLINE #endif /* The size of memory objects is often computed through expressions of type size_t. Example: void* p = malloc (header_size + n * element_size). These computations can lead to overflow. When this happens, malloc() returns a piece of memory that is way too small, and the program then crashes while attempting to fill the memory. To avoid this, the functions and macros in this file check for overflow. The convention is that SIZE_MAX represents overflow. malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc implementation that uses mmap --, it's recommended to use size_overflow_p() or size_in_bounds_p() before invoking malloc(). The example thus becomes: size_t size = xsum (header_size, xtimes (n, element_size)); void *p = (size_in_bounds_p (size) ? malloc (size) : NULL); */ /* Convert an arbitrary value >= 0 to type size_t. */ #define xcast_size_t(N) \ ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) /* Sum of two sizes, with overflow check. */ XSIZE_INLINE size_t #if __GNUC__ >= 3 __attribute__ ((__pure__)) #endif xsum (size_t size1, size_t size2) { size_t sum = size1 + size2; return (sum >= size1 ? sum : SIZE_MAX); } /* Sum of three sizes, with overflow check. */ XSIZE_INLINE size_t #if __GNUC__ >= 3 __attribute__ ((__pure__)) #endif xsum3 (size_t size1, size_t size2, size_t size3) { return xsum (xsum (size1, size2), size3); } /* Sum of four sizes, with overflow check. */ XSIZE_INLINE size_t #if __GNUC__ >= 3 __attribute__ ((__pure__)) #endif xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) { return xsum (xsum (xsum (size1, size2), size3), size4); } /* Maximum of two sizes, with overflow check. */ XSIZE_INLINE size_t #if __GNUC__ >= 3 __attribute__ ((__pure__)) #endif xmax (size_t size1, size_t size2) { /* No explicit check is needed here, because for any n: max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */ return (size1 >= size2 ? size1 : size2); } /* Multiplication of a count with an element size, with overflow check. The count must be >= 0 and the element size must be > 0. This is a macro, not a function, so that it works correctly even when N is of a wider type and N > SIZE_MAX. */ #define xtimes(N, ELSIZE) \ ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX) /* Check for overflow. */ #define size_overflow_p(SIZE) \ ((SIZE) == SIZE_MAX) /* Check against overflow. */ #define size_in_bounds_p(SIZE) \ ((SIZE) != SIZE_MAX) _GL_INLINE_HEADER_END #endif /* _XSIZE_H */ lftp-4.6.3a/lib/fpucw.h0000644000015000007670000001113312466374011011621 00000000000000/* Manipulating the FPU control word. Copyright (C) 2007-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2007. 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 . */ #ifndef _FPUCW_H #define _FPUCW_H /* The i386 floating point hardware (the 387 compatible FPU, not the modern SSE/SSE2 hardware) has a controllable rounding precision. It is specified through the 'PC' bits in the FPU control word ('fctrl' register). (See the GNU libc i386 header for details.) On some platforms, such as Linux or Solaris, the default precision setting is set to "extended precision". This means that 'long double' instructions operate correctly, but 'double' computations often produce slightly different results as on strictly IEEE 754 conforming systems. On some platforms, such as NetBSD, the default precision is set to "double precision". This means that 'long double' instructions will operate only as 'double', i.e. lead to wrong results. Similarly on FreeBSD 6.4, at least for the division of 'long double' numbers. The FPU control word is under control of the application, i.e. it is not required to be set either way by the ABI. (In fact, the i386 ABI http://refspecs.freestandards.org/elf/abi386-4.pdf page 3-12 = page 38 is not clear about it. But in any case, gcc treats the control word like a "preserved" register: it emits code that assumes that the control word is preserved across calls, and it restores the control word at the end of functions that modify it.) See Vincent Lefèvre's page http://www.vinc17.org/research/extended.en.html for a good explanation. See http://www.uwsg.iu.edu/hypermail/linux/kernel/0103.0/0453.html for some argumentation which setting should be the default. */ /* This header file provides the following facilities: fpucw_t integral type holding the value of 'fctrl' FPU_PC_MASK bit mask denoting the precision control FPU_PC_DOUBLE precision control for 53 bits mantissa FPU_PC_EXTENDED precision control for 64 bits mantissa GET_FPUCW () yields the current FPU control word SET_FPUCW (word) sets the FPU control word DECL_LONG_DOUBLE_ROUNDING variable declaration for BEGIN/END_LONG_DOUBLE_ROUNDING BEGIN_LONG_DOUBLE_ROUNDING () starts a sequence of instructions with 'long double' safe operation precision END_LONG_DOUBLE_ROUNDING () ends a sequence of instructions with 'long double' safe operation precision */ /* Inline assembler like this works only with GNU C. */ #if (defined __i386__ || defined __x86_64__) && defined __GNUC__ typedef unsigned short fpucw_t; /* glibc calls this fpu_control_t */ # define FPU_PC_MASK 0x0300 # define FPU_PC_DOUBLE 0x200 /* glibc calls this _FPU_DOUBLE */ # define FPU_PC_EXTENDED 0x300 /* glibc calls this _FPU_EXTENDED */ # define GET_FPUCW() \ ({ fpucw_t _cw; \ __asm__ __volatile__ ("fnstcw %0" : "=m" (*&_cw)); \ _cw; \ }) # define SET_FPUCW(word) \ (void)({ fpucw_t _ncw = (word); \ __asm__ __volatile__ ("fldcw %0" : : "m" (*&_ncw)); \ }) # define DECL_LONG_DOUBLE_ROUNDING \ fpucw_t oldcw; # define BEGIN_LONG_DOUBLE_ROUNDING() \ (void)(oldcw = GET_FPUCW (), \ SET_FPUCW ((oldcw & ~FPU_PC_MASK) | FPU_PC_EXTENDED)) # define END_LONG_DOUBLE_ROUNDING() \ SET_FPUCW (oldcw) #else typedef unsigned int fpucw_t; # define FPU_PC_MASK 0 # define FPU_PC_DOUBLE 0 # define FPU_PC_EXTENDED 0 # define GET_FPUCW() 0 # define SET_FPUCW(word) (void)(word) # define DECL_LONG_DOUBLE_ROUNDING # define BEGIN_LONG_DOUBLE_ROUNDING() # define END_LONG_DOUBLE_ROUNDING() #endif #endif /* _FPUCW_H */ lftp-4.6.3a/lib/exitfail.c0000644000015000007670000000153312466374011012300 00000000000000/* Failure exit status Copyright (C) 2002-2003, 2005-2007, 2009-2015 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 . */ #include #include "exitfail.h" #include int volatile exit_failure = EXIT_FAILURE; lftp-4.6.3a/lib/isnanf.c0000644000015000007670000000151712466374011011753 00000000000000/* Test for NaN that does not need libm. Copyright (C) 2007, 2009-2015 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 . */ /* Written by Bruno Haible , 2007. */ #define USE_FLOAT #include "isnan.c" lftp-4.6.3a/lib/inttypes.in.h0000644000015000007670000006476112531301055012767 00000000000000/* Copyright (C) 2006-2015 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Derek Price. This file is part of gnulib. 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 . */ /* * ISO C 99 for platforms that lack it. * */ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* Include the original if it exists, and if this file has not been included yet or if this file includes gnulib stdint.h which in turn includes this file. The include_next requires a split double-inclusion guard. */ #if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H # if @HAVE_INTTYPES_H@ /* Some pre-C++11 implementations need this. */ # if defined __cplusplus && ! defined __STDC_FORMAT_MACROS # define __STDC_FORMAT_MACROS 1 # endif # @INCLUDE_NEXT@ @NEXT_INTTYPES_H@ # endif #endif #if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H #define INTTYPES_H /* Include or the gnulib replacement. But avoid namespace pollution on glibc systems. */ #ifndef __GLIBC__ # include #endif /* Get CHAR_BIT. */ #include /* On mingw, __USE_MINGW_ANSI_STDIO only works if is also included */ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # include #endif #if !(INT_MIN == INT32_MIN && INT_MAX == INT32_MAX) # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to ." #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. */ /* 7.8.1 Macros for format specifiers */ #if defined _TNS_R_TARGET /* Tandem NonStop R series and compatible platforms released before July 2005 support %Ld but not %lld. */ # define _LONG_LONG_FORMAT_PREFIX "L" #else # define _LONG_LONG_FORMAT_PREFIX "ll" #endif #if !defined PRId8 || @PRI_MACROS_BROKEN@ # undef PRId8 # ifdef INT8_MAX # define PRId8 "d" # endif #endif #if !defined PRIi8 || @PRI_MACROS_BROKEN@ # undef PRIi8 # ifdef INT8_MAX # define PRIi8 "i" # endif #endif #if !defined PRIo8 || @PRI_MACROS_BROKEN@ # undef PRIo8 # ifdef UINT8_MAX # define PRIo8 "o" # endif #endif #if !defined PRIu8 || @PRI_MACROS_BROKEN@ # undef PRIu8 # ifdef UINT8_MAX # define PRIu8 "u" # endif #endif #if !defined PRIx8 || @PRI_MACROS_BROKEN@ # undef PRIx8 # ifdef UINT8_MAX # define PRIx8 "x" # endif #endif #if !defined PRIX8 || @PRI_MACROS_BROKEN@ # undef PRIX8 # ifdef UINT8_MAX # define PRIX8 "X" # endif #endif #if !defined PRId16 || @PRI_MACROS_BROKEN@ # undef PRId16 # ifdef INT16_MAX # define PRId16 "d" # endif #endif #if !defined PRIi16 || @PRI_MACROS_BROKEN@ # undef PRIi16 # ifdef INT16_MAX # define PRIi16 "i" # endif #endif #if !defined PRIo16 || @PRI_MACROS_BROKEN@ # undef PRIo16 # ifdef UINT16_MAX # define PRIo16 "o" # endif #endif #if !defined PRIu16 || @PRI_MACROS_BROKEN@ # undef PRIu16 # ifdef UINT16_MAX # define PRIu16 "u" # endif #endif #if !defined PRIx16 || @PRI_MACROS_BROKEN@ # undef PRIx16 # ifdef UINT16_MAX # define PRIx16 "x" # endif #endif #if !defined PRIX16 || @PRI_MACROS_BROKEN@ # undef PRIX16 # ifdef UINT16_MAX # define PRIX16 "X" # endif #endif #if !defined PRId32 || @PRI_MACROS_BROKEN@ # undef PRId32 # ifdef INT32_MAX # define PRId32 "d" # endif #endif #if !defined PRIi32 || @PRI_MACROS_BROKEN@ # undef PRIi32 # ifdef INT32_MAX # define PRIi32 "i" # endif #endif #if !defined PRIo32 || @PRI_MACROS_BROKEN@ # undef PRIo32 # ifdef UINT32_MAX # define PRIo32 "o" # endif #endif #if !defined PRIu32 || @PRI_MACROS_BROKEN@ # undef PRIu32 # ifdef UINT32_MAX # define PRIu32 "u" # endif #endif #if !defined PRIx32 || @PRI_MACROS_BROKEN@ # undef PRIx32 # ifdef UINT32_MAX # define PRIx32 "x" # endif #endif #if !defined PRIX32 || @PRI_MACROS_BROKEN@ # undef PRIX32 # ifdef UINT32_MAX # define PRIX32 "X" # endif #endif #ifdef INT64_MAX # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@) # define _PRI64_PREFIX "l" # elif defined _MSC_VER || defined __MINGW32__ # define _PRI64_PREFIX "I64" # elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 # define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX # endif # if !defined PRId64 || @PRI_MACROS_BROKEN@ # undef PRId64 # define PRId64 _PRI64_PREFIX "d" # endif # if !defined PRIi64 || @PRI_MACROS_BROKEN@ # undef PRIi64 # define PRIi64 _PRI64_PREFIX "i" # endif #endif #ifdef UINT64_MAX # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@) # define _PRIu64_PREFIX "l" # elif defined _MSC_VER || defined __MINGW32__ # define _PRIu64_PREFIX "I64" # elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 # define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX # endif # if !defined PRIo64 || @PRI_MACROS_BROKEN@ # undef PRIo64 # define PRIo64 _PRIu64_PREFIX "o" # endif # if !defined PRIu64 || @PRI_MACROS_BROKEN@ # undef PRIu64 # define PRIu64 _PRIu64_PREFIX "u" # endif # if !defined PRIx64 || @PRI_MACROS_BROKEN@ # undef PRIx64 # define PRIx64 _PRIu64_PREFIX "x" # endif # if !defined PRIX64 || @PRI_MACROS_BROKEN@ # undef PRIX64 # define PRIX64 _PRIu64_PREFIX "X" # endif #endif #if !defined PRIdLEAST8 || @PRI_MACROS_BROKEN@ # undef PRIdLEAST8 # define PRIdLEAST8 "d" #endif #if !defined PRIiLEAST8 || @PRI_MACROS_BROKEN@ # undef PRIiLEAST8 # define PRIiLEAST8 "i" #endif #if !defined PRIoLEAST8 || @PRI_MACROS_BROKEN@ # undef PRIoLEAST8 # define PRIoLEAST8 "o" #endif #if !defined PRIuLEAST8 || @PRI_MACROS_BROKEN@ # undef PRIuLEAST8 # define PRIuLEAST8 "u" #endif #if !defined PRIxLEAST8 || @PRI_MACROS_BROKEN@ # undef PRIxLEAST8 # define PRIxLEAST8 "x" #endif #if !defined PRIXLEAST8 || @PRI_MACROS_BROKEN@ # undef PRIXLEAST8 # define PRIXLEAST8 "X" #endif #if !defined PRIdLEAST16 || @PRI_MACROS_BROKEN@ # undef PRIdLEAST16 # define PRIdLEAST16 "d" #endif #if !defined PRIiLEAST16 || @PRI_MACROS_BROKEN@ # undef PRIiLEAST16 # define PRIiLEAST16 "i" #endif #if !defined PRIoLEAST16 || @PRI_MACROS_BROKEN@ # undef PRIoLEAST16 # define PRIoLEAST16 "o" #endif #if !defined PRIuLEAST16 || @PRI_MACROS_BROKEN@ # undef PRIuLEAST16 # define PRIuLEAST16 "u" #endif #if !defined PRIxLEAST16 || @PRI_MACROS_BROKEN@ # undef PRIxLEAST16 # define PRIxLEAST16 "x" #endif #if !defined PRIXLEAST16 || @PRI_MACROS_BROKEN@ # undef PRIXLEAST16 # define PRIXLEAST16 "X" #endif #if !defined PRIdLEAST32 || @PRI_MACROS_BROKEN@ # undef PRIdLEAST32 # define PRIdLEAST32 "d" #endif #if !defined PRIiLEAST32 || @PRI_MACROS_BROKEN@ # undef PRIiLEAST32 # define PRIiLEAST32 "i" #endif #if !defined PRIoLEAST32 || @PRI_MACROS_BROKEN@ # undef PRIoLEAST32 # define PRIoLEAST32 "o" #endif #if !defined PRIuLEAST32 || @PRI_MACROS_BROKEN@ # undef PRIuLEAST32 # define PRIuLEAST32 "u" #endif #if !defined PRIxLEAST32 || @PRI_MACROS_BROKEN@ # undef PRIxLEAST32 # define PRIxLEAST32 "x" #endif #if !defined PRIXLEAST32 || @PRI_MACROS_BROKEN@ # undef PRIXLEAST32 # define PRIXLEAST32 "X" #endif #ifdef INT64_MAX # if !defined PRIdLEAST64 || @PRI_MACROS_BROKEN@ # undef PRIdLEAST64 # define PRIdLEAST64 PRId64 # endif # if !defined PRIiLEAST64 || @PRI_MACROS_BROKEN@ # undef PRIiLEAST64 # define PRIiLEAST64 PRIi64 # endif #endif #ifdef UINT64_MAX # if !defined PRIoLEAST64 || @PRI_MACROS_BROKEN@ # undef PRIoLEAST64 # define PRIoLEAST64 PRIo64 # endif # if !defined PRIuLEAST64 || @PRI_MACROS_BROKEN@ # undef PRIuLEAST64 # define PRIuLEAST64 PRIu64 # endif # if !defined PRIxLEAST64 || @PRI_MACROS_BROKEN@ # undef PRIxLEAST64 # define PRIxLEAST64 PRIx64 # endif # if !defined PRIXLEAST64 || @PRI_MACROS_BROKEN@ # undef PRIXLEAST64 # define PRIXLEAST64 PRIX64 # endif #endif #if !defined PRIdFAST8 || @PRI_MACROS_BROKEN@ # undef PRIdFAST8 # if INT_FAST8_MAX > INT32_MAX # define PRIdFAST8 PRId64 # else # define PRIdFAST8 "d" # endif #endif #if !defined PRIiFAST8 || @PRI_MACROS_BROKEN@ # undef PRIiFAST8 # if INT_FAST8_MAX > INT32_MAX # define PRIiFAST8 PRIi64 # else # define PRIiFAST8 "i" # endif #endif #if !defined PRIoFAST8 || @PRI_MACROS_BROKEN@ # undef PRIoFAST8 # if UINT_FAST8_MAX > UINT32_MAX # define PRIoFAST8 PRIo64 # else # define PRIoFAST8 "o" # endif #endif #if !defined PRIuFAST8 || @PRI_MACROS_BROKEN@ # undef PRIuFAST8 # if UINT_FAST8_MAX > UINT32_MAX # define PRIuFAST8 PRIu64 # else # define PRIuFAST8 "u" # endif #endif #if !defined PRIxFAST8 || @PRI_MACROS_BROKEN@ # undef PRIxFAST8 # if UINT_FAST8_MAX > UINT32_MAX # define PRIxFAST8 PRIx64 # else # define PRIxFAST8 "x" # endif #endif #if !defined PRIXFAST8 || @PRI_MACROS_BROKEN@ # undef PRIXFAST8 # if UINT_FAST8_MAX > UINT32_MAX # define PRIXFAST8 PRIX64 # else # define PRIXFAST8 "X" # endif #endif #if !defined PRIdFAST16 || @PRI_MACROS_BROKEN@ # undef PRIdFAST16 # if INT_FAST16_MAX > INT32_MAX # define PRIdFAST16 PRId64 # else # define PRIdFAST16 "d" # endif #endif #if !defined PRIiFAST16 || @PRI_MACROS_BROKEN@ # undef PRIiFAST16 # if INT_FAST16_MAX > INT32_MAX # define PRIiFAST16 PRIi64 # else # define PRIiFAST16 "i" # endif #endif #if !defined PRIoFAST16 || @PRI_MACROS_BROKEN@ # undef PRIoFAST16 # if UINT_FAST16_MAX > UINT32_MAX # define PRIoFAST16 PRIo64 # else # define PRIoFAST16 "o" # endif #endif #if !defined PRIuFAST16 || @PRI_MACROS_BROKEN@ # undef PRIuFAST16 # if UINT_FAST16_MAX > UINT32_MAX # define PRIuFAST16 PRIu64 # else # define PRIuFAST16 "u" # endif #endif #if !defined PRIxFAST16 || @PRI_MACROS_BROKEN@ # undef PRIxFAST16 # if UINT_FAST16_MAX > UINT32_MAX # define PRIxFAST16 PRIx64 # else # define PRIxFAST16 "x" # endif #endif #if !defined PRIXFAST16 || @PRI_MACROS_BROKEN@ # undef PRIXFAST16 # if UINT_FAST16_MAX > UINT32_MAX # define PRIXFAST16 PRIX64 # else # define PRIXFAST16 "X" # endif #endif #if !defined PRIdFAST32 || @PRI_MACROS_BROKEN@ # undef PRIdFAST32 # if INT_FAST32_MAX > INT32_MAX # define PRIdFAST32 PRId64 # else # define PRIdFAST32 "d" # endif #endif #if !defined PRIiFAST32 || @PRI_MACROS_BROKEN@ # undef PRIiFAST32 # if INT_FAST32_MAX > INT32_MAX # define PRIiFAST32 PRIi64 # else # define PRIiFAST32 "i" # endif #endif #if !defined PRIoFAST32 || @PRI_MACROS_BROKEN@ # undef PRIoFAST32 # if UINT_FAST32_MAX > UINT32_MAX # define PRIoFAST32 PRIo64 # else # define PRIoFAST32 "o" # endif #endif #if !defined PRIuFAST32 || @PRI_MACROS_BROKEN@ # undef PRIuFAST32 # if UINT_FAST32_MAX > UINT32_MAX # define PRIuFAST32 PRIu64 # else # define PRIuFAST32 "u" # endif #endif #if !defined PRIxFAST32 || @PRI_MACROS_BROKEN@ # undef PRIxFAST32 # if UINT_FAST32_MAX > UINT32_MAX # define PRIxFAST32 PRIx64 # else # define PRIxFAST32 "x" # endif #endif #if !defined PRIXFAST32 || @PRI_MACROS_BROKEN@ # undef PRIXFAST32 # if UINT_FAST32_MAX > UINT32_MAX # define PRIXFAST32 PRIX64 # else # define PRIXFAST32 "X" # endif #endif #ifdef INT64_MAX # if !defined PRIdFAST64 || @PRI_MACROS_BROKEN@ # undef PRIdFAST64 # define PRIdFAST64 PRId64 # endif # if !defined PRIiFAST64 || @PRI_MACROS_BROKEN@ # undef PRIiFAST64 # define PRIiFAST64 PRIi64 # endif #endif #ifdef UINT64_MAX # if !defined PRIoFAST64 || @PRI_MACROS_BROKEN@ # undef PRIoFAST64 # define PRIoFAST64 PRIo64 # endif # if !defined PRIuFAST64 || @PRI_MACROS_BROKEN@ # undef PRIuFAST64 # define PRIuFAST64 PRIu64 # endif # if !defined PRIxFAST64 || @PRI_MACROS_BROKEN@ # undef PRIxFAST64 # define PRIxFAST64 PRIx64 # endif # if !defined PRIXFAST64 || @PRI_MACROS_BROKEN@ # undef PRIXFAST64 # define PRIXFAST64 PRIX64 # endif #endif #if !defined PRIdMAX || @PRI_MACROS_BROKEN@ # undef PRIdMAX # if @INT32_MAX_LT_INTMAX_MAX@ # define PRIdMAX PRId64 # else # define PRIdMAX "ld" # endif #endif #if !defined PRIiMAX || @PRI_MACROS_BROKEN@ # undef PRIiMAX # if @INT32_MAX_LT_INTMAX_MAX@ # define PRIiMAX PRIi64 # else # define PRIiMAX "li" # endif #endif #if !defined PRIoMAX || @PRI_MACROS_BROKEN@ # undef PRIoMAX # if @UINT32_MAX_LT_UINTMAX_MAX@ # define PRIoMAX PRIo64 # else # define PRIoMAX "lo" # endif #endif #if !defined PRIuMAX || @PRI_MACROS_BROKEN@ # undef PRIuMAX # if @UINT32_MAX_LT_UINTMAX_MAX@ # define PRIuMAX PRIu64 # else # define PRIuMAX "lu" # endif #endif #if !defined PRIxMAX || @PRI_MACROS_BROKEN@ # undef PRIxMAX # if @UINT32_MAX_LT_UINTMAX_MAX@ # define PRIxMAX PRIx64 # else # define PRIxMAX "lx" # endif #endif #if !defined PRIXMAX || @PRI_MACROS_BROKEN@ # undef PRIXMAX # if @UINT32_MAX_LT_UINTMAX_MAX@ # define PRIXMAX PRIX64 # else # define PRIXMAX "lX" # endif #endif #if !defined PRIdPTR || @PRI_MACROS_BROKEN@ # undef PRIdPTR # ifdef INTPTR_MAX # define PRIdPTR @PRIPTR_PREFIX@ "d" # endif #endif #if !defined PRIiPTR || @PRI_MACROS_BROKEN@ # undef PRIiPTR # ifdef INTPTR_MAX # define PRIiPTR @PRIPTR_PREFIX@ "i" # endif #endif #if !defined PRIoPTR || @PRI_MACROS_BROKEN@ # undef PRIoPTR # ifdef UINTPTR_MAX # define PRIoPTR @PRIPTR_PREFIX@ "o" # endif #endif #if !defined PRIuPTR || @PRI_MACROS_BROKEN@ # undef PRIuPTR # ifdef UINTPTR_MAX # define PRIuPTR @PRIPTR_PREFIX@ "u" # endif #endif #if !defined PRIxPTR || @PRI_MACROS_BROKEN@ # undef PRIxPTR # ifdef UINTPTR_MAX # define PRIxPTR @PRIPTR_PREFIX@ "x" # endif #endif #if !defined PRIXPTR || @PRI_MACROS_BROKEN@ # undef PRIXPTR # ifdef UINTPTR_MAX # define PRIXPTR @PRIPTR_PREFIX@ "X" # endif #endif #if !defined SCNd8 || @PRI_MACROS_BROKEN@ # undef SCNd8 # ifdef INT8_MAX # define SCNd8 "hhd" # endif #endif #if !defined SCNi8 || @PRI_MACROS_BROKEN@ # undef SCNi8 # ifdef INT8_MAX # define SCNi8 "hhi" # endif #endif #if !defined SCNo8 || @PRI_MACROS_BROKEN@ # undef SCNo8 # ifdef UINT8_MAX # define SCNo8 "hho" # endif #endif #if !defined SCNu8 || @PRI_MACROS_BROKEN@ # undef SCNu8 # ifdef UINT8_MAX # define SCNu8 "hhu" # endif #endif #if !defined SCNx8 || @PRI_MACROS_BROKEN@ # undef SCNx8 # ifdef UINT8_MAX # define SCNx8 "hhx" # endif #endif #if !defined SCNd16 || @PRI_MACROS_BROKEN@ # undef SCNd16 # ifdef INT16_MAX # define SCNd16 "hd" # endif #endif #if !defined SCNi16 || @PRI_MACROS_BROKEN@ # undef SCNi16 # ifdef INT16_MAX # define SCNi16 "hi" # endif #endif #if !defined SCNo16 || @PRI_MACROS_BROKEN@ # undef SCNo16 # ifdef UINT16_MAX # define SCNo16 "ho" # endif #endif #if !defined SCNu16 || @PRI_MACROS_BROKEN@ # undef SCNu16 # ifdef UINT16_MAX # define SCNu16 "hu" # endif #endif #if !defined SCNx16 || @PRI_MACROS_BROKEN@ # undef SCNx16 # ifdef UINT16_MAX # define SCNx16 "hx" # endif #endif #if !defined SCNd32 || @PRI_MACROS_BROKEN@ # undef SCNd32 # ifdef INT32_MAX # define SCNd32 "d" # endif #endif #if !defined SCNi32 || @PRI_MACROS_BROKEN@ # undef SCNi32 # ifdef INT32_MAX # define SCNi32 "i" # endif #endif #if !defined SCNo32 || @PRI_MACROS_BROKEN@ # undef SCNo32 # ifdef UINT32_MAX # define SCNo32 "o" # endif #endif #if !defined SCNu32 || @PRI_MACROS_BROKEN@ # undef SCNu32 # ifdef UINT32_MAX # define SCNu32 "u" # endif #endif #if !defined SCNx32 || @PRI_MACROS_BROKEN@ # undef SCNx32 # ifdef UINT32_MAX # define SCNx32 "x" # endif #endif #ifdef INT64_MAX # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@) # define _SCN64_PREFIX "l" # elif defined _MSC_VER || defined __MINGW32__ # define _SCN64_PREFIX "I64" # elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 # define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX # endif # if !defined SCNd64 || @PRI_MACROS_BROKEN@ # undef SCNd64 # define SCNd64 _SCN64_PREFIX "d" # endif # if !defined SCNi64 || @PRI_MACROS_BROKEN@ # undef SCNi64 # define SCNi64 _SCN64_PREFIX "i" # endif #endif #ifdef UINT64_MAX # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@) # define _SCNu64_PREFIX "l" # elif defined _MSC_VER || defined __MINGW32__ # define _SCNu64_PREFIX "I64" # elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 # define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX # endif # if !defined SCNo64 || @PRI_MACROS_BROKEN@ # undef SCNo64 # define SCNo64 _SCNu64_PREFIX "o" # endif # if !defined SCNu64 || @PRI_MACROS_BROKEN@ # undef SCNu64 # define SCNu64 _SCNu64_PREFIX "u" # endif # if !defined SCNx64 || @PRI_MACROS_BROKEN@ # undef SCNx64 # define SCNx64 _SCNu64_PREFIX "x" # endif #endif #if !defined SCNdLEAST8 || @PRI_MACROS_BROKEN@ # undef SCNdLEAST8 # define SCNdLEAST8 "hhd" #endif #if !defined SCNiLEAST8 || @PRI_MACROS_BROKEN@ # undef SCNiLEAST8 # define SCNiLEAST8 "hhi" #endif #if !defined SCNoLEAST8 || @PRI_MACROS_BROKEN@ # undef SCNoLEAST8 # define SCNoLEAST8 "hho" #endif #if !defined SCNuLEAST8 || @PRI_MACROS_BROKEN@ # undef SCNuLEAST8 # define SCNuLEAST8 "hhu" #endif #if !defined SCNxLEAST8 || @PRI_MACROS_BROKEN@ # undef SCNxLEAST8 # define SCNxLEAST8 "hhx" #endif #if !defined SCNdLEAST16 || @PRI_MACROS_BROKEN@ # undef SCNdLEAST16 # define SCNdLEAST16 "hd" #endif #if !defined SCNiLEAST16 || @PRI_MACROS_BROKEN@ # undef SCNiLEAST16 # define SCNiLEAST16 "hi" #endif #if !defined SCNoLEAST16 || @PRI_MACROS_BROKEN@ # undef SCNoLEAST16 # define SCNoLEAST16 "ho" #endif #if !defined SCNuLEAST16 || @PRI_MACROS_BROKEN@ # undef SCNuLEAST16 # define SCNuLEAST16 "hu" #endif #if !defined SCNxLEAST16 || @PRI_MACROS_BROKEN@ # undef SCNxLEAST16 # define SCNxLEAST16 "hx" #endif #if !defined SCNdLEAST32 || @PRI_MACROS_BROKEN@ # undef SCNdLEAST32 # define SCNdLEAST32 "d" #endif #if !defined SCNiLEAST32 || @PRI_MACROS_BROKEN@ # undef SCNiLEAST32 # define SCNiLEAST32 "i" #endif #if !defined SCNoLEAST32 || @PRI_MACROS_BROKEN@ # undef SCNoLEAST32 # define SCNoLEAST32 "o" #endif #if !defined SCNuLEAST32 || @PRI_MACROS_BROKEN@ # undef SCNuLEAST32 # define SCNuLEAST32 "u" #endif #if !defined SCNxLEAST32 || @PRI_MACROS_BROKEN@ # undef SCNxLEAST32 # define SCNxLEAST32 "x" #endif #ifdef INT64_MAX # if !defined SCNdLEAST64 || @PRI_MACROS_BROKEN@ # undef SCNdLEAST64 # define SCNdLEAST64 SCNd64 # endif # if !defined SCNiLEAST64 || @PRI_MACROS_BROKEN@ # undef SCNiLEAST64 # define SCNiLEAST64 SCNi64 # endif #endif #ifdef UINT64_MAX # if !defined SCNoLEAST64 || @PRI_MACROS_BROKEN@ # undef SCNoLEAST64 # define SCNoLEAST64 SCNo64 # endif # if !defined SCNuLEAST64 || @PRI_MACROS_BROKEN@ # undef SCNuLEAST64 # define SCNuLEAST64 SCNu64 # endif # if !defined SCNxLEAST64 || @PRI_MACROS_BROKEN@ # undef SCNxLEAST64 # define SCNxLEAST64 SCNx64 # endif #endif #if !defined SCNdFAST8 || @PRI_MACROS_BROKEN@ # undef SCNdFAST8 # if INT_FAST8_MAX > INT32_MAX # define SCNdFAST8 SCNd64 # elif INT_FAST8_MAX == 0x7fff # define SCNdFAST8 "hd" # elif INT_FAST8_MAX == 0x7f # define SCNdFAST8 "hhd" # else # define SCNdFAST8 "d" # endif #endif #if !defined SCNiFAST8 || @PRI_MACROS_BROKEN@ # undef SCNiFAST8 # if INT_FAST8_MAX > INT32_MAX # define SCNiFAST8 SCNi64 # elif INT_FAST8_MAX == 0x7fff # define SCNiFAST8 "hi" # elif INT_FAST8_MAX == 0x7f # define SCNiFAST8 "hhi" # else # define SCNiFAST8 "i" # endif #endif #if !defined SCNoFAST8 || @PRI_MACROS_BROKEN@ # undef SCNoFAST8 # if UINT_FAST8_MAX > UINT32_MAX # define SCNoFAST8 SCNo64 # elif UINT_FAST8_MAX == 0xffff # define SCNoFAST8 "ho" # elif UINT_FAST8_MAX == 0xff # define SCNoFAST8 "hho" # else # define SCNoFAST8 "o" # endif #endif #if !defined SCNuFAST8 || @PRI_MACROS_BROKEN@ # undef SCNuFAST8 # if UINT_FAST8_MAX > UINT32_MAX # define SCNuFAST8 SCNu64 # elif UINT_FAST8_MAX == 0xffff # define SCNuFAST8 "hu" # elif UINT_FAST8_MAX == 0xff # define SCNuFAST8 "hhu" # else # define SCNuFAST8 "u" # endif #endif #if !defined SCNxFAST8 || @PRI_MACROS_BROKEN@ # undef SCNxFAST8 # if UINT_FAST8_MAX > UINT32_MAX # define SCNxFAST8 SCNx64 # elif UINT_FAST8_MAX == 0xffff # define SCNxFAST8 "hx" # elif UINT_FAST8_MAX == 0xff # define SCNxFAST8 "hhx" # else # define SCNxFAST8 "x" # endif #endif #if !defined SCNdFAST16 || @PRI_MACROS_BROKEN@ # undef SCNdFAST16 # if INT_FAST16_MAX > INT32_MAX # define SCNdFAST16 SCNd64 # elif INT_FAST16_MAX == 0x7fff # define SCNdFAST16 "hd" # else # define SCNdFAST16 "d" # endif #endif #if !defined SCNiFAST16 || @PRI_MACROS_BROKEN@ # undef SCNiFAST16 # if INT_FAST16_MAX > INT32_MAX # define SCNiFAST16 SCNi64 # elif INT_FAST16_MAX == 0x7fff # define SCNiFAST16 "hi" # else # define SCNiFAST16 "i" # endif #endif #if !defined SCNoFAST16 || @PRI_MACROS_BROKEN@ # undef SCNoFAST16 # if UINT_FAST16_MAX > UINT32_MAX # define SCNoFAST16 SCNo64 # elif UINT_FAST16_MAX == 0xffff # define SCNoFAST16 "ho" # else # define SCNoFAST16 "o" # endif #endif #if !defined SCNuFAST16 || @PRI_MACROS_BROKEN@ # undef SCNuFAST16 # if UINT_FAST16_MAX > UINT32_MAX # define SCNuFAST16 SCNu64 # elif UINT_FAST16_MAX == 0xffff # define SCNuFAST16 "hu" # else # define SCNuFAST16 "u" # endif #endif #if !defined SCNxFAST16 || @PRI_MACROS_BROKEN@ # undef SCNxFAST16 # if UINT_FAST16_MAX > UINT32_MAX # define SCNxFAST16 SCNx64 # elif UINT_FAST16_MAX == 0xffff # define SCNxFAST16 "hx" # else # define SCNxFAST16 "x" # endif #endif #if !defined SCNdFAST32 || @PRI_MACROS_BROKEN@ # undef SCNdFAST32 # if INT_FAST32_MAX > INT32_MAX # define SCNdFAST32 SCNd64 # else # define SCNdFAST32 "d" # endif #endif #if !defined SCNiFAST32 || @PRI_MACROS_BROKEN@ # undef SCNiFAST32 # if INT_FAST32_MAX > INT32_MAX # define SCNiFAST32 SCNi64 # else # define SCNiFAST32 "i" # endif #endif #if !defined SCNoFAST32 || @PRI_MACROS_BROKEN@ # undef SCNoFAST32 # if UINT_FAST32_MAX > UINT32_MAX # define SCNoFAST32 SCNo64 # else # define SCNoFAST32 "o" # endif #endif #if !defined SCNuFAST32 || @PRI_MACROS_BROKEN@ # undef SCNuFAST32 # if UINT_FAST32_MAX > UINT32_MAX # define SCNuFAST32 SCNu64 # else # define SCNuFAST32 "u" # endif #endif #if !defined SCNxFAST32 || @PRI_MACROS_BROKEN@ # undef SCNxFAST32 # if UINT_FAST32_MAX > UINT32_MAX # define SCNxFAST32 SCNx64 # else # define SCNxFAST32 "x" # endif #endif #ifdef INT64_MAX # if !defined SCNdFAST64 || @PRI_MACROS_BROKEN@ # undef SCNdFAST64 # define SCNdFAST64 SCNd64 # endif # if !defined SCNiFAST64 || @PRI_MACROS_BROKEN@ # undef SCNiFAST64 # define SCNiFAST64 SCNi64 # endif #endif #ifdef UINT64_MAX # if !defined SCNoFAST64 || @PRI_MACROS_BROKEN@ # undef SCNoFAST64 # define SCNoFAST64 SCNo64 # endif # if !defined SCNuFAST64 || @PRI_MACROS_BROKEN@ # undef SCNuFAST64 # define SCNuFAST64 SCNu64 # endif # if !defined SCNxFAST64 || @PRI_MACROS_BROKEN@ # undef SCNxFAST64 # define SCNxFAST64 SCNx64 # endif #endif #if !defined SCNdMAX || @PRI_MACROS_BROKEN@ # undef SCNdMAX # if @INT32_MAX_LT_INTMAX_MAX@ # define SCNdMAX SCNd64 # else # define SCNdMAX "ld" # endif #endif #if !defined SCNiMAX || @PRI_MACROS_BROKEN@ # undef SCNiMAX # if @INT32_MAX_LT_INTMAX_MAX@ # define SCNiMAX SCNi64 # else # define SCNiMAX "li" # endif #endif #if !defined SCNoMAX || @PRI_MACROS_BROKEN@ # undef SCNoMAX # if @UINT32_MAX_LT_UINTMAX_MAX@ # define SCNoMAX SCNo64 # else # define SCNoMAX "lo" # endif #endif #if !defined SCNuMAX || @PRI_MACROS_BROKEN@ # undef SCNuMAX # if @UINT32_MAX_LT_UINTMAX_MAX@ # define SCNuMAX SCNu64 # else # define SCNuMAX "lu" # endif #endif #if !defined SCNxMAX || @PRI_MACROS_BROKEN@ # undef SCNxMAX # if @UINT32_MAX_LT_UINTMAX_MAX@ # define SCNxMAX SCNx64 # else # define SCNxMAX "lx" # endif #endif #if !defined SCNdPTR || @PRI_MACROS_BROKEN@ # undef SCNdPTR # ifdef INTPTR_MAX # define SCNdPTR @PRIPTR_PREFIX@ "d" # endif #endif #if !defined SCNiPTR || @PRI_MACROS_BROKEN@ # undef SCNiPTR # ifdef INTPTR_MAX # define SCNiPTR @PRIPTR_PREFIX@ "i" # endif #endif #if !defined SCNoPTR || @PRI_MACROS_BROKEN@ # undef SCNoPTR # ifdef UINTPTR_MAX # define SCNoPTR @PRIPTR_PREFIX@ "o" # endif #endif #if !defined SCNuPTR || @PRI_MACROS_BROKEN@ # undef SCNuPTR # ifdef UINTPTR_MAX # define SCNuPTR @PRIPTR_PREFIX@ "u" # endif #endif #if !defined SCNxPTR || @PRI_MACROS_BROKEN@ # undef SCNxPTR # ifdef UINTPTR_MAX # define SCNxPTR @PRIPTR_PREFIX@ "x" # endif #endif /* 7.8.2 Functions for greatest-width integer types */ #ifdef __cplusplus extern "C" { #endif #if @GNULIB_IMAXABS@ # if !@HAVE_DECL_IMAXABS@ extern intmax_t imaxabs (intmax_t); # endif #elif defined GNULIB_POSIXCHECK # undef imaxabs # if HAVE_RAW_DECL_IMAXABS _GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - " "use gnulib module imaxabs for portability"); # endif #endif #if @GNULIB_IMAXDIV@ # if !@HAVE_DECL_IMAXDIV@ # if !GNULIB_defined_imaxdiv_t typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t; # define GNULIB_defined_imaxdiv_t 1 # endif extern imaxdiv_t imaxdiv (intmax_t, intmax_t); # endif #elif defined GNULIB_POSIXCHECK # undef imaxdiv # if HAVE_RAW_DECL_IMAXDIV _GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - " "use gnulib module imaxdiv for portability"); # endif #endif #if @GNULIB_STRTOIMAX@ # if @REPLACE_STRTOIMAX@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strtoimax # define strtoimax rpl_strtoimax # endif _GL_FUNCDECL_RPL (strtoimax, intmax_t, (const char *, char **, int) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtoimax, intmax_t, (const char *, char **, int)); # else # if !@HAVE_DECL_STRTOIMAX@ # undef strtoimax _GL_FUNCDECL_SYS (strtoimax, intmax_t, (const char *, char **, int) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoimax, intmax_t, (const char *, char **, int)); # endif _GL_CXXALIASWARN (strtoimax); #elif defined GNULIB_POSIXCHECK # undef strtoimax # if HAVE_RAW_DECL_STRTOIMAX _GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - " "use gnulib module strtoimax for portability"); # endif #endif #if @GNULIB_STRTOUMAX@ # if @REPLACE_STRTOUMAX@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef strtoumax # define strtoumax rpl_strtoumax # endif _GL_FUNCDECL_RPL (strtoumax, uintmax_t, (const char *, char **, int) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strtoumax, uintmax_t, (const char *, char **, int)); # else # if !@HAVE_DECL_STRTOUMAX@ # undef strtoumax _GL_FUNCDECL_SYS (strtoumax, uintmax_t, (const char *, char **, int) _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strtoumax, uintmax_t, (const char *, char **, int)); # endif _GL_CXXALIASWARN (strtoumax); #elif defined GNULIB_POSIXCHECK # undef strtoumax # if HAVE_RAW_DECL_STRTOUMAX _GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - " "use gnulib module strtoumax for portability"); # endif #endif /* Don't bother defining or declaring wcstoimax and wcstoumax, since wide-character functions like this are hardly ever useful. */ #ifdef __cplusplus } #endif #endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */ lftp-4.6.3a/lib/setenv.c0000644000015000007670000002502612466374012012003 00000000000000/* Copyright (C) 1992, 1995-2003, 2005-2015 Free Software Foundation, Inc. This file is part of 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 . */ #if !_LIBC /* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc optimizes away the name == NULL test below. */ # define _GL_ARG_NONNULL(params) # define _GL_USE_STDLIB_ALLOC 1 # include #endif #include /* Specification. */ #include #include #ifndef __set_errno # define __set_errno(ev) ((errno) = (ev)) #endif #include #if _LIBC || HAVE_UNISTD_H # include #endif #if !_LIBC # include "malloca.h" #endif #if _LIBC || !HAVE_SETENV #if !_LIBC # define __environ environ #endif #if _LIBC /* This lock protects against simultaneous modifications of 'environ'. */ # include __libc_lock_define_initialized (static, envlock) # define LOCK __libc_lock_lock (envlock) # define UNLOCK __libc_lock_unlock (envlock) #else # define LOCK # define UNLOCK #endif /* In the GNU C library we must keep the namespace clean. */ #ifdef _LIBC # define setenv __setenv # define clearenv __clearenv # define tfind __tfind # define tsearch __tsearch #endif /* In the GNU C library implementation we try to be more clever and allow arbitrarily many changes of the environment given that the used values are from a small set. Outside glibc this will eat up all memory after a while. */ #if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \ && defined __GNUC__) # define USE_TSEARCH 1 # include typedef int (*compar_fn_t) (const void *, const void *); /* This is a pointer to the root of the search tree with the known values. */ static void *known_values; # define KNOWN_VALUE(Str) \ ({ \ void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \ value != NULL ? *(char **) value : NULL; \ }) # define STORE_VALUE(Str) \ tsearch (Str, &known_values, (compar_fn_t) strcmp) #else # undef USE_TSEARCH # define KNOWN_VALUE(Str) NULL # define STORE_VALUE(Str) do { } while (0) #endif /* If this variable is not a null pointer we allocated the current environment. */ static char **last_environ; /* This function is used by 'setenv' and 'putenv'. The difference between the two functions is that for the former must create a new string which is then placed in the environment, while the argument of 'putenv' must be used directly. This is all complicated by the fact that we try to reuse values once generated for a 'setenv' call since we can never free the strings. */ int __add_to_environ (const char *name, const char *value, const char *combined, int replace) { char **ep; size_t size; const size_t namelen = strlen (name); const size_t vallen = value != NULL ? strlen (value) + 1 : 0; LOCK; /* We have to get the pointer now that we have the lock and not earlier since another thread might have created a new environment. */ ep = __environ; size = 0; if (ep != NULL) { for (; *ep != NULL; ++ep) if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') break; else ++size; } if (ep == NULL || *ep == NULL) { char **new_environ; #ifdef USE_TSEARCH char *new_value; #endif /* We allocated this space; we can extend it. */ new_environ = (char **) (last_environ == NULL ? malloc ((size + 2) * sizeof (char *)) : realloc (last_environ, (size + 2) * sizeof (char *))); if (new_environ == NULL) { /* It's easier to set errno to ENOMEM than to rely on the 'malloc-posix' and 'realloc-posix' gnulib modules. */ __set_errno (ENOMEM); UNLOCK; return -1; } /* If the whole entry is given add it. */ if (combined != NULL) /* We must not add the string to the search tree since it belongs to the user. */ new_environ[size] = (char *) combined; else { /* See whether the value is already known. */ #ifdef USE_TSEARCH # ifdef _LIBC new_value = (char *) alloca (namelen + 1 + vallen); __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), value, vallen); # else new_value = (char *) malloca (namelen + 1 + vallen); if (new_value == NULL) { __set_errno (ENOMEM); UNLOCK; return -1; } memcpy (new_value, name, namelen); new_value[namelen] = '='; memcpy (&new_value[namelen + 1], value, vallen); # endif new_environ[size] = KNOWN_VALUE (new_value); if (new_environ[size] == NULL) #endif { new_environ[size] = (char *) malloc (namelen + 1 + vallen); if (new_environ[size] == NULL) { #if defined USE_TSEARCH && !defined _LIBC freea (new_value); #endif __set_errno (ENOMEM); UNLOCK; return -1; } #ifdef USE_TSEARCH memcpy (new_environ[size], new_value, namelen + 1 + vallen); #else memcpy (new_environ[size], name, namelen); new_environ[size][namelen] = '='; memcpy (&new_environ[size][namelen + 1], value, vallen); #endif /* And save the value now. We cannot do this when we remove the string since then we cannot decide whether it is a user string or not. */ STORE_VALUE (new_environ[size]); } #if defined USE_TSEARCH && !defined _LIBC freea (new_value); #endif } if (__environ != last_environ) memcpy ((char *) new_environ, (char *) __environ, size * sizeof (char *)); new_environ[size + 1] = NULL; last_environ = __environ = new_environ; } else if (replace) { char *np; /* Use the user string if given. */ if (combined != NULL) np = (char *) combined; else { #ifdef USE_TSEARCH char *new_value; # ifdef _LIBC new_value = alloca (namelen + 1 + vallen); __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), value, vallen); # else new_value = malloca (namelen + 1 + vallen); if (new_value == NULL) { __set_errno (ENOMEM); UNLOCK; return -1; } memcpy (new_value, name, namelen); new_value[namelen] = '='; memcpy (&new_value[namelen + 1], value, vallen); # endif np = KNOWN_VALUE (new_value); if (np == NULL) #endif { np = (char *) malloc (namelen + 1 + vallen); if (np == NULL) { #if defined USE_TSEARCH && !defined _LIBC freea (new_value); #endif __set_errno (ENOMEM); UNLOCK; return -1; } #ifdef USE_TSEARCH memcpy (np, new_value, namelen + 1 + vallen); #else memcpy (np, name, namelen); np[namelen] = '='; memcpy (&np[namelen + 1], value, vallen); #endif /* And remember the value. */ STORE_VALUE (np); } #if defined USE_TSEARCH && !defined _LIBC freea (new_value); #endif } *ep = np; } UNLOCK; return 0; } int setenv (const char *name, const char *value, int replace) { if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) { __set_errno (EINVAL); return -1; } return __add_to_environ (name, value, NULL, replace); } /* The 'clearenv' was planned to be added to POSIX.1 but probably never made it. Nevertheless the POSIX.9 standard (POSIX bindings for Fortran 77) requires this function. */ int clearenv (void) { LOCK; if (__environ == last_environ && __environ != NULL) { /* We allocated this environment so we can free it. */ free (__environ); last_environ = NULL; } /* Clear the environment pointer removes the whole environment. */ __environ = NULL; UNLOCK; return 0; } #ifdef _LIBC static void free_mem (void) { /* Remove all traces. */ clearenv (); /* Now remove the search tree. */ __tdestroy (known_values, free); known_values = NULL; } text_set_element (__libc_subfreeres, free_mem); # undef setenv # undef clearenv weak_alias (__setenv, setenv) weak_alias (__clearenv, clearenv) #endif #endif /* _LIBC || !HAVE_SETENV */ /* The rest of this file is called into use when replacing an existing but buggy setenv. Known bugs include failure to diagnose invalid name, and consuming a leading '=' from value. */ #if HAVE_SETENV # undef setenv # if !HAVE_DECL_SETENV extern int setenv (const char *, const char *, int); # endif # define STREQ(a, b) (strcmp (a, b) == 0) int rpl_setenv (const char *name, const char *value, int replace) { int result; if (!name || !*name || strchr (name, '=')) { errno = EINVAL; return -1; } /* Call the real setenv even if replace is 0, in case implementation has underlying data to update, such as when environ changes. */ result = setenv (name, value, replace); if (result == 0 && replace && *value == '=') { char *tmp = getenv (name); if (!STREQ (tmp, value)) { int saved_errno; size_t len = strlen (value); tmp = malloca (len + 2); /* Since leading '=' is eaten, double it up. */ *tmp = '='; memcpy (tmp + 1, value, len + 1); result = setenv (name, tmp, replace); saved_errno = errno; freea (tmp); errno = saved_errno; } } return result; } #endif /* HAVE_SETENV */ lftp-4.6.3a/lib/regexec.c0000644000015000007670000037771612466374012012141 00000000000000/* Extended regular expression matching and search library. Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . The GNU C Library 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. The GNU C Library 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 the GNU C Library; if not, see . */ static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, Idx n) internal_function; static void match_ctx_clean (re_match_context_t *mctx) internal_function; static void match_ctx_free (re_match_context_t *cache) internal_function; static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node, Idx str_idx, Idx from, Idx to) internal_function; static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx) internal_function; static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx) internal_function; static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx) internal_function; static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx) internal_function; static reg_errcode_t re_search_internal (const regex_t *preg, const char *string, Idx length, Idx start, Idx last_start, Idx stop, size_t nmatch, regmatch_t pmatch[], int eflags) internal_function; static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1, Idx length1, const char *string2, Idx length2, Idx start, regoff_t range, struct re_registers *regs, Idx stop, bool ret_len) internal_function; static regoff_t re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length, Idx start, regoff_t range, Idx stop, struct re_registers *regs, bool ret_len) internal_function; static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs, int regs_allocated) internal_function; static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) internal_function; static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match, Idx *p_match_first) internal_function; static Idx check_halt_state_context (const re_match_context_t *mctx, const re_dfastate_t *state, Idx idx) internal_function; static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch) internal_function; static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node, Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes) internal_function; static reg_errcode_t set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, regmatch_t *pmatch, bool fl_backtrack) internal_function; static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) internal_function; #ifdef RE_ENABLE_I18N static int sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, Idx node_idx, Idx str_idx, Idx max_str_idx) internal_function; #endif /* RE_ENABLE_I18N */ static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx) internal_function; static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, Idx str_idx, re_node_set *cur_dest) internal_function; static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx, re_sift_context_t *sctx, Idx str_idx, re_node_set *dest_nodes) internal_function; static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, const re_node_set *candidates) internal_function; static bool check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits, Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx) internal_function; static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, Idx subexp_idx, Idx from_node, Idx bkref_idx) internal_function; static int check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit, Idx subexp_idx, Idx node, Idx str_idx, Idx bkref_idx) internal_function; static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, const re_node_set *candidates, re_node_set *limits, struct re_backref_cache_entry *bkref_ents, Idx str_idx) internal_function; static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, Idx str_idx, const re_node_set *candidates) internal_function; static reg_errcode_t merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst, re_dfastate_t **src, Idx num) internal_function; static re_dfastate_t *find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) internal_function; static re_dfastate_t *transit_state (reg_errcode_t *err, re_match_context_t *mctx, re_dfastate_t *state) internal_function; static re_dfastate_t *merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, re_dfastate_t *next_state) internal_function; static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, Idx str_idx) internal_function; #if 0 static re_dfastate_t *transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, re_dfastate_t *pstate) internal_function; #endif #ifdef RE_ENABLE_I18N static reg_errcode_t transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) internal_function; #endif /* RE_ENABLE_I18N */ static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) internal_function; static reg_errcode_t get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx) internal_function; static reg_errcode_t get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str) internal_function; static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, Idx subexp_idx, int type) internal_function; static reg_errcode_t check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node, Idx top_str, Idx last_node, Idx last_str, int type) internal_function; static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx, re_node_set *cur_nodes, re_node_set *next_nodes) internal_function; static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, Idx ex_subexp, int type) internal_function; static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, Idx target, Idx ex_subexp, int type) internal_function; static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, Idx cur_str, Idx subexp_num, int type) internal_function; static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) internal_function; #ifdef RE_ENABLE_I18N static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, const re_string_t *input, Idx idx) internal_function; # ifdef _LIBC static unsigned int find_collation_sequence_value (const unsigned char *mbs, size_t name_len) internal_function; # endif /* _LIBC */ #endif /* RE_ENABLE_I18N */ static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, re_node_set *states_node, bitset_t *states_ch) internal_function; static bool check_node_accept (const re_match_context_t *mctx, const re_token_t *node, Idx idx) internal_function; static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len) internal_function; /* Entry point for POSIX code. */ /* regexec searches for a given pattern, specified by PREG, in the string STRING. If NMATCH is zero or REG_NOSUB was set in the cflags argument to 'regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at least NMATCH elements, and we set them to the offsets of the corresponding matched substrings. EFLAGS specifies "execution flags" which affect matching: if REG_NOTBOL is set, then ^ does not match at the beginning of the string; if REG_NOTEOL is set, then $ does not match at the end. We return 0 if we find a match and REG_NOMATCH if not. */ int regexec (preg, string, nmatch, pmatch, eflags) const regex_t *_Restrict_ preg; const char *_Restrict_ string; size_t nmatch; regmatch_t pmatch[_Restrict_arr_]; int eflags; { reg_errcode_t err; Idx start, length; re_dfa_t *dfa = preg->buffer; if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND)) return REG_BADPAT; if (eflags & REG_STARTEND) { start = pmatch[0].rm_so; length = pmatch[0].rm_eo; } else { start = 0; length = strlen (string); } lock_lock (dfa->lock); if (preg->no_sub) err = re_search_internal (preg, string, length, start, length, length, 0, NULL, eflags); else err = re_search_internal (preg, string, length, start, length, length, nmatch, pmatch, eflags); lock_unlock (dfa->lock); return err != REG_NOERROR; } #ifdef _LIBC # include versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4); # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) __typeof__ (__regexec) __compat_regexec; int attribute_compat_text_section __compat_regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string, size_t nmatch, regmatch_t pmatch[], int eflags) { return regexec (preg, string, nmatch, pmatch, eflags & (REG_NOTBOL | REG_NOTEOL)); } compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0); # endif #endif /* Entry points for GNU code. */ /* re_match, re_search, re_match_2, re_search_2 The former two functions operate on STRING with length LENGTH, while the later two operate on concatenation of STRING1 and STRING2 with lengths LENGTH1 and LENGTH2, respectively. re_match() matches the compiled pattern in BUFP against the string, starting at index START. re_search() first tries matching at index START, then it tries to match starting from index START + 1, and so on. The last start position tried is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same way as re_match().) The parameter STOP of re_{match,search}_2 specifies that no match exceeding the first STOP characters of the concatenation of the strings should be concerned. If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match and all groups is stored in REGS. (For the "_2" variants, the offsets are computed relative to the concatenation, not relative to the individual strings.) On success, re_match* functions return the length of the match, re_search* return the position of the start of the match. Return value -1 means no match was found and -2 indicates an internal error. */ regoff_t re_match (bufp, string, length, start, regs) struct re_pattern_buffer *bufp; const char *string; Idx length, start; struct re_registers *regs; { return re_search_stub (bufp, string, length, start, 0, length, regs, true); } #ifdef _LIBC weak_alias (__re_match, re_match) #endif regoff_t re_search (bufp, string, length, start, range, regs) struct re_pattern_buffer *bufp; const char *string; Idx length, start; regoff_t range; struct re_registers *regs; { return re_search_stub (bufp, string, length, start, range, length, regs, false); } #ifdef _LIBC weak_alias (__re_search, re_search) #endif regoff_t re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; Idx length1, length2, start, stop; struct re_registers *regs; { return re_search_2_stub (bufp, string1, length1, string2, length2, start, 0, regs, stop, true); } #ifdef _LIBC weak_alias (__re_match_2, re_match_2) #endif regoff_t re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; Idx length1, length2, start, stop; regoff_t range; struct re_registers *regs; { return re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs, stop, false); } #ifdef _LIBC weak_alias (__re_search_2, re_search_2) #endif static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1, Idx length1, const char *string2, Idx length2, Idx start, regoff_t range, struct re_registers *regs, Idx stop, bool ret_len) { const char *str; regoff_t rval; Idx len = length1 + length2; char *s = NULL; if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) return -2; /* Concatenate the strings. */ if (length2 > 0) if (length1 > 0) { s = re_malloc (char, len); if (BE (s == NULL, 0)) return -2; #ifdef _LIBC memcpy (__mempcpy (s, string1, length1), string2, length2); #else memcpy (s, string1, length1); memcpy (s + length1, string2, length2); #endif str = s; } else str = string2; else str = string1; rval = re_search_stub (bufp, str, len, start, range, stop, regs, ret_len); re_free (s); return rval; } /* The parameters have the same meaning as those of re_search. Additional parameters: If RET_LEN is true the length of the match is returned (re_match style); otherwise the position of the match is returned. */ static regoff_t re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length, Idx start, regoff_t range, Idx stop, struct re_registers *regs, bool ret_len) { reg_errcode_t result; regmatch_t *pmatch; Idx nregs; regoff_t rval; int eflags = 0; re_dfa_t *dfa = bufp->buffer; Idx last_start = start + range; /* Check for out-of-range. */ if (BE (start < 0 || start > length, 0)) return -1; if (BE (length < last_start || (0 <= range && last_start < start), 0)) last_start = length; else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0)) last_start = 0; lock_lock (dfa->lock); eflags |= (bufp->not_bol) ? REG_NOTBOL : 0; eflags |= (bufp->not_eol) ? REG_NOTEOL : 0; /* Compile fastmap if we haven't yet. */ if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate) re_compile_fastmap (bufp); if (BE (bufp->no_sub, 0)) regs = NULL; /* We need at least 1 register. */ if (regs == NULL) nregs = 1; else if (BE (bufp->regs_allocated == REGS_FIXED && regs->num_regs <= bufp->re_nsub, 0)) { nregs = regs->num_regs; if (BE (nregs < 1, 0)) { /* Nothing can be copied to regs. */ regs = NULL; nregs = 1; } } else nregs = bufp->re_nsub + 1; pmatch = re_malloc (regmatch_t, nregs); if (BE (pmatch == NULL, 0)) { rval = -2; goto out; } result = re_search_internal (bufp, string, length, start, last_start, stop, nregs, pmatch, eflags); rval = 0; /* I hope we needn't fill their regs with -1's when no match was found. */ if (result != REG_NOERROR) rval = result == REG_NOMATCH ? -1 : -2; else if (regs != NULL) { /* If caller wants register contents data back, copy them. */ bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs, bufp->regs_allocated); if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0)) rval = -2; } if (BE (rval == 0, 1)) { if (ret_len) { assert (pmatch[0].rm_so == start); rval = pmatch[0].rm_eo - start; } else rval = pmatch[0].rm_so; } re_free (pmatch); out: lock_unlock (dfa->lock); return rval; } static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs, int regs_allocated) { int rval = REGS_REALLOCATE; Idx i; Idx need_regs = nregs + 1; /* We need one extra element beyond 'num_regs' for the '-1' marker GNU code uses. */ /* Have the register data arrays been allocated? */ if (regs_allocated == REGS_UNALLOCATED) { /* No. So allocate them with malloc. */ regs->start = re_malloc (regoff_t, need_regs); if (BE (regs->start == NULL, 0)) return REGS_UNALLOCATED; regs->end = re_malloc (regoff_t, need_regs); if (BE (regs->end == NULL, 0)) { re_free (regs->start); return REGS_UNALLOCATED; } regs->num_regs = need_regs; } else if (regs_allocated == REGS_REALLOCATE) { /* Yes. If we need more elements than were already allocated, reallocate them. If we need fewer, just leave it alone. */ if (BE (need_regs > regs->num_regs, 0)) { regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs); regoff_t *new_end; if (BE (new_start == NULL, 0)) return REGS_UNALLOCATED; new_end = re_realloc (regs->end, regoff_t, need_regs); if (BE (new_end == NULL, 0)) { re_free (new_start); return REGS_UNALLOCATED; } regs->start = new_start; regs->end = new_end; regs->num_regs = need_regs; } } else { assert (regs_allocated == REGS_FIXED); /* This function may not be called with REGS_FIXED and nregs too big. */ assert (regs->num_regs >= nregs); rval = REGS_FIXED; } /* Copy the regs. */ for (i = 0; i < nregs; ++i) { regs->start[i] = pmatch[i].rm_so; regs->end[i] = pmatch[i].rm_eo; } for ( ; i < regs->num_regs; ++i) regs->start[i] = regs->end[i] = -1; return rval; } /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated using the malloc library routine, and must each be at least NUM_REGS * sizeof (regoff_t) bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ void re_set_registers (bufp, regs, num_regs, starts, ends) struct re_pattern_buffer *bufp; struct re_registers *regs; __re_size_t num_regs; regoff_t *starts, *ends; { if (num_regs) { bufp->regs_allocated = REGS_REALLOCATE; regs->num_regs = num_regs; regs->start = starts; regs->end = ends; } else { bufp->regs_allocated = REGS_UNALLOCATED; regs->num_regs = 0; regs->start = regs->end = NULL; } } #ifdef _LIBC weak_alias (__re_set_registers, re_set_registers) #endif /* Entry points compatible with 4.2 BSD regex library. We don't define them unless specifically requested. */ #if defined _REGEX_RE_COMP || defined _LIBC int # ifdef _LIBC weak_function # endif re_exec (s) const char *s; { return 0 == regexec (&re_comp_buf, s, 0, NULL, 0); } #endif /* _REGEX_RE_COMP */ /* Internal entry point. */ /* Searches for a compiled pattern PREG in the string STRING, whose length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same meaning as with regexec. LAST_START is START + RANGE, where START and RANGE have the same meaning as with re_search. Return REG_NOERROR if we find a match, and REG_NOMATCH if not, otherwise return the error code. Note: We assume front end functions already check ranges. (0 <= LAST_START && LAST_START <= LENGTH) */ static reg_errcode_t __attribute_warn_unused_result__ re_search_internal (const regex_t *preg, const char *string, Idx length, Idx start, Idx last_start, Idx stop, size_t nmatch, regmatch_t pmatch[], int eflags) { reg_errcode_t err; const re_dfa_t *dfa = preg->buffer; Idx left_lim, right_lim; int incr; bool fl_longest_match; int match_kind; Idx match_first; Idx match_last = REG_MISSING; Idx extra_nmatch; bool sb; int ch; #if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) re_match_context_t mctx = { .dfa = dfa }; #else re_match_context_t mctx; #endif char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate && start != last_start && !preg->can_be_null) ? preg->fastmap : NULL); RE_TRANSLATE_TYPE t = preg->translate; #if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) memset (&mctx, '\0', sizeof (re_match_context_t)); mctx.dfa = dfa; #endif extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0; nmatch -= extra_nmatch; /* Check if the DFA haven't been compiled. */ if (BE (preg->used == 0 || dfa->init_state == NULL || dfa->init_state_word == NULL || dfa->init_state_nl == NULL || dfa->init_state_begbuf == NULL, 0)) return REG_NOMATCH; #ifdef DEBUG /* We assume front-end functions already check them. */ assert (0 <= last_start && last_start <= length); #endif /* If initial states with non-begbuf contexts have no elements, the regex must be anchored. If preg->newline_anchor is set, we'll never use init_state_nl, so do not check it. */ if (dfa->init_state->nodes.nelem == 0 && dfa->init_state_word->nodes.nelem == 0 && (dfa->init_state_nl->nodes.nelem == 0 || !preg->newline_anchor)) { if (start != 0 && last_start != 0) return REG_NOMATCH; start = last_start = 0; } /* We must check the longest matching, if nmatch > 0. */ fl_longest_match = (nmatch != 0 || dfa->nbackref); err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, preg->translate, (preg->syntax & RE_ICASE) != 0, dfa); if (BE (err != REG_NOERROR, 0)) goto free_return; mctx.input.stop = stop; mctx.input.raw_stop = stop; mctx.input.newline_anchor = preg->newline_anchor; err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); if (BE (err != REG_NOERROR, 0)) goto free_return; /* We will log all the DFA states through which the dfa pass, if nmatch > 1, or this dfa has "multibyte node", which is a back-reference or a node which can accept multibyte character or multi character collating element. */ if (nmatch > 1 || dfa->has_mb_node) { /* Avoid overflow. */ if (BE ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) <= mctx.input.bufs_len), 0)) { err = REG_ESPACE; goto free_return; } mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); if (BE (mctx.state_log == NULL, 0)) { err = REG_ESPACE; goto free_return; } } else mctx.state_log = NULL; match_first = start; mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF : CONTEXT_NEWLINE | CONTEXT_BEGBUF; /* Check incrementally whether the input string matches. */ incr = (last_start < start) ? -1 : 1; left_lim = (last_start < start) ? last_start : start; right_lim = (last_start < start) ? start : last_start; sb = dfa->mb_cur_max == 1; match_kind = (fastmap ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0) | (start <= last_start ? 2 : 0) | (t != NULL ? 1 : 0)) : 8); for (;; match_first += incr) { err = REG_NOMATCH; if (match_first < left_lim || right_lim < match_first) goto free_return; /* Advance as rapidly as possible through the string, until we find a plausible place to start matching. This may be done with varying efficiency, so there are various possibilities: only the most common of them are specialized, in order to save on code size. We use a switch statement for speed. */ switch (match_kind) { case 8: /* No fastmap. */ break; case 7: /* Fastmap with single-byte translation, match forward. */ while (BE (match_first < right_lim, 1) && !fastmap[t[(unsigned char) string[match_first]]]) ++match_first; goto forward_match_found_start_or_reached_end; case 6: /* Fastmap without translation, match forward. */ while (BE (match_first < right_lim, 1) && !fastmap[(unsigned char) string[match_first]]) ++match_first; forward_match_found_start_or_reached_end: if (BE (match_first == right_lim, 0)) { ch = match_first >= length ? 0 : (unsigned char) string[match_first]; if (!fastmap[t ? t[ch] : ch]) goto free_return; } break; case 4: case 5: /* Fastmap without multi-byte translation, match backwards. */ while (match_first >= left_lim) { ch = match_first >= length ? 0 : (unsigned char) string[match_first]; if (fastmap[t ? t[ch] : ch]) break; --match_first; } if (match_first < left_lim) goto free_return; break; default: /* In this case, we can't determine easily the current byte, since it might be a component byte of a multibyte character. Then we use the constructed buffer instead. */ for (;;) { /* If MATCH_FIRST is out of the valid range, reconstruct the buffers. */ __re_size_t offset = match_first - mctx.input.raw_mbs_idx; if (BE (offset >= (__re_size_t) mctx.input.valid_raw_len, 0)) { err = re_string_reconstruct (&mctx.input, match_first, eflags); if (BE (err != REG_NOERROR, 0)) goto free_return; offset = match_first - mctx.input.raw_mbs_idx; } /* If MATCH_FIRST is out of the buffer, leave it as '\0'. Note that MATCH_FIRST must not be smaller than 0. */ ch = (match_first >= length ? 0 : re_string_byte_at (&mctx.input, offset)); if (fastmap[ch]) break; match_first += incr; if (match_first < left_lim || match_first > right_lim) { err = REG_NOMATCH; goto free_return; } } break; } /* Reconstruct the buffers so that the matcher can assume that the matching starts from the beginning of the buffer. */ err = re_string_reconstruct (&mctx.input, match_first, eflags); if (BE (err != REG_NOERROR, 0)) goto free_return; #ifdef RE_ENABLE_I18N /* Don't consider this char as a possible match start if it part, yet isn't the head, of a multibyte character. */ if (!sb && !re_string_first_byte (&mctx.input, 0)) continue; #endif /* It seems to be appropriate one, then use the matcher. */ /* We assume that the matching starts from 0. */ mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0; match_last = check_matching (&mctx, fl_longest_match, start <= last_start ? &match_first : NULL); if (match_last != REG_MISSING) { if (BE (match_last == REG_ERROR, 0)) { err = REG_ESPACE; goto free_return; } else { mctx.match_last = match_last; if ((!preg->no_sub && nmatch > 1) || dfa->nbackref) { re_dfastate_t *pstate = mctx.state_log[match_last]; mctx.last_node = check_halt_state_context (&mctx, pstate, match_last); } if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match) || dfa->nbackref) { err = prune_impossible_nodes (&mctx); if (err == REG_NOERROR) break; if (BE (err != REG_NOMATCH, 0)) goto free_return; match_last = REG_MISSING; } else break; /* We found a match. */ } } match_ctx_clean (&mctx); } #ifdef DEBUG assert (match_last != REG_MISSING); assert (err == REG_NOERROR); #endif /* Set pmatch[] if we need. */ if (nmatch > 0) { Idx reg_idx; /* Initialize registers. */ for (reg_idx = 1; reg_idx < nmatch; ++reg_idx) pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1; /* Set the points where matching start/end. */ pmatch[0].rm_so = 0; pmatch[0].rm_eo = mctx.match_last; /* FIXME: This function should fail if mctx.match_last exceeds the maximum possible regoff_t value. We need a new error code REG_OVERFLOW. */ if (!preg->no_sub && nmatch > 1) { err = set_regs (preg, &mctx, nmatch, pmatch, dfa->has_plural_match && dfa->nbackref > 0); if (BE (err != REG_NOERROR, 0)) goto free_return; } /* At last, add the offset to each register, since we slid the buffers so that we could assume that the matching starts from 0. */ for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) if (pmatch[reg_idx].rm_so != -1) { #ifdef RE_ENABLE_I18N if (BE (mctx.input.offsets_needed != 0, 0)) { pmatch[reg_idx].rm_so = (pmatch[reg_idx].rm_so == mctx.input.valid_len ? mctx.input.valid_raw_len : mctx.input.offsets[pmatch[reg_idx].rm_so]); pmatch[reg_idx].rm_eo = (pmatch[reg_idx].rm_eo == mctx.input.valid_len ? mctx.input.valid_raw_len : mctx.input.offsets[pmatch[reg_idx].rm_eo]); } #else assert (mctx.input.offsets_needed == 0); #endif pmatch[reg_idx].rm_so += match_first; pmatch[reg_idx].rm_eo += match_first; } for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx) { pmatch[nmatch + reg_idx].rm_so = -1; pmatch[nmatch + reg_idx].rm_eo = -1; } if (dfa->subexp_map) for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++) if (dfa->subexp_map[reg_idx] != reg_idx) { pmatch[reg_idx + 1].rm_so = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so; pmatch[reg_idx + 1].rm_eo = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo; } } free_return: re_free (mctx.state_log); if (dfa->nbackref) match_ctx_free (&mctx); re_string_destruct (&mctx.input); return err; } static reg_errcode_t __attribute_warn_unused_result__ prune_impossible_nodes (re_match_context_t *mctx) { const re_dfa_t *const dfa = mctx->dfa; Idx halt_node, match_last; reg_errcode_t ret; re_dfastate_t **sifted_states; re_dfastate_t **lim_states = NULL; re_sift_context_t sctx; #ifdef DEBUG assert (mctx->state_log != NULL); #endif match_last = mctx->match_last; halt_node = mctx->last_node; /* Avoid overflow. */ if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) <= match_last, 0)) return REG_ESPACE; sifted_states = re_malloc (re_dfastate_t *, match_last + 1); if (BE (sifted_states == NULL, 0)) { ret = REG_ESPACE; goto free_return; } if (dfa->nbackref) { lim_states = re_malloc (re_dfastate_t *, match_last + 1); if (BE (lim_states == NULL, 0)) { ret = REG_ESPACE; goto free_return; } while (1) { memset (lim_states, '\0', sizeof (re_dfastate_t *) * (match_last + 1)); sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); ret = sift_states_backward (mctx, &sctx); re_node_set_free (&sctx.limits); if (BE (ret != REG_NOERROR, 0)) goto free_return; if (sifted_states[0] != NULL || lim_states[0] != NULL) break; do { --match_last; if (! REG_VALID_INDEX (match_last)) { ret = REG_NOMATCH; goto free_return; } } while (mctx->state_log[match_last] == NULL || !mctx->state_log[match_last]->halt); halt_node = check_halt_state_context (mctx, mctx->state_log[match_last], match_last); } ret = merge_state_array (dfa, sifted_states, lim_states, match_last + 1); re_free (lim_states); lim_states = NULL; if (BE (ret != REG_NOERROR, 0)) goto free_return; } else { sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); ret = sift_states_backward (mctx, &sctx); re_node_set_free (&sctx.limits); if (BE (ret != REG_NOERROR, 0)) goto free_return; if (sifted_states[0] == NULL) { ret = REG_NOMATCH; goto free_return; } } re_free (mctx->state_log); mctx->state_log = sifted_states; sifted_states = NULL; mctx->last_node = halt_node; mctx->match_last = match_last; ret = REG_NOERROR; free_return: re_free (sifted_states); re_free (lim_states); return ret; } /* Acquire an initial state and return it. We must select appropriate initial state depending on the context, since initial states may have constraints like "\<", "^", etc.. */ static inline re_dfastate_t * __attribute__ ((always_inline)) internal_function acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, Idx idx) { const re_dfa_t *const dfa = mctx->dfa; if (dfa->init_state->has_constraint) { unsigned int context; context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags); if (IS_WORD_CONTEXT (context)) return dfa->init_state_word; else if (IS_ORDINARY_CONTEXT (context)) return dfa->init_state; else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context)) return dfa->init_state_begbuf; else if (IS_NEWLINE_CONTEXT (context)) return dfa->init_state_nl; else if (IS_BEGBUF_CONTEXT (context)) { /* It is relatively rare case, then calculate on demand. */ return re_acquire_state_context (err, dfa, dfa->init_state->entrance_nodes, context); } else /* Must not happen? */ return dfa->init_state; } else return dfa->init_state; } /* Check whether the regular expression match input string INPUT or not, and return the index where the matching end. Return REG_MISSING if there is no match, and return REG_ERROR in case of an error. FL_LONGEST_MATCH means we want the POSIX longest matching. If P_MATCH_FIRST is not NULL, and the match fails, it is set to the next place where we may want to try matching. Note that the matcher assumes that the matching starts from the current index of the buffer. */ static Idx internal_function __attribute_warn_unused_result__ check_matching (re_match_context_t *mctx, bool fl_longest_match, Idx *p_match_first) { const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; Idx match = 0; Idx match_last = REG_MISSING; Idx cur_str_idx = re_string_cur_idx (&mctx->input); re_dfastate_t *cur_state; bool at_init_state = p_match_first != NULL; Idx next_start_idx = cur_str_idx; err = REG_NOERROR; cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); /* An initial state must not be NULL (invalid). */ if (BE (cur_state == NULL, 0)) { assert (err == REG_ESPACE); return REG_ERROR; } if (mctx->state_log != NULL) { mctx->state_log[cur_str_idx] = cur_state; /* Check OP_OPEN_SUBEXP in the initial state in case that we use them later. E.g. Processing back references. */ if (BE (dfa->nbackref, 0)) { at_init_state = false; err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); if (BE (err != REG_NOERROR, 0)) return err; if (cur_state->has_backref) { err = transit_state_bkref (mctx, &cur_state->nodes); if (BE (err != REG_NOERROR, 0)) return err; } } } /* If the RE accepts NULL string. */ if (BE (cur_state->halt, 0)) { if (!cur_state->has_constraint || check_halt_state_context (mctx, cur_state, cur_str_idx)) { if (!fl_longest_match) return cur_str_idx; else { match_last = cur_str_idx; match = 1; } } } while (!re_string_eoi (&mctx->input)) { re_dfastate_t *old_state = cur_state; Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1; if ((BE (next_char_idx >= mctx->input.bufs_len, 0) && mctx->input.bufs_len < mctx->input.len) || (BE (next_char_idx >= mctx->input.valid_len, 0) && mctx->input.valid_len < mctx->input.len)) { err = extend_buffers (mctx, next_char_idx + 1); if (BE (err != REG_NOERROR, 0)) { assert (err == REG_ESPACE); return REG_ERROR; } } cur_state = transit_state (&err, mctx, cur_state); if (mctx->state_log != NULL) cur_state = merge_state_with_log (&err, mctx, cur_state); if (cur_state == NULL) { /* Reached the invalid state or an error. Try to recover a valid state using the state log, if available and if we have not already found a valid (even if not the longest) match. */ if (BE (err != REG_NOERROR, 0)) return REG_ERROR; if (mctx->state_log == NULL || (match && !fl_longest_match) || (cur_state = find_recover_state (&err, mctx)) == NULL) break; } if (BE (at_init_state, 0)) { if (old_state == cur_state) next_start_idx = next_char_idx; else at_init_state = false; } if (cur_state->halt) { /* Reached a halt state. Check the halt state can satisfy the current context. */ if (!cur_state->has_constraint || check_halt_state_context (mctx, cur_state, re_string_cur_idx (&mctx->input))) { /* We found an appropriate halt state. */ match_last = re_string_cur_idx (&mctx->input); match = 1; /* We found a match, do not modify match_first below. */ p_match_first = NULL; if (!fl_longest_match) break; } } } if (p_match_first) *p_match_first += next_start_idx; return match_last; } /* Check NODE match the current context. */ static bool internal_function check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context) { re_token_type_t type = dfa->nodes[node].type; unsigned int constraint = dfa->nodes[node].constraint; if (type != END_OF_RE) return false; if (!constraint) return true; if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context)) return false; return true; } /* Check the halt state STATE match the current context. Return 0 if not match, if the node, STATE has, is a halt node and match the context, return the node. */ static Idx internal_function check_halt_state_context (const re_match_context_t *mctx, const re_dfastate_t *state, Idx idx) { Idx i; unsigned int context; #ifdef DEBUG assert (state->halt); #endif context = re_string_context_at (&mctx->input, idx, mctx->eflags); for (i = 0; i < state->nodes.nelem; ++i) if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context)) return state->nodes.elems[i]; return 0; } /* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA corresponding to the DFA). Return the destination node, and update EPS_VIA_NODES; return REG_MISSING in case of errors. */ static Idx internal_function proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs, Idx *pidx, Idx node, re_node_set *eps_via_nodes, struct re_fail_stack_t *fs) { const re_dfa_t *const dfa = mctx->dfa; Idx i; bool ok; if (IS_EPSILON_NODE (dfa->nodes[node].type)) { re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; re_node_set *edests = &dfa->edests[node]; Idx dest_node; ok = re_node_set_insert (eps_via_nodes, node); if (BE (! ok, 0)) return REG_ERROR; /* Pick up a valid destination, or return REG_MISSING if none is found. */ for (dest_node = REG_MISSING, i = 0; i < edests->nelem; ++i) { Idx candidate = edests->elems[i]; if (!re_node_set_contains (cur_nodes, candidate)) continue; if (dest_node == REG_MISSING) dest_node = candidate; else { /* In order to avoid infinite loop like "(a*)*", return the second epsilon-transition if the first was already considered. */ if (re_node_set_contains (eps_via_nodes, dest_node)) return candidate; /* Otherwise, push the second epsilon-transition on the fail stack. */ else if (fs != NULL && push_fail_stack (fs, *pidx, candidate, nregs, regs, eps_via_nodes)) return REG_ERROR; /* We know we are going to exit. */ break; } } return dest_node; } else { Idx naccepted = 0; re_token_type_t type = dfa->nodes[node].type; #ifdef RE_ENABLE_I18N if (dfa->nodes[node].accept_mb) naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); else #endif /* RE_ENABLE_I18N */ if (type == OP_BACK_REF) { Idx subexp_idx = dfa->nodes[node].opr.idx + 1; naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; if (fs != NULL) { if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1) return REG_MISSING; else if (naccepted) { char *buf = (char *) re_string_get_buffer (&mctx->input); if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx, naccepted) != 0) return REG_MISSING; } } if (naccepted == 0) { Idx dest_node; ok = re_node_set_insert (eps_via_nodes, node); if (BE (! ok, 0)) return REG_ERROR; dest_node = dfa->edests[node].elems[0]; if (re_node_set_contains (&mctx->state_log[*pidx]->nodes, dest_node)) return dest_node; } } if (naccepted != 0 || check_node_accept (mctx, dfa->nodes + node, *pidx)) { Idx dest_node = dfa->nexts[node]; *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted; if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL || !re_node_set_contains (&mctx->state_log[*pidx]->nodes, dest_node))) return REG_MISSING; re_node_set_empty (eps_via_nodes); return dest_node; } } return REG_MISSING; } static reg_errcode_t internal_function __attribute_warn_unused_result__ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node, Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes) { reg_errcode_t err; Idx num = fs->num++; if (fs->num == fs->alloc) { struct re_fail_stack_ent_t *new_array; new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t) * fs->alloc * 2)); if (new_array == NULL) return REG_ESPACE; fs->alloc *= 2; fs->stack = new_array; } fs->stack[num].idx = str_idx; fs->stack[num].node = dest_node; fs->stack[num].regs = re_malloc (regmatch_t, nregs); if (fs->stack[num].regs == NULL) return REG_ESPACE; memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs); err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes); return err; } static Idx internal_function pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes) { Idx num = --fs->num; assert (REG_VALID_INDEX (num)); *pidx = fs->stack[num].idx; memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs); re_node_set_free (eps_via_nodes); re_free (fs->stack[num].regs); *eps_via_nodes = fs->stack[num].eps_via_nodes; return fs->stack[num].node; } /* Set the positions where the subexpressions are starts/ends to registers PMATCH. Note: We assume that pmatch[0] is already set, and pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, regmatch_t *pmatch, bool fl_backtrack) { const re_dfa_t *dfa = preg->buffer; Idx idx, cur_node; re_node_set eps_via_nodes; struct re_fail_stack_t *fs; struct re_fail_stack_t fs_body = { 0, 2, NULL }; regmatch_t *prev_idx_match; bool prev_idx_match_malloced = false; #ifdef DEBUG assert (nmatch > 1); assert (mctx->state_log != NULL); #endif if (fl_backtrack) { fs = &fs_body; fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc); if (fs->stack == NULL) return REG_ESPACE; } else fs = NULL; cur_node = dfa->init_node; re_node_set_init_empty (&eps_via_nodes); if (__libc_use_alloca (nmatch * sizeof (regmatch_t))) prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t)); else { prev_idx_match = re_malloc (regmatch_t, nmatch); if (prev_idx_match == NULL) { free_fail_stack_return (fs); return REG_ESPACE; } prev_idx_match_malloced = true; } memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) { update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch); if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node) { Idx reg_idx; if (fs) { for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1) break; if (reg_idx == nmatch) { re_node_set_free (&eps_via_nodes); if (prev_idx_match_malloced) re_free (prev_idx_match); return free_fail_stack_return (fs); } cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, &eps_via_nodes); } else { re_node_set_free (&eps_via_nodes); if (prev_idx_match_malloced) re_free (prev_idx_match); return REG_NOERROR; } } /* Proceed to next node. */ cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node, &eps_via_nodes, fs); if (BE (! REG_VALID_INDEX (cur_node), 0)) { if (BE (cur_node == REG_ERROR, 0)) { re_node_set_free (&eps_via_nodes); if (prev_idx_match_malloced) re_free (prev_idx_match); free_fail_stack_return (fs); return REG_ESPACE; } if (fs) cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, &eps_via_nodes); else { re_node_set_free (&eps_via_nodes); if (prev_idx_match_malloced) re_free (prev_idx_match); return REG_NOMATCH; } } } re_node_set_free (&eps_via_nodes); if (prev_idx_match_malloced) re_free (prev_idx_match); return free_fail_stack_return (fs); } static reg_errcode_t internal_function free_fail_stack_return (struct re_fail_stack_t *fs) { if (fs) { Idx fs_idx; for (fs_idx = 0; fs_idx < fs->num; ++fs_idx) { re_node_set_free (&fs->stack[fs_idx].eps_via_nodes); re_free (fs->stack[fs_idx].regs); } re_free (fs->stack); } return REG_NOERROR; } static void internal_function update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch) { int type = dfa->nodes[cur_node].type; if (type == OP_OPEN_SUBEXP) { Idx reg_num = dfa->nodes[cur_node].opr.idx + 1; /* We are at the first node of this sub expression. */ if (reg_num < nmatch) { pmatch[reg_num].rm_so = cur_idx; pmatch[reg_num].rm_eo = -1; } } else if (type == OP_CLOSE_SUBEXP) { Idx reg_num = dfa->nodes[cur_node].opr.idx + 1; if (reg_num < nmatch) { /* We are at the last node of this sub expression. */ if (pmatch[reg_num].rm_so < cur_idx) { pmatch[reg_num].rm_eo = cur_idx; /* This is a non-empty match or we are not inside an optional subexpression. Accept this right away. */ memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); } else { if (dfa->nodes[cur_node].opt_subexp && prev_idx_match[reg_num].rm_so != -1) /* We transited through an empty match for an optional subexpression, like (a?)*, and this is not the subexp's first match. Copy back the old content of the registers so that matches of an inner subexpression are undone as well, like in ((a?))*. */ memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch); else /* We completed a subexpression, but it may be part of an optional one, so do not update PREV_IDX_MATCH. */ pmatch[reg_num].rm_eo = cur_idx; } } } } /* This function checks the STATE_LOG from the SCTX->last_str_idx to 0 and sift the nodes in each states according to the following rules. Updated state_log will be wrote to STATE_LOG. Rules: We throw away the Node 'a' in the STATE_LOG[STR_IDX] if... 1. When STR_IDX == MATCH_LAST(the last index in the state_log): If 'a' isn't the LAST_NODE and 'a' can't epsilon transit to the LAST_NODE, we throw away the node 'a'. 2. When 0 <= STR_IDX < MATCH_LAST and 'a' accepts string 's' and transit to 'b': i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw away the node 'a'. ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is thrown away, we throw away the node 'a'. 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b': i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the node 'a'. ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away, we throw away the node 'a'. */ #define STATE_NODE_CONTAINS(state,node) \ ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) static reg_errcode_t internal_function sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx) { reg_errcode_t err; int null_cnt = 0; Idx str_idx = sctx->last_str_idx; re_node_set cur_dest; #ifdef DEBUG assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL); #endif /* Build sifted state_log[str_idx]. It has the nodes which can epsilon transit to the last_node and the last_node itself. */ err = re_node_set_init_1 (&cur_dest, sctx->last_node); if (BE (err != REG_NOERROR, 0)) return err; err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); if (BE (err != REG_NOERROR, 0)) goto free_return; /* Then check each states in the state_log. */ while (str_idx > 0) { /* Update counters. */ null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0; if (null_cnt > mctx->max_mb_elem_len) { memset (sctx->sifted_states, '\0', sizeof (re_dfastate_t *) * str_idx); re_node_set_free (&cur_dest); return REG_NOERROR; } re_node_set_empty (&cur_dest); --str_idx; if (mctx->state_log[str_idx]) { err = build_sifted_states (mctx, sctx, str_idx, &cur_dest); if (BE (err != REG_NOERROR, 0)) goto free_return; } /* Add all the nodes which satisfy the following conditions: - It can epsilon transit to a node in CUR_DEST. - It is in CUR_SRC. And update state_log. */ err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); if (BE (err != REG_NOERROR, 0)) goto free_return; } err = REG_NOERROR; free_return: re_node_set_free (&cur_dest); return err; } static reg_errcode_t internal_function __attribute_warn_unused_result__ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, Idx str_idx, re_node_set *cur_dest) { const re_dfa_t *const dfa = mctx->dfa; const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes; Idx i; /* Then build the next sifted state. We build the next sifted state on 'cur_dest', and update 'sifted_states[str_idx]' with 'cur_dest'. Note: 'cur_dest' is the sifted state from 'state_log[str_idx + 1]'. 'cur_src' points the node_set of the old 'state_log[str_idx]' (with the epsilon nodes pre-filtered out). */ for (i = 0; i < cur_src->nelem; i++) { Idx prev_node = cur_src->elems[i]; int naccepted = 0; bool ok; #ifdef DEBUG re_token_type_t type = dfa->nodes[prev_node].type; assert (!IS_EPSILON_NODE (type)); #endif #ifdef RE_ENABLE_I18N /* If the node may accept "multi byte". */ if (dfa->nodes[prev_node].accept_mb) naccepted = sift_states_iter_mb (mctx, sctx, prev_node, str_idx, sctx->last_str_idx); #endif /* RE_ENABLE_I18N */ /* We don't check backreferences here. See update_cur_sifted_state(). */ if (!naccepted && check_node_accept (mctx, dfa->nodes + prev_node, str_idx) && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1], dfa->nexts[prev_node])) naccepted = 1; if (naccepted == 0) continue; if (sctx->limits.nelem) { Idx to_idx = str_idx + naccepted; if (check_dst_limits (mctx, &sctx->limits, dfa->nexts[prev_node], to_idx, prev_node, str_idx)) continue; } ok = re_node_set_insert (cur_dest, prev_node); if (BE (! ok, 0)) return REG_ESPACE; } return REG_NOERROR; } /* Helper functions. */ static reg_errcode_t internal_function clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx) { Idx top = mctx->state_log_top; if ((next_state_log_idx >= mctx->input.bufs_len && mctx->input.bufs_len < mctx->input.len) || (next_state_log_idx >= mctx->input.valid_len && mctx->input.valid_len < mctx->input.len)) { reg_errcode_t err; err = extend_buffers (mctx, next_state_log_idx + 1); if (BE (err != REG_NOERROR, 0)) return err; } if (top < next_state_log_idx) { memset (mctx->state_log + top + 1, '\0', sizeof (re_dfastate_t *) * (next_state_log_idx - top)); mctx->state_log_top = next_state_log_idx; } return REG_NOERROR; } static reg_errcode_t internal_function merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst, re_dfastate_t **src, Idx num) { Idx st_idx; reg_errcode_t err; for (st_idx = 0; st_idx < num; ++st_idx) { if (dst[st_idx] == NULL) dst[st_idx] = src[st_idx]; else if (src[st_idx] != NULL) { re_node_set merged_set; err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes, &src[st_idx]->nodes); if (BE (err != REG_NOERROR, 0)) return err; dst[st_idx] = re_acquire_state (&err, dfa, &merged_set); re_node_set_free (&merged_set); if (BE (err != REG_NOERROR, 0)) return err; } } return REG_NOERROR; } static reg_errcode_t internal_function update_cur_sifted_state (const re_match_context_t *mctx, re_sift_context_t *sctx, Idx str_idx, re_node_set *dest_nodes) { const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err = REG_NOERROR; const re_node_set *candidates; candidates = ((mctx->state_log[str_idx] == NULL) ? NULL : &mctx->state_log[str_idx]->nodes); if (dest_nodes->nelem == 0) sctx->sifted_states[str_idx] = NULL; else { if (candidates) { /* At first, add the nodes which can epsilon transit to a node in DEST_NODE. */ err = add_epsilon_src_nodes (dfa, dest_nodes, candidates); if (BE (err != REG_NOERROR, 0)) return err; /* Then, check the limitations in the current sift_context. */ if (sctx->limits.nelem) { err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits, mctx->bkref_ents, str_idx); if (BE (err != REG_NOERROR, 0)) return err; } } sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes); if (BE (err != REG_NOERROR, 0)) return err; } if (candidates && mctx->state_log[str_idx]->has_backref) { err = sift_states_bkref (mctx, sctx, str_idx, candidates); if (BE (err != REG_NOERROR, 0)) return err; } return REG_NOERROR; } static reg_errcode_t internal_function __attribute_warn_unused_result__ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, const re_node_set *candidates) { reg_errcode_t err = REG_NOERROR; Idx i; re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes); if (BE (err != REG_NOERROR, 0)) return err; if (!state->inveclosure.alloc) { err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem); if (BE (err != REG_NOERROR, 0)) return REG_ESPACE; for (i = 0; i < dest_nodes->nelem; i++) { err = re_node_set_merge (&state->inveclosure, dfa->inveclosures + dest_nodes->elems[i]); if (BE (err != REG_NOERROR, 0)) return REG_ESPACE; } } return re_node_set_add_intersect (dest_nodes, candidates, &state->inveclosure); } static reg_errcode_t internal_function sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes, const re_node_set *candidates) { Idx ecl_idx; reg_errcode_t err; re_node_set *inv_eclosure = dfa->inveclosures + node; re_node_set except_nodes; re_node_set_init_empty (&except_nodes); for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) { Idx cur_node = inv_eclosure->elems[ecl_idx]; if (cur_node == node) continue; if (IS_EPSILON_NODE (dfa->nodes[cur_node].type)) { Idx edst1 = dfa->edests[cur_node].elems[0]; Idx edst2 = ((dfa->edests[cur_node].nelem > 1) ? dfa->edests[cur_node].elems[1] : REG_MISSING); if ((!re_node_set_contains (inv_eclosure, edst1) && re_node_set_contains (dest_nodes, edst1)) || (REG_VALID_NONZERO_INDEX (edst2) && !re_node_set_contains (inv_eclosure, edst2) && re_node_set_contains (dest_nodes, edst2))) { err = re_node_set_add_intersect (&except_nodes, candidates, dfa->inveclosures + cur_node); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&except_nodes); return err; } } } } for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) { Idx cur_node = inv_eclosure->elems[ecl_idx]; if (!re_node_set_contains (&except_nodes, cur_node)) { Idx idx = re_node_set_contains (dest_nodes, cur_node) - 1; re_node_set_remove_at (dest_nodes, idx); } } re_node_set_free (&except_nodes); return REG_NOERROR; } static bool internal_function check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits, Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx) { const re_dfa_t *const dfa = mctx->dfa; Idx lim_idx, src_pos, dst_pos; Idx dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx); Idx src_bkref_idx = search_cur_bkref_entry (mctx, src_idx); for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) { Idx subexp_idx; struct re_backref_cache_entry *ent; ent = mctx->bkref_ents + limits->elems[lim_idx]; subexp_idx = dfa->nodes[ent->node].opr.idx; dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], subexp_idx, dst_node, dst_idx, dst_bkref_idx); src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], subexp_idx, src_node, src_idx, src_bkref_idx); /* In case of: ( ) ( ) ( ) */ if (src_pos == dst_pos) continue; /* This is unrelated limitation. */ else return true; } return false; } static int internal_function check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, Idx subexp_idx, Idx from_node, Idx bkref_idx) { const re_dfa_t *const dfa = mctx->dfa; const re_node_set *eclosures = dfa->eclosures + from_node; Idx node_idx; /* Else, we are on the boundary: examine the nodes on the epsilon closure. */ for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx) { Idx node = eclosures->elems[node_idx]; switch (dfa->nodes[node].type) { case OP_BACK_REF: if (bkref_idx != REG_MISSING) { struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx; do { Idx dst; int cpos; if (ent->node != node) continue; if (subexp_idx < BITSET_WORD_BITS && !(ent->eps_reachable_subexps_map & ((bitset_word_t) 1 << subexp_idx))) continue; /* Recurse trying to reach the OP_OPEN_SUBEXP and OP_CLOSE_SUBEXP cases below. But, if the destination node is the same node as the source node, don't recurse because it would cause an infinite loop: a regex that exhibits this behavior is ()\1*\1* */ dst = dfa->edests[node].elems[0]; if (dst == from_node) { if (boundaries & 1) return -1; else /* if (boundaries & 2) */ return 0; } cpos = check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, dst, bkref_idx); if (cpos == -1 /* && (boundaries & 1) */) return -1; if (cpos == 0 && (boundaries & 2)) return 0; if (subexp_idx < BITSET_WORD_BITS) ent->eps_reachable_subexps_map &= ~((bitset_word_t) 1 << subexp_idx); } while (ent++->more); } break; case OP_OPEN_SUBEXP: if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx) return -1; break; case OP_CLOSE_SUBEXP: if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx) return 0; break; default: break; } } return (boundaries & 2) ? 1 : 0; } static int internal_function check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit, Idx subexp_idx, Idx from_node, Idx str_idx, Idx bkref_idx) { struct re_backref_cache_entry *lim = mctx->bkref_ents + limit; int boundaries; /* If we are outside the range of the subexpression, return -1 or 1. */ if (str_idx < lim->subexp_from) return -1; if (lim->subexp_to < str_idx) return 1; /* If we are within the subexpression, return 0. */ boundaries = (str_idx == lim->subexp_from); boundaries |= (str_idx == lim->subexp_to) << 1; if (boundaries == 0) return 0; /* Else, examine epsilon closure. */ return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, from_node, bkref_idx); } /* Check the limitations of sub expressions LIMITS, and remove the nodes which are against limitations from DEST_NODES. */ static reg_errcode_t internal_function check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, const re_node_set *candidates, re_node_set *limits, struct re_backref_cache_entry *bkref_ents, Idx str_idx) { reg_errcode_t err; Idx node_idx, lim_idx; for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) { Idx subexp_idx; struct re_backref_cache_entry *ent; ent = bkref_ents + limits->elems[lim_idx]; if (str_idx <= ent->subexp_from || ent->str_idx < str_idx) continue; /* This is unrelated limitation. */ subexp_idx = dfa->nodes[ent->node].opr.idx; if (ent->subexp_to == str_idx) { Idx ops_node = REG_MISSING; Idx cls_node = REG_MISSING; for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) { Idx node = dest_nodes->elems[node_idx]; re_token_type_t type = dfa->nodes[node].type; if (type == OP_OPEN_SUBEXP && subexp_idx == dfa->nodes[node].opr.idx) ops_node = node; else if (type == OP_CLOSE_SUBEXP && subexp_idx == dfa->nodes[node].opr.idx) cls_node = node; } /* Check the limitation of the open subexpression. */ /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */ if (REG_VALID_INDEX (ops_node)) { err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes, candidates); if (BE (err != REG_NOERROR, 0)) return err; } /* Check the limitation of the close subexpression. */ if (REG_VALID_INDEX (cls_node)) for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) { Idx node = dest_nodes->elems[node_idx]; if (!re_node_set_contains (dfa->inveclosures + node, cls_node) && !re_node_set_contains (dfa->eclosures + node, cls_node)) { /* It is against this limitation. Remove it form the current sifted state. */ err = sub_epsilon_src_nodes (dfa, node, dest_nodes, candidates); if (BE (err != REG_NOERROR, 0)) return err; --node_idx; } } } else /* (ent->subexp_to != str_idx) */ { for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) { Idx node = dest_nodes->elems[node_idx]; re_token_type_t type = dfa->nodes[node].type; if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP) { if (subexp_idx != dfa->nodes[node].opr.idx) continue; /* It is against this limitation. Remove it form the current sifted state. */ err = sub_epsilon_src_nodes (dfa, node, dest_nodes, candidates); if (BE (err != REG_NOERROR, 0)) return err; } } } } return REG_NOERROR; } static reg_errcode_t internal_function __attribute_warn_unused_result__ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, Idx str_idx, const re_node_set *candidates) { const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; Idx node_idx, node; re_sift_context_t local_sctx; Idx first_idx = search_cur_bkref_entry (mctx, str_idx); if (first_idx == REG_MISSING) return REG_NOERROR; local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */ for (node_idx = 0; node_idx < candidates->nelem; ++node_idx) { Idx enabled_idx; re_token_type_t type; struct re_backref_cache_entry *entry; node = candidates->elems[node_idx]; type = dfa->nodes[node].type; /* Avoid infinite loop for the REs like "()\1+". */ if (node == sctx->last_node && str_idx == sctx->last_str_idx) continue; if (type != OP_BACK_REF) continue; entry = mctx->bkref_ents + first_idx; enabled_idx = first_idx; do { Idx subexp_len; Idx to_idx; Idx dst_node; bool ok; re_dfastate_t *cur_state; if (entry->node != node) continue; subexp_len = entry->subexp_to - entry->subexp_from; to_idx = str_idx + subexp_len; dst_node = (subexp_len ? dfa->nexts[node] : dfa->edests[node].elems[0]); if (to_idx > sctx->last_str_idx || sctx->sifted_states[to_idx] == NULL || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node) || check_dst_limits (mctx, &sctx->limits, node, str_idx, dst_node, to_idx)) continue; if (local_sctx.sifted_states == NULL) { local_sctx = *sctx; err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits); if (BE (err != REG_NOERROR, 0)) goto free_return; } local_sctx.last_node = node; local_sctx.last_str_idx = str_idx; ok = re_node_set_insert (&local_sctx.limits, enabled_idx); if (BE (! ok, 0)) { err = REG_ESPACE; goto free_return; } cur_state = local_sctx.sifted_states[str_idx]; err = sift_states_backward (mctx, &local_sctx); if (BE (err != REG_NOERROR, 0)) goto free_return; if (sctx->limited_states != NULL) { err = merge_state_array (dfa, sctx->limited_states, local_sctx.sifted_states, str_idx + 1); if (BE (err != REG_NOERROR, 0)) goto free_return; } local_sctx.sifted_states[str_idx] = cur_state; re_node_set_remove (&local_sctx.limits, enabled_idx); /* mctx->bkref_ents may have changed, reload the pointer. */ entry = mctx->bkref_ents + enabled_idx; } while (enabled_idx++, entry++->more); } err = REG_NOERROR; free_return: if (local_sctx.sifted_states != NULL) { re_node_set_free (&local_sctx.limits); } return err; } #ifdef RE_ENABLE_I18N static int internal_function sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, Idx node_idx, Idx str_idx, Idx max_str_idx) { const re_dfa_t *const dfa = mctx->dfa; int naccepted; /* Check the node can accept "multi byte". */ naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); if (naccepted > 0 && str_idx + naccepted <= max_str_idx && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], dfa->nexts[node_idx])) /* The node can't accept the "multi byte", or the destination was already thrown away, then the node could't accept the current input "multi byte". */ naccepted = 0; /* Otherwise, it is sure that the node could accept 'naccepted' bytes input. */ return naccepted; } #endif /* RE_ENABLE_I18N */ /* Functions for state transition. */ /* Return the next state to which the current state STATE will transit by accepting the current input byte, and update STATE_LOG if necessary. If STATE can accept a multibyte char/collating element/back reference update the destination of STATE_LOG. */ static re_dfastate_t * internal_function __attribute_warn_unused_result__ transit_state (reg_errcode_t *err, re_match_context_t *mctx, re_dfastate_t *state) { re_dfastate_t **trtable; unsigned char ch; #ifdef RE_ENABLE_I18N /* If the current state can accept multibyte. */ if (BE (state->accept_mb, 0)) { *err = transit_state_mb (mctx, state); if (BE (*err != REG_NOERROR, 0)) return NULL; } #endif /* RE_ENABLE_I18N */ /* Then decide the next state with the single byte. */ #if 0 if (0) /* don't use transition table */ return transit_state_sb (err, mctx, state); #endif /* Use transition table */ ch = re_string_fetch_byte (&mctx->input); for (;;) { trtable = state->trtable; if (BE (trtable != NULL, 1)) return trtable[ch]; trtable = state->word_trtable; if (BE (trtable != NULL, 1)) { unsigned int context; context = re_string_context_at (&mctx->input, re_string_cur_idx (&mctx->input) - 1, mctx->eflags); if (IS_WORD_CONTEXT (context)) return trtable[ch + SBC_MAX]; else return trtable[ch]; } if (!build_trtable (mctx->dfa, state)) { *err = REG_ESPACE; return NULL; } /* Retry, we now have a transition table. */ } } /* Update the state_log if we need */ static re_dfastate_t * internal_function merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, re_dfastate_t *next_state) { const re_dfa_t *const dfa = mctx->dfa; Idx cur_idx = re_string_cur_idx (&mctx->input); if (cur_idx > mctx->state_log_top) { mctx->state_log[cur_idx] = next_state; mctx->state_log_top = cur_idx; } else if (mctx->state_log[cur_idx] == 0) { mctx->state_log[cur_idx] = next_state; } else { re_dfastate_t *pstate; unsigned int context; re_node_set next_nodes, *log_nodes, *table_nodes = NULL; /* If (state_log[cur_idx] != 0), it implies that cur_idx is the destination of a multibyte char/collating element/ back reference. Then the next state is the union set of these destinations and the results of the transition table. */ pstate = mctx->state_log[cur_idx]; log_nodes = pstate->entrance_nodes; if (next_state != NULL) { table_nodes = next_state->entrance_nodes; *err = re_node_set_init_union (&next_nodes, table_nodes, log_nodes); if (BE (*err != REG_NOERROR, 0)) return NULL; } else next_nodes = *log_nodes; /* Note: We already add the nodes of the initial state, then we don't need to add them here. */ context = re_string_context_at (&mctx->input, re_string_cur_idx (&mctx->input) - 1, mctx->eflags); next_state = mctx->state_log[cur_idx] = re_acquire_state_context (err, dfa, &next_nodes, context); /* We don't need to check errors here, since the return value of this function is next_state and ERR is already set. */ if (table_nodes != NULL) re_node_set_free (&next_nodes); } if (BE (dfa->nbackref, 0) && next_state != NULL) { /* Check OP_OPEN_SUBEXP in the current state in case that we use them later. We must check them here, since the back references in the next state might use them. */ *err = check_subexp_matching_top (mctx, &next_state->nodes, cur_idx); if (BE (*err != REG_NOERROR, 0)) return NULL; /* If the next state has back references. */ if (next_state->has_backref) { *err = transit_state_bkref (mctx, &next_state->nodes); if (BE (*err != REG_NOERROR, 0)) return NULL; next_state = mctx->state_log[cur_idx]; } } return next_state; } /* Skip bytes in the input that correspond to part of a multi-byte match, then look in the log for a state from which to restart matching. */ static re_dfastate_t * internal_function find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) { re_dfastate_t *cur_state; do { Idx max = mctx->state_log_top; Idx cur_str_idx = re_string_cur_idx (&mctx->input); do { if (++cur_str_idx > max) return NULL; re_string_skip_bytes (&mctx->input, 1); } while (mctx->state_log[cur_str_idx] == NULL); cur_state = merge_state_with_log (err, mctx, NULL); } while (*err == REG_NOERROR && cur_state == NULL); return cur_state; } /* Helper functions for transit_state. */ /* From the node set CUR_NODES, pick up the nodes whose types are OP_OPEN_SUBEXP and which have corresponding back references in the regular expression. And register them to use them later for evaluating the corresponding back references. */ static reg_errcode_t internal_function check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, Idx str_idx) { const re_dfa_t *const dfa = mctx->dfa; Idx node_idx; reg_errcode_t err; /* TODO: This isn't efficient. Because there might be more than one nodes whose types are OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all nodes. E.g. RE: (a){2} */ for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx) { Idx node = cur_nodes->elems[node_idx]; if (dfa->nodes[node].type == OP_OPEN_SUBEXP && dfa->nodes[node].opr.idx < BITSET_WORD_BITS && (dfa->used_bkref_map & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx))) { err = match_ctx_add_subtop (mctx, node, str_idx); if (BE (err != REG_NOERROR, 0)) return err; } } return REG_NOERROR; } #if 0 /* Return the next state to which the current state STATE will transit by accepting the current input byte. */ static re_dfastate_t * transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, re_dfastate_t *state) { const re_dfa_t *const dfa = mctx->dfa; re_node_set next_nodes; re_dfastate_t *next_state; Idx node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input); unsigned int context; *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); if (BE (*err != REG_NOERROR, 0)) return NULL; for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) { Idx cur_node = state->nodes.elems[node_cnt]; if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx)) { *err = re_node_set_merge (&next_nodes, dfa->eclosures + dfa->nexts[cur_node]); if (BE (*err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return NULL; } } } context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags); next_state = re_acquire_state_context (err, dfa, &next_nodes, context); /* We don't need to check errors here, since the return value of this function is next_state and ERR is already set. */ re_node_set_free (&next_nodes); re_string_skip_bytes (&mctx->input, 1); return next_state; } #endif #ifdef RE_ENABLE_I18N static reg_errcode_t internal_function transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) { const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; Idx i; for (i = 0; i < pstate->nodes.nelem; ++i) { re_node_set dest_nodes, *new_nodes; Idx cur_node_idx = pstate->nodes.elems[i]; int naccepted; Idx dest_idx; unsigned int context; re_dfastate_t *dest_state; if (!dfa->nodes[cur_node_idx].accept_mb) continue; if (dfa->nodes[cur_node_idx].constraint) { context = re_string_context_at (&mctx->input, re_string_cur_idx (&mctx->input), mctx->eflags); if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint, context)) continue; } /* How many bytes the node can accept? */ naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input, re_string_cur_idx (&mctx->input)); if (naccepted == 0) continue; /* The node can accepts 'naccepted' bytes. */ dest_idx = re_string_cur_idx (&mctx->input) + naccepted; mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted : mctx->max_mb_elem_len); err = clean_state_log_if_needed (mctx, dest_idx); if (BE (err != REG_NOERROR, 0)) return err; #ifdef DEBUG assert (dfa->nexts[cur_node_idx] != REG_MISSING); #endif new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx]; dest_state = mctx->state_log[dest_idx]; if (dest_state == NULL) dest_nodes = *new_nodes; else { err = re_node_set_init_union (&dest_nodes, dest_state->entrance_nodes, new_nodes); if (BE (err != REG_NOERROR, 0)) return err; } context = re_string_context_at (&mctx->input, dest_idx - 1, mctx->eflags); mctx->state_log[dest_idx] = re_acquire_state_context (&err, dfa, &dest_nodes, context); if (dest_state != NULL) re_node_set_free (&dest_nodes); if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0)) return err; } return REG_NOERROR; } #endif /* RE_ENABLE_I18N */ static reg_errcode_t internal_function transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) { const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; Idx i; Idx cur_str_idx = re_string_cur_idx (&mctx->input); for (i = 0; i < nodes->nelem; ++i) { Idx dest_str_idx, prev_nelem, bkc_idx; Idx node_idx = nodes->elems[i]; unsigned int context; const re_token_t *node = dfa->nodes + node_idx; re_node_set *new_dest_nodes; /* Check whether 'node' is a backreference or not. */ if (node->type != OP_BACK_REF) continue; if (node->constraint) { context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags); if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) continue; } /* 'node' is a backreference. Check the substring which the substring matched. */ bkc_idx = mctx->nbkref_ents; err = get_subexp (mctx, node_idx, cur_str_idx); if (BE (err != REG_NOERROR, 0)) goto free_return; /* And add the epsilon closures (which is 'new_dest_nodes') of the backreference to appropriate state_log. */ #ifdef DEBUG assert (dfa->nexts[node_idx] != REG_MISSING); #endif for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx) { Idx subexp_len; re_dfastate_t *dest_state; struct re_backref_cache_entry *bkref_ent; bkref_ent = mctx->bkref_ents + bkc_idx; if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx) continue; subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from; new_dest_nodes = (subexp_len == 0 ? dfa->eclosures + dfa->edests[node_idx].elems[0] : dfa->eclosures + dfa->nexts[node_idx]); dest_str_idx = (cur_str_idx + bkref_ent->subexp_to - bkref_ent->subexp_from); context = re_string_context_at (&mctx->input, dest_str_idx - 1, mctx->eflags); dest_state = mctx->state_log[dest_str_idx]; prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0 : mctx->state_log[cur_str_idx]->nodes.nelem); /* Add 'new_dest_node' to state_log. */ if (dest_state == NULL) { mctx->state_log[dest_str_idx] = re_acquire_state_context (&err, dfa, new_dest_nodes, context); if (BE (mctx->state_log[dest_str_idx] == NULL && err != REG_NOERROR, 0)) goto free_return; } else { re_node_set dest_nodes; err = re_node_set_init_union (&dest_nodes, dest_state->entrance_nodes, new_dest_nodes); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&dest_nodes); goto free_return; } mctx->state_log[dest_str_idx] = re_acquire_state_context (&err, dfa, &dest_nodes, context); re_node_set_free (&dest_nodes); if (BE (mctx->state_log[dest_str_idx] == NULL && err != REG_NOERROR, 0)) goto free_return; } /* We need to check recursively if the backreference can epsilon transit. */ if (subexp_len == 0 && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem) { err = check_subexp_matching_top (mctx, new_dest_nodes, cur_str_idx); if (BE (err != REG_NOERROR, 0)) goto free_return; err = transit_state_bkref (mctx, new_dest_nodes); if (BE (err != REG_NOERROR, 0)) goto free_return; } } } err = REG_NOERROR; free_return: return err; } /* Enumerate all the candidates which the backreference BKREF_NODE can match at BKREF_STR_IDX, and register them by match_ctx_add_entry(). Note that we might collect inappropriate candidates here. However, the cost of checking them strictly here is too high, then we delay these checking for prune_impossible_nodes(). */ static reg_errcode_t internal_function __attribute_warn_unused_result__ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx) { const re_dfa_t *const dfa = mctx->dfa; Idx subexp_num, sub_top_idx; const char *buf = (const char *) re_string_get_buffer (&mctx->input); /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); if (cache_idx != REG_MISSING) { const struct re_backref_cache_entry *entry = mctx->bkref_ents + cache_idx; do if (entry->node == bkref_node) return REG_NOERROR; /* We already checked it. */ while (entry++->more); } subexp_num = dfa->nodes[bkref_node].opr.idx; /* For each sub expression */ for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx) { reg_errcode_t err; re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx]; re_sub_match_last_t *sub_last; Idx sub_last_idx, sl_str, bkref_str_off; if (dfa->nodes[sub_top->node].opr.idx != subexp_num) continue; /* It isn't related. */ sl_str = sub_top->str_idx; bkref_str_off = bkref_str_idx; /* At first, check the last node of sub expressions we already evaluated. */ for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx) { regoff_t sl_str_diff; sub_last = sub_top->lasts[sub_last_idx]; sl_str_diff = sub_last->str_idx - sl_str; /* The matched string by the sub expression match with the substring at the back reference? */ if (sl_str_diff > 0) { if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0)) { /* Not enough chars for a successful match. */ if (bkref_str_off + sl_str_diff > mctx->input.len) break; err = clean_state_log_if_needed (mctx, bkref_str_off + sl_str_diff); if (BE (err != REG_NOERROR, 0)) return err; buf = (const char *) re_string_get_buffer (&mctx->input); } if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0) /* We don't need to search this sub expression any more. */ break; } bkref_str_off += sl_str_diff; sl_str += sl_str_diff; err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, bkref_str_idx); /* Reload buf, since the preceding call might have reallocated the buffer. */ buf = (const char *) re_string_get_buffer (&mctx->input); if (err == REG_NOMATCH) continue; if (BE (err != REG_NOERROR, 0)) return err; } if (sub_last_idx < sub_top->nlasts) continue; if (sub_last_idx > 0) ++sl_str; /* Then, search for the other last nodes of the sub expression. */ for (; sl_str <= bkref_str_idx; ++sl_str) { Idx cls_node; regoff_t sl_str_off; const re_node_set *nodes; sl_str_off = sl_str - sub_top->str_idx; /* The matched string by the sub expression match with the substring at the back reference? */ if (sl_str_off > 0) { if (BE (bkref_str_off >= mctx->input.valid_len, 0)) { /* If we are at the end of the input, we cannot match. */ if (bkref_str_off >= mctx->input.len) break; err = extend_buffers (mctx, bkref_str_off + 1); if (BE (err != REG_NOERROR, 0)) return err; buf = (const char *) re_string_get_buffer (&mctx->input); } if (buf [bkref_str_off++] != buf[sl_str - 1]) break; /* We don't need to search this sub expression any more. */ } if (mctx->state_log[sl_str] == NULL) continue; /* Does this state have a ')' of the sub expression? */ nodes = &mctx->state_log[sl_str]->nodes; cls_node = find_subexp_node (dfa, nodes, subexp_num, OP_CLOSE_SUBEXP); if (cls_node == REG_MISSING) continue; /* No. */ if (sub_top->path == NULL) { sub_top->path = calloc (sizeof (state_array_t), sl_str - sub_top->str_idx + 1); if (sub_top->path == NULL) return REG_ESPACE; } /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node in the current context? */ err = check_arrival (mctx, sub_top->path, sub_top->node, sub_top->str_idx, cls_node, sl_str, OP_CLOSE_SUBEXP); if (err == REG_NOMATCH) continue; if (BE (err != REG_NOERROR, 0)) return err; sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); if (BE (sub_last == NULL, 0)) return REG_ESPACE; err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, bkref_str_idx); if (err == REG_NOMATCH) continue; } } return REG_NOERROR; } /* Helper functions for get_subexp(). */ /* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR. If it can arrive, register the sub expression expressed with SUB_TOP and SUB_LAST. */ static reg_errcode_t internal_function get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str) { reg_errcode_t err; Idx to_idx; /* Can the subexpression arrive the back reference? */ err = check_arrival (mctx, &sub_last->path, sub_last->node, sub_last->str_idx, bkref_node, bkref_str, OP_OPEN_SUBEXP); if (err != REG_NOERROR) return err; err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, sub_last->str_idx); if (BE (err != REG_NOERROR, 0)) return err; to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; return clean_state_log_if_needed (mctx, to_idx); } /* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX. Search '(' if FL_OPEN, or search ')' otherwise. TODO: This function isn't efficient... Because there might be more than one nodes whose types are OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all nodes. E.g. RE: (a){2} */ static Idx internal_function find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, Idx subexp_idx, int type) { Idx cls_idx; for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx) { Idx cls_node = nodes->elems[cls_idx]; const re_token_t *node = dfa->nodes + cls_node; if (node->type == type && node->opr.idx == subexp_idx) return cls_node; } return REG_MISSING; } /* Check whether the node TOP_NODE at TOP_STR can arrive to the node LAST_NODE at LAST_STR. We record the path onto PATH since it will be heavily reused. Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node, Idx top_str, Idx last_node, Idx last_str, int type) { const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err = REG_NOERROR; Idx subexp_num, backup_cur_idx, str_idx, null_cnt; re_dfastate_t *cur_state = NULL; re_node_set *cur_nodes, next_nodes; re_dfastate_t **backup_state_log; unsigned int context; subexp_num = dfa->nodes[top_node].opr.idx; /* Extend the buffer if we need. */ if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0)) { re_dfastate_t **new_array; Idx old_alloc = path->alloc; Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1; Idx new_alloc; if (BE (IDX_MAX - old_alloc < incr_alloc, 0)) return REG_ESPACE; new_alloc = old_alloc + incr_alloc; if (BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0)) return REG_ESPACE; new_array = re_realloc (path->array, re_dfastate_t *, new_alloc); if (BE (new_array == NULL, 0)) return REG_ESPACE; path->array = new_array; path->alloc = new_alloc; memset (new_array + old_alloc, '\0', sizeof (re_dfastate_t *) * (path->alloc - old_alloc)); } str_idx = path->next_idx ? path->next_idx : top_str; /* Temporary modify MCTX. */ backup_state_log = mctx->state_log; backup_cur_idx = mctx->input.cur_idx; mctx->state_log = path->array; mctx->input.cur_idx = str_idx; /* Setup initial node set. */ context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); if (str_idx == top_str) { err = re_node_set_init_1 (&next_nodes, top_node); if (BE (err != REG_NOERROR, 0)) return err; err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; } } else { cur_state = mctx->state_log[str_idx]; if (cur_state && cur_state->has_backref) { err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); if (BE (err != REG_NOERROR, 0)) return err; } else re_node_set_init_empty (&next_nodes); } if (str_idx == top_str || (cur_state && cur_state->has_backref)) { if (next_nodes.nelem) { err = expand_bkref_cache (mctx, &next_nodes, str_idx, subexp_num, type); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; } } cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); if (BE (cur_state == NULL && err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; } mctx->state_log[str_idx] = cur_state; } for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;) { re_node_set_empty (&next_nodes); if (mctx->state_log[str_idx + 1]) { err = re_node_set_merge (&next_nodes, &mctx->state_log[str_idx + 1]->nodes); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; } } if (cur_state) { err = check_arrival_add_next_nodes (mctx, str_idx, &cur_state->non_eps_nodes, &next_nodes); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; } } ++str_idx; if (next_nodes.nelem) { err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; } err = expand_bkref_cache (mctx, &next_nodes, str_idx, subexp_num, type); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; } } context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); if (BE (cur_state == NULL && err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; } mctx->state_log[str_idx] = cur_state; null_cnt = cur_state == NULL ? null_cnt + 1 : 0; } re_node_set_free (&next_nodes); cur_nodes = (mctx->state_log[last_str] == NULL ? NULL : &mctx->state_log[last_str]->nodes); path->next_idx = str_idx; /* Fix MCTX. */ mctx->state_log = backup_state_log; mctx->input.cur_idx = backup_cur_idx; /* Then check the current node set has the node LAST_NODE. */ if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node)) return REG_NOERROR; return REG_NOMATCH; } /* Helper functions for check_arrival. */ /* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them to NEXT_NODES. TODO: This function is similar to the functions transit_state*(), however this function has many additional works. Can't we unify them? */ static reg_errcode_t internal_function __attribute_warn_unused_result__ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx, re_node_set *cur_nodes, re_node_set *next_nodes) { const re_dfa_t *const dfa = mctx->dfa; bool ok; Idx cur_idx; #ifdef RE_ENABLE_I18N reg_errcode_t err = REG_NOERROR; #endif re_node_set union_set; re_node_set_init_empty (&union_set); for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) { int naccepted = 0; Idx cur_node = cur_nodes->elems[cur_idx]; #ifdef DEBUG re_token_type_t type = dfa->nodes[cur_node].type; assert (!IS_EPSILON_NODE (type)); #endif #ifdef RE_ENABLE_I18N /* If the node may accept "multi byte". */ if (dfa->nodes[cur_node].accept_mb) { naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input, str_idx); if (naccepted > 1) { re_dfastate_t *dest_state; Idx next_node = dfa->nexts[cur_node]; Idx next_idx = str_idx + naccepted; dest_state = mctx->state_log[next_idx]; re_node_set_empty (&union_set); if (dest_state) { err = re_node_set_merge (&union_set, &dest_state->nodes); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&union_set); return err; } } ok = re_node_set_insert (&union_set, next_node); if (BE (! ok, 0)) { re_node_set_free (&union_set); return REG_ESPACE; } mctx->state_log[next_idx] = re_acquire_state (&err, dfa, &union_set); if (BE (mctx->state_log[next_idx] == NULL && err != REG_NOERROR, 0)) { re_node_set_free (&union_set); return err; } } } #endif /* RE_ENABLE_I18N */ if (naccepted || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) { ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); if (BE (! ok, 0)) { re_node_set_free (&union_set); return REG_ESPACE; } } } re_node_set_free (&union_set); return REG_NOERROR; } /* For all the nodes in CUR_NODES, add the epsilon closures of them to CUR_NODES, however exclude the nodes which are: - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN. - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN. */ static reg_errcode_t internal_function check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, Idx ex_subexp, int type) { reg_errcode_t err; Idx idx, outside_node; re_node_set new_nodes; #ifdef DEBUG assert (cur_nodes->nelem); #endif err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); if (BE (err != REG_NOERROR, 0)) return err; /* Create a new node set NEW_NODES with the nodes which are epsilon closures of the node in CUR_NODES. */ for (idx = 0; idx < cur_nodes->nelem; ++idx) { Idx cur_node = cur_nodes->elems[idx]; const re_node_set *eclosure = dfa->eclosures + cur_node; outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type); if (outside_node == REG_MISSING) { /* There are no problematic nodes, just merge them. */ err = re_node_set_merge (&new_nodes, eclosure); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&new_nodes); return err; } } else { /* There are problematic nodes, re-calculate incrementally. */ err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node, ex_subexp, type); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&new_nodes); return err; } } } re_node_set_free (cur_nodes); *cur_nodes = new_nodes; return REG_NOERROR; } /* Helper function for check_arrival_expand_ecl. Check incrementally the epsilon closure of TARGET, and if it isn't problematic append it to DST_NODES. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, Idx target, Idx ex_subexp, int type) { Idx cur_node; for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);) { bool ok; if (dfa->nodes[cur_node].type == type && dfa->nodes[cur_node].opr.idx == ex_subexp) { if (type == OP_CLOSE_SUBEXP) { ok = re_node_set_insert (dst_nodes, cur_node); if (BE (! ok, 0)) return REG_ESPACE; } break; } ok = re_node_set_insert (dst_nodes, cur_node); if (BE (! ok, 0)) return REG_ESPACE; if (dfa->edests[cur_node].nelem == 0) break; if (dfa->edests[cur_node].nelem == 2) { reg_errcode_t err; err = check_arrival_expand_ecl_sub (dfa, dst_nodes, dfa->edests[cur_node].elems[1], ex_subexp, type); if (BE (err != REG_NOERROR, 0)) return err; } cur_node = dfa->edests[cur_node].elems[0]; } return REG_NOERROR; } /* For all the back references in the current state, calculate the destination of the back references by the appropriate entry in MCTX->BKREF_ENTS. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, Idx cur_str, Idx subexp_num, int type) { const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str); struct re_backref_cache_entry *ent; if (cache_idx_start == REG_MISSING) return REG_NOERROR; restart: ent = mctx->bkref_ents + cache_idx_start; do { Idx to_idx, next_node; /* Is this entry ENT is appropriate? */ if (!re_node_set_contains (cur_nodes, ent->node)) continue; /* No. */ to_idx = cur_str + ent->subexp_to - ent->subexp_from; /* Calculate the destination of the back reference, and append it to MCTX->STATE_LOG. */ if (to_idx == cur_str) { /* The backreference did epsilon transit, we must re-check all the node in the current state. */ re_node_set new_dests; reg_errcode_t err2, err3; next_node = dfa->edests[ent->node].elems[0]; if (re_node_set_contains (cur_nodes, next_node)) continue; err = re_node_set_init_1 (&new_dests, next_node); err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type); err3 = re_node_set_merge (cur_nodes, &new_dests); re_node_set_free (&new_dests); if (BE (err != REG_NOERROR || err2 != REG_NOERROR || err3 != REG_NOERROR, 0)) { err = (err != REG_NOERROR ? err : (err2 != REG_NOERROR ? err2 : err3)); return err; } /* TODO: It is still inefficient... */ goto restart; } else { re_node_set union_set; next_node = dfa->nexts[ent->node]; if (mctx->state_log[to_idx]) { bool ok; if (re_node_set_contains (&mctx->state_log[to_idx]->nodes, next_node)) continue; err = re_node_set_init_copy (&union_set, &mctx->state_log[to_idx]->nodes); ok = re_node_set_insert (&union_set, next_node); if (BE (err != REG_NOERROR || ! ok, 0)) { re_node_set_free (&union_set); err = err != REG_NOERROR ? err : REG_ESPACE; return err; } } else { err = re_node_set_init_1 (&union_set, next_node); if (BE (err != REG_NOERROR, 0)) return err; } mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set); re_node_set_free (&union_set); if (BE (mctx->state_log[to_idx] == NULL && err != REG_NOERROR, 0)) return err; } } while (ent++->more); return REG_NOERROR; } /* Build transition table for the state. Return true if successful. */ static bool internal_function build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) { reg_errcode_t err; Idx i, j; int ch; bool need_word_trtable = false; bitset_word_t elem, mask; bool dests_node_malloced = false; bool dest_states_malloced = false; Idx ndests; /* Number of the destination states from 'state'. */ re_dfastate_t **trtable; re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl; re_node_set follows, *dests_node; bitset_t *dests_ch; bitset_t acceptable; struct dests_alloc { re_node_set dests_node[SBC_MAX]; bitset_t dests_ch[SBC_MAX]; } *dests_alloc; /* We build DFA states which corresponds to the destination nodes from 'state'. 'dests_node[i]' represents the nodes which i-th destination state contains, and 'dests_ch[i]' represents the characters which i-th destination state accepts. */ if (__libc_use_alloca (sizeof (struct dests_alloc))) dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc)); else { dests_alloc = re_malloc (struct dests_alloc, 1); if (BE (dests_alloc == NULL, 0)) return false; dests_node_malloced = true; } dests_node = dests_alloc->dests_node; dests_ch = dests_alloc->dests_ch; /* Initialize transition table. */ state->word_trtable = state->trtable = NULL; /* At first, group all nodes belonging to 'state' into several destinations. */ ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); if (BE (! REG_VALID_NONZERO_INDEX (ndests), 0)) { if (dests_node_malloced) free (dests_alloc); /* Return false in case of an error, true otherwise. */ if (ndests == 0) { state->trtable = (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); if (BE (state->trtable == NULL, 0)) return false; return true; } return false; } err = re_node_set_alloc (&follows, ndests + 1); if (BE (err != REG_NOERROR, 0)) goto out_free; /* Avoid arithmetic overflow in size calculation. */ if (BE ((((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX) / (3 * sizeof (re_dfastate_t *))) < ndests), 0)) goto out_free; if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX + ndests * 3 * sizeof (re_dfastate_t *))) dest_states = (re_dfastate_t **) alloca (ndests * 3 * sizeof (re_dfastate_t *)); else { dest_states = (re_dfastate_t **) malloc (ndests * 3 * sizeof (re_dfastate_t *)); if (BE (dest_states == NULL, 0)) { out_free: if (dest_states_malloced) free (dest_states); re_node_set_free (&follows); for (i = 0; i < ndests; ++i) re_node_set_free (dests_node + i); if (dests_node_malloced) free (dests_alloc); return false; } dest_states_malloced = true; } dest_states_word = dest_states + ndests; dest_states_nl = dest_states_word + ndests; bitset_empty (acceptable); /* Then build the states for all destinations. */ for (i = 0; i < ndests; ++i) { Idx next_node; re_node_set_empty (&follows); /* Merge the follows of this destination states. */ for (j = 0; j < dests_node[i].nelem; ++j) { next_node = dfa->nexts[dests_node[i].elems[j]]; if (next_node != REG_MISSING) { err = re_node_set_merge (&follows, dfa->eclosures + next_node); if (BE (err != REG_NOERROR, 0)) goto out_free; } } dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0); if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0)) goto out_free; /* If the new state has context constraint, build appropriate states for these contexts. */ if (dest_states[i]->has_constraint) { dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows, CONTEXT_WORD); if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0)) goto out_free; if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1) need_word_trtable = true; dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows, CONTEXT_NEWLINE); if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0)) goto out_free; } else { dest_states_word[i] = dest_states[i]; dest_states_nl[i] = dest_states[i]; } bitset_merge (acceptable, dests_ch[i]); } if (!BE (need_word_trtable, 0)) { /* We don't care about whether the following character is a word character, or we are in a single-byte character set so we can discern by looking at the character code: allocate a 256-entry transition table. */ trtable = state->trtable = (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); if (BE (trtable == NULL, 0)) goto out_free; /* For all characters ch...: */ for (i = 0; i < BITSET_WORDS; ++i) for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; elem; mask <<= 1, elem >>= 1, ++ch) if (BE (elem & 1, 0)) { /* There must be exactly one destination which accepts character ch. See group_nodes_into_DFAstates. */ for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) ; /* j-th destination accepts the word character ch. */ if (dfa->word_char[i] & mask) trtable[ch] = dest_states_word[j]; else trtable[ch] = dest_states[j]; } } else { /* We care about whether the following character is a word character, and we are in a multi-byte character set: discern by looking at the character code: build two 256-entry transition tables, one starting at trtable[0] and one starting at trtable[SBC_MAX]. */ trtable = state->word_trtable = (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); if (BE (trtable == NULL, 0)) goto out_free; /* For all characters ch...: */ for (i = 0; i < BITSET_WORDS; ++i) for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; elem; mask <<= 1, elem >>= 1, ++ch) if (BE (elem & 1, 0)) { /* There must be exactly one destination which accepts character ch. See group_nodes_into_DFAstates. */ for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) ; /* j-th destination accepts the word character ch. */ trtable[ch] = dest_states[j]; trtable[ch + SBC_MAX] = dest_states_word[j]; } } /* new line */ if (bitset_contain (acceptable, NEWLINE_CHAR)) { /* The current state accepts newline character. */ for (j = 0; j < ndests; ++j) if (bitset_contain (dests_ch[j], NEWLINE_CHAR)) { /* k-th destination accepts newline character. */ trtable[NEWLINE_CHAR] = dest_states_nl[j]; if (need_word_trtable) trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j]; /* There must be only one destination which accepts newline. See group_nodes_into_DFAstates. */ break; } } if (dest_states_malloced) free (dest_states); re_node_set_free (&follows); for (i = 0; i < ndests; ++i) re_node_set_free (dests_node + i); if (dests_node_malloced) free (dests_alloc); return true; } /* Group all nodes belonging to STATE into several destinations. Then for all destinations, set the nodes belonging to the destination to DESTS_NODE[i] and set the characters accepted by the destination to DEST_CH[i]. This function return the number of destinations. */ static Idx internal_function group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, re_node_set *dests_node, bitset_t *dests_ch) { reg_errcode_t err; bool ok; Idx i, j, k; Idx ndests; /* Number of the destinations from 'state'. */ bitset_t accepts; /* Characters a node can accept. */ const re_node_set *cur_nodes = &state->nodes; bitset_empty (accepts); ndests = 0; /* For all the nodes belonging to 'state', */ for (i = 0; i < cur_nodes->nelem; ++i) { re_token_t *node = &dfa->nodes[cur_nodes->elems[i]]; re_token_type_t type = node->type; unsigned int constraint = node->constraint; /* Enumerate all single byte character this node can accept. */ if (type == CHARACTER) bitset_set (accepts, node->opr.c); else if (type == SIMPLE_BRACKET) { bitset_merge (accepts, node->opr.sbcset); } else if (type == OP_PERIOD) { #ifdef RE_ENABLE_I18N if (dfa->mb_cur_max > 1) bitset_merge (accepts, dfa->sb_char); else #endif bitset_set_all (accepts); if (!(dfa->syntax & RE_DOT_NEWLINE)) bitset_clear (accepts, '\n'); if (dfa->syntax & RE_DOT_NOT_NULL) bitset_clear (accepts, '\0'); } #ifdef RE_ENABLE_I18N else if (type == OP_UTF8_PERIOD) { if (ASCII_CHARS % BITSET_WORD_BITS == 0) memset (accepts, -1, ASCII_CHARS / CHAR_BIT); else bitset_merge (accepts, utf8_sb_map); if (!(dfa->syntax & RE_DOT_NEWLINE)) bitset_clear (accepts, '\n'); if (dfa->syntax & RE_DOT_NOT_NULL) bitset_clear (accepts, '\0'); } #endif else continue; /* Check the 'accepts' and sift the characters which are not match it the context. */ if (constraint) { if (constraint & NEXT_NEWLINE_CONSTRAINT) { bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR); bitset_empty (accepts); if (accepts_newline) bitset_set (accepts, NEWLINE_CHAR); else continue; } if (constraint & NEXT_ENDBUF_CONSTRAINT) { bitset_empty (accepts); continue; } if (constraint & NEXT_WORD_CONSTRAINT) { bitset_word_t any_set = 0; if (type == CHARACTER && !node->word_char) { bitset_empty (accepts); continue; } #ifdef RE_ENABLE_I18N if (dfa->mb_cur_max > 1) for (j = 0; j < BITSET_WORDS; ++j) any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); else #endif for (j = 0; j < BITSET_WORDS; ++j) any_set |= (accepts[j] &= dfa->word_char[j]); if (!any_set) continue; } if (constraint & NEXT_NOTWORD_CONSTRAINT) { bitset_word_t any_set = 0; if (type == CHARACTER && node->word_char) { bitset_empty (accepts); continue; } #ifdef RE_ENABLE_I18N if (dfa->mb_cur_max > 1) for (j = 0; j < BITSET_WORDS; ++j) any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j])); else #endif for (j = 0; j < BITSET_WORDS; ++j) any_set |= (accepts[j] &= ~dfa->word_char[j]); if (!any_set) continue; } } /* Then divide 'accepts' into DFA states, or create a new state. Above, we make sure that accepts is not empty. */ for (j = 0; j < ndests; ++j) { bitset_t intersec; /* Intersection sets, see below. */ bitset_t remains; /* Flags, see below. */ bitset_word_t has_intersec, not_subset, not_consumed; /* Optimization, skip if this state doesn't accept the character. */ if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c)) continue; /* Enumerate the intersection set of this state and 'accepts'. */ has_intersec = 0; for (k = 0; k < BITSET_WORDS; ++k) has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k]; /* And skip if the intersection set is empty. */ if (!has_intersec) continue; /* Then check if this state is a subset of 'accepts'. */ not_subset = not_consumed = 0; for (k = 0; k < BITSET_WORDS; ++k) { not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k]; not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k]; } /* If this state isn't a subset of 'accepts', create a new group state, which has the 'remains'. */ if (not_subset) { bitset_copy (dests_ch[ndests], remains); bitset_copy (dests_ch[j], intersec); err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]); if (BE (err != REG_NOERROR, 0)) goto error_return; ++ndests; } /* Put the position in the current group. */ ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]); if (BE (! ok, 0)) goto error_return; /* If all characters are consumed, go to next node. */ if (!not_consumed) break; } /* Some characters remain, create a new group. */ if (j == ndests) { bitset_copy (dests_ch[ndests], accepts); err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]); if (BE (err != REG_NOERROR, 0)) goto error_return; ++ndests; bitset_empty (accepts); } } return ndests; error_return: for (j = 0; j < ndests; ++j) re_node_set_free (dests_node + j); return REG_MISSING; } #ifdef RE_ENABLE_I18N /* Check how many bytes the node 'dfa->nodes[node_idx]' accepts. Return the number of the bytes the node accepts. STR_IDX is the current index of the input string. This function handles the nodes which can accept one character, or one collating element like '.', '[a-z]', opposite to the other nodes can only accept one byte. */ static int internal_function check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, const re_string_t *input, Idx str_idx) { const re_token_t *node = dfa->nodes + node_idx; int char_len, elem_len; Idx i; if (BE (node->type == OP_UTF8_PERIOD, 0)) { unsigned char c = re_string_byte_at (input, str_idx), d; if (BE (c < 0xc2, 1)) return 0; if (str_idx + 2 > input->len) return 0; d = re_string_byte_at (input, str_idx + 1); if (c < 0xe0) return (d < 0x80 || d > 0xbf) ? 0 : 2; else if (c < 0xf0) { char_len = 3; if (c == 0xe0 && d < 0xa0) return 0; } else if (c < 0xf8) { char_len = 4; if (c == 0xf0 && d < 0x90) return 0; } else if (c < 0xfc) { char_len = 5; if (c == 0xf8 && d < 0x88) return 0; } else if (c < 0xfe) { char_len = 6; if (c == 0xfc && d < 0x84) return 0; } else return 0; if (str_idx + char_len > input->len) return 0; for (i = 1; i < char_len; ++i) { d = re_string_byte_at (input, str_idx + i); if (d < 0x80 || d > 0xbf) return 0; } return char_len; } char_len = re_string_char_size_at (input, str_idx); if (node->type == OP_PERIOD) { if (char_len <= 1) return 0; /* FIXME: I don't think this if is needed, as both '\n' and '\0' are char_len == 1. */ /* '.' accepts any one character except the following two cases. */ if ((!(dfa->syntax & RE_DOT_NEWLINE) && re_string_byte_at (input, str_idx) == '\n') || ((dfa->syntax & RE_DOT_NOT_NULL) && re_string_byte_at (input, str_idx) == '\0')) return 0; return char_len; } elem_len = re_string_elem_size_at (input, str_idx); if ((elem_len <= 1 && char_len <= 1) || char_len == 0) return 0; if (node->type == COMPLEX_BRACKET) { const re_charset_t *cset = node->opr.mbcset; # ifdef _LIBC const unsigned char *pin = ((const unsigned char *) re_string_get_buffer (input) + str_idx); Idx j; uint32_t nrules; # endif /* _LIBC */ int match_len = 0; wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars) ? re_string_wchar_at (input, str_idx) : 0); /* match with multibyte character? */ for (i = 0; i < cset->nmbchars; ++i) if (wc == cset->mbchars[i]) { match_len = char_len; goto check_node_accept_bytes_match; } /* match with character_class? */ for (i = 0; i < cset->nchar_classes; ++i) { wctype_t wt = cset->char_classes[i]; if (__iswctype (wc, wt)) { match_len = char_len; goto check_node_accept_bytes_match; } } # ifdef _LIBC nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); if (nrules != 0) { unsigned int in_collseq = 0; const int32_t *table, *indirect; const unsigned char *weights, *extra; const char *collseqwc; /* This #include defines a local function! */ # include /* match with collating_symbol? */ if (cset->ncoll_syms) extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); for (i = 0; i < cset->ncoll_syms; ++i) { const unsigned char *coll_sym = extra + cset->coll_syms[i]; /* Compare the length of input collating element and the length of current collating element. */ if (*coll_sym != elem_len) continue; /* Compare each bytes. */ for (j = 0; j < *coll_sym; j++) if (pin[j] != coll_sym[1 + j]) break; if (j == *coll_sym) { /* Match if every bytes is equal. */ match_len = j; goto check_node_accept_bytes_match; } } if (cset->nranges) { if (elem_len <= char_len) { collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); in_collseq = __collseq_table_lookup (collseqwc, wc); } else in_collseq = find_collation_sequence_value (pin, elem_len); } /* match with range expression? */ /* FIXME: Implement rational ranges here, too. */ for (i = 0; i < cset->nranges; ++i) if (cset->range_starts[i] <= in_collseq && in_collseq <= cset->range_ends[i]) { match_len = elem_len; goto check_node_accept_bytes_match; } /* match with equivalence_class? */ if (cset->nequiv_classes) { const unsigned char *cp = pin; table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); int32_t idx = findidx (&cp, elem_len); if (idx > 0) for (i = 0; i < cset->nequiv_classes; ++i) { int32_t equiv_class_idx = cset->equiv_classes[i]; size_t weight_len = weights[idx & 0xffffff]; if (weight_len == weights[equiv_class_idx & 0xffffff] && (idx >> 24) == (equiv_class_idx >> 24)) { Idx cnt = 0; idx &= 0xffffff; equiv_class_idx &= 0xffffff; while (cnt <= weight_len && (weights[equiv_class_idx + 1 + cnt] == weights[idx + 1 + cnt])) ++cnt; if (cnt > weight_len) { match_len = elem_len; goto check_node_accept_bytes_match; } } } } } else # endif /* _LIBC */ { /* match with range expression? */ for (i = 0; i < cset->nranges; ++i) { if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i]) { match_len = char_len; goto check_node_accept_bytes_match; } } } check_node_accept_bytes_match: if (!cset->non_match) return match_len; else { if (match_len > 0) return 0; else return (elem_len > char_len) ? elem_len : char_len; } } return 0; } # ifdef _LIBC static unsigned int internal_function find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) { uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); if (nrules == 0) { if (mbs_len == 1) { /* No valid character. Match it as a single byte character. */ const unsigned char *collseq = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); return collseq[mbs[0]]; } return UINT_MAX; } else { int32_t idx; const unsigned char *extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); int32_t extrasize = (const unsigned char *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra; for (idx = 0; idx < extrasize;) { int mbs_cnt; bool found = false; int32_t elem_mbs_len; /* Skip the name of collating element name. */ idx = idx + extra[idx] + 1; elem_mbs_len = extra[idx++]; if (mbs_len == elem_mbs_len) { for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt) if (extra[idx + mbs_cnt] != mbs[mbs_cnt]) break; if (mbs_cnt == elem_mbs_len) /* Found the entry. */ found = true; } /* Skip the byte sequence of the collating element. */ idx += elem_mbs_len; /* Adjust for the alignment. */ idx = (idx + 3) & ~3; /* Skip the collation sequence value. */ idx += sizeof (uint32_t); /* Skip the wide char sequence of the collating element. */ idx = idx + sizeof (uint32_t) * (*(int32_t *) (extra + idx) + 1); /* If we found the entry, return the sequence value. */ if (found) return *(uint32_t *) (extra + idx); /* Skip the collation sequence value. */ idx += sizeof (uint32_t); } return UINT_MAX; } } # endif /* _LIBC */ #endif /* RE_ENABLE_I18N */ /* Check whether the node accepts the byte which is IDX-th byte of the INPUT. */ static bool internal_function check_node_accept (const re_match_context_t *mctx, const re_token_t *node, Idx idx) { unsigned char ch; ch = re_string_byte_at (&mctx->input, idx); switch (node->type) { case CHARACTER: if (node->opr.c != ch) return false; break; case SIMPLE_BRACKET: if (!bitset_contain (node->opr.sbcset, ch)) return false; break; #ifdef RE_ENABLE_I18N case OP_UTF8_PERIOD: if (ch >= ASCII_CHARS) return false; /* FALLTHROUGH */ #endif case OP_PERIOD: if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) return false; break; default: return false; } if (node->constraint) { /* The node has constraints. Check whether the current context satisfies the constraints. */ unsigned int context = re_string_context_at (&mctx->input, idx, mctx->eflags); if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) return false; } return true; } /* Extend the buffers, if the buffers have run out. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ extend_buffers (re_match_context_t *mctx, int min_len) { reg_errcode_t ret; re_string_t *pstr = &mctx->input; /* Avoid overflow. */ if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2 <= pstr->bufs_len, 0)) return REG_ESPACE; /* Double the lengths of the buffers, but allocate at least MIN_LEN. */ ret = re_string_realloc_buffers (pstr, MAX (min_len, MIN (pstr->len, pstr->bufs_len * 2))); if (BE (ret != REG_NOERROR, 0)) return ret; if (mctx->state_log != NULL) { /* And double the length of state_log. */ /* XXX We have no indication of the size of this buffer. If this allocation fail we have no indication that the state_log array does not have the right size. */ re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *, pstr->bufs_len + 1); if (BE (new_array == NULL, 0)) return REG_ESPACE; mctx->state_log = new_array; } /* Then reconstruct the buffers. */ if (pstr->icase) { #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) { ret = build_wcs_upper_buffer (pstr); if (BE (ret != REG_NOERROR, 0)) return ret; } else #endif /* RE_ENABLE_I18N */ build_upper_buffer (pstr); } else { #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) build_wcs_buffer (pstr); else #endif /* RE_ENABLE_I18N */ { if (pstr->trans != NULL) re_string_translate_buffer (pstr); } } return REG_NOERROR; } /* Functions for matching context. */ /* Initialize MCTX. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ match_ctx_init (re_match_context_t *mctx, int eflags, Idx n) { mctx->eflags = eflags; mctx->match_last = REG_MISSING; if (n > 0) { /* Avoid overflow. */ size_t max_object_size = MAX (sizeof (struct re_backref_cache_entry), sizeof (re_sub_match_top_t *)); if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n, 0)) return REG_ESPACE; mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); mctx->sub_tops = re_malloc (re_sub_match_top_t *, n); if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0)) return REG_ESPACE; } /* Already zero-ed by the caller. else mctx->bkref_ents = NULL; mctx->nbkref_ents = 0; mctx->nsub_tops = 0; */ mctx->abkref_ents = n; mctx->max_mb_elem_len = 1; mctx->asub_tops = n; return REG_NOERROR; } /* Clean the entries which depend on the current input in MCTX. This function must be invoked when the matcher changes the start index of the input, or changes the input string. */ static void internal_function match_ctx_clean (re_match_context_t *mctx) { Idx st_idx; for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx) { Idx sl_idx; re_sub_match_top_t *top = mctx->sub_tops[st_idx]; for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx) { re_sub_match_last_t *last = top->lasts[sl_idx]; re_free (last->path.array); re_free (last); } re_free (top->lasts); if (top->path) { re_free (top->path->array); re_free (top->path); } free (top); } mctx->nsub_tops = 0; mctx->nbkref_ents = 0; } /* Free all the memory associated with MCTX. */ static void internal_function match_ctx_free (re_match_context_t *mctx) { /* First, free all the memory associated with MCTX->SUB_TOPS. */ match_ctx_clean (mctx); re_free (mctx->sub_tops); re_free (mctx->bkref_ents); } /* Add a new backreference entry to MCTX. Note that we assume that caller never call this function with duplicate entry, and call with STR_IDX which isn't smaller than any existing entry. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from, Idx to) { if (mctx->nbkref_ents >= mctx->abkref_ents) { struct re_backref_cache_entry* new_entry; new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry, mctx->abkref_ents * 2); if (BE (new_entry == NULL, 0)) { re_free (mctx->bkref_ents); return REG_ESPACE; } mctx->bkref_ents = new_entry; memset (mctx->bkref_ents + mctx->nbkref_ents, '\0', sizeof (struct re_backref_cache_entry) * mctx->abkref_ents); mctx->abkref_ents *= 2; } if (mctx->nbkref_ents > 0 && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx) mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1; mctx->bkref_ents[mctx->nbkref_ents].node = node; mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx; mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from; mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to; /* This is a cache that saves negative results of check_dst_limits_calc_pos. If bit N is clear, means that this entry won't epsilon-transition to an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression. If it is set, check_dst_limits_calc_pos_1 will recurse and try to find one such node. A backreference does not epsilon-transition unless it is empty, so set to all zeros if FROM != TO. */ mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map = (from == to ? -1 : 0); mctx->bkref_ents[mctx->nbkref_ents++].more = 0; if (mctx->max_mb_elem_len < to - from) mctx->max_mb_elem_len = to - from; return REG_NOERROR; } /* Return the first entry with the same str_idx, or REG_MISSING if none is found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */ static Idx internal_function search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx) { Idx left, right, mid, last; last = right = mctx->nbkref_ents; for (left = 0; left < right;) { mid = (left + right) / 2; if (mctx->bkref_ents[mid].str_idx < str_idx) left = mid + 1; else right = mid; } if (left < last && mctx->bkref_ents[left].str_idx == str_idx) return left; else return REG_MISSING; } /* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches at STR_IDX. */ static reg_errcode_t internal_function __attribute_warn_unused_result__ match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx) { #ifdef DEBUG assert (mctx->sub_tops != NULL); assert (mctx->asub_tops > 0); #endif if (BE (mctx->nsub_tops == mctx->asub_tops, 0)) { Idx new_asub_tops = mctx->asub_tops * 2; re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops, re_sub_match_top_t *, new_asub_tops); if (BE (new_array == NULL, 0)) return REG_ESPACE; mctx->sub_tops = new_array; mctx->asub_tops = new_asub_tops; } mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t)); if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0)) return REG_ESPACE; mctx->sub_tops[mctx->nsub_tops]->node = node; mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx; return REG_NOERROR; } /* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */ static re_sub_match_last_t * internal_function match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx) { re_sub_match_last_t *new_entry; if (BE (subtop->nlasts == subtop->alasts, 0)) { Idx new_alasts = 2 * subtop->alasts + 1; re_sub_match_last_t **new_array = re_realloc (subtop->lasts, re_sub_match_last_t *, new_alasts); if (BE (new_array == NULL, 0)) return NULL; subtop->lasts = new_array; subtop->alasts = new_alasts; } new_entry = calloc (1, sizeof (re_sub_match_last_t)); if (BE (new_entry != NULL, 1)) { subtop->lasts[subtop->nlasts] = new_entry; new_entry->node = node; new_entry->str_idx = str_idx; ++subtop->nlasts; } return new_entry; } static void internal_function sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx) { sctx->sifted_states = sifted_sts; sctx->limited_states = limited_sts; sctx->last_node = last_node; sctx->last_str_idx = last_str_idx; re_node_set_init_empty (&sctx->limits); } lftp-4.6.3a/lib/strings.in.h0000644000015000007670000000765612466374012012613 00000000000000/* A substitute . Copyright (C) 2007-2015 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 . */ #ifndef _@GUARD_PREFIX@_STRINGS_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* Minix 3.1.8 has a bug: must be included before . But avoid namespace pollution on glibc systems. */ #if defined __minix && !defined __GLIBC__ # include #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 #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 */ lftp-4.6.3a/lib/stdint.in.h0000644000015000007670000004456412466374012012426 00000000000000/* Copyright (C) 2001-2002, 2004-2015 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. This file is part of gnulib. 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 . */ /* * ISO C 99 for platforms that lack it. * */ #ifndef _@GUARD_PREFIX@_STDINT_H #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif @PRAGMA_COLUMNS@ /* When including a system file that in turn includes , use the system , not our substitute. This avoids problems with (for example) VMS, whose includes . */ #define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H /* On Android (Bionic libc), includes this file before having defined 'time_t'. Therefore in this case avoid including other system header files; just include the system's . Ideally we should test __BIONIC__ here, but it is only defined after has been included; hence test __ANDROID__ instead. */ #if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H # @INCLUDE_NEXT@ @NEXT_STDINT_H@ #else /* Get those types that are already defined in other system include files, so that we can "#define int8_t signed char" below without worrying about a later system include file containing a "typedef signed char int8_t;" that will get messed up by our macro. Our macros should all be consistent with the system versions, except for the "fast" types and macros, which we recommend against using in public interfaces due to compiler differences. */ #if @HAVE_STDINT_H@ # if defined __sgi && ! defined __c99 /* Bypass IRIX's if in C89 mode, since it merely annoys users with "This header file is to be used only for c99 mode compilations" diagnostics. */ # define __STDINT_H__ # endif /* Some pre-C++11 implementations need this. */ # ifdef __cplusplus # ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS 1 # endif # ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS 1 # endif # endif /* Other systems may have an incomplete or buggy . Include it before , since any "#include " in would reinclude us, skipping our contents because _@GUARD_PREFIX@_STDINT_H is defined. The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_STDINT_H@ #endif #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H #define _@GUARD_PREFIX@_STDINT_H /* defines some of the stdint.h types as well, on glibc, IRIX 6.5, and OpenBSD 3.8 (via ). AIX 5.2 isn't needed and causes troubles. Mac OS X 10.4.6 includes (which is us), but relies on the system definitions, so include after @NEXT_STDINT_H@. */ #if @HAVE_SYS_TYPES_H@ && ! defined _AIX # include #endif /* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, LONG_MIN, LONG_MAX, ULONG_MAX. */ #include #if @HAVE_INTTYPES_H@ /* In OpenBSD 3.8, includes , which defines int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. also defines intptr_t and uintptr_t. */ # include #elif @HAVE_SYS_INTTYPES_H@ /* Solaris 7 has the types except the *_fast*_t types, and the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ # include #endif #if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ /* Linux libc4 >= 4.6.7 and libc5 have a that defines int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is included by . */ # include #endif #undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H /* Minimum and maximum values for an integer type under the usual assumption. Return an unspecified value if BITS == 0, adding a check to pacify picky compilers. */ #define _STDINT_MIN(signed, bits, zero) \ ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero)) #define _STDINT_MAX(signed, bits, zero) \ ((signed) \ ? ~ _STDINT_MIN (signed, bits, zero) \ : /* The expression for the unsigned case. The subtraction of (signed) \ is a nop in the unsigned case and avoids "signed integer overflow" \ warnings in the signed case. */ \ ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) #if !GNULIB_defined_stdint_types /* 7.18.1.1. Exact-width integer types */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. */ #undef int8_t #undef uint8_t typedef signed char gl_int8_t; typedef unsigned char gl_uint8_t; #define int8_t gl_int8_t #define uint8_t gl_uint8_t #undef int16_t #undef uint16_t typedef short int gl_int16_t; typedef unsigned short int gl_uint16_t; #define int16_t gl_int16_t #define uint16_t gl_uint16_t #undef int32_t #undef uint32_t typedef int gl_int32_t; typedef unsigned int gl_uint32_t; #define int32_t gl_int32_t #define uint32_t gl_uint32_t /* If the system defines INT64_MAX, assume int64_t works. That way, if the underlying platform defines int64_t to be a 64-bit long long int, the code below won't mistakenly define it to be a 64-bit long int, which would mess up C++ name mangling. We must use #ifdef rather than #if, to avoid an error with HP-UX 10.20 cc. */ #ifdef INT64_MAX # define GL_INT64_T #else /* Do not undefine int64_t if gnulib is not being used with 64-bit types, since otherwise it breaks platforms like Tandem/NSK. */ # if LONG_MAX >> 31 >> 31 == 1 # undef int64_t typedef long int gl_int64_t; # define int64_t gl_int64_t # define GL_INT64_T # elif defined _MSC_VER # undef int64_t typedef __int64 gl_int64_t; # define int64_t gl_int64_t # define GL_INT64_T # elif @HAVE_LONG_LONG_INT@ # undef int64_t typedef long long int gl_int64_t; # define int64_t gl_int64_t # define GL_INT64_T # endif #endif #ifdef UINT64_MAX # define GL_UINT64_T #else # if ULONG_MAX >> 31 >> 31 >> 1 == 1 # undef uint64_t typedef unsigned long int gl_uint64_t; # define uint64_t gl_uint64_t # define GL_UINT64_T # elif defined _MSC_VER # undef uint64_t typedef unsigned __int64 gl_uint64_t; # define uint64_t gl_uint64_t # define GL_UINT64_T # elif @HAVE_UNSIGNED_LONG_LONG_INT@ # undef uint64_t typedef unsigned long long int gl_uint64_t; # define uint64_t gl_uint64_t # define GL_UINT64_T # endif #endif /* Avoid collision with Solaris 2.5.1 etc. */ #define _UINT8_T #define _UINT32_T #define _UINT64_T /* 7.18.1.2. Minimum-width integer types */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types are the same as the corresponding N_t types. */ #undef int_least8_t #undef uint_least8_t #undef int_least16_t #undef uint_least16_t #undef int_least32_t #undef uint_least32_t #undef int_least64_t #undef uint_least64_t #define int_least8_t int8_t #define uint_least8_t uint8_t #define int_least16_t int16_t #define uint_least16_t uint16_t #define int_least32_t int32_t #define uint_least32_t uint32_t #ifdef GL_INT64_T # define int_least64_t int64_t #endif #ifdef GL_UINT64_T # define uint_least64_t uint64_t #endif /* 7.18.1.3. Fastest minimum-width integer types */ /* Note: Other substitutes may define these types differently. It is not recommended to use these types in public header files. */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types are taken from the same list of types. The following code normally uses types consistent with glibc, as that lessens the chance of incompatibility with older GNU hosts. */ #undef int_fast8_t #undef uint_fast8_t #undef int_fast16_t #undef uint_fast16_t #undef int_fast32_t #undef uint_fast32_t #undef int_fast64_t #undef uint_fast64_t typedef signed char gl_int_fast8_t; typedef unsigned char gl_uint_fast8_t; #ifdef __sun /* Define types compatible with SunOS 5.10, so that code compiled under earlier SunOS versions works with code compiled under SunOS 5.10. */ typedef int gl_int_fast32_t; typedef unsigned int gl_uint_fast32_t; #else typedef long int gl_int_fast32_t; typedef unsigned long int gl_uint_fast32_t; #endif typedef gl_int_fast32_t gl_int_fast16_t; typedef gl_uint_fast32_t gl_uint_fast16_t; #define int_fast8_t gl_int_fast8_t #define uint_fast8_t gl_uint_fast8_t #define int_fast16_t gl_int_fast16_t #define uint_fast16_t gl_uint_fast16_t #define int_fast32_t gl_int_fast32_t #define uint_fast32_t gl_uint_fast32_t #ifdef GL_INT64_T # define int_fast64_t int64_t #endif #ifdef GL_UINT64_T # define uint_fast64_t uint64_t #endif /* 7.18.1.4. Integer types capable of holding object pointers */ #undef intptr_t #undef uintptr_t typedef long int gl_intptr_t; typedef unsigned long int gl_uintptr_t; #define intptr_t gl_intptr_t #define uintptr_t gl_uintptr_t /* 7.18.1.5. Greatest-width integer types */ /* Note: These types are compiler dependent. It may be unwise to use them in public header files. */ /* If the system defines INTMAX_MAX, assume that intmax_t works, and similarly for UINTMAX_MAX and uintmax_t. This avoids problems with assuming one type where another is used by the system. */ #ifndef INTMAX_MAX # undef INTMAX_C # undef intmax_t # if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 typedef long long int gl_intmax_t; # define intmax_t gl_intmax_t # elif defined GL_INT64_T # define intmax_t int64_t # else typedef long int gl_intmax_t; # define intmax_t gl_intmax_t # endif #endif #ifndef UINTMAX_MAX # undef UINTMAX_C # undef uintmax_t # if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 typedef unsigned long long int gl_uintmax_t; # define uintmax_t gl_uintmax_t # elif defined GL_UINT64_T # define uintmax_t uint64_t # else typedef unsigned long int gl_uintmax_t; # define uintmax_t gl_uintmax_t # endif #endif /* Verify that intmax_t and uintmax_t have the same size. Too much code breaks if this is not the case. If this check fails, the reason is likely to be found in the autoconf macros. */ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) ? 1 : -1]; #define GNULIB_defined_stdint_types 1 #endif /* !GNULIB_defined_stdint_types */ /* 7.18.2. Limits of specified-width integer types */ /* 7.18.2.1. Limits of exact-width integer types */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. */ #undef INT8_MIN #undef INT8_MAX #undef UINT8_MAX #define INT8_MIN (~ INT8_MAX) #define INT8_MAX 127 #define UINT8_MAX 255 #undef INT16_MIN #undef INT16_MAX #undef UINT16_MAX #define INT16_MIN (~ INT16_MAX) #define INT16_MAX 32767 #define UINT16_MAX 65535 #undef INT32_MIN #undef INT32_MAX #undef UINT32_MAX #define INT32_MIN (~ INT32_MAX) #define INT32_MAX 2147483647 #define UINT32_MAX 4294967295U #if defined GL_INT64_T && ! defined INT64_MAX /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 evaluates the latter incorrectly in preprocessor expressions. */ # define INT64_MIN (- INTMAX_C (1) << 63) # define INT64_MAX INTMAX_C (9223372036854775807) #endif #if defined GL_UINT64_T && ! defined UINT64_MAX # define UINT64_MAX UINTMAX_C (18446744073709551615) #endif /* 7.18.2.2. Limits of minimum-width integer types */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types are the same as the corresponding N_t types. */ #undef INT_LEAST8_MIN #undef INT_LEAST8_MAX #undef UINT_LEAST8_MAX #define INT_LEAST8_MIN INT8_MIN #define INT_LEAST8_MAX INT8_MAX #define UINT_LEAST8_MAX UINT8_MAX #undef INT_LEAST16_MIN #undef INT_LEAST16_MAX #undef UINT_LEAST16_MAX #define INT_LEAST16_MIN INT16_MIN #define INT_LEAST16_MAX INT16_MAX #define UINT_LEAST16_MAX UINT16_MAX #undef INT_LEAST32_MIN #undef INT_LEAST32_MAX #undef UINT_LEAST32_MAX #define INT_LEAST32_MIN INT32_MIN #define INT_LEAST32_MAX INT32_MAX #define UINT_LEAST32_MAX UINT32_MAX #undef INT_LEAST64_MIN #undef INT_LEAST64_MAX #ifdef GL_INT64_T # define INT_LEAST64_MIN INT64_MIN # define INT_LEAST64_MAX INT64_MAX #endif #undef UINT_LEAST64_MAX #ifdef GL_UINT64_T # define UINT_LEAST64_MAX UINT64_MAX #endif /* 7.18.2.3. Limits of fastest minimum-width integer types */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types are taken from the same list of types. */ #undef INT_FAST8_MIN #undef INT_FAST8_MAX #undef UINT_FAST8_MAX #define INT_FAST8_MIN SCHAR_MIN #define INT_FAST8_MAX SCHAR_MAX #define UINT_FAST8_MAX UCHAR_MAX #undef INT_FAST16_MIN #undef INT_FAST16_MAX #undef UINT_FAST16_MAX #define INT_FAST16_MIN INT_FAST32_MIN #define INT_FAST16_MAX INT_FAST32_MAX #define UINT_FAST16_MAX UINT_FAST32_MAX #undef INT_FAST32_MIN #undef INT_FAST32_MAX #undef UINT_FAST32_MAX #ifdef __sun # define INT_FAST32_MIN INT_MIN # define INT_FAST32_MAX INT_MAX # define UINT_FAST32_MAX UINT_MAX #else # define INT_FAST32_MIN LONG_MIN # define INT_FAST32_MAX LONG_MAX # define UINT_FAST32_MAX ULONG_MAX #endif #undef INT_FAST64_MIN #undef INT_FAST64_MAX #ifdef GL_INT64_T # define INT_FAST64_MIN INT64_MIN # define INT_FAST64_MAX INT64_MAX #endif #undef UINT_FAST64_MAX #ifdef GL_UINT64_T # define UINT_FAST64_MAX UINT64_MAX #endif /* 7.18.2.4. Limits of integer types capable of holding object pointers */ #undef INTPTR_MIN #undef INTPTR_MAX #undef UINTPTR_MAX #define INTPTR_MIN LONG_MIN #define INTPTR_MAX LONG_MAX #define UINTPTR_MAX ULONG_MAX /* 7.18.2.5. Limits of greatest-width integer types */ #ifndef INTMAX_MAX # undef INTMAX_MIN # ifdef INT64_MAX # define INTMAX_MIN INT64_MIN # define INTMAX_MAX INT64_MAX # else # define INTMAX_MIN INT32_MIN # define INTMAX_MAX INT32_MAX # endif #endif #ifndef UINTMAX_MAX # ifdef UINT64_MAX # define UINTMAX_MAX UINT64_MAX # else # define UINTMAX_MAX UINT32_MAX # endif #endif /* 7.18.3. Limits of other integer types */ /* ptrdiff_t limits */ #undef PTRDIFF_MIN #undef PTRDIFF_MAX #if @APPLE_UNIVERSAL_BUILD@ # ifdef _LP64 # define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l) # define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) # else # define PTRDIFF_MIN _STDINT_MIN (1, 32, 0) # define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) # endif #else # define PTRDIFF_MIN \ _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) # define PTRDIFF_MAX \ _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) #endif /* sig_atomic_t limits */ #undef SIG_ATOMIC_MIN #undef SIG_ATOMIC_MAX #define SIG_ATOMIC_MIN \ _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ 0@SIG_ATOMIC_T_SUFFIX@) #define SIG_ATOMIC_MAX \ _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ 0@SIG_ATOMIC_T_SUFFIX@) /* size_t limit */ #undef SIZE_MAX #if @APPLE_UNIVERSAL_BUILD@ # ifdef _LP64 # define SIZE_MAX _STDINT_MAX (0, 64, 0ul) # else # define SIZE_MAX _STDINT_MAX (0, 32, 0ul) # endif #else # define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) #endif /* wchar_t limits */ /* Get WCHAR_MIN, WCHAR_MAX. This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested includes -> -> -> , and the latter includes and assumes its types are already defined. */ #if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) /* BSD/OS 4.0.1 has a bug: , and must be included before . */ # include # include # include # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H # include # undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H #endif #undef WCHAR_MIN #undef WCHAR_MAX #define WCHAR_MIN \ _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) #define WCHAR_MAX \ _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) /* wint_t limits */ #undef WINT_MIN #undef WINT_MAX #define WINT_MIN \ _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) #define WINT_MAX \ _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) /* 7.18.4. Macros for integer constants */ /* 7.18.4.1. Macros for minimum-width integer constants */ /* According to ISO C 99 Technical Corrigendum 1 */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ #undef INT8_C #undef UINT8_C #define INT8_C(x) x #define UINT8_C(x) x #undef INT16_C #undef UINT16_C #define INT16_C(x) x #define UINT16_C(x) x #undef INT32_C #undef UINT32_C #define INT32_C(x) x #define UINT32_C(x) x ## U #undef INT64_C #undef UINT64_C #if LONG_MAX >> 31 >> 31 == 1 # define INT64_C(x) x##L #elif defined _MSC_VER # define INT64_C(x) x##i64 #elif @HAVE_LONG_LONG_INT@ # define INT64_C(x) x##LL #endif #if ULONG_MAX >> 31 >> 31 >> 1 == 1 # define UINT64_C(x) x##UL #elif defined _MSC_VER # define UINT64_C(x) x##ui64 #elif @HAVE_UNSIGNED_LONG_LONG_INT@ # define UINT64_C(x) x##ULL #endif /* 7.18.4.2. Macros for greatest-width integer constants */ #ifndef INTMAX_C # if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 # define INTMAX_C(x) x##LL # elif defined GL_INT64_T # define INTMAX_C(x) INT64_C(x) # else # define INTMAX_C(x) x##L # endif #endif #ifndef UINTMAX_C # if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 # define UINTMAX_C(x) x##ULL # elif defined GL_UINT64_T # define UINTMAX_C(x) UINT64_C(x) # else # define UINTMAX_C(x) x##UL # endif #endif #endif /* _@GUARD_PREFIX@_STDINT_H */ #endif /* !(defined __ANDROID__ && ...) */ #endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ lftp-4.6.3a/lib/frexpl.c0000644000015000007670000000175612466374011012002 00000000000000/* Split a 'long double' into fraction and mantissa. Copyright (C) 2007, 2009-2015 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 . */ #include #if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Specification. */ # include long double frexpl (long double x, int *expptr) { return frexp (x, expptr); } #else # define USE_LONG_DOUBLE # include "frexp.c" #endif lftp-4.6.3a/lib/uniwidth/0000755000015000007670000000000012540300656012235 500000000000000lftp-4.6.3a/lib/uniwidth/cjk.h0000644000015000007670000000314512466374012013104 00000000000000/* Test for CJK encoding. Copyright (C) 2001-2002, 2005-2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2002. 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 . */ #include "streq.h" static int is_cjk_encoding (const char *encoding) { if (0 /* Legacy Japanese encodings */ || STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0) /* Legacy Chinese encodings */ || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) || STREQ_OPT (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0) || STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0) || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0) /* Legacy Korean encodings */ || STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) || STREQ_OPT (encoding, "CP949", 'C', 'P', '9', '4', '9', 0, 0, 0, 0) || STREQ_OPT (encoding, "JOHAB", 'J', 'O', 'H', 'A', 'B', 0, 0, 0, 0)) return 1; return 0; } lftp-4.6.3a/lib/uniwidth/width.c0000644000015000007670000006224712466374012013457 00000000000000/* Determine display width of Unicode character. Copyright (C) 2001-2002, 2006-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2002. 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 . */ #include /* Specification. */ #include "uniwidth.h" #include "cjk.h" /* * Non-spacing attribute table. * Consists of: * - Non-spacing characters; generated from PropList.txt or * "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt" * - Format control characters; generated from * "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt" * - Zero width characters; generated from * "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt" */ static const unsigned char nonspacing_table_data[35*64] = { /* 0x0000-0x01ff */ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */ 0xff, 0xff, 0xff, 0xff, 0x00, 0x20, 0x00, 0x00, /* 0x0080-0x00bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00c0-0x00ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0100-0x013f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0140-0x017f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0180-0x01bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x01c0-0x01ff */ /* 0x0200-0x03ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0200-0x023f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0240-0x027f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0280-0x02bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x02c0-0x02ff */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x0300-0x033f */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, /* 0x0340-0x037f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0380-0x03bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x03c0-0x03ff */ /* 0x0400-0x05ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0400-0x043f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0440-0x047f */ 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0480-0x04bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04c0-0x04ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0500-0x053f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0540-0x057f */ 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xbf, /* 0x0580-0x05bf */ 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x05c0-0x05ff */ /* 0x0600-0x07ff */ 0x3f, 0x00, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */ 0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0680-0x06bf */ 0x00, 0x00, 0xc0, 0xbf, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */ 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x0700-0x073f */ 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0740-0x077f */ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, /* 0x0780-0x07bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x07c0-0x07ff */ /* 0x0800-0x09ff */ 0x00, 0x00, 0xc0, 0xfb, 0xef, 0x3e, 0x00, 0x00, /* 0x0800-0x083f */ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0880-0x08bf */ 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, /* 0x08c0-0x08ff */ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, /* 0x0900-0x093f */ 0xfe, 0x21, 0xfe, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0980-0x09bf */ 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x09c0-0x09ff */ /* 0x0a00-0x0bff */ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a00-0x0a3f */ 0x86, 0x39, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, /* 0x0a40-0x0a7f */ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a80-0x0abf */ 0xbe, 0x21, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0ac0-0x0aff */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0x0b00-0x0b3f */ 0x1e, 0x20, 0x40, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0b40-0x0b7f */ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0b80-0x0bbf */ 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0bc0-0x0bff */ /* 0x0c00-0x0dff */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, /* 0x0c00-0x0c3f */ 0xc1, 0x3d, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0c40-0x0c7f */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0c80-0x0cbf */ 0x00, 0x30, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0cc0-0x0cff */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d00-0x0d3f */ 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0d40-0x0d7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d80-0x0dbf */ 0x00, 0x04, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0dc0-0x0dff */ /* 0x0e00-0x0fff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x07, /* 0x0e00-0x0e3f */ 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0e40-0x0e7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x1b, /* 0x0e80-0x0ebf */ 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0ec0-0x0eff */ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xa0, 0x02, /* 0x0f00-0x0f3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, /* 0x0f40-0x0f7f */ 0xdf, 0xe0, 0xff, 0xfe, 0xff, 0xff, 0xff, 0x1f, /* 0x0f80-0x0fbf */ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0fc0-0x0fff */ /* 0x1000-0x11ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfd, 0x66, /* 0x1000-0x103f */ 0x00, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x1e, 0x00, /* 0x1040-0x107f */ 0x64, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c0-0x10ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1100-0x113f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1140-0x117f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1180-0x11bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c0-0x11ff */ /* 0x1200-0x13ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1200-0x123f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1240-0x127f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1280-0x12bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x12c0-0x12ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1300-0x133f */ 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, /* 0x1340-0x137f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1380-0x13bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13c0-0x13ff */ /* 0x1600-0x17ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1600-0x163f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1640-0x167f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1680-0x16bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16c0-0x16ff */ 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, /* 0x1700-0x173f */ 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, /* 0x1740-0x177f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x3f, /* 0x1780-0x17bf */ 0x40, 0xfe, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x17c0-0x17ff */ /* 0x1800-0x19ff */ 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1800-0x183f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1840-0x187f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x1880-0x18bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18c0-0x18ff */ 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x04, 0x0e, /* 0x1900-0x193f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1940-0x197f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1980-0x19bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x19c0-0x19ff */ /* 0x1a00-0x1bff */ 0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */ 0x00, 0x00, 0x40, 0x7f, 0xe5, 0x1f, 0xf8, 0x9f, /* 0x1a40-0x1a7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, /* 0x1a80-0x1abf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ac0-0x1aff */ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x17, /* 0x1b00-0x1b3f */ 0x04, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x1b40-0x1b7f */ 0x03, 0x00, 0x00, 0x00, 0x3c, 0x3b, 0x00, 0x00, /* 0x1b80-0x1bbf */ 0x00, 0x00, 0x00, 0x00, 0x40, 0xa3, 0x03, 0x00, /* 0x1bc0-0x1bff */ /* 0x1c00-0x1dff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x00, /* 0x1c00-0x1c3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c40-0x1c7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c80-0x1cbf */ 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x10, 0x03, /* 0x1cc0-0x1cff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d00-0x1d3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d40-0x1d7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d80-0x1dbf */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf0, /* 0x1dc0-0x1dff */ /* 0x2000-0x21ff */ 0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, /* 0x2000-0x203f */ 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0x00, 0x00, /* 0x2040-0x207f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2080-0x20bf */ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, /* 0x20c0-0x20ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2100-0x213f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2140-0x217f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2180-0x21bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x21c0-0x21ff */ /* 0x2c00-0x2dff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c00-0x2c3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c40-0x2c7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c80-0x2cbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, /* 0x2cc0-0x2cff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d00-0x2d3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x2d40-0x2d7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d80-0x2dbf */ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x2dc0-0x2dff */ /* 0x3000-0x31ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x3000-0x303f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3040-0x307f */ 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, /* 0x3080-0x30bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30c0-0x30ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3100-0x313f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3140-0x317f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3180-0x31bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x31c0-0x31ff */ /* 0xa600-0xa7ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa600-0xa63f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf7, 0x3f, /* 0xa640-0xa67f */ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, /* 0xa6c0-0xa6ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa700-0xa73f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa740-0xa77f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa780-0xa7bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa7c0-0xa7ff */ /* 0xa800-0xa9ff */ 0x44, 0x08, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0xa800-0xa83f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa840-0xa87f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa880-0xa8bf */ 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, /* 0xa8c0-0xa8ff */ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, /* 0xa900-0xa93f */ 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa940-0xa97f */ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x13, /* 0xa980-0xa9bf */ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */ /* 0xaa00-0xabff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x66, 0x00, /* 0xaa00-0xaa3f */ 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0xaa40-0xaa7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0xc1, /* 0xaa80-0xaabf */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x00, /* 0xaac0-0xaaff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab00-0xab3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */ 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, /* 0xabc0-0xabff */ /* 0xfa00-0xfbff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa00-0xfa3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa40-0xfa7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa80-0xfabf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfac0-0xfaff */ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, /* 0xfb00-0xfb3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb40-0xfb7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb80-0xfbbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfbc0-0xfbff */ /* 0xfe00-0xffff */ 0xff, 0xff, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, /* 0xfe00-0xfe3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe40-0xfe7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe80-0xfebf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0xfec0-0xfeff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff00-0xff3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff40-0xff7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff80-0xffbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, /* 0xffc0-0xffff */ /* 0x10000-0x101ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10000-0x1003f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10040-0x1007f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10080-0x100bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x100c0-0x100ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10100-0x1013f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10140-0x1017f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10180-0x101bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, /* 0x101c0-0x101ff */ /* 0x10200-0x103ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10200-0x1023f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10240-0x1027f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10280-0x102bf */ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, /* 0x102c0-0x102ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10300-0x1033f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, /* 0x10340-0x1037f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10380-0x103bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x103c0-0x103ff */ /* 0x10a00-0x10bff */ 0x6e, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, /* 0x10a00-0x10a3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a40-0x10a7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a80-0x10abf */ 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0x10ac0-0x10aff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b00-0x10b3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b40-0x10b7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b80-0x10bbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10bc0-0x10bff */ /* 0x11000-0x111ff */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11000-0x1103f */ 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x11040-0x1107f */ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x26, /* 0x11080-0x110bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x110c0-0x110ff */ 0x07, 0x00, 0x00, 0x00, 0x80, 0xef, 0x1f, 0x00, /* 0x11100-0x1113f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, /* 0x11140-0x1117f */ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x7f, /* 0x11180-0x111bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */ /* 0x11200-0x113ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xd3, 0x00, /* 0x11200-0x1123f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11240-0x1127f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11280-0x112bf */ 0x00, 0x00, 0x00, 0x80, 0xf8, 0x07, 0x00, 0x00, /* 0x112c0-0x112ff */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x11300-0x1133f */ 0x01, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x1f, 0x00, /* 0x11340-0x1137f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11380-0x113bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x113c0-0x113ff */ /* 0x11400-0x115ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11400-0x1143f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11440-0x1147f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x85, /* 0x11480-0x114bf */ 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x114c0-0x114ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11500-0x1153f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11540-0x1157f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xb0, /* 0x11580-0x115bf */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x115c0-0x115ff */ /* 0x11600-0x117ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xa7, /* 0x11600-0x1163f */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11640-0x1167f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0xbf, 0x00, /* 0x11680-0x116bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x116c0-0x116ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11700-0x1173f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11740-0x1177f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11780-0x117bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x117c0-0x117ff */ /* 0x16a00-0x16bff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a00-0x16a3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a40-0x16a7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a80-0x16abf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, /* 0x16ac0-0x16aff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 0x16b00-0x16b3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b40-0x16b7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b80-0x16bbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16bc0-0x16bff */ /* 0x16e00-0x16fff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e00-0x16e3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e40-0x16e7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e80-0x16ebf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16ec0-0x16eff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f00-0x16f3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f40-0x16f7f */ 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f80-0x16fbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16fc0-0x16fff */ /* 0x1bc00-0x1bdff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc00-0x1bc3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc40-0x1bc7f */ 0x00, 0x00, 0x00, 0x60, 0x0f, 0x00, 0x00, 0x00, /* 0x1bc80-0x1bcbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bcc0-0x1bcff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd00-0x1bd3f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd40-0x1bd7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd80-0x1bdbf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bdc0-0x1bdff */ /* 0x1d000-0x1d1ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d000-0x1d03f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d040-0x1d07f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d080-0x1d0bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d0c0-0x1d0ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d100-0x1d13f */ 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xf8, 0xff, /* 0x1d140-0x1d17f */ 0xe7, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x1d180-0x1d1bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d1c0-0x1d1ff */ /* 0x1d200-0x1d3ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d200-0x1d23f */ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d240-0x1d27f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d280-0x1d2bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d2c0-0x1d2ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d300-0x1d33f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d340-0x1d37f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d380-0x1d3bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d3c0-0x1d3ff */ /* 0x1e800-0x1e9ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e800-0x1e83f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e840-0x1e87f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e880-0x1e8bf */ 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e8c0-0x1e8ff */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e900-0x1e93f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e940-0x1e97f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e980-0x1e9bf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0x1e9c0-0x1e9ff */ }; static const signed char nonspacing_table_ind[248] = { 0, 1, 2, 3, 4, 5, 6, 7, /* 0x0000-0x0fff */ 8, 9, -1, 10, 11, 12, 13, -1, /* 0x1000-0x1fff */ 14, -1, -1, -1, -1, -1, 15, -1, /* 0x2000-0x2fff */ 16, -1, -1, -1, -1, -1, -1, -1, /* 0x3000-0x3fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x4000-0x4fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x5000-0x5fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x6000-0x6fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x7000-0x7fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x8000-0x8fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x9000-0x9fff */ -1, -1, -1, 17, 18, 19, -1, -1, /* 0xa000-0xafff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb000-0xbfff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc000-0xcfff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd000-0xdfff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */ -1, -1, -1, -1, -1, 20, -1, 21, /* 0xf000-0xffff */ 22, 23, -1, -1, -1, 24, -1, -1, /* 0x10000-0x10fff */ 25, 26, 27, 28, -1, -1, -1, -1, /* 0x11000-0x11fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x15000-0x15fff */ -1, -1, -1, -1, -1, 29, -1, 30, /* 0x16000-0x16fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x17000-0x17fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18000-0x18fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x19000-0x19fff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */ -1, -1, -1, -1, -1, -1, 31, -1, /* 0x1b000-0x1bfff */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1c000-0x1cfff */ 32, 33, -1, -1, -1, -1, -1, -1, /* 0x1d000-0x1dfff */ -1, -1, -1, -1, 34, -1, -1, -1 /* 0x1e000-0x1efff */ }; /* Determine number of column positions required for UC. */ int uc_width1 (ucs4_t uc) { /* Test for non-spacing or control character. */ if ((uc >> 9) < 248) { int ind = nonspacing_table_ind[uc >> 9]; if (ind >= 0) if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1) { if (uc > 0 && uc < 0xa0) return -1; else return 0; } } else if ((uc >> 9) == (0xe0000 >> 9)) { if (uc >= 0xe0100) { if (uc <= 0xe01ef) return 0; } else { if (uc >= 0xe0020 ? uc <= 0xe007f : uc == 0xe0001) return 0; } } /* Test for double-width character. * Generated from "grep '^[^;]\{4,5\};[WF]' EastAsianWidth.txt" * and "grep '^[^;]\{4,5\};[^WF]' EastAsianWidth.txt" */ if (uc >= 0x1100 && ((uc < 0x1160) /* Hangul Jamo */ || (uc >= 0x2329 && uc < 0x232b) /* Angle Brackets */ || (uc >= 0x2e80 && uc < 0xa4d0 /* CJK ... Yi */ && !(uc == 0x303f) && !(uc >= 0x4dc0 && uc < 0x4e00)) || (uc >= 0xac00 && uc < 0xd7a4) /* Hangul Syllables */ || (uc >= 0xf900 && uc < 0xfb00) /* CJK Compatibility Ideographs */ || (uc >= 0xfe10 && uc < 0xfe20) /* Presentation Forms for Vertical */ || (uc >= 0xfe30 && uc < 0xfe70) /* CJK Compatibility Forms */ || (uc >= 0xff00 && uc < 0xff61) /* Fullwidth Forms */ || (uc >= 0xffe0 && uc < 0xffe7) /* Fullwidth Signs */ || (uc >= 0x20000 && uc <= 0x2ffff) /* Supplementary Ideographic Plane */ || (uc >= 0x30000 && uc <= 0x3ffff) /* Tertiary Ideographic Plane */ ) ) return 2; return 1; } int uc_width (ucs4_t uc, const char *encoding) { int w = uc_width1 (uc); /* In ancient CJK encodings, Cyrillic and most other characters are double-width as well. */ if (uc >= 0x00A1 && uc < 0xFF61 && uc != 0x20A9 && w == 1 && is_cjk_encoding (encoding)) return 2; return w; } lftp-4.6.3a/lib/error.h0000644000015000007670000000553212531301055011623 00000000000000/* Declaration for error-reporting function Copyright (C) 1995-1997, 2003, 2006, 2008-2015 Free Software Foundation, Inc. This file is part of 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 . */ #ifndef _ERROR_H #define _ERROR_H 1 /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) #else # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif /* On mingw, the flavor of printf depends on whether the extensions module * is in use; the check for determines the witness macro. */ #ifndef _GL_ATTRIBUTE_SPEC_PRINTF # if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU # define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__ # else # define _GL_ATTRIBUTE_SPEC_PRINTF __printf__ # endif #endif #ifdef __cplusplus extern "C" { #endif /* Print a message with 'fprintf (stderr, FORMAT, ...)'; if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */ extern void error (int __status, int __errnum, const char *__format, ...) _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 3, 4)); extern void error_at_line (int __status, int __errnum, const char *__fname, unsigned int __lineno, const char *__format, ...) _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 5, 6)); /* If NULL, error will flush stdout, then print on stderr the program name, a colon and a space. Otherwise, error will call this function without parameters instead. */ extern void (*error_print_progname) (void); /* This variable is incremented each time 'error' is called. */ extern unsigned int error_message_count; /* Sometimes we want to have at most one error per line. This variable controls whether this mode is selected or not. */ extern int error_one_per_line; #ifdef __cplusplus } #endif #endif /* error.h */ lftp-4.6.3a/lib/quotearg.c0000644000015000007670000007565612466374011012343 00000000000000/* quotearg.c - quote arguments for output Copyright (C) 1998-2002, 2004-2015 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 . */ /* Written by Paul Eggert */ /* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that the quoting_options_from_style function might be candidate for attribute 'pure' */ #if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" #endif #include #include "quotearg.h" #include "quote.h" #include "xalloc.h" #include "c-strcaseeq.h" #include "localcharset.h" #include #include #include #include #include #include #include #include #include "gettext.h" #define _(msgid) gettext (msgid) #define N_(msgid) msgid #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif #define INT_BITS (sizeof (int) * CHAR_BIT) struct quoting_options { /* Basic quoting style. */ enum quoting_style style; /* Additional flags. Bitwise combination of enum quoting_flags. */ int flags; /* Quote the characters indicated by this bit vector even if the quoting style would not normally require them to be quoted. */ unsigned int quote_these_too[(UCHAR_MAX / INT_BITS) + 1]; /* The left quote for custom_quoting_style. */ char const *left_quote; /* The right quote for custom_quoting_style. */ char const *right_quote; }; /* Names of quoting styles. */ char const *const quoting_style_args[] = { "literal", "shell", "shell-always", "c", "c-maybe", "escape", "locale", "clocale", 0 }; /* Correspondences to quoting style names. */ enum quoting_style const quoting_style_vals[] = { literal_quoting_style, shell_quoting_style, shell_always_quoting_style, c_quoting_style, c_maybe_quoting_style, escape_quoting_style, locale_quoting_style, clocale_quoting_style }; /* The default quoting options. */ static struct quoting_options default_quoting_options; /* Allocate a new set of quoting options, with contents initially identical to O if O is not null, or to the default if O is null. It is the caller's responsibility to free the result. */ struct quoting_options * clone_quoting_options (struct quoting_options *o) { int e = errno; struct quoting_options *p = xmemdup (o ? o : &default_quoting_options, sizeof *o); errno = e; return p; } /* Get the value of O's quoting style. If O is null, use the default. */ enum quoting_style get_quoting_style (struct quoting_options *o) { return (o ? o : &default_quoting_options)->style; } /* In O (or in the default if O is null), set the value of the quoting style to S. */ void set_quoting_style (struct quoting_options *o, enum quoting_style s) { (o ? o : &default_quoting_options)->style = s; } /* In O (or in the default if O is null), set the value of the quoting options for character C to I. Return the old value. Currently, the only values defined for I are 0 (the default) and 1 (which means to quote the character even if it would not otherwise be quoted). */ int set_char_quoting (struct quoting_options *o, char c, int i) { unsigned char uc = c; unsigned int *p = (o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS; int shift = uc % INT_BITS; int r = (*p >> shift) & 1; *p ^= ((i & 1) ^ r) << shift; return r; } /* In O (or in the default if O is null), set the value of the quoting options flag to I, which can be a bitwise combination of enum quoting_flags, or 0 for default behavior. Return the old value. */ int set_quoting_flags (struct quoting_options *o, int i) { int r; if (!o) o = &default_quoting_options; r = o->flags; o->flags = i; return r; } void set_custom_quoting (struct quoting_options *o, char const *left_quote, char const *right_quote) { if (!o) o = &default_quoting_options; o->style = custom_quoting_style; if (!left_quote || !right_quote) abort (); o->left_quote = left_quote; o->right_quote = right_quote; } /* Return quoting options for STYLE, with no extra quoting. */ static struct quoting_options /* NOT PURE!! */ quoting_options_from_style (enum quoting_style style) { struct quoting_options o = { literal_quoting_style, 0, { 0 }, NULL, NULL }; if (style == custom_quoting_style) abort (); o.style = style; return o; } /* MSGID approximates a quotation mark. Return its translation if it has one; otherwise, return either it or "\"", depending on S. S is either clocale_quoting_style or locale_quoting_style. */ static char const * gettext_quote (char const *msgid, enum quoting_style s) { char const *translation = _(msgid); char const *locale_code; if (translation != msgid) return translation; /* For UTF-8 and GB-18030, use single quotes U+2018 and U+2019. Here is a list of other locales that include U+2018 and U+2019: ISO-8859-7 0xA1 KOI8-T 0x91 CP869 0x8B CP874 0x91 CP932 0x81 0x65 CP936 0xA1 0xAE CP949 0xA1 0xAE CP950 0xA1 0xA5 CP1250 0x91 CP1251 0x91 CP1252 0x91 CP1253 0x91 CP1254 0x91 CP1255 0x91 CP1256 0x91 CP1257 0x91 EUC-JP 0xA1 0xC6 EUC-KR 0xA1 0xAE EUC-TW 0xA1 0xE4 BIG5 0xA1 0xA5 BIG5-HKSCS 0xA1 0xA5 EUC-CN 0xA1 0xAE GBK 0xA1 0xAE Georgian-PS 0x91 PT154 0x91 None of these is still in wide use; using iconv is overkill. */ locale_code = locale_charset (); if (STRCASEEQ (locale_code, "UTF-8", 'U','T','F','-','8',0,0,0,0)) return msgid[0] == '`' ? "\xe2\x80\x98": "\xe2\x80\x99"; if (STRCASEEQ (locale_code, "GB18030", 'G','B','1','8','0','3','0',0,0)) return msgid[0] == '`' ? "\xa1\ae": "\xa1\xaf"; return (s == clocale_quoting_style ? "\"" : "'"); } /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of argument ARG (of size ARGSIZE), using QUOTING_STYLE, FLAGS, and QUOTE_THESE_TOO to control quoting. Terminate the output with a null character, and return the written size of the output, not counting the terminating null. If BUFFERSIZE is too small to store the output string, return the value that would have been returned had BUFFERSIZE been large enough. If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE. This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG, ARGSIZE, O), except it breaks O into its component pieces and is not careful about errno. */ static size_t quotearg_buffer_restyled (char *buffer, size_t buffersize, char const *arg, size_t argsize, enum quoting_style quoting_style, int flags, unsigned int const *quote_these_too, char const *left_quote, char const *right_quote) { size_t i; size_t len = 0; char const *quote_string = 0; size_t quote_string_len = 0; bool backslash_escapes = false; bool unibyte_locale = MB_CUR_MAX == 1; bool elide_outer_quotes = (flags & QA_ELIDE_OUTER_QUOTES) != 0; #define STORE(c) \ do \ { \ if (len < buffersize) \ buffer[len] = (c); \ len++; \ } \ while (0) switch (quoting_style) { case c_maybe_quoting_style: quoting_style = c_quoting_style; elide_outer_quotes = true; /* Fall through. */ case c_quoting_style: if (!elide_outer_quotes) STORE ('"'); backslash_escapes = true; quote_string = "\""; quote_string_len = 1; break; case escape_quoting_style: backslash_escapes = true; elide_outer_quotes = false; break; case locale_quoting_style: case clocale_quoting_style: case custom_quoting_style: { if (quoting_style != custom_quoting_style) { /* TRANSLATORS: Get translations for open and closing quotation marks. The message catalog should translate "`" to a left quotation mark suitable for the locale, and similarly for "'". For example, a French Unicode local should translate these to U+00AB (LEFT-POINTING DOUBLE ANGLE QUOTATION MARK), and U+00BB (RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK), respectively. If the catalog has no translation, we will try to use Unicode U+2018 (LEFT SINGLE QUOTATION MARK) and Unicode U+2019 (RIGHT SINGLE QUOTATION MARK). If the current locale is not Unicode, locale_quoting_style will quote 'like this', and clocale_quoting_style will quote "like this". You should always include translations for "`" and "'" even if U+2018 and U+2019 are appropriate for your locale. If you don't know what to put here, please see and use glyphs suitable for your language. */ left_quote = gettext_quote (N_("`"), quoting_style); right_quote = gettext_quote (N_("'"), quoting_style); } if (!elide_outer_quotes) for (quote_string = left_quote; *quote_string; quote_string++) STORE (*quote_string); backslash_escapes = true; quote_string = right_quote; quote_string_len = strlen (quote_string); } break; case shell_quoting_style: quoting_style = shell_always_quoting_style; elide_outer_quotes = true; /* Fall through. */ case shell_always_quoting_style: if (!elide_outer_quotes) STORE ('\''); quote_string = "'"; quote_string_len = 1; break; case literal_quoting_style: elide_outer_quotes = false; break; default: abort (); } for (i = 0; ! (argsize == SIZE_MAX ? arg[i] == '\0' : i == argsize); i++) { unsigned char c; unsigned char esc; bool is_right_quote = false; if (backslash_escapes && quote_string_len && (i + quote_string_len <= (argsize == SIZE_MAX && 1 < quote_string_len /* Use strlen only if we must: when argsize is SIZE_MAX, and when the quote string is more than 1 byte long. If we do call strlen, save the result. */ ? (argsize = strlen (arg)) : argsize)) && memcmp (arg + i, quote_string, quote_string_len) == 0) { if (elide_outer_quotes) goto force_outer_quoting_style; is_right_quote = true; } c = arg[i]; switch (c) { case '\0': if (backslash_escapes) { if (elide_outer_quotes) goto force_outer_quoting_style; STORE ('\\'); /* If quote_string were to begin with digits, we'd need to test for the end of the arg as well. However, it's hard to imagine any locale that would use digits in quotes, and set_custom_quoting is documented not to accept them. */ if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9') { STORE ('0'); STORE ('0'); } c = '0'; /* We don't have to worry that this last '0' will be backslash-escaped because, again, quote_string should not start with it and because quote_these_too is documented as not accepting it. */ } else if (flags & QA_ELIDE_NULL_BYTES) continue; break; case '?': switch (quoting_style) { case shell_always_quoting_style: if (elide_outer_quotes) goto force_outer_quoting_style; break; case c_quoting_style: if ((flags & QA_SPLIT_TRIGRAPHS) && i + 2 < argsize && arg[i + 1] == '?') switch (arg[i + 2]) { case '!': case '\'': case '(': case ')': case '-': case '/': case '<': case '=': case '>': /* Escape the second '?' in what would otherwise be a trigraph. */ if (elide_outer_quotes) goto force_outer_quoting_style; c = arg[i + 2]; i += 2; STORE ('?'); STORE ('"'); STORE ('"'); STORE ('?'); break; default: break; } break; default: break; } break; case '\a': esc = 'a'; goto c_escape; case '\b': esc = 'b'; goto c_escape; case '\f': esc = 'f'; goto c_escape; case '\n': esc = 'n'; goto c_and_shell_escape; case '\r': esc = 'r'; goto c_and_shell_escape; case '\t': esc = 't'; goto c_and_shell_escape; case '\v': esc = 'v'; goto c_escape; case '\\': esc = c; /* No need to escape the escape if we are trying to elide outer quotes and nothing else is problematic. */ if (backslash_escapes && elide_outer_quotes && quote_string_len) goto store_c; c_and_shell_escape: if (quoting_style == shell_always_quoting_style && elide_outer_quotes) goto force_outer_quoting_style; /* Fall through. */ c_escape: if (backslash_escapes) { c = esc; goto store_escape; } break; case '{': case '}': /* sometimes special if isolated */ if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1)) break; /* Fall through. */ case '#': case '~': if (i != 0) break; /* Fall through. */ case ' ': case '!': /* special in bash */ case '"': case '$': case '&': case '(': case ')': case '*': case ';': case '<': case '=': /* sometimes special in 0th or (with "set -k") later args */ case '>': case '[': case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */ case '`': case '|': /* A shell special character. In theory, '$' and '`' could be the first bytes of multibyte characters, which means we should check them with mbrtowc, but in practice this doesn't happen so it's not worth worrying about. */ if (quoting_style == shell_always_quoting_style && elide_outer_quotes) goto force_outer_quoting_style; break; case '\'': if (quoting_style == shell_always_quoting_style) { if (elide_outer_quotes) goto force_outer_quoting_style; STORE ('\''); STORE ('\\'); STORE ('\''); } break; case '%': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case ']': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': /* These characters don't cause problems, no matter what the quoting style is. They cannot start multibyte sequences. A digit or a special letter would cause trouble if it appeared at the beginning of quote_string because we'd then escape by prepending a backslash. However, it's hard to imagine any locale that would use digits or letters as quotes, and set_custom_quoting is documented not to accept them. Also, a digit or a special letter would cause trouble if it appeared in quote_these_too, but that's also documented as not accepting them. */ break; default: /* If we have a multibyte sequence, copy it until we reach its end, find an error, or come back to the initial shift state. For C-like styles, if the sequence has unprintable characters, escape the whole sequence, since we can't easily escape single characters within it. */ { /* Length of multibyte sequence found so far. */ size_t m; bool printable; if (unibyte_locale) { m = 1; printable = isprint (c) != 0; } else { mbstate_t mbstate; memset (&mbstate, 0, sizeof mbstate); m = 0; printable = true; if (argsize == SIZE_MAX) argsize = strlen (arg); do { wchar_t w; size_t bytes = mbrtowc (&w, &arg[i + m], argsize - (i + m), &mbstate); if (bytes == 0) break; else if (bytes == (size_t) -1) { printable = false; break; } else if (bytes == (size_t) -2) { printable = false; while (i + m < argsize && arg[i + m]) m++; break; } else { /* Work around a bug with older shells that "see" a '\' that is really the 2nd byte of a multibyte character. In practice the problem is limited to ASCII chars >= '@' that are shell special chars. */ if ('[' == 0x5b && elide_outer_quotes && quoting_style == shell_always_quoting_style) { size_t j; for (j = 1; j < bytes; j++) switch (arg[i + m + j]) { case '[': case '\\': case '^': case '`': case '|': goto force_outer_quoting_style; default: break; } } if (! iswprint (w)) printable = false; m += bytes; } } while (! mbsinit (&mbstate)); } if (1 < m || (backslash_escapes && ! printable)) { /* Output a multibyte sequence, or an escaped unprintable unibyte character. */ size_t ilim = i + m; for (;;) { if (backslash_escapes && ! printable) { if (elide_outer_quotes) goto force_outer_quoting_style; STORE ('\\'); STORE ('0' + (c >> 6)); STORE ('0' + ((c >> 3) & 7)); c = '0' + (c & 7); } else if (is_right_quote) { STORE ('\\'); is_right_quote = false; } if (ilim <= i + 1) break; STORE (c); c = arg[++i]; } goto store_c; } } } if (! ((backslash_escapes || elide_outer_quotes) && quote_these_too && quote_these_too[c / INT_BITS] >> (c % INT_BITS) & 1) && !is_right_quote) goto store_c; store_escape: if (elide_outer_quotes) goto force_outer_quoting_style; STORE ('\\'); store_c: STORE (c); } if (len == 0 && quoting_style == shell_always_quoting_style && elide_outer_quotes) goto force_outer_quoting_style; if (quote_string && !elide_outer_quotes) for (; *quote_string; quote_string++) STORE (*quote_string); if (len < buffersize) buffer[len] = '\0'; return len; force_outer_quoting_style: /* Don't reuse quote_these_too, since the addition of outer quotes sufficiently quotes the specified characters. */ return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, quoting_style, flags & ~QA_ELIDE_OUTER_QUOTES, NULL, left_quote, right_quote); } /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of argument ARG (of size ARGSIZE), using O to control quoting. If O is null, use the default. Terminate the output with a null character, and return the written size of the output, not counting the terminating null. If BUFFERSIZE is too small to store the output string, return the value that would have been returned had BUFFERSIZE been large enough. If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE. */ size_t quotearg_buffer (char *buffer, size_t buffersize, char const *arg, size_t argsize, struct quoting_options const *o) { struct quoting_options const *p = o ? o : &default_quoting_options; int e = errno; size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize, p->style, p->flags, p->quote_these_too, p->left_quote, p->right_quote); errno = e; return r; } /* Equivalent to quotearg_alloc (ARG, ARGSIZE, NULL, O). */ char * quotearg_alloc (char const *arg, size_t argsize, struct quoting_options const *o) { return quotearg_alloc_mem (arg, argsize, NULL, o); } /* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly allocated storage containing the quoted string, and store the resulting size into *SIZE, if non-NULL. The result can contain embedded null bytes only if ARGSIZE is not SIZE_MAX, SIZE is not NULL, and set_quoting_flags has not set the null byte elision flag. */ char * quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size, struct quoting_options const *o) { struct quoting_options const *p = o ? o : &default_quoting_options; int e = errno; /* Elide embedded null bytes if we can't return a size. */ int flags = p->flags | (size ? 0 : QA_ELIDE_NULL_BYTES); size_t bufsize = quotearg_buffer_restyled (0, 0, arg, argsize, p->style, flags, p->quote_these_too, p->left_quote, p->right_quote) + 1; char *buf = xcharalloc (bufsize); quotearg_buffer_restyled (buf, bufsize, arg, argsize, p->style, flags, p->quote_these_too, p->left_quote, p->right_quote); errno = e; if (size) *size = bufsize - 1; return buf; } /* A storage slot with size and pointer to a value. */ struct slotvec { size_t size; char *val; }; /* Preallocate a slot 0 buffer, so that the caller can always quote one small component of a "memory exhausted" message in slot 0. */ static char slot0[256]; static unsigned int nslots = 1; static struct slotvec slotvec0 = {sizeof slot0, slot0}; static struct slotvec *slotvec = &slotvec0; void quotearg_free (void) { struct slotvec *sv = slotvec; unsigned int i; for (i = 1; i < nslots; i++) free (sv[i].val); if (sv[0].val != slot0) { free (sv[0].val); slotvec0.size = sizeof slot0; slotvec0.val = slot0; } if (sv != &slotvec0) { free (sv); slotvec = &slotvec0; } nslots = 1; } /* Use storage slot N to return a quoted version of argument ARG. ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a null-terminated string. OPTIONS specifies the quoting options. The returned value points to static storage that can be reused by the next call to this function with the same value of N. N must be nonnegative. N is deliberately declared with type "int" to allow for future extensions (using negative values). */ static char * quotearg_n_options (int n, char const *arg, size_t argsize, struct quoting_options const *options) { int e = errno; unsigned int n0 = n; struct slotvec *sv = slotvec; if (n < 0) abort (); if (nslots <= n0) { /* FIXME: technically, the type of n1 should be 'unsigned int', but that evokes an unsuppressible warning from gcc-4.0.1 and older. If gcc ever provides an option to suppress that warning, revert to the original type, so that the test in xalloc_oversized is once again performed only at compile time. */ size_t n1 = n0 + 1; bool preallocated = (sv == &slotvec0); if (xalloc_oversized (n1, sizeof *sv)) xalloc_die (); slotvec = sv = xrealloc (preallocated ? NULL : sv, n1 * sizeof *sv); if (preallocated) *sv = slotvec0; memset (sv + nslots, 0, (n1 - nslots) * sizeof *sv); nslots = n1; } { size_t size = sv[n].size; char *val = sv[n].val; /* Elide embedded null bytes since we don't return a size. */ int flags = options->flags | QA_ELIDE_NULL_BYTES; size_t qsize = quotearg_buffer_restyled (val, size, arg, argsize, options->style, flags, options->quote_these_too, options->left_quote, options->right_quote); if (size <= qsize) { sv[n].size = size = qsize + 1; if (val != slot0) free (val); sv[n].val = val = xcharalloc (size); quotearg_buffer_restyled (val, size, arg, argsize, options->style, flags, options->quote_these_too, options->left_quote, options->right_quote); } errno = e; return val; } } char * quotearg_n (int n, char const *arg) { return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options); } char * quotearg_n_mem (int n, char const *arg, size_t argsize) { return quotearg_n_options (n, arg, argsize, &default_quoting_options); } char * quotearg (char const *arg) { return quotearg_n (0, arg); } char * quotearg_mem (char const *arg, size_t argsize) { return quotearg_n_mem (0, arg, argsize); } char * quotearg_n_style (int n, enum quoting_style s, char const *arg) { struct quoting_options const o = quoting_options_from_style (s); return quotearg_n_options (n, arg, SIZE_MAX, &o); } char * quotearg_n_style_mem (int n, enum quoting_style s, char const *arg, size_t argsize) { struct quoting_options const o = quoting_options_from_style (s); return quotearg_n_options (n, arg, argsize, &o); } char * quotearg_style (enum quoting_style s, char const *arg) { return quotearg_n_style (0, s, arg); } char * quotearg_style_mem (enum quoting_style s, char const *arg, size_t argsize) { return quotearg_n_style_mem (0, s, arg, argsize); } char * quotearg_char_mem (char const *arg, size_t argsize, char ch) { struct quoting_options options; options = default_quoting_options; set_char_quoting (&options, ch, 1); return quotearg_n_options (0, arg, argsize, &options); } char * quotearg_char (char const *arg, char ch) { return quotearg_char_mem (arg, SIZE_MAX, ch); } char * quotearg_colon (char const *arg) { return quotearg_char (arg, ':'); } char * quotearg_colon_mem (char const *arg, size_t argsize) { return quotearg_char_mem (arg, argsize, ':'); } char * quotearg_n_custom (int n, char const *left_quote, char const *right_quote, char const *arg) { return quotearg_n_custom_mem (n, left_quote, right_quote, arg, SIZE_MAX); } char * quotearg_n_custom_mem (int n, char const *left_quote, char const *right_quote, char const *arg, size_t argsize) { struct quoting_options o = default_quoting_options; set_custom_quoting (&o, left_quote, right_quote); return quotearg_n_options (n, arg, argsize, &o); } char * quotearg_custom (char const *left_quote, char const *right_quote, char const *arg) { return quotearg_n_custom (0, left_quote, right_quote, arg); } char * quotearg_custom_mem (char const *left_quote, char const *right_quote, char const *arg, size_t argsize) { return quotearg_n_custom_mem (0, left_quote, right_quote, arg, argsize); } /* The quoting option used by the functions of quote.h. */ struct quoting_options quote_quoting_options = { locale_quoting_style, 0, { 0 }, NULL, NULL }; char const * quote_n_mem (int n, char const *arg, size_t argsize) { return quotearg_n_options (n, arg, argsize, "e_quoting_options); } char const * quote_mem (char const *arg, size_t argsize) { return quote_n_mem (0, arg, argsize); } char const * quote_n (int n, char const *arg) { return quote_n_mem (n, arg, SIZE_MAX); } char const * quote (char const *arg) { return quote_n (0, arg); } lftp-4.6.3a/lib/unsetenv.c0000644000015000007670000000547212466374012012351 00000000000000/* Copyright (C) 1992, 1995-2002, 2005-2015 Free Software Foundation, Inc. This file is part of 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 . */ /* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc optimizes away the name == NULL test below. */ #define _GL_ARG_NONNULL(params) #include /* Specification. */ #include #include #if !_LIBC # define __set_errno(ev) ((errno) = (ev)) #endif #include #include #if !_LIBC # define __environ environ #endif #if _LIBC /* This lock protects against simultaneous modifications of 'environ'. */ # include __libc_lock_define_initialized (static, envlock) # define LOCK __libc_lock_lock (envlock) # define UNLOCK __libc_lock_unlock (envlock) #else # define LOCK # define UNLOCK #endif /* In the GNU C library we must keep the namespace clean. */ #ifdef _LIBC # define unsetenv __unsetenv #endif #if _LIBC || !HAVE_UNSETENV int unsetenv (const char *name) { size_t len; char **ep; if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) { __set_errno (EINVAL); return -1; } len = strlen (name); LOCK; ep = __environ; while (*ep != NULL) if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { /* Found it. Remove this pointer by moving later ones back. */ char **dp = ep; do dp[0] = dp[1]; while (*dp++); /* Continue the loop in case NAME appears again. */ } else ++ep; UNLOCK; return 0; } #ifdef _LIBC # undef unsetenv weak_alias (__unsetenv, unsetenv) #endif #else /* HAVE_UNSETENV */ # undef unsetenv # if !HAVE_DECL_UNSETENV # if VOID_UNSETENV extern void unsetenv (const char *); # else extern int unsetenv (const char *); # endif # endif /* Call the underlying unsetenv, in case there is hidden bookkeeping that needs updating beyond just modifying environ. */ int rpl_unsetenv (const char *name) { int result = 0; if (!name || !*name || strchr (name, '=')) { errno = EINVAL; return -1; } while (getenv (name)) # if !VOID_UNSETENV result = # endif unsetenv (name); return result; } #endif /* HAVE_UNSETENV */ lftp-4.6.3a/lib/dirent-private.h0000644000015000007670000000275512466374011013444 00000000000000/* Private details of the DIR type. Copyright (C) 2011-2015 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 . */ #ifndef _DIRENT_PRIVATE_H #define _DIRENT_PRIVATE_H 1 #define WIN32_LEAN_AND_MEAN #include struct gl_directory { /* Status, or error code to produce in next readdir() call. -2 means the end of the directory is already reached, -1 means the entry was already filled by FindFirstFile, 0 means the entry needs to be filled using FindNextFile. A positive value is an error code. */ int status; /* Handle, reading the directory, at current position. */ HANDLE current; /* Found directory entry. */ WIN32_FIND_DATA entry; /* Argument to pass to FindFirstFile. It consists of the absolutized directory name, followed by a directory separator and the wildcards. */ char dir_name_mask[1]; }; #endif /* _DIRENT_PRIVATE_H */ lftp-4.6.3a/lib/stat.c0000644000015000007670000001066612466374012011456 00000000000000/* Work around platform bugs in stat. Copyright (C) 2009-2015 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 . */ /* written by Eric Blake */ /* If the user's config.h happens to include , let it include only the system's here, so that orig_stat doesn't recurse to rpl_stat. */ #define __need_system_sys_stat_h #include /* Get the original definition of stat. It might be defined as a macro. */ #include #include #undef __need_system_sys_stat_h #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # if _GL_WINDOWS_64_BIT_ST_SIZE # undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ # define stat _stati64 # define REPLACE_FUNC_STAT_DIR 1 # undef REPLACE_FUNC_STAT_FILE # elif REPLACE_FUNC_STAT_FILE /* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a. Bypass it. */ # define stat _stat # define REPLACE_FUNC_STAT_DIR 1 # undef REPLACE_FUNC_STAT_FILE # endif #endif static int orig_stat (const char *filename, struct stat *buf) { return stat (filename, buf); } /* Specification. */ /* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ #include "sys/stat.h" #include #include #include #include #include "dosname.h" #include "verify.h" #if REPLACE_FUNC_STAT_DIR # include "pathmax.h" /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also have a constant PATH_MAX. */ # ifndef PATH_MAX # error "Please port this replacement to your platform" # endif #endif /* Store information about NAME into ST. Work around bugs with trailing slashes. Mingw has other bugs (such as st_ino always being 0 on success) which this wrapper does not work around. But at least this implementation provides the ability to emulate fchdir correctly. */ int rpl_stat (char const *name, struct stat *st) { int result = orig_stat (name, st); #if REPLACE_FUNC_STAT_FILE /* Solaris 9 mistakenly succeeds when given a non-directory with a trailing slash. */ if (result == 0 && !S_ISDIR (st->st_mode)) { size_t len = strlen (name); if (ISSLASH (name[len - 1])) { errno = ENOTDIR; return -1; } } #endif /* REPLACE_FUNC_STAT_FILE */ #if REPLACE_FUNC_STAT_DIR if (result == -1 && errno == ENOENT) { /* Due to mingw's oddities, there are some directories (like c:\) where stat() only succeeds with a trailing slash, and other directories (like c:\windows) where stat() only succeeds without a trailing slash. But we want the two to be synonymous, since chdir() manages either style. Likewise, Mingw also reports ENOENT for names longer than PATH_MAX, when we want ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR. Fortunately, mingw PATH_MAX is small enough for stack allocation. */ char fixed_name[PATH_MAX + 1] = {0}; size_t len = strlen (name); bool check_dir = false; verify (PATH_MAX <= 4096); if (PATH_MAX <= len) errno = ENAMETOOLONG; else if (len) { strcpy (fixed_name, name); if (ISSLASH (fixed_name[len - 1])) { check_dir = true; while (len && ISSLASH (fixed_name[len - 1])) fixed_name[--len] = '\0'; if (!len) fixed_name[0] = '/'; } else fixed_name[len++] = '/'; result = orig_stat (fixed_name, st); if (result == 0 && check_dir && !S_ISDIR (st->st_mode)) { result = -1; errno = ENOTDIR; } } } #endif /* REPLACE_FUNC_STAT_DIR */ return result; } lftp-4.6.3a/lib/stat-macros.h0000644000015000007670000000022012122621313012712 00000000000000/* All the mode bits that can be affected by chmod. */ #define CHMOD_MODE_BITS \ (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) lftp-4.6.3a/lib/strftime.c0000644000015000007670000013631012466374012012333 00000000000000/* Copyright (C) 1991-2001, 2003-2007, 2009-2015 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. 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 . */ #ifdef _LIBC # define HAVE_STRUCT_ERA_ENTRY 1 # define HAVE_TM_GMTOFF 1 # define HAVE_TM_ZONE 1 # define HAVE_TZNAME 1 # define HAVE_TZSET 1 # include "../locale/localeinfo.h" #else # include # if FPRINTFTIME # include "fprintftime.h" # else # include "strftime.h" # endif #endif #include #include #if HAVE_TZNAME && !HAVE_DECL_TZNAME extern char *tzname[]; #endif /* Do multibyte processing if multibyte encodings are supported, unless multibyte sequences are safe in formats. Multibyte sequences are safe if they cannot contain byte sequences that look like format conversion specifications. The multibyte encodings used by the C library on the various platforms (UTF-8, GB2312, GBK, CP936, GB18030, EUC-TW, BIG5, BIG5-HKSCS, CP950, EUC-JP, EUC-KR, CP949, SHIFT_JIS, CP932, JOHAB) are safe for formats, because the byte '%' cannot occur in a multibyte character except in the first byte. The DEC-HANYU encoding used on OSF/1 is not safe for formats, but this encoding has never been seen in real-life use, so we ignore it. */ #if !(defined __osf__ && 0) # define MULTIBYTE_IS_FORMAT_SAFE 1 #endif #define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE) #if DO_MULTIBYTE # include static const mbstate_t mbstate_zero; #endif #include #include #include #include #include #ifdef COMPILE_WIDE # include # define CHAR_T wchar_t # define UCHAR_T unsigned int # define L_(Str) L##Str # define NLW(Sym) _NL_W##Sym # define MEMCPY(d, s, n) __wmemcpy (d, s, n) # define STRLEN(s) __wcslen (s) #else # define CHAR_T char # define UCHAR_T unsigned char # define L_(Str) Str # define NLW(Sym) Sym # define MEMCPY(d, s, n) memcpy (d, s, n) # define STRLEN(s) strlen (s) #endif /* Shift A right by B bits portably, by dividing A by 2**B and truncating towards minus infinity. A and B should be free of side effects, and B should be in the range 0 <= B <= INT_BITS - 2, where INT_BITS is the number of useful bits in an int. GNU code can assume that INT_BITS is at least 32. ISO C99 says that A >> B is implementation-defined if A < 0. Some implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ #define SHR(a, b) \ (-1 >> 1 == -1 \ ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) /* Bound on length of the string representing an integer type or expression T. Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485; add 1 for integer division truncation; add 1 more for a minus sign if needed. */ #define INT_STRLEN_BOUND(t) \ ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2) #define TM_YEAR_BASE 1900 #ifndef __isleap /* Nonzero if YEAR is a leap year (every 4 years, except every 100th isn't, and every 400th is). */ # define __isleap(year) \ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) #endif #ifdef _LIBC # define tzname __tzname # define tzset __tzset #endif #if !HAVE_TM_GMTOFF /* Portable standalone applications should supply a "time.h" that declares a POSIX-compliant localtime_r, for the benefit of older implementations that lack localtime_r or have a nonstandard one. See the gnulib time_r module for one way to implement this. */ # undef __gmtime_r # undef __localtime_r # define __gmtime_r gmtime_r # define __localtime_r localtime_r #endif #ifndef FPRINTFTIME # define FPRINTFTIME 0 #endif #if FPRINTFTIME # define STREAM_OR_CHAR_T FILE # define STRFTIME_ARG(x) /* empty */ #else # define STREAM_OR_CHAR_T CHAR_T # define STRFTIME_ARG(x) x, #endif #if FPRINTFTIME # define memset_byte(P, Len, Byte) \ do { size_t _i; for (_i = 0; _i < Len; _i++) fputc (Byte, P); } while (0) # define memset_space(P, Len) memset_byte (P, Len, ' ') # define memset_zero(P, Len) memset_byte (P, Len, '0') #elif defined COMPILE_WIDE # define memset_space(P, Len) (wmemset (P, L' ', Len), (P) += (Len)) # define memset_zero(P, Len) (wmemset (P, L'0', Len), (P) += (Len)) #else # define memset_space(P, Len) (memset (P, ' ', Len), (P) += (Len)) # define memset_zero(P, Len) (memset (P, '0', Len), (P) += (Len)) #endif #if FPRINTFTIME # define advance(P, N) #else # define advance(P, N) ((P) += (N)) #endif #define add(n, f) \ do \ { \ size_t _n = (n); \ size_t _w = (width < 0 ? 0 : width); \ size_t _incr = _n < _w ? _w : _n; \ if (_incr >= maxsize - i) \ return 0; \ if (p) \ { \ if (digits == 0 && _n < _w) \ { \ size_t _delta = width - _n; \ if (pad == L_('0')) \ memset_zero (p, _delta); \ else \ memset_space (p, _delta); \ } \ f; \ advance (p, _n); \ } \ i += _incr; \ } while (0) #if FPRINTFTIME # define add1(C) add (1, fputc (C, p)) #else # define add1(C) add (1, *p = C) #endif #if FPRINTFTIME # define cpy(n, s) \ add ((n), \ do \ { \ if (to_lowcase) \ fwrite_lowcase (p, (s), _n); \ else if (to_uppcase) \ fwrite_uppcase (p, (s), _n); \ else \ { \ /* Ignore the value of fwrite. The caller can determine whether \ an error occurred by inspecting ferror (P). All known fwrite \ implementations set the stream's error indicator when they \ fail due to ENOMEM etc., even though C11 and POSIX.1-2008 do \ not require this. */ \ fwrite (s, _n, 1, p); \ } \ } \ while (0) \ ) #else # define cpy(n, s) \ add ((n), \ if (to_lowcase) \ memcpy_lowcase (p, (s), _n LOCALE_ARG); \ else if (to_uppcase) \ memcpy_uppcase (p, (s), _n LOCALE_ARG); \ else \ MEMCPY ((void *) p, (void const *) (s), _n)) #endif #ifdef COMPILE_WIDE # ifndef USE_IN_EXTENDED_LOCALE_MODEL # undef __mbsrtowcs_l # define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st) # endif # define widen(os, ws, l) \ { \ mbstate_t __st; \ const char *__s = os; \ memset (&__st, '\0', sizeof (__st)); \ l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \ ws = (wchar_t *) alloca ((l + 1) * sizeof (wchar_t)); \ (void) __mbsrtowcs_l (ws, &__s, l, &__st, loc); \ } #endif #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL /* We use this code also for the extended locale handling where the function gets as an additional argument the locale which has to be used. To access the values we have to redefine the _NL_CURRENT macro. */ # define strftime __strftime_l # define wcsftime __wcsftime_l # undef _NL_CURRENT # define _NL_CURRENT(category, item) \ (current->values[_NL_ITEM_INDEX (item)].string) # define LOCALE_ARG , loc # define LOCALE_PARAM_PROTO , __locale_t loc # define HELPER_LOCALE_ARG , current #else # define LOCALE_PARAM_PROTO # define LOCALE_ARG # ifdef _LIBC # define HELPER_LOCALE_ARG , _NL_CURRENT_DATA (LC_TIME) # else # define HELPER_LOCALE_ARG # endif #endif #ifdef COMPILE_WIDE # ifdef USE_IN_EXTENDED_LOCALE_MODEL # define TOUPPER(Ch, L) __towupper_l (Ch, L) # define TOLOWER(Ch, L) __towlower_l (Ch, L) # else # define TOUPPER(Ch, L) towupper (Ch) # define TOLOWER(Ch, L) towlower (Ch) # endif #else # ifdef USE_IN_EXTENDED_LOCALE_MODEL # define TOUPPER(Ch, L) __toupper_l (Ch, L) # define TOLOWER(Ch, L) __tolower_l (Ch, L) # else # define TOUPPER(Ch, L) toupper (Ch) # define TOLOWER(Ch, L) tolower (Ch) # endif #endif /* We don't use 'isdigit' here since the locale dependent interpretation is not what we want here. We only need to accept the arabic digits in the ASCII range. One day there is perhaps a more reliable way to accept other sets of digits. */ #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) #if FPRINTFTIME static void fwrite_lowcase (FILE *fp, const CHAR_T *src, size_t len) { while (len-- > 0) { fputc (TOLOWER ((UCHAR_T) *src, loc), fp); ++src; } } static void fwrite_uppcase (FILE *fp, const CHAR_T *src, size_t len) { while (len-- > 0) { fputc (TOUPPER ((UCHAR_T) *src, loc), fp); ++src; } } #else static CHAR_T * memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_PROTO) { while (len-- > 0) dest[len] = TOLOWER ((UCHAR_T) src[len], loc); return dest; } static CHAR_T * memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_PROTO) { while (len-- > 0) dest[len] = TOUPPER ((UCHAR_T) src[len], loc); return dest; } #endif #if ! HAVE_TM_GMTOFF /* Yield the difference between *A and *B, measured in seconds, ignoring leap seconds. */ # define tm_diff ftime_tm_diff static int tm_diff (const struct tm *a, const struct tm *b) { /* Compute intervening leap days correctly even if year is negative. Take care to avoid int overflow in leap day calculations, but it's OK to assume that A and B are close to each other. */ int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); int a100 = a4 / 25 - (a4 % 25 < 0); int b100 = b4 / 25 - (b4 % 25 < 0); int a400 = SHR (a100, 2); int b400 = SHR (b100, 2); int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); int years = a->tm_year - b->tm_year; int days = (365 * years + intervening_leap_days + (a->tm_yday - b->tm_yday)); return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); } #endif /* ! HAVE_TM_GMTOFF */ /* The number of days from the first day of the first ISO week of this year to the year day YDAY with week day WDAY. ISO weeks start on Monday; the first ISO week has the year's first Thursday. YDAY may be as small as YDAY_MINIMUM. */ #define ISO_WEEK_START_WDAY 1 /* Monday */ #define ISO_WEEK1_WDAY 4 /* Thursday */ #define YDAY_MINIMUM (-366) #ifdef __GNUC__ __inline__ #endif static int iso_week_days (int yday, int wday) { /* Add enough to the first operand of % to make it nonnegative. */ int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; return (yday - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); } /* When compiling this file, GNU applications can #define my_strftime to a symbol (typically nstrftime) to get an extended strftime with extra arguments UT and NS. Emacs is a special case for now, but this Emacs-specific code can be removed once Emacs's config.h defines my_strftime. */ #if defined emacs && !defined my_strftime # define my_strftime nstrftime #endif #if FPRINTFTIME # undef my_strftime # define my_strftime fprintftime #endif #ifdef my_strftime # define extra_args , ut, ns # define extra_args_spec , int ut, int ns #else # if defined COMPILE_WIDE # define my_strftime wcsftime # define nl_get_alt_digit _nl_get_walt_digit # else # define my_strftime strftime # define nl_get_alt_digit _nl_get_alt_digit # endif # define extra_args # define extra_args_spec /* We don't have this information in general. */ # define ut 0 # define ns 0 #endif /* Just like my_strftime, below, but with one more parameter, UPCASE, to indicate that the result should be converted to upper case. */ static size_t strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) const CHAR_T *format, const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) { #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL struct locale_data *const current = loc->__locales[LC_TIME]; #endif #if FPRINTFTIME size_t maxsize = (size_t) -1; #endif int hour12 = tp->tm_hour; #ifdef _NL_CURRENT /* We cannot make the following values variables since we must delay the evaluation of these values until really needed since some expressions might not be valid in every situation. The 'struct tm' might be generated by a strptime() call that initialized only a few elements. Dereference the pointers only if the format requires this. Then it is ok to fail if the pointers are invalid. */ # define a_wkday \ ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday)) # define f_wkday \ ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday)) # define a_month \ ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon)) # define f_month \ ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)) # define ampm \ ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ ? NLW(PM_STR) : NLW(AM_STR))) # define aw_len STRLEN (a_wkday) # define am_len STRLEN (a_month) # define ap_len STRLEN (ampm) #endif const char *zone; size_t i = 0; STREAM_OR_CHAR_T *p = s; const CHAR_T *f; #if DO_MULTIBYTE && !defined COMPILE_WIDE const char *format_end = NULL; #endif #if ! defined _LIBC && ! HAVE_RUN_TZSET_TEST /* Solaris 2.5.x and 2.6 tzset sometimes modify the storage returned by localtime. On such systems, we must either use the tzset and localtime wrappers to work around the bug (which sets HAVE_RUN_TZSET_TEST) or make a copy of the structure. */ struct tm copy = *tp; tp = © #endif zone = NULL; #if HAVE_TM_ZONE /* The POSIX test suite assumes that setting the environment variable TZ to a new value before calling strftime() will influence the result (the %Z format) even if the information in TP is computed with a totally different time zone. This is bogus: though POSIX allows bad behavior like this, POSIX does not require it. Do the right thing instead. */ zone = (const char *) tp->tm_zone; #endif #if HAVE_TZNAME if (ut) { if (! (zone && *zone)) zone = "GMT"; } else { /* POSIX.1 requires that local time zone information be used as though strftime called tzset. */ # if HAVE_TZSET tzset (); # endif } #endif if (hour12 > 12) hour12 -= 12; else if (hour12 == 0) hour12 = 12; for (f = format; *f != '\0'; ++f) { int pad = 0; /* Padding for number ('-', '_', or 0). */ int modifier; /* Field modifier ('E', 'O', or 0). */ int digits = 0; /* Max digits for numeric format. */ int number_value; /* Numeric value to be printed. */ unsigned int u_number_value; /* (unsigned int) number_value. */ bool negative_number; /* The number is negative. */ bool always_output_a_sign; /* +/- should always be output. */ int tz_colon_mask; /* Bitmask of where ':' should appear. */ const CHAR_T *subfmt; CHAR_T sign_char; CHAR_T *bufp; CHAR_T buf[1 + 2 /* for the two colons in a %::z or %:::z time zone */ + (sizeof (int) < sizeof (time_t) ? INT_STRLEN_BOUND (time_t) : INT_STRLEN_BOUND (int))]; int width = -1; bool to_lowcase = false; bool to_uppcase = upcase; size_t colons; bool change_case = false; int format_char; #if DO_MULTIBYTE && !defined COMPILE_WIDE switch (*f) { case L_('%'): break; case L_('\b'): case L_('\t'): case L_('\n'): case L_('\v'): case L_('\f'): case L_('\r'): case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'): case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'): case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'): case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'): case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'): case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'): case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'): case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'): case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'): case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'): case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'): case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'): case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'): case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'): case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'): case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'): case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'): case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'): case L_('~'): /* The C Standard requires these 98 characters (plus '%') to be in the basic execution character set. None of these characters can start a multibyte sequence, so they need not be analyzed further. */ add1 (*f); continue; default: /* Copy this multibyte sequence until we reach its end, find an error, or come back to the initial shift state. */ { mbstate_t mbstate = mbstate_zero; size_t len = 0; size_t fsize; if (! format_end) format_end = f + strlen (f) + 1; fsize = format_end - f; do { size_t bytes = mbrlen (f + len, fsize - len, &mbstate); if (bytes == 0) break; if (bytes == (size_t) -2) { len += strlen (f + len); break; } if (bytes == (size_t) -1) { len++; break; } len += bytes; } while (! mbsinit (&mbstate)); cpy (len, f); f += len - 1; continue; } } #else /* ! DO_MULTIBYTE */ /* Either multibyte encodings are not supported, they are safe for formats, so any non-'%' byte can be copied through, or this is the wide character version. */ if (*f != L_('%')) { add1 (*f); continue; } #endif /* ! DO_MULTIBYTE */ /* Check for flags that can modify a format. */ while (1) { switch (*++f) { /* This influences the number formats. */ case L_('_'): case L_('-'): case L_('0'): pad = *f; continue; /* This changes textual output. */ case L_('^'): to_uppcase = true; continue; case L_('#'): change_case = true; continue; default: break; } break; } /* As a GNU extension we allow to specify the field width. */ if (ISDIGIT (*f)) { width = 0; do { if (width > INT_MAX / 10 || (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10)) /* Avoid overflow. */ width = INT_MAX; else { width *= 10; width += *f - L_('0'); } ++f; } while (ISDIGIT (*f)); } /* Check for modifiers. */ switch (*f) { case L_('E'): case L_('O'): modifier = *f++; break; default: modifier = 0; break; } /* Now do the specified format. */ format_char = *f; switch (format_char) { #define DO_NUMBER(d, v) \ do \ { \ digits = d; \ number_value = v; \ goto do_number; \ } \ while (0) #define DO_SIGNED_NUMBER(d, negative, v) \ do \ { \ digits = d; \ negative_number = negative; \ u_number_value = v; \ goto do_signed_number; \ } \ while (0) /* The mask is not what you might think. When the ordinal i'th bit is set, insert a colon before the i'th digit of the time zone representation. */ #define DO_TZ_OFFSET(d, negative, mask, v) \ do \ { \ digits = d; \ negative_number = negative; \ tz_colon_mask = mask; \ u_number_value = v; \ goto do_tz_offset; \ } \ while (0) #define DO_NUMBER_SPACEPAD(d, v) \ do \ { \ digits = d; \ number_value = v; \ goto do_number_spacepad; \ } \ while (0) case L_('%'): if (modifier != 0) goto bad_format; add1 (*f); break; case L_('a'): if (modifier != 0) goto bad_format; if (change_case) { to_uppcase = true; to_lowcase = false; } #ifdef _NL_CURRENT cpy (aw_len, a_wkday); break; #else goto underlying_strftime; #endif case 'A': if (modifier != 0) goto bad_format; if (change_case) { to_uppcase = true; to_lowcase = false; } #ifdef _NL_CURRENT cpy (STRLEN (f_wkday), f_wkday); break; #else goto underlying_strftime; #endif case L_('b'): case L_('h'): if (change_case) { to_uppcase = true; to_lowcase = false; } if (modifier != 0) goto bad_format; #ifdef _NL_CURRENT cpy (am_len, a_month); break; #else goto underlying_strftime; #endif case L_('B'): if (modifier != 0) goto bad_format; if (change_case) { to_uppcase = true; to_lowcase = false; } #ifdef _NL_CURRENT cpy (STRLEN (f_month), f_month); break; #else goto underlying_strftime; #endif case L_('c'): if (modifier == L_('O')) goto bad_format; #ifdef _NL_CURRENT if (! (modifier == 'E' && (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_D_T_FMT))) != '\0'))) subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); #else goto underlying_strftime; #endif subformat: { size_t len = strftime_case_ (to_uppcase, NULL, STRFTIME_ARG ((size_t) -1) subfmt, tp extra_args LOCALE_ARG); add (len, strftime_case_ (to_uppcase, p, STRFTIME_ARG (maxsize - i) subfmt, tp extra_args LOCALE_ARG)); } break; #if !(defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY) underlying_strftime: { /* The relevant information is available only via the underlying strftime implementation, so use that. */ char ufmt[5]; char *u = ufmt; char ubuf[1024]; /* enough for any single format in practice */ size_t len; /* Make sure we're calling the actual underlying strftime. In some cases, config.h contains something like "#define strftime rpl_strftime". */ # ifdef strftime # undef strftime size_t strftime (); # endif /* The space helps distinguish strftime failure from empty output. */ *u++ = ' '; *u++ = '%'; if (modifier != 0) *u++ = modifier; *u++ = format_char; *u = '\0'; len = strftime (ubuf, sizeof ubuf, ufmt, tp); if (len != 0) cpy (len - 1, ubuf + 1); } break; #endif case L_('C'): if (modifier == L_('O')) goto bad_format; if (modifier == L_('E')) { #if HAVE_STRUCT_ERA_ENTRY struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); if (era) { # ifdef COMPILE_WIDE size_t len = __wcslen (era->era_wname); cpy (len, era->era_wname); # else size_t len = strlen (era->era_name); cpy (len, era->era_name); # endif break; } #else goto underlying_strftime; #endif } { int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; century -= tp->tm_year % 100 < 0 && 0 < century; DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century); } case L_('x'): if (modifier == L_('O')) goto bad_format; #ifdef _NL_CURRENT if (! (modifier == L_('E') && (*(subfmt = (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) != L_('\0')))) subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); goto subformat; #else goto underlying_strftime; #endif case L_('D'): if (modifier != 0) goto bad_format; subfmt = L_("%m/%d/%y"); goto subformat; case L_('d'): if (modifier == L_('E')) goto bad_format; DO_NUMBER (2, tp->tm_mday); case L_('e'): if (modifier == L_('E')) goto bad_format; DO_NUMBER_SPACEPAD (2, tp->tm_mday); /* All numeric formats set DIGITS and NUMBER_VALUE (or U_NUMBER_VALUE) and then jump to one of these labels. */ do_tz_offset: always_output_a_sign = true; goto do_number_body; do_number_spacepad: /* Force '_' flag unless overridden by '0' or '-' flag. */ if (pad != L_('0') && pad != L_('-')) pad = L_('_'); do_number: /* Format NUMBER_VALUE according to the MODIFIER flag. */ negative_number = number_value < 0; u_number_value = number_value; do_signed_number: always_output_a_sign = false; tz_colon_mask = 0; do_number_body: /* Format U_NUMBER_VALUE according to the MODIFIER flag. NEGATIVE_NUMBER is nonzero if the original number was negative; in this case it was converted directly to unsigned int (i.e., modulo (UINT_MAX + 1)) without negating it. */ if (modifier == L_('O') && !negative_number) { #ifdef _NL_CURRENT /* Get the locale specific alternate representation of the number. If none exist NULL is returned. */ const CHAR_T *cp = nl_get_alt_digit (u_number_value HELPER_LOCALE_ARG); if (cp != NULL) { size_t digitlen = STRLEN (cp); if (digitlen != 0) { cpy (digitlen, cp); break; } } #else goto underlying_strftime; #endif } bufp = buf + sizeof (buf) / sizeof (buf[0]); if (negative_number) u_number_value = - u_number_value; do { if (tz_colon_mask & 1) *--bufp = ':'; tz_colon_mask >>= 1; *--bufp = u_number_value % 10 + L_('0'); u_number_value /= 10; } while (u_number_value != 0 || tz_colon_mask != 0); do_number_sign_and_padding: if (digits < width) digits = width; sign_char = (negative_number ? L_('-') : always_output_a_sign ? L_('+') : 0); if (pad == L_('-')) { if (sign_char) add1 (sign_char); } else { int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0])) - bufp) - !!sign_char; if (padding > 0) { if (pad == L_('_')) { if ((size_t) padding >= maxsize - i) return 0; if (p) memset_space (p, padding); i += padding; width = width > padding ? width - padding : 0; if (sign_char) add1 (sign_char); } else { if ((size_t) digits >= maxsize - i) return 0; if (sign_char) add1 (sign_char); if (p) memset_zero (p, padding); i += padding; width = 0; } } else { if (sign_char) add1 (sign_char); } } cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp); break; case L_('F'): if (modifier != 0) goto bad_format; subfmt = L_("%Y-%m-%d"); goto subformat; case L_('H'): if (modifier == L_('E')) goto bad_format; DO_NUMBER (2, tp->tm_hour); case L_('I'): if (modifier == L_('E')) goto bad_format; DO_NUMBER (2, hour12); case L_('k'): /* GNU extension. */ if (modifier == L_('E')) goto bad_format; DO_NUMBER_SPACEPAD (2, tp->tm_hour); case L_('l'): /* GNU extension. */ if (modifier == L_('E')) goto bad_format; DO_NUMBER_SPACEPAD (2, hour12); case L_('j'): if (modifier == L_('E')) goto bad_format; DO_SIGNED_NUMBER (3, tp->tm_yday < -1, tp->tm_yday + 1U); case L_('M'): if (modifier == L_('E')) goto bad_format; DO_NUMBER (2, tp->tm_min); case L_('m'): if (modifier == L_('E')) goto bad_format; DO_SIGNED_NUMBER (2, tp->tm_mon < -1, tp->tm_mon + 1U); #ifndef _LIBC case L_('N'): /* GNU extension. */ if (modifier == L_('E')) goto bad_format; number_value = ns; if (width == -1) width = 9; else { /* Take an explicit width less than 9 as a precision. */ int j; for (j = width; j < 9; j++) number_value /= 10; } DO_NUMBER (width, number_value); #endif case L_('n'): add1 (L_('\n')); break; case L_('P'): to_lowcase = true; #ifndef _NL_CURRENT format_char = L_('p'); #endif /* FALLTHROUGH */ case L_('p'): if (change_case) { to_uppcase = false; to_lowcase = true; } #ifdef _NL_CURRENT cpy (ap_len, ampm); break; #else goto underlying_strftime; #endif case L_('R'): subfmt = L_("%H:%M"); goto subformat; case L_('r'): #ifdef _NL_CURRENT if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT_AMPM))) == L_('\0')) subfmt = L_("%I:%M:%S %p"); goto subformat; #else goto underlying_strftime; #endif case L_('S'): if (modifier == L_('E')) goto bad_format; DO_NUMBER (2, tp->tm_sec); case L_('s'): /* GNU extension. */ { struct tm ltm; time_t t; ltm = *tp; t = mktime (<m); /* Generate string value for T using time_t arithmetic; this works even if sizeof (long) < sizeof (time_t). */ bufp = buf + sizeof (buf) / sizeof (buf[0]); negative_number = t < 0; do { int d = t % 10; t /= 10; *--bufp = (negative_number ? -d : d) + L_('0'); } while (t != 0); digits = 1; always_output_a_sign = false; goto do_number_sign_and_padding; } case L_('X'): if (modifier == L_('O')) goto bad_format; #ifdef _NL_CURRENT if (! (modifier == L_('E') && (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT))) != L_('\0')))) subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); goto subformat; #else goto underlying_strftime; #endif case L_('T'): subfmt = L_("%H:%M:%S"); goto subformat; case L_('t'): add1 (L_('\t')); break; case L_('u'): DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); case L_('U'): if (modifier == L_('E')) goto bad_format; DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); case L_('V'): case L_('g'): case L_('G'): if (modifier == L_('E')) goto bad_format; { /* YEAR is a leap year if and only if (tp->tm_year + TM_YEAR_BASE) is a leap year, except that YEAR and YEAR - 1 both work correctly even when (tp->tm_year + TM_YEAR_BASE) would overflow. */ int year = (tp->tm_year + (tp->tm_year < 0 ? TM_YEAR_BASE % 400 : TM_YEAR_BASE % 400 - 400)); int year_adjust = 0; int days = iso_week_days (tp->tm_yday, tp->tm_wday); if (days < 0) { /* This ISO week belongs to the previous year. */ year_adjust = -1; days = iso_week_days (tp->tm_yday + (365 + __isleap (year - 1)), tp->tm_wday); } else { int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), tp->tm_wday); if (0 <= d) { /* This ISO week belongs to the next year. */ year_adjust = 1; days = d; } } switch (*f) { case L_('g'): { int yy = (tp->tm_year % 100 + year_adjust) % 100; DO_NUMBER (2, (0 <= yy ? yy : tp->tm_year < -TM_YEAR_BASE - year_adjust ? -yy : yy + 100)); } case L_('G'): DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, (tp->tm_year + (unsigned int) TM_YEAR_BASE + year_adjust)); default: DO_NUMBER (2, days / 7 + 1); } } case L_('W'): if (modifier == L_('E')) goto bad_format; DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); case L_('w'): if (modifier == L_('E')) goto bad_format; DO_NUMBER (1, tp->tm_wday); case L_('Y'): if (modifier == 'E') { #if HAVE_STRUCT_ERA_ENTRY struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); if (era) { # ifdef COMPILE_WIDE subfmt = era->era_wformat; # else subfmt = era->era_format; # endif goto subformat; } #else goto underlying_strftime; #endif } if (modifier == L_('O')) goto bad_format; DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE, tp->tm_year + (unsigned int) TM_YEAR_BASE); case L_('y'): if (modifier == L_('E')) { #if HAVE_STRUCT_ERA_ENTRY struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); if (era) { int delta = tp->tm_year - era->start_date[0]; DO_NUMBER (1, (era->offset + delta * era->absolute_direction)); } #else goto underlying_strftime; #endif } { int yy = tp->tm_year % 100; if (yy < 0) yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; DO_NUMBER (2, yy); } case L_('Z'): if (change_case) { to_uppcase = false; to_lowcase = true; } #if HAVE_TZNAME /* The tzset() call might have changed the value. */ if (!(zone && *zone) && tp->tm_isdst >= 0) zone = tzname[tp->tm_isdst != 0]; #endif if (! zone) zone = ""; #ifdef COMPILE_WIDE { /* The zone string is always given in multibyte form. We have to transform it first. */ wchar_t *wczone; size_t len; widen (zone, wczone, len); cpy (len, wczone); } #else cpy (strlen (zone), zone); #endif break; case L_(':'): /* :, ::, and ::: are valid only just before 'z'. :::: etc. are rejected later. */ for (colons = 1; f[colons] == L_(':'); colons++) continue; if (f[colons] != L_('z')) goto bad_format; f += colons; goto do_z_conversion; case L_('z'): colons = 0; do_z_conversion: if (tp->tm_isdst < 0) break; { int diff; int hour_diff; int min_diff; int sec_diff; #if HAVE_TM_GMTOFF diff = tp->tm_gmtoff; #else if (ut) diff = 0; else { struct tm gtm; struct tm ltm; time_t lt; ltm = *tp; lt = mktime (<m); if (lt == (time_t) -1) { /* mktime returns -1 for errors, but -1 is also a valid time_t value. Check whether an error really occurred. */ struct tm tm; if (! __localtime_r (<, &tm) || ((ltm.tm_sec ^ tm.tm_sec) | (ltm.tm_min ^ tm.tm_min) | (ltm.tm_hour ^ tm.tm_hour) | (ltm.tm_mday ^ tm.tm_mday) | (ltm.tm_mon ^ tm.tm_mon) | (ltm.tm_year ^ tm.tm_year))) break; } if (! __gmtime_r (<, >m)) break; diff = tm_diff (<m, >m); } #endif hour_diff = diff / 60 / 60; min_diff = diff / 60 % 60; sec_diff = diff % 60; switch (colons) { case 0: /* +hhmm */ DO_TZ_OFFSET (5, diff < 0, 0, hour_diff * 100 + min_diff); case 1: tz_hh_mm: /* +hh:mm */ DO_TZ_OFFSET (6, diff < 0, 04, hour_diff * 100 + min_diff); case 2: tz_hh_mm_ss: /* +hh:mm:ss */ DO_TZ_OFFSET (9, diff < 0, 024, hour_diff * 10000 + min_diff * 100 + sec_diff); case 3: /* +hh if possible, else +hh:mm, else +hh:mm:ss */ if (sec_diff != 0) goto tz_hh_mm_ss; if (min_diff != 0) goto tz_hh_mm; DO_TZ_OFFSET (3, diff < 0, 0, hour_diff); default: goto bad_format; } } case L_('\0'): /* GNU extension: % at end of format. */ --f; /* Fall through. */ default: /* Unknown format; output the format, including the '%', since this is most likely the right thing to do if a multibyte string has been misparsed. */ bad_format: { int flen; for (flen = 1; f[1 - flen] != L_('%'); flen++) continue; cpy (flen, &f[1 - flen]); } break; } } #if ! FPRINTFTIME if (p && maxsize != 0) *p = L_('\0'); #endif return i; } /* Write information from TP into S according to the format string FORMAT, writing no more that MAXSIZE characters (including the terminating '\0') and returning number of characters written. If S is NULL, nothing will be written anywhere, so to determine how many characters would be written, use NULL for S and (size_t) -1 for MAXSIZE. */ size_t my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) const CHAR_T *format, const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) { return strftime_case_ (false, s, STRFTIME_ARG (maxsize) format, tp extra_args LOCALE_ARG); } #if defined _LIBC && ! FPRINTFTIME libc_hidden_def (my_strftime) #endif #if defined emacs && ! FPRINTFTIME /* For Emacs we have a separate interface which corresponds to the normal strftime function plus the ut argument, but without the ns argument. */ size_t emacs_strftimeu (char *s, size_t maxsize, const char *format, const struct tm *tp, int ut) { return my_strftime (s, maxsize, format, tp, ut, 0); } #endif lftp-4.6.3a/lib/xsize.c0000644000015000007670000000011612122621313011616 00000000000000#include #define XSIZE_INLINE _GL_EXTERN_INLINE #include "xsize.h" lftp-4.6.3a/lib/parse-datetime.y0000644000015000007670000013352712466374011013436 00000000000000%{ /* Parse a string into an internal time stamp. Copyright (C) 1999-2000, 2002-2015 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 . */ /* Originally written by Steven M. Bellovin while at the University of North Carolina at Chapel Hill. Later tweaked by a couple of people on Usenet. Completely overhauled by Rich $alz and Jim Berets in August, 1990. Modified by Paul Eggert in August 1999 to do the right thing about local DST. Also modified by Paul Eggert in February 2004 to support nanosecond-resolution time stamps, and in October 2004 to support TZ strings in dates. */ /* FIXME: Check for arithmetic overflow in all cases, not just some of them. */ #include #include "parse-datetime.h" #include "intprops.h" #include "timespec.h" #include "verify.h" /* There's no need to extend the stack, so there's no need to involve alloca. */ #define YYSTACK_USE_ALLOCA 0 /* Tell Bison how much stack space is needed. 20 should be plenty for this grammar, which is not right recursive. Beware setting it too high, since that might cause problems on machines whose implementations have lame stack-overflow checking. */ #define YYMAXDEPTH 20 #define YYINITDEPTH YYMAXDEPTH /* Since the code of parse-datetime.y is not included in the Emacs executable itself, there is no need to #define static in this file. Even if the code were included in the Emacs executable, it probably wouldn't do any harm to #undef it here; this will only cause problems if we try to write to a static variable, which I don't think this code needs to do. */ #ifdef emacs # undef static #endif #include #include #include #include #include #include "xalloc.h" /* Bison's skeleton tests _STDLIB_H, while some stdlib.h headers use _STDLIB_H_ as witness. Map the latter to the one bison uses. */ /* FIXME: this is temporary. Remove when we have a mechanism to ensure that the version we're using is fixed, too. */ #ifdef _STDLIB_H_ # undef _STDLIB_H # define _STDLIB_H 1 #endif /* ISDIGIT differs from isdigit, as follows: - Its arg may be any int or unsigned int; it need not be an unsigned char or EOF. - It's typically faster. POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to isdigit unless it's important to use the locale's definition of "digit" even when the host does not conform to POSIX. */ #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) /* Shift A right by B bits portably, by dividing A by 2**B and truncating towards minus infinity. A and B should be free of side effects, and B should be in the range 0 <= B <= INT_BITS - 2, where INT_BITS is the number of useful bits in an int. GNU code can assume that INT_BITS is at least 32. ISO C99 says that A >> B is implementation-defined if A < 0. Some implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ #define SHR(a, b) \ (-1 >> 1 == -1 \ ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) #define EPOCH_YEAR 1970 #define TM_YEAR_BASE 1900 #define HOUR(x) ((x) * 60) /* long_time_t is a signed integer type that contains all time_t values. */ verify (TYPE_IS_INTEGER (time_t)); #if TIME_T_FITS_IN_LONG_INT typedef long int long_time_t; #else typedef time_t long_time_t; #endif /* Convert a possibly-signed character to an unsigned character. This is a bit safer than casting to unsigned char, since it catches some type errors that the cast doesn't. */ static unsigned char to_uchar (char ch) { return ch; } /* Lots of this code assumes time_t and time_t-like values fit into long_time_t. */ verify (TYPE_MINIMUM (long_time_t) <= TYPE_MINIMUM (time_t) && TYPE_MAXIMUM (time_t) <= TYPE_MAXIMUM (long_time_t)); /* FIXME: It also assumes that signed integer overflow silently wraps around, but this is not true any more with recent versions of GCC 4. */ /* An integer value, and the number of digits in its textual representation. */ typedef struct { bool negative; long int value; size_t digits; } textint; /* An entry in the lexical lookup table. */ typedef struct { char const *name; int type; int value; } table; /* Meridian: am, pm, or 24-hour style. */ enum { MERam, MERpm, MER24 }; enum { BILLION = 1000000000, LOG10_BILLION = 9 }; /* Relative times. */ typedef struct { /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */ long int year; long int month; long int day; long int hour; long int minutes; long_time_t seconds; long int ns; } relative_time; #if HAVE_COMPOUND_LITERALS # define RELATIVE_TIME_0 ((relative_time) { 0, 0, 0, 0, 0, 0, 0 }) #else static relative_time const RELATIVE_TIME_0; #endif /* Information passed to and from the parser. */ typedef struct { /* The input string remaining to be parsed. */ const char *input; /* N, if this is the Nth Tuesday. */ long int day_ordinal; /* Day of week; Sunday is 0. */ int day_number; /* tm_isdst flag for the local zone. */ int local_isdst; /* Time zone, in minutes east of UTC. */ long int time_zone; /* Style used for time. */ int meridian; /* Gregorian year, month, day, hour, minutes, seconds, and nanoseconds. */ textint year; long int month; long int day; long int hour; long int minutes; struct timespec seconds; /* includes nanoseconds */ /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */ relative_time rel; /* Presence or counts of nonterminals of various flavors parsed so far. */ bool timespec_seen; bool rels_seen; size_t dates_seen; size_t days_seen; size_t local_zones_seen; size_t dsts_seen; size_t times_seen; size_t zones_seen; /* Table of local time zone abbreviations, terminated by a null entry. */ table local_time_zone_table[3]; } parser_control; union YYSTYPE; static int yylex (union YYSTYPE *, parser_control *); static int yyerror (parser_control const *, char const *); static long int time_zone_hhmm (parser_control *, textint, long int); /* Extract into *PC any date and time info from a string of digits of the form e.g., YYYYMMDD, YYMMDD, HHMM, HH (and sometimes YYY, YYYY, ...). */ static void digits_to_date_time (parser_control *pc, textint text_int) { if (pc->dates_seen && ! pc->year.digits && ! pc->rels_seen && (pc->times_seen || 2 < text_int.digits)) pc->year = text_int; else { if (4 < text_int.digits) { pc->dates_seen++; pc->day = text_int.value % 100; pc->month = (text_int.value / 100) % 100; pc->year.value = text_int.value / 10000; pc->year.digits = text_int.digits - 4; } else { pc->times_seen++; if (text_int.digits <= 2) { pc->hour = text_int.value; pc->minutes = 0; } else { pc->hour = text_int.value / 100; pc->minutes = text_int.value % 100; } pc->seconds.tv_sec = 0; pc->seconds.tv_nsec = 0; pc->meridian = MER24; } } } /* Increment PC->rel by FACTOR * REL (FACTOR is 1 or -1). */ static void apply_relative_time (parser_control *pc, relative_time rel, int factor) { pc->rel.ns += factor * rel.ns; pc->rel.seconds += factor * rel.seconds; pc->rel.minutes += factor * rel.minutes; pc->rel.hour += factor * rel.hour; pc->rel.day += factor * rel.day; pc->rel.month += factor * rel.month; pc->rel.year += factor * rel.year; pc->rels_seen = true; } /* Set PC-> hour, minutes, seconds and nanoseconds members from arguments. */ static void set_hhmmss (parser_control *pc, long int hour, long int minutes, time_t sec, long int nsec) { pc->hour = hour; pc->minutes = minutes; pc->seconds.tv_sec = sec; pc->seconds.tv_nsec = nsec; } %} /* We want a reentrant parser, even if the TZ manipulation and the calls to localtime and gmtime are not reentrant. */ %pure-parser %parse-param { parser_control *pc } %lex-param { parser_control *pc } /* This grammar has 31 shift/reduce conflicts. */ %expect 31 %union { long int intval; textint textintval; struct timespec timespec; relative_time rel; } %token tAGO %token tDST %token tYEAR_UNIT tMONTH_UNIT tHOUR_UNIT tMINUTE_UNIT tSEC_UNIT %token tDAY_UNIT tDAY_SHIFT %token tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN %token tMONTH tORDINAL tZONE %token tSNUMBER tUNUMBER %token tSDECIMAL_NUMBER tUDECIMAL_NUMBER %type o_colon_minutes %type seconds signed_seconds unsigned_seconds %type relunit relunit_snumber dayshift %% spec: timespec | items ; timespec: '@' seconds { pc->seconds = $2; pc->timespec_seen = true; } ; items: /* empty */ | items item ; item: datetime { pc->times_seen++; pc->dates_seen++; } | time { pc->times_seen++; } | local_zone { pc->local_zones_seen++; } | zone { pc->zones_seen++; } | date { pc->dates_seen++; } | day { pc->days_seen++; } | rel | number | hybrid ; datetime: iso_8601_datetime ; iso_8601_datetime: iso_8601_date 'T' iso_8601_time ; time: tUNUMBER tMERIDIAN { set_hhmmss (pc, $1.value, 0, 0, 0); pc->meridian = $2; } | tUNUMBER ':' tUNUMBER tMERIDIAN { set_hhmmss (pc, $1.value, $3.value, 0, 0); pc->meridian = $4; } | tUNUMBER ':' tUNUMBER ':' unsigned_seconds tMERIDIAN { set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); pc->meridian = $6; } | iso_8601_time ; iso_8601_time: tUNUMBER zone_offset { set_hhmmss (pc, $1.value, 0, 0, 0); pc->meridian = MER24; } | tUNUMBER ':' tUNUMBER o_zone_offset { set_hhmmss (pc, $1.value, $3.value, 0, 0); pc->meridian = MER24; } | tUNUMBER ':' tUNUMBER ':' unsigned_seconds o_zone_offset { set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); pc->meridian = MER24; } ; o_zone_offset: /* empty */ | zone_offset ; zone_offset: tSNUMBER o_colon_minutes { pc->zones_seen++; pc->time_zone = time_zone_hhmm (pc, $1, $2); } ; local_zone: tLOCAL_ZONE { pc->local_isdst = $1; pc->dsts_seen += (0 < $1); } | tLOCAL_ZONE tDST { pc->local_isdst = 1; pc->dsts_seen += (0 < $1) + 1; } ; /* Note 'T' is a special case, as it is used as the separator in ISO 8601 date and time of day representation. */ zone: tZONE { pc->time_zone = $1; } | 'T' { pc->time_zone = HOUR(7); } | tZONE relunit_snumber { pc->time_zone = $1; apply_relative_time (pc, $2, 1); } | 'T' relunit_snumber { pc->time_zone = HOUR(7); apply_relative_time (pc, $2, 1); } | tZONE tSNUMBER o_colon_minutes { pc->time_zone = $1 + time_zone_hhmm (pc, $2, $3); } | tDAYZONE { pc->time_zone = $1 + 60; } | tZONE tDST { pc->time_zone = $1 + 60; } ; day: tDAY { pc->day_ordinal = 0; pc->day_number = $1; } | tDAY ',' { pc->day_ordinal = 0; pc->day_number = $1; } | tORDINAL tDAY { pc->day_ordinal = $1; pc->day_number = $2; } | tUNUMBER tDAY { pc->day_ordinal = $1.value; pc->day_number = $2; } ; date: tUNUMBER '/' tUNUMBER { pc->month = $1.value; pc->day = $3.value; } | tUNUMBER '/' tUNUMBER '/' tUNUMBER { /* Interpret as YYYY/MM/DD if the first value has 4 or more digits, otherwise as MM/DD/YY. The goal in recognizing YYYY/MM/DD is solely to support legacy machine-generated dates like those in an RCS log listing. If you want portability, use the ISO 8601 format. */ if (4 <= $1.digits) { pc->year = $1; pc->month = $3.value; pc->day = $5.value; } else { pc->month = $1.value; pc->day = $3.value; pc->year = $5; } } | tUNUMBER tMONTH tSNUMBER { /* e.g. 17-JUN-1992. */ pc->day = $1.value; pc->month = $2; pc->year.value = -$3.value; pc->year.digits = $3.digits; } | tMONTH tSNUMBER tSNUMBER { /* e.g. JUN-17-1992. */ pc->month = $1; pc->day = -$2.value; pc->year.value = -$3.value; pc->year.digits = $3.digits; } | tMONTH tUNUMBER { pc->month = $1; pc->day = $2.value; } | tMONTH tUNUMBER ',' tUNUMBER { pc->month = $1; pc->day = $2.value; pc->year = $4; } | tUNUMBER tMONTH { pc->day = $1.value; pc->month = $2; } | tUNUMBER tMONTH tUNUMBER { pc->day = $1.value; pc->month = $2; pc->year = $3; } | iso_8601_date ; iso_8601_date: tUNUMBER tSNUMBER tSNUMBER { /* ISO 8601 format. YYYY-MM-DD. */ pc->year = $1; pc->month = -$2.value; pc->day = -$3.value; } ; rel: relunit tAGO { apply_relative_time (pc, $1, $2); } | relunit { apply_relative_time (pc, $1, 1); } | dayshift { apply_relative_time (pc, $1, 1); } ; relunit: tORDINAL tYEAR_UNIT { $$ = RELATIVE_TIME_0; $$.year = $1; } | tUNUMBER tYEAR_UNIT { $$ = RELATIVE_TIME_0; $$.year = $1.value; } | tYEAR_UNIT { $$ = RELATIVE_TIME_0; $$.year = 1; } | tORDINAL tMONTH_UNIT { $$ = RELATIVE_TIME_0; $$.month = $1; } | tUNUMBER tMONTH_UNIT { $$ = RELATIVE_TIME_0; $$.month = $1.value; } | tMONTH_UNIT { $$ = RELATIVE_TIME_0; $$.month = 1; } | tORDINAL tDAY_UNIT { $$ = RELATIVE_TIME_0; $$.day = $1 * $2; } | tUNUMBER tDAY_UNIT { $$ = RELATIVE_TIME_0; $$.day = $1.value * $2; } | tDAY_UNIT { $$ = RELATIVE_TIME_0; $$.day = $1; } | tORDINAL tHOUR_UNIT { $$ = RELATIVE_TIME_0; $$.hour = $1; } | tUNUMBER tHOUR_UNIT { $$ = RELATIVE_TIME_0; $$.hour = $1.value; } | tHOUR_UNIT { $$ = RELATIVE_TIME_0; $$.hour = 1; } | tORDINAL tMINUTE_UNIT { $$ = RELATIVE_TIME_0; $$.minutes = $1; } | tUNUMBER tMINUTE_UNIT { $$ = RELATIVE_TIME_0; $$.minutes = $1.value; } | tMINUTE_UNIT { $$ = RELATIVE_TIME_0; $$.minutes = 1; } | tORDINAL tSEC_UNIT { $$ = RELATIVE_TIME_0; $$.seconds = $1; } | tUNUMBER tSEC_UNIT { $$ = RELATIVE_TIME_0; $$.seconds = $1.value; } | tSDECIMAL_NUMBER tSEC_UNIT { $$ = RELATIVE_TIME_0; $$.seconds = $1.tv_sec; $$.ns = $1.tv_nsec; } | tUDECIMAL_NUMBER tSEC_UNIT { $$ = RELATIVE_TIME_0; $$.seconds = $1.tv_sec; $$.ns = $1.tv_nsec; } | tSEC_UNIT { $$ = RELATIVE_TIME_0; $$.seconds = 1; } | relunit_snumber ; relunit_snumber: tSNUMBER tYEAR_UNIT { $$ = RELATIVE_TIME_0; $$.year = $1.value; } | tSNUMBER tMONTH_UNIT { $$ = RELATIVE_TIME_0; $$.month = $1.value; } | tSNUMBER tDAY_UNIT { $$ = RELATIVE_TIME_0; $$.day = $1.value * $2; } | tSNUMBER tHOUR_UNIT { $$ = RELATIVE_TIME_0; $$.hour = $1.value; } | tSNUMBER tMINUTE_UNIT { $$ = RELATIVE_TIME_0; $$.minutes = $1.value; } | tSNUMBER tSEC_UNIT { $$ = RELATIVE_TIME_0; $$.seconds = $1.value; } ; dayshift: tDAY_SHIFT { $$ = RELATIVE_TIME_0; $$.day = $1; } ; seconds: signed_seconds | unsigned_seconds; signed_seconds: tSDECIMAL_NUMBER | tSNUMBER { $$.tv_sec = $1.value; $$.tv_nsec = 0; } ; unsigned_seconds: tUDECIMAL_NUMBER | tUNUMBER { $$.tv_sec = $1.value; $$.tv_nsec = 0; } ; number: tUNUMBER { digits_to_date_time (pc, $1); } ; hybrid: tUNUMBER relunit_snumber { /* Hybrid all-digit and relative offset, so that we accept e.g., "YYYYMMDD +N days" as well as "YYYYMMDD N days". */ digits_to_date_time (pc, $1); apply_relative_time (pc, $2, 1); } ; o_colon_minutes: /* empty */ { $$ = -1; } | ':' tUNUMBER { $$ = $2.value; } ; %% static table const meridian_table[] = { { "AM", tMERIDIAN, MERam }, { "A.M.", tMERIDIAN, MERam }, { "PM", tMERIDIAN, MERpm }, { "P.M.", tMERIDIAN, MERpm }, { NULL, 0, 0 } }; static table const dst_table[] = { { "DST", tDST, 0 } }; static table const month_and_day_table[] = { { "JANUARY", tMONTH, 1 }, { "FEBRUARY", tMONTH, 2 }, { "MARCH", tMONTH, 3 }, { "APRIL", tMONTH, 4 }, { "MAY", tMONTH, 5 }, { "JUNE", tMONTH, 6 }, { "JULY", tMONTH, 7 }, { "AUGUST", tMONTH, 8 }, { "SEPTEMBER",tMONTH, 9 }, { "SEPT", tMONTH, 9 }, { "OCTOBER", tMONTH, 10 }, { "NOVEMBER", tMONTH, 11 }, { "DECEMBER", tMONTH, 12 }, { "SUNDAY", tDAY, 0 }, { "MONDAY", tDAY, 1 }, { "TUESDAY", tDAY, 2 }, { "TUES", tDAY, 2 }, { "WEDNESDAY",tDAY, 3 }, { "WEDNES", tDAY, 3 }, { "THURSDAY", tDAY, 4 }, { "THUR", tDAY, 4 }, { "THURS", tDAY, 4 }, { "FRIDAY", tDAY, 5 }, { "SATURDAY", tDAY, 6 }, { NULL, 0, 0 } }; static table const time_units_table[] = { { "YEAR", tYEAR_UNIT, 1 }, { "MONTH", tMONTH_UNIT, 1 }, { "FORTNIGHT",tDAY_UNIT, 14 }, { "WEEK", tDAY_UNIT, 7 }, { "DAY", tDAY_UNIT, 1 }, { "HOUR", tHOUR_UNIT, 1 }, { "MINUTE", tMINUTE_UNIT, 1 }, { "MIN", tMINUTE_UNIT, 1 }, { "SECOND", tSEC_UNIT, 1 }, { "SEC", tSEC_UNIT, 1 }, { NULL, 0, 0 } }; /* Assorted relative-time words. */ static table const relative_time_table[] = { { "TOMORROW", tDAY_SHIFT, 1 }, { "YESTERDAY",tDAY_SHIFT, -1 }, { "TODAY", tDAY_SHIFT, 0 }, { "NOW", tDAY_SHIFT, 0 }, { "LAST", tORDINAL, -1 }, { "THIS", tORDINAL, 0 }, { "NEXT", tORDINAL, 1 }, { "FIRST", tORDINAL, 1 }, /*{ "SECOND", tORDINAL, 2 }, */ { "THIRD", tORDINAL, 3 }, { "FOURTH", tORDINAL, 4 }, { "FIFTH", tORDINAL, 5 }, { "SIXTH", tORDINAL, 6 }, { "SEVENTH", tORDINAL, 7 }, { "EIGHTH", tORDINAL, 8 }, { "NINTH", tORDINAL, 9 }, { "TENTH", tORDINAL, 10 }, { "ELEVENTH", tORDINAL, 11 }, { "TWELFTH", tORDINAL, 12 }, { "AGO", tAGO, -1 }, { "HENCE", tAGO, 1 }, { NULL, 0, 0 } }; /* The universal time zone table. These labels can be used even for time stamps that would not otherwise be valid, e.g., GMT time stamps in London during summer. */ static table const universal_time_zone_table[] = { { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */ { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */ { "UTC", tZONE, HOUR ( 0) }, { NULL, 0, 0 } }; /* The time zone table. This table is necessarily incomplete, as time zone abbreviations are ambiguous; e.g. Australians interpret "EST" as Eastern time in Australia, not as US Eastern Standard Time. You cannot rely on parse_datetime to handle arbitrary time zone abbreviations; use numeric abbreviations like "-0500" instead. */ static table const time_zone_table[] = { { "WET", tZONE, HOUR ( 0) }, /* Western European */ { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */ { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */ { "ART", tZONE, -HOUR ( 3) }, /* Argentina */ { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */ { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */ { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */ { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */ { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */ { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */ { "CLT", tZONE, -HOUR ( 4) }, /* Chile */ { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */ { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */ { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */ { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */ { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */ { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */ { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */ { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */ { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */ { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */ { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */ { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */ { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */ { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */ { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */ { "WAT", tZONE, HOUR ( 1) }, /* West Africa */ { "CET", tZONE, HOUR ( 1) }, /* Central European */ { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */ { "MET", tZONE, HOUR ( 1) }, /* Middle European */ { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */ { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ { "EET", tZONE, HOUR ( 2) }, /* Eastern European */ { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */ { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */ { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */ { "EAT", tZONE, HOUR ( 3) }, /* East Africa */ { "MSK", tZONE, HOUR ( 3) }, /* Moscow */ { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */ { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */ { "SGT", tZONE, HOUR ( 8) }, /* Singapore */ { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */ { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */ { "GST", tZONE, HOUR (10) }, /* Guam Standard */ { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */ { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */ { NULL, 0, 0 } }; /* Military time zone table. Note 'T' is a special case, as it is used as the separator in ISO 8601 date and time of day representation. */ static table const military_table[] = { { "A", tZONE, -HOUR ( 1) }, { "B", tZONE, -HOUR ( 2) }, { "C", tZONE, -HOUR ( 3) }, { "D", tZONE, -HOUR ( 4) }, { "E", tZONE, -HOUR ( 5) }, { "F", tZONE, -HOUR ( 6) }, { "G", tZONE, -HOUR ( 7) }, { "H", tZONE, -HOUR ( 8) }, { "I", tZONE, -HOUR ( 9) }, { "K", tZONE, -HOUR (10) }, { "L", tZONE, -HOUR (11) }, { "M", tZONE, -HOUR (12) }, { "N", tZONE, HOUR ( 1) }, { "O", tZONE, HOUR ( 2) }, { "P", tZONE, HOUR ( 3) }, { "Q", tZONE, HOUR ( 4) }, { "R", tZONE, HOUR ( 5) }, { "S", tZONE, HOUR ( 6) }, { "T", 'T', 0 }, { "U", tZONE, HOUR ( 8) }, { "V", tZONE, HOUR ( 9) }, { "W", tZONE, HOUR (10) }, { "X", tZONE, HOUR (11) }, { "Y", tZONE, HOUR (12) }, { "Z", tZONE, HOUR ( 0) }, { NULL, 0, 0 } }; /* Convert a time zone expressed as HH:MM into an integer count of minutes. If MM is negative, then S is of the form HHMM and needs to be picked apart; otherwise, S is of the form HH. As specified in http://www.opengroup.org/susv3xbd/xbd_chap08.html#tag_08_03, allow only valid TZ range, and consider first two digits as hours, if no minutes specified. */ static long int time_zone_hhmm (parser_control *pc, textint s, long int mm) { long int n_minutes; /* If the length of S is 1 or 2 and no minutes are specified, interpret it as a number of hours. */ if (s.digits <= 2 && mm < 0) s.value *= 100; if (mm < 0) n_minutes = (s.value / 100) * 60 + s.value % 100; else n_minutes = s.value * 60 + (s.negative ? -mm : mm); /* If the absolute number of minutes is larger than 24 hours, arrange to reject it by incrementing pc->zones_seen. Thus, we allow only values in the range UTC-24:00 to UTC+24:00. */ if (24 * 60 < abs (n_minutes)) pc->zones_seen++; return n_minutes; } static int to_hour (long int hours, int meridian) { switch (meridian) { default: /* Pacify GCC. */ case MER24: return 0 <= hours && hours < 24 ? hours : -1; case MERam: return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1; case MERpm: return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1; } } static long int to_year (textint textyear) { long int year = textyear.value; if (year < 0) year = -year; /* XPG4 suggests that years 00-68 map to 2000-2068, and years 69-99 map to 1969-1999. */ else if (textyear.digits == 2) year += year < 69 ? 2000 : 1900; return year; } static table const * _GL_ATTRIBUTE_PURE lookup_zone (parser_control const *pc, char const *name) { table const *tp; for (tp = universal_time_zone_table; tp->name; tp++) if (strcmp (name, tp->name) == 0) return tp; /* Try local zone abbreviations before those in time_zone_table, as the local ones are more likely to be right. */ for (tp = pc->local_time_zone_table; tp->name; tp++) if (strcmp (name, tp->name) == 0) return tp; for (tp = time_zone_table; tp->name; tp++) if (strcmp (name, tp->name) == 0) return tp; return NULL; } #if ! HAVE_TM_GMTOFF /* Yield the difference between *A and *B, measured in seconds, ignoring leap seconds. The body of this function is taken directly from the GNU C Library; see src/strftime.c. */ static long int tm_diff (struct tm const *a, struct tm const *b) { /* Compute intervening leap days correctly even if year is negative. Take care to avoid int overflow in leap day calculations. */ int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); int a100 = a4 / 25 - (a4 % 25 < 0); int b100 = b4 / 25 - (b4 % 25 < 0); int a400 = SHR (a100, 2); int b400 = SHR (b100, 2); int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); long int ayear = a->tm_year; long int years = ayear - b->tm_year; long int days = (365 * years + intervening_leap_days + (a->tm_yday - b->tm_yday)); return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); } #endif /* ! HAVE_TM_GMTOFF */ static table const * lookup_word (parser_control const *pc, char *word) { char *p; char *q; size_t wordlen; table const *tp; bool period_found; bool abbrev; /* Make it uppercase. */ for (p = word; *p; p++) { unsigned char ch = *p; *p = c_toupper (ch); } for (tp = meridian_table; tp->name; tp++) if (strcmp (word, tp->name) == 0) return tp; /* See if we have an abbreviation for a month. */ wordlen = strlen (word); abbrev = wordlen == 3 || (wordlen == 4 && word[3] == '.'); for (tp = month_and_day_table; tp->name; tp++) if ((abbrev ? strncmp (word, tp->name, 3) : strcmp (word, tp->name)) == 0) return tp; if ((tp = lookup_zone (pc, word))) return tp; if (strcmp (word, dst_table[0].name) == 0) return dst_table; for (tp = time_units_table; tp->name; tp++) if (strcmp (word, tp->name) == 0) return tp; /* Strip off any plural and try the units table again. */ if (word[wordlen - 1] == 'S') { word[wordlen - 1] = '\0'; for (tp = time_units_table; tp->name; tp++) if (strcmp (word, tp->name) == 0) return tp; word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */ } for (tp = relative_time_table; tp->name; tp++) if (strcmp (word, tp->name) == 0) return tp; /* Military time zones. */ if (wordlen == 1) for (tp = military_table; tp->name; tp++) if (word[0] == tp->name[0]) return tp; /* Drop out any periods and try the time zone table again. */ for (period_found = false, p = q = word; (*p = *q); q++) if (*q == '.') period_found = true; else p++; if (period_found && (tp = lookup_zone (pc, word))) return tp; return NULL; } static int yylex (union YYSTYPE *lvalp, parser_control *pc) { unsigned char c; size_t count; for (;;) { while (c = *pc->input, c_isspace (c)) pc->input++; if (ISDIGIT (c) || c == '-' || c == '+') { char const *p; int sign; unsigned long int value; if (c == '-' || c == '+') { sign = c == '-' ? -1 : 1; while (c = *++pc->input, c_isspace (c)) continue; if (! ISDIGIT (c)) /* skip the '-' sign */ continue; } else sign = 0; p = pc->input; for (value = 0; ; value *= 10) { unsigned long int value1 = value + (c - '0'); if (value1 < value) return '?'; value = value1; c = *++p; if (! ISDIGIT (c)) break; if (ULONG_MAX / 10 < value) return '?'; } if ((c == '.' || c == ',') && ISDIGIT (p[1])) { time_t s; int ns; int digits; unsigned long int value1; /* Check for overflow when converting value to time_t. */ if (sign < 0) { s = - value; if (0 < s) return '?'; value1 = -s; } else { s = value; if (s < 0) return '?'; value1 = s; } if (value != value1) return '?'; /* Accumulate fraction, to ns precision. */ p++; ns = *p++ - '0'; for (digits = 2; digits <= LOG10_BILLION; digits++) { ns *= 10; if (ISDIGIT (*p)) ns += *p++ - '0'; } /* Skip excess digits, truncating toward -Infinity. */ if (sign < 0) for (; ISDIGIT (*p); p++) if (*p != '0') { ns++; break; } while (ISDIGIT (*p)) p++; /* Adjust to the timespec convention, which is that tv_nsec is always a positive offset even if tv_sec is negative. */ if (sign < 0 && ns) { s--; if (! (s < 0)) return '?'; ns = BILLION - ns; } lvalp->timespec.tv_sec = s; lvalp->timespec.tv_nsec = ns; pc->input = p; return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER; } else { lvalp->textintval.negative = sign < 0; if (sign < 0) { lvalp->textintval.value = - value; if (0 < lvalp->textintval.value) return '?'; } else { lvalp->textintval.value = value; if (lvalp->textintval.value < 0) return '?'; } lvalp->textintval.digits = p - pc->input; pc->input = p; return sign ? tSNUMBER : tUNUMBER; } } if (c_isalpha (c)) { char buff[20]; char *p = buff; table const *tp; do { if (p < buff + sizeof buff - 1) *p++ = c; c = *++pc->input; } while (c_isalpha (c) || c == '.'); *p = '\0'; tp = lookup_word (pc, buff); if (! tp) return '?'; lvalp->intval = tp->value; return tp->type; } if (c != '(') return to_uchar (*pc->input++); count = 0; do { c = *pc->input++; if (c == '\0') return c; if (c == '(') count++; else if (c == ')') count--; } while (count != 0); } } /* Do nothing if the parser reports an error. */ static int yyerror (parser_control const *pc _GL_UNUSED, char const *s _GL_UNUSED) { return 0; } /* If *TM0 is the old and *TM1 is the new value of a struct tm after passing it to mktime, return true if it's OK that mktime returned T. It's not OK if *TM0 has out-of-range members. */ static bool mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t) { if (t == (time_t) -1) { /* Guard against falsely reporting an error when parsing a time stamp that happens to equal (time_t) -1, on a host that supports such a time stamp. */ tm1 = localtime (&t); if (!tm1) return false; } return ! ((tm0->tm_sec ^ tm1->tm_sec) | (tm0->tm_min ^ tm1->tm_min) | (tm0->tm_hour ^ tm1->tm_hour) | (tm0->tm_mday ^ tm1->tm_mday) | (tm0->tm_mon ^ tm1->tm_mon) | (tm0->tm_year ^ tm1->tm_year)); } /* A reasonable upper bound for the size of ordinary TZ strings. Use heap allocation if TZ's length exceeds this. */ enum { TZBUFSIZE = 100 }; /* Return a copy of TZ, stored in TZBUF if it fits, and heap-allocated otherwise. */ static char * get_tz (char tzbuf[TZBUFSIZE]) { char *tz = getenv ("TZ"); if (tz) { size_t tzsize = strlen (tz) + 1; tz = (tzsize <= TZBUFSIZE ? memcpy (tzbuf, tz, tzsize) : xmemdup (tz, tzsize)); } return tz; } /* Parse a date/time string, storing the resulting time value into *RESULT. The string itself is pointed to by P. Return true if successful. P can be an incomplete or relative time specification; if so, use *NOW as the basis for the returned time. */ bool parse_datetime (struct timespec *result, char const *p, struct timespec const *now) { time_t Start; long int Start_ns; struct tm const *tmp; struct tm tm; struct tm tm0; parser_control pc; struct timespec gettime_buffer; unsigned char c; bool tz_was_altered = false; char *tz0 = NULL; char tz0buf[TZBUFSIZE]; bool ok = true; if (! now) { gettime (&gettime_buffer); now = &gettime_buffer; } Start = now->tv_sec; Start_ns = now->tv_nsec; tmp = localtime (&now->tv_sec); if (! tmp) return false; while (c = *p, c_isspace (c)) p++; if (strncmp (p, "TZ=\"", 4) == 0) { char const *tzbase = p + 4; size_t tzsize = 1; char const *s; for (s = tzbase; *s; s++, tzsize++) if (*s == '\\') { s++; if (! (*s == '\\' || *s == '"')) break; } else if (*s == '"') { char *z; char *tz1; char tz1buf[TZBUFSIZE]; bool large_tz = TZBUFSIZE < tzsize; bool setenv_ok; tz0 = get_tz (tz0buf); z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf; for (s = tzbase; *s != '"'; s++) *z++ = *(s += *s == '\\'); *z = '\0'; setenv_ok = setenv ("TZ", tz1, 1) == 0; if (large_tz) free (tz1); if (!setenv_ok) goto fail; tz_was_altered = true; p = s + 1; while (c = *p, c_isspace (c)) p++; break; } } /* As documented, be careful to treat the empty string just like a date string of "0". Without this, an empty string would be declared invalid when parsed during a DST transition. */ if (*p == '\0') p = "0"; pc.input = p; pc.year.value = tmp->tm_year; pc.year.value += TM_YEAR_BASE; pc.year.digits = 0; pc.month = tmp->tm_mon + 1; pc.day = tmp->tm_mday; pc.hour = tmp->tm_hour; pc.minutes = tmp->tm_min; pc.seconds.tv_sec = tmp->tm_sec; pc.seconds.tv_nsec = Start_ns; tm.tm_isdst = tmp->tm_isdst; pc.meridian = MER24; pc.rel = RELATIVE_TIME_0; pc.timespec_seen = false; pc.rels_seen = false; pc.dates_seen = 0; pc.days_seen = 0; pc.times_seen = 0; pc.local_zones_seen = 0; pc.dsts_seen = 0; pc.zones_seen = 0; #if HAVE_STRUCT_TM_TM_ZONE pc.local_time_zone_table[0].name = tmp->tm_zone; pc.local_time_zone_table[0].type = tLOCAL_ZONE; pc.local_time_zone_table[0].value = tmp->tm_isdst; pc.local_time_zone_table[1].name = NULL; /* Probe the names used in the next three calendar quarters, looking for a tm_isdst different from the one we already have. */ { int quarter; for (quarter = 1; quarter <= 3; quarter++) { time_t probe = Start + quarter * (90 * 24 * 60 * 60); struct tm const *probe_tm = localtime (&probe); if (probe_tm && probe_tm->tm_zone && probe_tm->tm_isdst != pc.local_time_zone_table[0].value) { { pc.local_time_zone_table[1].name = probe_tm->tm_zone; pc.local_time_zone_table[1].type = tLOCAL_ZONE; pc.local_time_zone_table[1].value = probe_tm->tm_isdst; pc.local_time_zone_table[2].name = NULL; } break; } } } #else #if HAVE_TZNAME { # if !HAVE_DECL_TZNAME extern char *tzname[]; # endif int i; for (i = 0; i < 2; i++) { pc.local_time_zone_table[i].name = tzname[i]; pc.local_time_zone_table[i].type = tLOCAL_ZONE; pc.local_time_zone_table[i].value = i; } pc.local_time_zone_table[i].name = NULL; } #else pc.local_time_zone_table[0].name = NULL; #endif #endif if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name && ! strcmp (pc.local_time_zone_table[0].name, pc.local_time_zone_table[1].name)) { /* This locale uses the same abbreviation for standard and daylight times. So if we see that abbreviation, we don't know whether it's daylight time. */ pc.local_time_zone_table[0].value = -1; pc.local_time_zone_table[1].name = NULL; } if (yyparse (&pc) != 0) goto fail; if (pc.timespec_seen) *result = pc.seconds; else { if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen | (pc.local_zones_seen + pc.zones_seen))) goto fail; tm.tm_year = to_year (pc.year) - TM_YEAR_BASE; tm.tm_mon = pc.month - 1; tm.tm_mday = pc.day; if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen)) { tm.tm_hour = to_hour (pc.hour, pc.meridian); if (tm.tm_hour < 0) goto fail; tm.tm_min = pc.minutes; tm.tm_sec = pc.seconds.tv_sec; } else { tm.tm_hour = tm.tm_min = tm.tm_sec = 0; pc.seconds.tv_nsec = 0; } /* Let mktime deduce tm_isdst if we have an absolute time stamp. */ if (pc.dates_seen | pc.days_seen | pc.times_seen) tm.tm_isdst = -1; /* But if the input explicitly specifies local time with or without DST, give mktime that information. */ if (pc.local_zones_seen) tm.tm_isdst = pc.local_isdst; tm0 = tm; Start = mktime (&tm); if (! mktime_ok (&tm0, &tm, Start)) { if (! pc.zones_seen) goto fail; else { /* Guard against falsely reporting errors near the time_t boundaries when parsing times in other time zones. For example, suppose the input string "1969-12-31 23:00:00 -0100", the current time zone is 8 hours ahead of UTC, and the min time_t value is 1970-01-01 00:00:00 UTC. Then the min localtime value is 1970-01-01 08:00:00, and mktime will therefore fail on 1969-12-31 23:00:00. To work around the problem, set the time zone to 1 hour behind UTC temporarily by setting TZ="XXX1:00" and try mktime again. */ long int time_zone = pc.time_zone; long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone; long int abs_time_zone_hour = abs_time_zone / 60; int abs_time_zone_min = abs_time_zone % 60; char tz1buf[sizeof "XXX+0:00" + sizeof pc.time_zone * CHAR_BIT / 3]; if (!tz_was_altered) tz0 = get_tz (tz0buf); sprintf (tz1buf, "XXX%s%ld:%02d", &"-"[time_zone < 0], abs_time_zone_hour, abs_time_zone_min); if (setenv ("TZ", tz1buf, 1) != 0) goto fail; tz_was_altered = true; tm = tm0; Start = mktime (&tm); if (! mktime_ok (&tm0, &tm, Start)) goto fail; } } if (pc.days_seen && ! pc.dates_seen) { tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7 + 7 * (pc.day_ordinal - (0 < pc.day_ordinal && tm.tm_wday != pc.day_number))); tm.tm_isdst = -1; Start = mktime (&tm); if (Start == (time_t) -1) goto fail; } /* Add relative date. */ if (pc.rel.year | pc.rel.month | pc.rel.day) { int year = tm.tm_year + pc.rel.year; int month = tm.tm_mon + pc.rel.month; int day = tm.tm_mday + pc.rel.day; if (((year < tm.tm_year) ^ (pc.rel.year < 0)) | ((month < tm.tm_mon) ^ (pc.rel.month < 0)) | ((day < tm.tm_mday) ^ (pc.rel.day < 0))) goto fail; tm.tm_year = year; tm.tm_mon = month; tm.tm_mday = day; tm.tm_hour = tm0.tm_hour; tm.tm_min = tm0.tm_min; tm.tm_sec = tm0.tm_sec; tm.tm_isdst = tm0.tm_isdst; Start = mktime (&tm); if (Start == (time_t) -1) goto fail; } /* The only "output" of this if-block is an updated Start value, so this block must follow others that clobber Start. */ if (pc.zones_seen) { long int delta = pc.time_zone * 60; time_t t1; #ifdef HAVE_TM_GMTOFF delta -= tm.tm_gmtoff; #else time_t t = Start; struct tm const *gmt = gmtime (&t); if (! gmt) goto fail; delta -= tm_diff (&tm, gmt); #endif t1 = Start - delta; if ((Start < t1) != (delta < 0)) goto fail; /* time_t overflow */ Start = t1; } /* Add relative hours, minutes, and seconds. On hosts that support leap seconds, ignore the possibility of leap seconds; e.g., "+ 10 minutes" adds 600 seconds, even if one of them is a leap second. Typically this is not what the user wants, but it's too hard to do it the other way, because the time zone indicator must be applied before relative times, and if mktime is applied again the time zone will be lost. */ { long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns; long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION; time_t t0 = Start; long int d1 = 60 * 60 * pc.rel.hour; time_t t1 = t0 + d1; long int d2 = 60 * pc.rel.minutes; time_t t2 = t1 + d2; long_time_t d3 = pc.rel.seconds; long_time_t t3 = t2 + d3; long int d4 = (sum_ns - normalized_ns) / BILLION; long_time_t t4 = t3 + d4; time_t t5 = t4; if ((d1 / (60 * 60) ^ pc.rel.hour) | (d2 / 60 ^ pc.rel.minutes) | ((t1 < t0) ^ (d1 < 0)) | ((t2 < t1) ^ (d2 < 0)) | ((t3 < t2) ^ (d3 < 0)) | ((t4 < t3) ^ (d4 < 0)) | (t5 != t4)) goto fail; result->tv_sec = t5; result->tv_nsec = normalized_ns; } } goto done; fail: ok = false; done: if (tz_was_altered) ok &= (tz0 ? setenv ("TZ", tz0, 1) : unsetenv ("TZ")) == 0; if (tz0 != tz0buf) free (tz0); return ok; } #if TEST int main (int ac, char **av) { char buff[BUFSIZ]; printf ("Enter date, or blank line to exit.\n\t> "); fflush (stdout); buff[BUFSIZ - 1] = '\0'; while (fgets (buff, BUFSIZ - 1, stdin) && buff[0]) { struct timespec d; struct tm const *tm; if (! parse_datetime (&d, buff, NULL)) printf ("Bad format - couldn't convert.\n"); else if (! (tm = localtime (&d.tv_sec))) { long int sec = d.tv_sec; printf ("localtime (%ld) failed\n", sec); } else { int ns = d.tv_nsec; printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, ns); } printf ("\t> "); fflush (stdout); } return 0; } #endif /* TEST */ lftp-4.6.3a/lib/isnanf-nolibm.h0000644000015000007670000000270112466374011013232 00000000000000/* Test for NaN that does not need libm. Copyright (C) 2007-2015 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 . */ #if HAVE_ISNANF_IN_LIBC /* Get declaration of isnan macro or (older) isnanf function. */ # include # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) # elif defined isnan # undef isnanf # define isnanf(x) isnan ((float)(x)) # else /* Get declaration of isnanf(), if not declared in . */ # if defined __sgi /* We can't include , because it conflicts with our definition of isnand. Therefore declare isnanf separately. */ extern int isnanf (float x); # endif # endif #else /* Test whether X is a NaN. */ # undef isnanf # define isnanf rpl_isnanf extern int isnanf (float x); #endif lftp-4.6.3a/build-aux/0000755000015000007670000000000012540300655011525 500000000000000lftp-4.6.3a/build-aux/missing0000755000015000007670000001533012404036304013042 00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # 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 2, 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 . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: lftp-4.6.3a/build-aux/config.sub0000755000015000007670000010576212404036304013437 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2014 Free Software Foundation, Inc. timestamp='2014-07-28' # This file 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 . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-* | ppc64p7-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: lftp-4.6.3a/build-aux/config.guess0000755000015000007670000012355012404036304013767 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2014 Free Software Foundation, Inc. timestamp='2014-03-23' # This file 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 . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches with a ChangeLog entry to config-patches@gnu.org. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: lftp-4.6.3a/build-aux/config.rpath0000755000015000007670000004421612540234035013762 00000000000000#! /bin/sh # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # # Copyright 1996-2015 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit , 1996 # # 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. # # The first argument passed to this file is the canonical host specification, # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld # should be set by the caller. # # The set of defined variables is at the end of this script. # Known limitations: # - On IRIX 6.5 with CC="cc", the run time search patch must not be longer # than 256 bytes, otherwise the compiler driver will dump core. The only # known workaround is to choose shorter directory names for the build # directory and/or the installation directory. # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a shrext=.so host="$1" host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` # Code taken from libtool.m4's _LT_CC_BASENAME. for cc_temp in $CC""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` # Code taken from libtool.m4's _LT_COMPILER_PIC. wl= if test "$GCC" = yes; then wl='-Wl,' else case "$host_os" in aix*) wl='-Wl,' ;; mingw* | cygwin* | pw32* | os2* | cegcc*) ;; hpux9* | hpux10* | hpux11*) wl='-Wl,' ;; irix5* | irix6* | nonstopux*) wl='-Wl,' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in ecc*) wl='-Wl,' ;; icc* | ifort*) wl='-Wl,' ;; lf95*) wl='-Wl,' ;; nagfor*) wl='-Wl,-Wl,,' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) wl='-Wl,' ;; ccc*) wl='-Wl,' ;; xl* | bgxl* | bgf* | mpixl*) wl='-Wl,' ;; como) wl='-lopt=' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ F* | *Sun*Fortran*) wl= ;; *Sun\ C*) wl='-Wl,' ;; esac ;; esac ;; newsos6) ;; *nto* | *qnx*) ;; osf3* | osf4* | osf5*) wl='-Wl,' ;; rdos*) ;; solaris*) case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) wl='-Qoption ld ' ;; *) wl='-Wl,' ;; esac ;; sunos4*) wl='-Qoption ld ' ;; sysv4 | sysv4.2uw2* | sysv4.3*) wl='-Wl,' ;; sysv4*MP*) ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) wl='-Wl,' ;; unicos*) wl='-Wl,' ;; uts4*) ;; esac fi # Code taken from libtool.m4's _LT_LINKER_SHLIBS. hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_direct=no hardcode_minus_L=no case "$host_os" in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes if test "$with_gnu_ld" = yes; then # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. # Unlike libtool, we use -rpath here, not --rpath, since the documented # option of GNU ld is called -rpath, not --rpath. hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' case "$host_os" in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no fi ;; amigaos*) case "$host_cpu" in powerpc) ;; m68k) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then : else ld_shlibs=no fi ;; haiku*) ;; interix[3-9]*) hardcode_direct=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; netbsd*) ;; solaris*) if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then ld_shlibs=no elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' else ld_shlibs=no fi ;; esac ;; sunos4*) hardcode_direct=yes ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then hardcode_libdir_flag_spec= fi else case "$host_os" in aix3*) # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac fi hardcode_direct=yes hardcode_libdir_separator=':' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac fi # Begin _LT_AC_SYS_LIBPATH_AIX. echo 'int main () { return 0; }' > conftest.c ${CC} ${LDFLAGS} conftest.c -o conftest aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` fi if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib" fi rm -f conftest.c conftest # End _LT_AC_SYS_LIBPATH_AIX. if test "$aix_use_runtimelinking" = yes; then hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' else hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" fi fi ;; amigaos*) case "$host_cpu" in powerpc) ;; m68k) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' libext=lib ;; darwin* | rhapsody*) hardcode_direct=no if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then : else ld_shlibs=no fi ;; dgux*) hardcode_libdir_flag_spec='-L$libdir' ;; freebsd2.[01]*) hardcode_direct=yes hardcode_minus_L=yes ;; freebsd* | dragonfly*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; hpux9*) hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; hpux10*) if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no ;; *) hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; netbsd*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; newsos6) hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then hardcode_libdir_flag_spec='${wl}-rpath,$libdir' else case "$host_os" in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) hardcode_libdir_flag_spec='-R$libdir' ;; *) hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; osf3*) hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) if test "$GCC" = yes; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else # Both cc and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi hardcode_libdir_separator=: ;; solaris*) hardcode_libdir_flag_spec='-R$libdir' ;; sunos4*) hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes ;; sysv4) case $host_vendor in sni) hardcode_direct=yes # is this really true??? ;; siemens) hardcode_direct=no ;; motorola) hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac ;; sysv4.3*) ;; sysv4*MP*) if test -d /usr/nec; then ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) ;; sysv5* | sco3.2v5* | sco5v6*) hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' hardcode_libdir_separator=':' ;; uts4*) hardcode_libdir_flag_spec='-L$libdir' ;; *) ld_shlibs=no ;; esac fi # Check dynamic linker characteristics # Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. # Unlike libtool.m4, here we don't care about _all_ names of the library, but # only about the one the linker finds when passed -lNAME. This is the last # element of library_names_spec in libtool.m4, or possibly two of them if the # linker has special search rules. library_names_spec= # the last element of library_names_spec in libtool.m4 libname_spec='lib$name' case "$host_os" in aix3*) library_names_spec='$libname.a' ;; aix[4-9]*) library_names_spec='$libname$shrext' ;; amigaos*) case "$host_cpu" in powerpc*) library_names_spec='$libname$shrext' ;; m68k) library_names_spec='$libname.a' ;; esac ;; beos*) library_names_spec='$libname$shrext' ;; bsdi[45]*) library_names_spec='$libname$shrext' ;; cygwin* | mingw* | pw32* | cegcc*) shrext=.dll library_names_spec='$libname.dll.a $libname.lib' ;; darwin* | rhapsody*) shrext=.dylib library_names_spec='$libname$shrext' ;; dgux*) library_names_spec='$libname$shrext' ;; freebsd[23].*) library_names_spec='$libname$shrext$versuffix' ;; freebsd* | dragonfly*) library_names_spec='$libname$shrext' ;; gnu*) library_names_spec='$libname$shrext' ;; haiku*) library_names_spec='$libname$shrext' ;; hpux9* | hpux10* | hpux11*) case $host_cpu in ia64*) shrext=.so ;; hppa*64*) shrext=.sl ;; *) shrext=.sl ;; esac library_names_spec='$libname$shrext' ;; interix[3-9]*) library_names_spec='$libname$shrext' ;; irix5* | irix6* | nonstopux*) library_names_spec='$libname$shrext' case "$host_os" in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; *) libsuff= shlibsuff= ;; esac ;; esac ;; linux*oldld* | linux*aout* | linux*coff*) ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) library_names_spec='$libname$shrext' ;; knetbsd*-gnu) library_names_spec='$libname$shrext' ;; netbsd*) library_names_spec='$libname$shrext' ;; newsos6) library_names_spec='$libname$shrext' ;; *nto* | *qnx*) library_names_spec='$libname$shrext' ;; openbsd*) library_names_spec='$libname$shrext$versuffix' ;; os2*) libname_spec='$name' shrext=.dll library_names_spec='$libname.a' ;; osf3* | osf4* | osf5*) library_names_spec='$libname$shrext' ;; rdos*) ;; solaris*) library_names_spec='$libname$shrext' ;; sunos4*) library_names_spec='$libname$shrext$versuffix' ;; sysv4 | sysv4.3*) library_names_spec='$libname$shrext' ;; sysv4*MP*) library_names_spec='$libname$shrext' ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) library_names_spec='$libname$shrext' ;; tpf*) library_names_spec='$libname$shrext' ;; uts4*) library_names_spec='$libname$shrext' ;; esac sed_quote_subst='s/\(["`$\\]\)/\\\1/g' escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` shlibext=`echo "$shrext" | sed -e 's,^\.,,'` escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. # # 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 2, 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 . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . get_dirname () { case $1 in */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';; # Otherwise, we want the empty string (not "."). esac } # guard FILE # ---------- # The CPP macro used to guard inclusion of FILE. guard () { printf '%s\n' "$1" \ | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \ -e 's/__*/_/g' } # quote_for_sed [STRING] # ---------------------- # Return STRING (or stdin) quoted to be used as a sed pattern. quote_for_sed () { case $# in 0) cat;; 1) printf '%s\n' "$1";; esac \ | sed -e 's|[][\\.*]|\\&|g' } case "$1" in '') echo "$0: No files given. Try '$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input=$1 shift # We'll later need for a correct munging of "#line" directives. input_sub_rx=`get_dirname "$input" | quote_for_sed` case $input in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input=`pwd`/$input ;; esac input_rx=`get_dirname "$input" | quote_for_sed` # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot=false if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot=true fi # The parser itself, the first file, is the destination of the .y.c # rule in the Makefile. parser=$1 # A sed program to s/FROM/TO/g for all the FROM/TO so that, for # instance, we rename #include "y.tab.h" into #include "parse.h" # during the conversion from y.tab.c to parse.c. sed_fix_filenames= # Also rename header guards, as Bison 2.7 for instance uses its header # guard in its implementation file. sed_fix_header_guards= while test $# -ne 0; do if test x"$1" = x"--"; then shift break fi from=$1 # Handle y_tab.c and y_tab.h output by DOS if $y_tab_nodot; then case $from in "y.tab.c") from=y_tab.c;; "y.tab.h") from=y_tab.h;; esac fi shift to=$1 shift sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;" sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;" done # The program to run. prog=$1 shift # Make any relative path in $prog absolute. case $prog in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog=`pwd`/$prog ;; esac dirname=ylwrap$$ do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then for from in * do to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"` if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend '../'. case $to in [\\/]* | ?:[\\/]*) target=$to;; *) target=../$to;; esac # Do not overwrite unchanged header files to avoid useless # recompilations. Always update the parser itself: it is the # destination of the .y.c rule in the Makefile. Divert the # output of all other files to a temporary file so we can # compare them to existing versions. if test $from != $parser; then realtarget=$target target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'` fi # Munge "#line" or "#" directives. Don't let the resulting # debug information point at an absolute srcdir. Use the real # output file name, not yy.lex.c for instance. Adjust the # include guards too. sed -e "/^#/!b" \ -e "s|$input_rx|$input_sub_rx|" \ -e "$sed_fix_filenames" \ -e "$sed_fix_header_guards" \ "$from" >"$target" || ret=$? # Check whether files must be updated. if test "$from" != "$parser"; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$to is unchanged" rm -f "$target" else echo "updating $to" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the parser. This is a # blatant hack to let us support using "yacc -d". If -d is not # specified, don't fail when the header file is "missing". if test "$from" = "$parser"; then ret=1 fi fi done fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: lftp-4.6.3a/build-aux/compile0000755000015000007670000001624512404036304013027 00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # Written by Tom Tromey . # # 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 2, 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 . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: lftp-4.6.3a/build-aux/install-sh0000755000015000007670000003325512404036304013455 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: lftp-4.6.3a/build-aux/depcomp0000755000015000007670000005601612404036304013026 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-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 2, 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 . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: lftp-4.6.3a/build-aux/snippet/0000755000015000007670000000000012540300656013210 500000000000000lftp-4.6.3a/build-aux/snippet/unused-parameter.h0000644000015000007670000000304212466374011016564 00000000000000/* A C macro for declaring that specific function parameters are not used. Copyright (C) 2008-2015 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 . */ /* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter declarations for parameters that are not used. This helps to reduce warnings, such as from GCC -Wunused-parameter. The syntax is as follows: type param _GL_UNUSED_PARAMETER or more generally param_decl _GL_UNUSED_PARAMETER For example: int param _GL_UNUSED_PARAMETER int *(*param)(void) _GL_UNUSED_PARAMETER Other possible, but obscure and discouraged syntaxes: int _GL_UNUSED_PARAMETER *(*param)(void) _GL_UNUSED_PARAMETER int *(*param)(void) */ #ifndef _GL_UNUSED_PARAMETER # if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) # define _GL_UNUSED_PARAMETER __attribute__ ((__unused__)) # else # define _GL_UNUSED_PARAMETER # endif #endif lftp-4.6.3a/build-aux/snippet/c++defs.h0000644000015000007670000002675312533305066014532 00000000000000/* C++ compatible function declaration macros. Copyright (C) 2010-2015 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 . */ #ifndef _GL_CXXDEFS_H #define _GL_CXXDEFS_H /* The three most frequent use cases of these macros are: * For providing a substitute for a function that is missing on some platforms, but is declared and works fine on the platforms on which it exists: #if @GNULIB_FOO@ # if !@HAVE_FOO@ _GL_FUNCDECL_SYS (foo, ...); # endif _GL_CXXALIAS_SYS (foo, ...); _GL_CXXALIASWARN (foo); #elif defined GNULIB_POSIXCHECK ... #endif * For providing a replacement for a function that exists on all platforms, but is broken/insufficient and needs to be replaced on some platforms: #if @GNULIB_FOO@ # if @REPLACE_FOO@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef foo # define foo rpl_foo # endif _GL_FUNCDECL_RPL (foo, ...); _GL_CXXALIAS_RPL (foo, ...); # else _GL_CXXALIAS_SYS (foo, ...); # endif _GL_CXXALIASWARN (foo); #elif defined GNULIB_POSIXCHECK ... #endif * For providing a replacement for a function that exists on some platforms but is broken/insufficient and needs to be replaced on some of them and is additionally either missing or undeclared on some other platforms: #if @GNULIB_FOO@ # if @REPLACE_FOO@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef foo # define foo rpl_foo # endif _GL_FUNCDECL_RPL (foo, ...); _GL_CXXALIAS_RPL (foo, ...); # else # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ _GL_FUNCDECL_SYS (foo, ...); # endif _GL_CXXALIAS_SYS (foo, ...); # endif _GL_CXXALIASWARN (foo); #elif defined GNULIB_POSIXCHECK ... #endif */ /* _GL_EXTERN_C declaration; performs the declaration with C linkage. */ #if defined __cplusplus # define _GL_EXTERN_C extern "C" #else # define _GL_EXTERN_C extern #endif /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); declares a replacement function, named rpl_func, with the given prototype, consisting of return type, parameters, and attributes. Example: _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1))); */ #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ _GL_EXTERN_C rettype rpl_func parameters_and_attributes /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); declares the system function, named func, with the given prototype, consisting of return type, parameters, and attributes. Example: _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1))); */ #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ _GL_EXTERN_C rettype func parameters_and_attributes /* _GL_CXXALIAS_RPL (func, rettype, parameters); declares a C++ alias called GNULIB_NAMESPACE::func that redirects to rpl_func, if GNULIB_NAMESPACE is defined. Example: _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); */ #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) #if defined __cplusplus && defined GNULIB_NAMESPACE # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ namespace GNULIB_NAMESPACE \ { \ rettype (*const func) parameters = ::rpl_func; \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ _GL_EXTERN_C int _gl_cxxalias_dummy #endif /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); except that the C function rpl_func may have a slightly different declaration. A cast is used to silence the "invalid conversion" error that would otherwise occur. */ #if defined __cplusplus && defined GNULIB_NAMESPACE # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ namespace GNULIB_NAMESPACE \ { \ rettype (*const func) parameters = \ reinterpret_cast(::rpl_func); \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ _GL_EXTERN_C int _gl_cxxalias_dummy #endif /* _GL_CXXALIAS_SYS (func, rettype, parameters); declares a C++ alias called GNULIB_NAMESPACE::func that redirects to the system provided function func, if GNULIB_NAMESPACE is defined. Example: _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); */ #if defined __cplusplus && defined GNULIB_NAMESPACE /* If we were to write rettype (*const func) parameters = ::func; like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls better (remove an indirection through a 'static' pointer variable), but then the _GL_CXXALIASWARN macro below would cause a warning not only for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ namespace GNULIB_NAMESPACE \ { \ static rettype (*func) parameters = ::func; \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ _GL_EXTERN_C int _gl_cxxalias_dummy #endif /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); is like _GL_CXXALIAS_SYS (func, rettype, parameters); except that the C function func may have a slightly different declaration. A cast is used to silence the "invalid conversion" error that would otherwise occur. */ #if defined __cplusplus && defined GNULIB_NAMESPACE # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ namespace GNULIB_NAMESPACE \ { \ static rettype (*func) parameters = \ reinterpret_cast(::func); \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ _GL_EXTERN_C int _gl_cxxalias_dummy #endif /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); is like _GL_CXXALIAS_SYS (func, rettype, parameters); except that the C function is picked among a set of overloaded functions, namely the one with rettype2 and parameters2. Two consecutive casts are used to silence the "cannot find a match" and "invalid conversion" errors that would otherwise occur. */ #if defined __cplusplus && defined GNULIB_NAMESPACE /* The outer cast must be a reinterpret_cast. The inner cast: When the function is defined as a set of overloaded functions, it works as a static_cast<>, choosing the designated variant. When the function is defined as a single variant, it works as a reinterpret_cast<>. The parenthesized cast syntax works both ways. */ # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ namespace GNULIB_NAMESPACE \ { \ static rettype (*func) parameters = \ reinterpret_cast( \ (rettype2(*)parameters2)(::func)); \ } \ _GL_EXTERN_C int _gl_cxxalias_dummy #else # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ _GL_EXTERN_C int _gl_cxxalias_dummy #endif /* _GL_CXXALIASWARN (func); causes a warning to be emitted when ::func is used but not when GNULIB_NAMESPACE::func is used. func must be defined without overloaded variants. */ #if defined __cplusplus && defined GNULIB_NAMESPACE # define _GL_CXXALIASWARN(func) \ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) # define _GL_CXXALIASWARN_1(func,namespace) \ _GL_CXXALIASWARN_2 (func, namespace) /* To work around GCC bug , we enable the warning only when not optimizing. */ # if !__OPTIMIZE__ # define _GL_CXXALIASWARN_2(func,namespace) \ _GL_WARN_ON_USE (func, \ "The symbol ::" #func " refers to the system function. " \ "Use " #namespace "::" #func " instead.") # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING # define _GL_CXXALIASWARN_2(func,namespace) \ extern __typeof__ (func) func # else # define _GL_CXXALIASWARN_2(func,namespace) \ _GL_EXTERN_C int _gl_cxxalias_dummy # endif #else # define _GL_CXXALIASWARN(func) \ _GL_EXTERN_C int _gl_cxxalias_dummy #endif /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); causes a warning to be emitted when the given overloaded variant of ::func is used but not when GNULIB_NAMESPACE::func is used. */ #if defined __cplusplus && defined GNULIB_NAMESPACE # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ GNULIB_NAMESPACE) # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) /* To work around GCC bug , we enable the warning only when not optimizing. */ # if !__OPTIMIZE__ # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ "The symbol ::" #func " refers to the system function. " \ "Use " #namespace "::" #func " instead.") # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ extern __typeof__ (func) func # else # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ _GL_EXTERN_C int _gl_cxxalias_dummy # endif #else # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ _GL_EXTERN_C int _gl_cxxalias_dummy #endif #endif /* _GL_CXXDEFS_H */ lftp-4.6.3a/build-aux/snippet/warn-on-use.h0000644000015000007670000001200712533305066015456 00000000000000/* A C macro for emitting warnings if a function is used. Copyright (C) 2010-2015 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 . */ /* _GL_WARN_ON_USE (function, "literal string") issues a declaration for FUNCTION which will then trigger a compiler warning containing the text of "literal string" anywhere that function is called, if supported by the compiler. If the compiler does not support this feature, the macro expands to an unused extern declaration. This macro is useful for marking a function as a potential portability trap, with the intent that "literal string" include instructions on the replacement function that should be used instead. However, one of the reasons that a function is a portability trap is if it has the wrong signature. Declaring FUNCTION with a different signature in C is a compilation error, so this macro must use the same type as any existing declaration so that programs that avoid the problematic FUNCTION do not fail to compile merely because they included a header that poisoned the function. But this implies that _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already have a declaration. Use of this macro implies that there must not be any other macro hiding the declaration of FUNCTION; but undefining FUNCTION first is part of the poisoning process anyway (although for symbols that are provided only via a macro, the result is a compilation error rather than a warning containing "literal string"). Also note that in C++, it is only safe to use if FUNCTION has no overloads. For an example, it is possible to poison 'getline' by: - adding a call to gl_WARN_ON_USE_PREPARE([[#include ]], [getline]) in configure.ac, which potentially defines HAVE_RAW_DECL_GETLINE - adding this code to a header that wraps the system : #undef getline #if HAVE_RAW_DECL_GETLINE _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" "not universally present; use the gnulib module getline"); #endif It is not possible to directly poison global variables. But it is possible to write a wrapper accessor function, and poison that (less common usage, like &environ, will cause a compilation error rather than issue the nice warning, but the end result of informing the developer about their portability problem is still achieved): #if HAVE_RAW_DECL_ENVIRON static char ***rpl_environ (void) { return &environ; } _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); # undef environ # define environ (*rpl_environ ()) #endif */ #ifndef _GL_WARN_ON_USE # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) /* A compiler attribute is available in gcc versions 4.3.0 and later. */ # define _GL_WARN_ON_USE(function, message) \ extern __typeof__ (function) function __attribute__ ((__warning__ (message))) # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING /* Verify the existence of the function. */ # define _GL_WARN_ON_USE(function, message) \ extern __typeof__ (function) function # else /* Unsupported. */ # define _GL_WARN_ON_USE(function, message) \ _GL_WARN_EXTERN_C int _gl_warn_on_use # endif #endif /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") is like _GL_WARN_ON_USE (function, "string"), except that the function is declared with the given prototype, consisting of return type, parameters, and attributes. This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does not work in this case. */ #ifndef _GL_WARN_ON_USE_CXX # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ extern rettype function parameters_and_attributes \ __attribute__ ((__warning__ (msg))) # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING /* Verify the existence of the function. */ # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ extern rettype function parameters_and_attributes # else /* Unsupported. */ # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ _GL_WARN_EXTERN_C int _gl_warn_on_use # endif #endif /* _GL_WARN_EXTERN_C declaration; performs the declaration with C linkage. */ #ifndef _GL_WARN_EXTERN_C # if defined __cplusplus # define _GL_WARN_EXTERN_C extern "C" # else # define _GL_WARN_EXTERN_C extern # endif #endif lftp-4.6.3a/build-aux/snippet/arg-nonnull.h0000644000015000007670000000230012533305066015532 00000000000000/* A C macro for declaring that specific arguments must not be NULL. Copyright (C) 2009-2015 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 . */ /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools that the values passed as arguments n, ..., m must be non-NULL pointers. n = 1 stands for the first argument, n = 2 for the second argument etc. */ #ifndef _GL_ARG_NONNULL # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) # else # define _GL_ARG_NONNULL(params) # endif #endif lftp-4.6.3a/build-aux/snippet/_Noreturn.h0000644000015000007670000000046212533305066015260 00000000000000#if !defined _Noreturn && __STDC_VERSION__ < 201112 # if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ || 0x5110 <= __SUNPRO_C) # define _Noreturn __attribute__ ((__noreturn__)) # elif 1200 <= _MSC_VER # define _Noreturn __declspec (noreturn) # else # define _Noreturn # endif #endif lftp-4.6.3a/build-aux/ltmain.sh0000644000015000007670000115505212533305057013301 00000000000000#! /bin/sh # libtool (GNU libtool) 2.4.2.418 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 . PROGRAM=libtool PACKAGE=libtool VERSION=2.4.2.418 package_revision=2.4.2.418 ## ------ ## ## Usage. ## ## ------ ## # Run './libtool --help' for help with using this script from the # command line. ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # After configure completes, it has a better idea of some of the # shell tools we need than the defaults used by the functions shared # with bootstrap, so set those here where they can still be over- # ridden by the user, but otherwise take precedence. : ${AUTOCONF="autoconf"} : ${AUTOMAKE="automake"} ## -------------------------- ## ## Source external libraries. ## ## -------------------------- ## # Much of our low-level functionality needs to be sourced from external # libraries, which are installed to $pkgauxdir. # Set a version string for this script. scriptversion=2013-08-23.20; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 # Copyright (C) 2004-2013 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # 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. # As a special exception to the GNU General Public License, if you distribute # this file as part of a program or library that is built using GNU Libtool, # you may include this file under the same distribution terms that you use # for the rest of that program. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNES 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 . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # Evaluate this file near the top of your script to gain access to # the functions and variables defined here: # # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh # # If you need to override any of the default environment variable # settings, do that before evaluating this file. ## -------------------- ## ## Shell normalisation. ## ## -------------------- ## # Some shells need a little help to be as Bourne compatible as possible. # Before doing anything else, make sure all that help has been provided! DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # NLS nuisances: We save the old values in case they are required later. _G_user_locale= _G_safe_locale= for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test set = \"\${$_G_var+set}\"; then save_$_G_var=\$$_G_var $_G_var=C export $_G_var _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Make sure IFS has a sensible default sp=' ' nl=' ' IFS="$sp $nl" # There are still modern systems that have problems with 'echo' mis- # handling backslashes, among others, so make sure $bs_echo is set to a # command that correctly interprets backslashes. # (this code from Autoconf 2.68) # Printing a long string crashes Solaris 7 /usr/bin/printf. bs_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' bs_echo=$bs_echo$bs_echo$bs_echo$bs_echo$bs_echo bs_echo=$bs_echo$bs_echo$bs_echo$bs_echo$bs_echo$bs_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $bs_echo`" = "X$bs_echo") 2>/dev/null; then bs_echo='print -r --' bs_echo_n='print -rn --' elif (test "X`printf %s $bs_echo`" = "X$bs_echo") 2>/dev/null; then bs_echo='printf %s\n' bs_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $bs_echo) 2>/dev/null`" = "X-n $bs_echo"; then bs_echo_body='eval /usr/ucb/echo -n "$1$nl"' bs_echo_n='/usr/ucb/echo -n' else bs_echo_body='eval expr "X$1" : "X\\(.*\\)"' bs_echo_n_body='eval arg=$1; case $arg in #( *"$nl"*) expr "X$arg" : "X\\(.*\\)$nl"; arg=`expr "X$arg" : ".*$nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$nl" ' export bs_echo_n_body bs_echo_n='sh -c $bs_echo_n_body bs_echo' fi export bs_echo_body bs_echo='sh -c $bs_echo_body bs_echo' fi ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # All uppercase variable names are used for environment variables. These # variables can be overridden by the user before calling a script that # uses them if a suitable command of that name is not already available # in the command search PATH. : ${CP="cp -f"} : ${ECHO="$bs_echo"} : ${EGREP="grep -E"} : ${FGREP="grep -F"} : ${GREP="grep"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SED="sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} ## -------------------- ## ## Useful sed snippets. ## ## -------------------- ## sed_dirname='s|/[^/]*$||' sed_basename='s|^.*/||' # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s|\([`"$\\]\)|\\\1|g' # Same as above, but do not quote variable references. sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' # Sed substitution that converts a w32 file name or path # that contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-'\' parameter expansions in output of sed_double_quote_subst that # were '\'-ed in input to the same. If an odd number of '\' preceded a # '$' in input to sed_double_quote_subst, that '$' was protected from # expansion. Since each input '\' is now two '\'s, look for any number # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. _G_bs='\\' _G_bs2='\\\\' _G_bs4='\\\\\\\\' _G_dollar='\$' sed_double_backslash="\ s/$_G_bs4/&\\ /g s/^$_G_bs2$_G_dollar/$_G_bs&/ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g s/\n//g" ## ----------------- ## ## Global variables. ## ## ----------------- ## # Except for the global variables explicitly listed below, the following # functions in the '^func_' namespace, and the '^require_' namespace # variables initialised in the 'Resource management' section, sourcing # this file will not pollute your global namespace with anything # else. There's no portable way to scope variables in Bourne shell # though, so actually running these functions will sometimes place # results into a variable named after the function, and often use # temporary variables in the '^_G_' namespace. If you are careful to # avoid using those namespaces casually in your sourcing script, things # should continue to work as you expect. And, of course, you can freely # overwrite any of the functions or variables defined here before # calling anything to customize them. EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. # Allow overriding, eg assuming that you follow the convention of # putting '$debug_cmd' at the start of all your functions, you can get # bash to show function call trace with: # # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name debug_cmd=${debug_cmd-":"} exit_cmd=: # By convention, finish your script with: # # exit $exit_status # # so that you can set exit_status to non-zero if you want to indicate # something went wrong during execution without actually bailing out at # the point of failure. exit_status=$EXIT_SUCCESS # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath=$0 # The name of this program. progname=`$bs_echo "$progpath" |$SED "$sed_basename"` # Make sure we have an absolute progpath for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=`$bs_echo "$progpath" |$SED "$sed_dirname"` progdir=`cd "$progdir" && pwd` progpath=$progdir/$progname ;; *) _G_IFS=$IFS IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS=$_G_IFS test -x "$progdir/$progname" && break done IFS=$_G_IFS test -n "$progdir" || progdir=`pwd` progpath=$progdir/$progname ;; esac ## ----------------- ## ## Standard options. ## ## ----------------- ## # The following options affect the operation of the functions defined # below, and should be set appropriately depending on run-time para- # meters passed on the command line. opt_dry_run=false opt_quiet=false opt_verbose=false # Categories 'all' and 'none' are always available. Append any others # you will pass as the first argument to func_warning from your own # code. warning_categories= # By default, display warnings according to 'opt_warning_types'. Set # 'warning_func' to ':' to elide all warnings, or func_fatal_error to # treat the next displayed warning as a fatal error. warning_func=func_warn_and_continue # Set to 'all' to display all warnings, 'none' to suppress all # warnings, or a space delimited list of some subset of # 'warning_categories' to display only the listed warnings. opt_warning_types=all ## -------------------- ## ## Resource management. ## ## -------------------- ## # This section contains definitions for functions that each ensure a # particular resource (a file, or a non-empty configuration variable for # example) is available, and if appropriate to extract default values # from pertinent package files. Call them using their associated # 'require_*' variable to ensure that they are executed, at most, once. # # It's entirely deliberate that calling these functions can set # variables that don't obey the namespace limitations obeyed by the rest # of this file, in order that that they be as useful as possible to # callers. # require_term_colors # ------------------- # Allow display of bold text on terminals that support it. require_term_colors=func_require_term_colors func_require_term_colors () { $debug_cmd test -t 1 && { # COLORTERM and USE_ANSI_COLORS environment variables take # precedence, because most terminfo databases neglect to describe # whether color sequences are supported. test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} if test 1 = "$USE_ANSI_COLORS"; then # Standard ANSI escape sequences tc_reset='' tc_bold=''; tc_standout='' tc_red=''; tc_green='' tc_blue=''; tc_cyan='' else # Otherwise trust the terminfo database after all. test -n "`tput sgr0 2>/dev/null`" && { tc_reset=`tput sgr0` test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` tc_standout=$tc_bold test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` } fi } require_term_colors=: } ## ----------------- ## ## Function library. ## ## ----------------- ## # This section contains a variety of useful functions to call in your # scripts. Take note of the portable wrappers for features provided by # some modern shells, which will fall back to slower equivalents on # less featureful shells. # func_append VAR VALUE # --------------------- # Append VALUE onto the existing contents of VAR. # We should try to minimise forks, especially on Windows where they are # unreasonably slow, so skip the feature probes when bash or zsh are # being used: if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then : ${_G_HAVE_ARITH_OP="yes"} : ${_G_HAVE_XSI_OPS="yes"} # The += operator was introduced in bash 3.1 case $BASH_VERSION in [12].* | 3.0 | 3.0*) ;; *) : ${_G_HAVE_PLUSEQ_OP="yes"} ;; esac fi # _G_HAVE_PLUSEQ_OP # Can be empty, in which case the shell is probed, "yes" if += is # useable or anything else if it does not work. test -z "$_G_HAVE_PLUSEQ_OP" \ && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ && _G_HAVE_PLUSEQ_OP=yes if test yes = "$_G_HAVE_PLUSEQ_OP" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_append () { $debug_cmd eval "$1+=\$2" }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_append () { $debug_cmd eval "$1=\$$1\$2" } fi # func_append_quoted VAR VALUE # ---------------------------- # Quote VALUE and append to the end of shell variable VAR, separated # by a space. if test yes = "$_G_HAVE_PLUSEQ_OP"; then eval 'func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1+=\\ \$func_quote_for_eval_result" }' else func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1=\$$1\\ \$func_quote_for_eval_result" } fi # func_append_uniq VAR VALUE # -------------------------- # Append unique VALUE onto the existing contents of VAR, assuming # entries are delimited by the first character of VALUE. For example: # # func_append_uniq options " --another-option option-argument" # # will only append to $options if " --another-option option-argument " # is not already present somewhere in $options already (note spaces at # each end implied by leading space in second argument). func_append_uniq () { $debug_cmd eval _G_current_value='`$bs_echo $'$1'`' _G_delim=`expr "$2" : '\(.\)'` case $_G_delim$_G_current_value$_G_delim in *"$2$_G_delim"*) ;; *) func_append "$@" ;; esac } # func_arith TERM... # ------------------ # Set func_arith_result to the result of evaluating TERMs. test -z "$_G_HAVE_ARITH_OP" \ && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ && _G_HAVE_ARITH_OP=yes if test yes = "$_G_HAVE_ARITH_OP"; then eval 'func_arith () { $debug_cmd func_arith_result=$(( $* )) }' else func_arith () { $debug_cmd func_arith_result=`expr "$@"` } fi # func_basename FILE # ------------------ # Set func_basename_result to FILE with everything up to and including # the last / stripped. if test yes = "$_G_HAVE_XSI_OPS"; then # If this shell supports suffix pattern removal, then use it to avoid # forking. Hide the definitions single quotes in case the shell chokes # on unsupported syntax... _b='func_basename_result=${1##*/}' _d='case $1 in */*) func_dirname_result=${1%/*}$2 ;; * ) func_dirname_result=$3 ;; esac' else # ...otherwise fall back to using sed. _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` if test "X$func_dirname_result" = "X$1"; then func_dirname_result=$3 else func_append func_dirname_result "$2" fi' fi eval 'func_basename () { $debug_cmd '"$_b"' }' # func_dirname FILE APPEND NONDIR_REPLACEMENT # ------------------------------------------- # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. eval 'func_dirname () { $debug_cmd '"$_d"' }' # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT # -------------------------------------------------------- # Perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # For efficiency, we do not delegate to the functions above but instead # duplicate the functionality here. eval 'func_dirname_and_basename () { $debug_cmd '"$_b"' '"$_d"' }' # func_echo ARG... # ---------------- # Echo program name prefixed message. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $bs_echo "$progname: $_G_line" done IFS=$func_echo_IFS } # func_echo_all ARG... # -------------------- # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_echo_infix_1 INFIX ARG... # ------------------------------ # Echo program name, followed by INFIX on the first line, with any # additional lines not showing INFIX. func_echo_infix_1 () { $debug_cmd $require_term_colors _G_infix=$1; shift _G_indent=$_G_infix _G_prefix="$progname: $_G_infix: " _G_message=$* # Strip color escape sequences before counting printable length for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" do test -n "$_G_tc" && { _G_esc_tc=`$bs_echo "$_G_tc" | sed "$sed_make_literal_regex"` _G_indent=`$bs_echo "$_G_indent" | sed "s|$_G_esc_tc||g"` } done _G_indent="$progname: "`echo "$_G_indent" | sed 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes func_echo_infix_1_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_infix_1_IFS $bs_echo "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 _G_prefix=$_G_indent done IFS=$func_echo_infix_1_IFS } # func_error ARG... # ----------------- # Echo program name prefixed message to standard error. func_error () { $debug_cmd $require_term_colors func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 } # func_fatal_error ARG... # ----------------------- # Echo program name prefixed message to standard error, and exit. func_fatal_error () { $debug_cmd func_error "$*" exit $EXIT_FAILURE } # func_grep EXPRESSION FILENAME # ----------------------------- # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $debug_cmd $GREP "$1" "$2" >/dev/null 2>&1 } # func_len STRING # --------------- # Set func_len_result to the length of STRING. STRING may not # start with a hyphen. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_len () { $debug_cmd func_len_result=${#1} }' else func_len () { $debug_cmd func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } fi # func_mkdir_p DIRECTORY-PATH # --------------------------- # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { $debug_cmd _G_directory_path=$1 _G_dir_list= if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then # Protect directory names starting with '-' case $_G_directory_path in -*) _G_directory_path=./$_G_directory_path ;; esac # While some portion of DIR does not yet exist... while test ! -d "$_G_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. _G_dir_list=$_G_directory_path:$_G_dir_list # If the last portion added has no slash in it, the list is done case $_G_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` done _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` func_mkdir_p_IFS=$IFS; IFS=: for _G_dir in $_G_dir_list; do IFS=$func_mkdir_p_IFS # mkdir can fail with a 'File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$_G_dir" 2>/dev/null || : done IFS=$func_mkdir_p_IFS # Bail out if we (or some other process) failed to create a directory. test -d "$_G_directory_path" || \ func_fatal_error "Failed to create '$1'" fi } # func_mktempdir [BASENAME] # ------------------------- # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, BASENAME is the basename for that directory. func_mktempdir () { $debug_cmd _G_template=${TMPDIR-/tmp}/${1-$progname} if test : = "$opt_dry_run"; then # Return a directory name, but don't create it in dry-run mode _G_tmpdir=$_G_template-$$ else # If mktemp works, use that first and foremost _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` if test ! -d "$_G_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race _G_tmpdir=$_G_template-${RANDOM-0}$$ func_mktempdir_umask=`umask` umask 0077 $MKDIR "$_G_tmpdir" umask $func_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$_G_tmpdir" || \ func_fatal_error "cannot create temporary directory '$_G_tmpdir'" fi $ECHO "$_G_tmpdir" } # func_normal_abspath PATH # ------------------------ # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. func_normal_abspath () { $debug_cmd # These SED scripts presuppose an absolute path with a trailing slash. _G_pathcar='s|^/\([^/]*\).*$|\1|' _G_pathcdr='s|^/[^/]*||' _G_removedotparts=':dotsl s|/\./|/|g t dotsl s|/\.$|/|' _G_collapseslashes='s|/\{1,\}|/|g' _G_finalslash='s|/*$|/|' # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` while :; do # Processed it all yet? if test / = "$func_normal_abspath_tpath"; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result"; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_notquiet ARG... # -------------------- # Echo program name prefixed message only when not in quiet mode. func_notquiet () { $debug_cmd $opt_quiet || func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_relative_path SRCDIR DSTDIR # -------------------------------- # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. func_relative_path () { $debug_cmd func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=$func_dirname_result if test -z "$func_relative_path_tlibdir"; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test -n "$func_stripname_result"; then func_append func_relative_path_result "/$func_stripname_result" fi # Normalisation. If bindir is libdir, return '.' else relative path. if test -n "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result" func_relative_path_result=$func_stripname_result fi test -n "$func_relative_path_result" || func_relative_path_result=. : } # func_quote_for_eval ARG... # -------------------------- # Aesthetically quote ARGs to be evaled later. # This function returns two values: # i) func_quote_for_eval_result # double-quoted, suitable for a subsequent eval # ii) func_quote_for_eval_unquoted_result # has all characters that are still active within double # quotes backslashified. func_quote_for_eval () { $debug_cmd func_quote_for_eval_unquoted_result= func_quote_for_eval_result= while test 0 -lt $#; do case $1 in *[\\\`\"\$]*) _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; *) _G_unquoted_arg=$1 ;; esac if test -n "$func_quote_for_eval_unquoted_result"; then func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" else func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" fi case $_G_unquoted_arg in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and variable expansion # for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_quoted_arg=\"$_G_unquoted_arg\" ;; *) _G_quoted_arg=$_G_unquoted_arg ;; esac if test -n "$func_quote_for_eval_result"; then func_append func_quote_for_eval_result " $_G_quoted_arg" else func_append func_quote_for_eval_result "$_G_quoted_arg" fi shift done } # func_quote_for_expand ARG # ------------------------- # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { $debug_cmd case $1 in *[\\\`\"]*) _G_arg=`$ECHO "$1" | $SED \ -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; *) _G_arg=$1 ;; esac case $_G_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_arg=\"$_G_arg\" ;; esac func_quote_for_expand_result=$_G_arg } # func_stripname PREFIX SUFFIX NAME # --------------------------------- # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_stripname () { $debug_cmd # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary variable first. func_stripname_result=$3 func_stripname_result=${func_stripname_result#"$1"} func_stripname_result=${func_stripname_result%"$2"} }' else func_stripname () { $debug_cmd case $2 in .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; esac } fi # func_show_eval CMD [FAIL_EXP] # ----------------------------- # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} func_quote_for_expand "$_G_cmd" eval "func_notquiet $func_quote_for_expand_result" $opt_dry_run || { eval "$_G_cmd" _G_status=$? if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_show_eval_locale CMD [FAIL_EXP] # ------------------------------------ # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} $opt_quiet || { func_quote_for_expand "$_G_cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || { eval "$_G_user_locale $_G_cmd" _G_status=$? eval "$_G_safe_locale" if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_tr_sh # ---------- # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { $debug_cmd case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_verbose ARG... # ------------------- # Echo program name prefixed message in verbose mode only. func_verbose () { $debug_cmd $opt_verbose && func_echo "$*" : } # func_warn_and_continue ARG... # ----------------------------- # Echo program name prefixed warning message to standard error. func_warn_and_continue () { $debug_cmd $require_term_colors func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 } # func_warning CATEGORY ARG... # ---------------------------- # Echo program name prefixed warning message to standard error. Warning # messages can be filtered according to CATEGORY, where this function # elides messages where CATEGORY is not listed in the global variable # 'opt_warning_types'. func_warning () { $debug_cmd # CATEGORY must be in the warning_categories list! case " $warning_categories " in *" $1 "*) ;; *) func_internal_error "invalid warning category '$1'" ;; esac _G_category=$1 shift case " $opt_warning_types " in *" $_G_category "*) $warning_func ${1+"$@"} ;; esac } # func_sort_ver VER1 VER2 # ----------------------- # 'sort -V' is not generally available. # Note this deviates from the version comparison in automake # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a # but this should suffice as we won't be specifying old # version formats or redundant trailing .0 in bootstrap.conf. # If we did want full compatibility then we should probably # use m4_version_compare from autoconf. func_sort_ver () { $debug_cmd ver1=$1 ver2=$2 # Split on '.' and compare each component. i=1 while :; do p1=`echo "$ver1" |cut -d. -f$i` p2=`echo "$ver2" |cut -d. -f$i` if test ! "$p1"; then echo "$1 $2" break elif test ! "$p2"; then echo "$2 $1" break elif test ! "$p1" = "$p2"; then if test "$p1" -gt "$p2" 2>/dev/null; then # numeric comparison echo "$2 $1" elif test "$p2" -gt "$p1" 2>/dev/null; then # numeric comparison echo "$1 $2" else # numeric, then lexicographic comparison lp=`printf "$p1\n$p2\n" |sort -n |tail -n1` if test "$lp" = "$p2"; then echo "$1 $2" else echo "$2 $1" fi fi break fi i=`expr $i + 1` done } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: #! /bin/sh # Set a version string for this script. scriptversion=2012-10-21.11; # UTC # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 # Copyright (C) 2010-2013 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # 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 . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # This file is a library for parsing options in your shell scripts along # with assorted other useful supporting features that you can make use # of too. # # For the simplest scripts you might need only: # # #!/bin/sh # . relative/path/to/funclib.sh # . relative/path/to/options-parser # scriptversion=1.0 # func_options ${1+"$@"} # eval set dummy "$func_options_result"; shift # ...rest of your script... # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file # starting with '# Written by ' and ending with '# warranty; '. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the # '# Written by ' line, like the one at the top of this file. # # The default options also support '--debug', which will turn on shell # execution tracing (see the comment above debug_cmd below for another # use), and '--verbose' and the func_verbose function to allow your script # to display verbose messages only when your user has specified # '--verbose'. # # After sourcing this file, you can plug processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. ## -------------- ## ## Configuration. ## ## -------------- ## # You should override these variables in your script after sourcing this # file so that they reflect the customisations you have added to the # option parser. # The usage line for option parsing errors and the start of '-h' and # '--help' output messages. You can embed shell variables for delayed # expansion at the time the message is displayed, but you will need to # quote other shell meta-characters carefully to prevent them being # expanded when the contents are evaled. usage='$progpath [OPTION]...' # Short help message in response to '-h' and '--help'. Add to this or # override it after sourcing this library to reflect the full set of # options your script accepts. usage_message="\ --debug enable verbose shell tracing -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -v, --verbose verbosely report processing --version print version information and exit -h, --help print short or long help message and exit " # Additional text appended to 'usage_message' in response to '--help'. long_help_message=" Warning categories include: 'all' show all warnings 'none' turn off all the warnings 'error' warnings are treated as fatal errors" # Help message printed before fatal option parsing errors. fatal_help="Try '\$progname --help' for more information." ## ------------------------- ## ## Hook function management. ## ## ------------------------- ## # This section contains functions for adding, removing, and running hooks # to the main code. A hook is just a named list of of function, that can # be run in order later on. # func_hookable FUNC_NAME # ----------------------- # Declare that FUNC_NAME will run hooks added with # 'func_add_hook FUNC_NAME ...'. func_hookable () { $debug_cmd func_append hookable_fns " $1" } # func_add_hook FUNC_NAME HOOK_FUNC # --------------------------------- # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must # first have been declared "hookable" by a call to 'func_hookable'. func_add_hook () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not accept hook functions." ;; esac eval func_append ${1}_hooks '" $2"' } # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ # Remove HOOK_FUNC from the list of functions called by FUNC_NAME. func_remove_hook () { $debug_cmd eval ${1}_hooks='`$bs_echo "\$'$1'_hooks" |$SED "s| '$2'||"`' } # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. # It is assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. func_run_hooks () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not support hook funcions.n" ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do eval $_G_hook '"$@"' # store returned options list back into positional # parameters for next 'cmd' execution. eval _G_hook_result=\$${_G_hook}_result eval set dummy "$_G_hook_result"; shift done func_quote_for_eval ${1+"$@"} func_run_hooks_result=$func_quote_for_eval_result } ## --------------- ## ## Option parsing. ## ## --------------- ## # In order to add your own option parsing hooks, you must accept the # full positional parameter list in your hook function, remove any # options that you action, and then pass back the remaining unprocessed # options in '_result', escaped suitably for # 'eval'. Like this: # # my_options_prep () # { # $debug_cmd # # # Extend the existing usage message. # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' # # func_quote_for_eval ${1+"$@"} # my_options_prep_result=$func_quote_for_eval_result # } # func_add_hook func_options_prep my_options_prep # # # my_silent_option () # { # $debug_cmd # # # Note that for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in # --silent|-s) opt_silent=: ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift # ;; # *) set dummy "$_G_opt" "$*"; shift; break ;; # esac # done # # func_quote_for_eval ${1+"$@"} # my_silent_option_result=$func_quote_for_eval_result # } # func_add_hook func_parse_options my_silent_option # # # my_option_validation () # { # $debug_cmd # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." # # func_quote_for_eval ${1+"$@"} # my_option_validation_result=$func_quote_for_eval_result # } # func_add_hook func_validate_options my_option_validation # # You'll alse need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the # individual implementations for details. func_hookable func_options func_options () { $debug_cmd func_options_prep ${1+"$@"} eval func_parse_options \ ${func_options_prep_result+"$func_options_prep_result"} eval func_validate_options \ ${func_parse_options_result+"$func_parse_options_result"} eval func_run_hooks func_options \ ${func_validate_options_result+"$func_validate_options_result"} # save modified positional parameters for caller func_options_result=$func_run_hooks_result } # func_options_prep [ARG]... # -------------------------- # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and # needs to propogate that back to rest of this script, then the complete # modified list must be put in 'func_run_hooks_result' before # returning. func_hookable func_options_prep func_options_prep () { $debug_cmd # Option defaults: opt_verbose=false opt_warning_types= func_run_hooks func_options_prep ${1+"$@"} # save modified positional parameters for caller func_options_prep_result=$func_run_hooks_result } # func_parse_options [ARG]... # --------------------------- # The main option parsing loop. func_hookable func_parse_options func_parse_options () { $debug_cmd func_parse_options_result= # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. func_run_hooks func_parse_options ${1+"$@"} # Adjust func_parse_options positional parameters to match eval set dummy "$func_run_hooks_result"; shift # Break out of the loop if we already parsed every option. test $# -gt 0 || break _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' func_echo "enabling shell trace mode" $debug_cmd ;; --no-warnings|--no-warning|--no-warn) set dummy --warnings none ${1+"$@"} shift ;; --warnings|--warning|-W) test $# = 0 && func_missing_arg $_G_opt && break case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above func_append_uniq opt_warning_types " $1" ;; *all) opt_warning_types=$warning_categories ;; *none) opt_warning_types=none warning_func=: ;; *error) opt_warning_types=$warning_categories warning_func=func_fatal_error ;; *) func_fatal_error \ "unsupported warning category: '$1'" ;; esac shift ;; --verbose|-v) opt_verbose=: ;; --version) func_version ;; -\?|-h) func_usage ;; --help) func_help ;; # Separate optargs to long options (plugins may need this): --*=*) func_split_equals "$_G_opt" set dummy "$func_split_equals_lhs" \ "$func_split_equals_rhs" ${1+"$@"} shift ;; # Separate optargs to short options: -W*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "$func_split_short_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-v*|-x*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; esac done # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} func_parse_options_result=$func_quote_for_eval_result } # func_validate_options [ARG]... # ------------------------------ # Perform any sanity checks on option settings and/or unconsumed # arguments. func_hookable func_validate_options func_validate_options () { $debug_cmd # Display all warnings if -W was not given. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" func_run_hooks func_validate_options ${1+"$@"} # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE # save modified positional parameters for caller func_validate_options_result=$func_run_hooks_result } ## ------------------## ## Helper functions. ## ## ------------------## # This section contains the helper functions used by the rest of the # hookable option parser framework in ascii-betical order. # func_fatal_help ARG... # ---------------------- # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { $debug_cmd eval \$bs_echo \""Usage: $usage"\" eval \$bs_echo \""$fatal_help"\" func_error ${1+"$@"} exit $EXIT_FAILURE } # func_help # --------- # Echo long help message to standard output and exit. func_help () { $debug_cmd func_usage_message $bs_echo "$long_help_message" exit 0 } # func_missing_arg ARGNAME # ------------------------ # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $debug_cmd func_error "Missing argument for '$1'." exit_cmd=exit } # func_split_equals STRING # ------------------------ # Set func_split_equals_lhs and func_split_equals_rhs shell variables after # splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_equals () { $debug_cmd func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} test "x$func_split_equals_lhs" = "x$1" \ && func_split_equals_rhs= }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_equals () { $debug_cmd func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` func_split_equals_rhs= test "x$func_split_equals_lhs" = "x$1" \ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` } fi #func_split_equals # func_split_short_opt SHORTOPT # ----------------------------- # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_short_opt () { $debug_cmd func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"} }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_short_opt () { $debug_cmd func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` } fi #func_split_short_opt # func_usage # ---------- # Echo short help message to standard output and exit. func_usage () { $debug_cmd func_usage_message $bs_echo "Run '$progname --help |${PAGER-more}' for full usage" exit 0 } # func_usage_message # ------------------ # Echo short help message to standard output. func_usage_message () { $debug_cmd eval \$bs_echo \""Usage: $usage"\" echo $SED -n 's|^# || /^Written by/{ x;p;x } h /^Written by/q' < "$progpath" echo eval \$bs_echo \""$usage_message"\" } # func_version # ------------ # Echo version message to standard output and exit. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n '/^##/q /(C)/!b go :more /\./!{ N s|\n# | | b more } :go /^# Written by /,/# warranty; / { s|^# || s|^# *$|| s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| p } /^# Written by / { s|^# || p } /^warranty; /q' < "$progpath" exit $? } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: # Set a version string. scriptversion='(GNU libtool) 2.4.2.418' # func_echo ARG... # ---------------- # Libtool also displays the current mode in messages, so override # funclib.sh func_echo with this custom definition. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $bs_echo "$progname${opt_mode+: $opt_mode}: $_G_line" done IFS=$func_echo_IFS } # func_warning ARG... # ------------------- # Libtool warnings are not categorized, so override funclib.sh # func_warning with this simpler definition. func_warning () { $debug_cmd $warning_func ${1+"$@"} } ## ---------------- ## ## Options parsing. ## ## ---------------- ## # Hook in the functions to make sure our own options are parsed during # the option parsing loop. usage='$progpath [OPTION]... [MODE-ARG]...' # Short help message in response to '-h'. usage_message="Options: --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --mode=MODE use operation mode MODE --no-warnings equivalent to '-Wnone' --preserve-dup-deps don't remove duplicate dependency libraries --quiet, --silent don't print informational messages --tag=TAG use configuration variables from tag TAG -v, --verbose print more informational messages than default --version print version information -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -h, --help, --help-all print short, long, or detailed help message " # Additional text appended to 'usage_message' in response to '--help'. long_help_message=$long_help_message" MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. When passed as first option, '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. Try '$progname --help --mode=MODE' for a more detailed description of MODE. When reporting a bug, please describe a test case to reproduce it and include the following information: host-triplet: $host shell: $SHELL compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) version: $progname (GNU libtool) 2.4.2.418 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . GNU libtool home page: . General help using GNU software: ." # func_lo2o OBJECT-NAME # --------------------- # Transform OBJECT-NAME from a '.lo' suffix to the platform specific # object suffix. lo2o=s/\\.lo\$/.$objext/ o2lo=s/\\.$objext\$/.lo/ if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_lo2o () { case $1 in *.lo) func_lo2o_result=${1%.lo}.$objext ;; * ) func_lo2o_result=$1 ;; esac }' # func_xform LIBOBJ-OR-SOURCE # --------------------------- # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) # suffix to a '.lo' libtool-object suffix. eval 'func_xform () { func_xform_result=${1%.*}.lo }' else # ...otherwise fall back to using sed. func_lo2o () { func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` } func_xform () { func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` } fi # func_fatal_configuration ARG... # ------------------------------- # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func__fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "Fatal configuration error." } # func_config # ----------- # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # ------------- # Display the features supported by this script. func_features () { echo "host: $host" if test yes = "$build_libtool_libs"; then echo "enable shared libraries" else echo "disable shared libraries" fi if test yes = "$build_old_libs"; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag TAGNAME # ----------------------- # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname=$1 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf=/$re_begincf/,/$re_endcf/p # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # ------------------------ # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # libtool_options_prep [ARG]... # ----------------------------- # Preparation for options parsed by libtool. libtool_options_prep () { $debug_mode # Option defaults: opt_config=false opt_dlopen= opt_dry_run=false opt_help=false opt_mode= opt_preserve_dup_deps=false opt_quiet=false nonopt= preserve_args= # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Pass back the list of options. func_quote_for_eval ${1+"$@"} libtool_options_prep_result=$func_quote_for_eval_result } func_add_hook func_options_prep libtool_options_prep # libtool_parse_options [ARG]... # --------------------------------- # Provide handling for libtool specific options. libtool_parse_options () { $debug_cmd # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do _G_opt=$1 shift case $_G_opt in --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) func_config ;; --dlopen|-dlopen) opt_dlopen="${opt_dlopen+$opt_dlopen }$1" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) func_features ;; --finish) set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $_G_opt && break opt_mode=$1 case $1 in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $_G_opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_quiet=false func_append preserve_args " $_G_opt" ;; --no-warnings|--no-warning|--no-warn) opt_warning=false func_append preserve_args " $_G_opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $_G_opt" ;; --silent|--quiet) opt_quiet=: opt_verbose=false func_append preserve_args " $_G_opt" ;; --tag) test $# = 0 && func_missing_arg $_G_opt && break opt_tag=$1 func_append preserve_args " $_G_opt $1" func_enable_tag "$1" shift ;; --verbose|-v) opt_quiet=false opt_verbose=: func_append preserve_args " $_G_opt" ;; # An option not handled by this hook function: *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; esac done # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} libtool_parse_options_result=$func_quote_for_eval_result } func_add_hook func_parse_options libtool_parse_options # libtool_validate_options [ARG]... # --------------------------------- # Perform any sanity checks on option settings and/or unconsumed # arguments. libtool_validate_options () { # save first non-option argument if test 0 -lt $#; then nonopt=$1 shift fi # preserve --debug test : = "$debug_cmd" || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match test yes != "$build_libtool_libs" \ && test yes != "$build_old_libs" \ && func_fatal_configuration "not configured to build any kind of library" # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test execute != "$opt_mode"; then func_error "unrecognized option '-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help=$help help="Try '$progname --help --mode=$opt_mode' for more information." } # Pass back the unparsed argument list func_quote_for_eval ${1+"$@"} libtool_validate_options_result=$func_quote_for_eval_result } func_add_hook func_validate_options libtool_validate_options # Process options as early as possible so that --help and --version # can return quickly. func_options ${1+"$@"} eval set dummy "$func_options_result"; shift ## ----------- ## ## Main. ## ## ----------- ## magic='%%%MAGIC variable%%%' magic_exe='%%%MAGIC EXE variable%%%' # Global variables. extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # func_lalib_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if 'file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case $lalib_p_line in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test yes = "$lalib_p" } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $debug_cmd save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # 'FILE.' does not work on cygwin managed mounts. func_source () { $debug_cmd case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case $lt_sysroot:$1 in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result='='$func_stripname_result ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $debug_cmd if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with '--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=$1 if test yes = "$build_libtool_libs"; then write_lobj=\'$2\' else write_lobj=none fi if test yes = "$build_old_libs"; then write_oldobj=\'$3\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $debug_cmd # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result= if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result"; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $debug_cmd if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $debug_cmd # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $debug_cmd if test -z "$2" && test -n "$1"; then func_error "Could not determine host file name corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result=$1 fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $debug_cmd if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " '$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result=$3 fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $debug_cmd case $4 in $1 ) func_to_host_path_result=$3$func_to_host_path_result ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via '$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $debug_cmd $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $debug_cmd case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result=$1 } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result=$func_convert_core_msys_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result=$func_convert_core_file_wine_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via '$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $debug_cmd if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd=func_convert_path_$func_stripname_result fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $debug_cmd func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result=$1 } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_msys_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_path_wine_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_dll_def_p FILE # True iff FILE is a Windows DLL '.def' file. # Keep in sync with _LT_DLL_DEF_P in libtool.m4 func_dll_def_p () { $debug_cmd func_dll_def_p_tmp=`$SED -n \ -e 's/^[ ]*//' \ -e '/^\(;.*\)*$/d' \ -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ -e q \ "$1"` test DEF = "$func_dll_def_p_tmp" } # func_mode_compile arg... func_mode_compile () { $debug_cmd # Get the compilation command and the source file. base_compile= srcfile=$nonopt # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg=$arg arg_mode=normal ;; target ) libobj=$arg arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify '-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs=$IFS; IFS=, for arg in $args; do IFS=$save_ifs func_append_quoted lastarg "$arg" done IFS=$save_ifs func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg=$srcfile srcfile=$arg ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with '-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj=$func_basename_result } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from '$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test yes = "$build_libtool_libs" \ || func_fatal_configuration "cannot build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname=$func_basename_result xdir=$func_dirname_result lobj=$xdir$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test yes = "$build_old_libs"; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test no = "$compiler_c_o"; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext lockfile=$output_obj.lock else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test yes = "$need_locks"; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test warn = "$need_locks"; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test yes = "$build_libtool_libs"; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test no != "$pic_mode"; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test yes = "$suppress_opt"; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test yes = "$build_old_libs"; then if test yes != "$pic_mode"; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test yes = "$compiler_c_o"; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test no != "$need_locks"; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test compile = "$opt_mode" && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a '.o' file suitable for static linking -static only build a '.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a 'standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix '.c' with the library object suffix, '.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to '-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the '--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the 'install' or 'cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with '-') are ignored. Every other argument is treated as a filename. Files ending in '.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in '.la', then a libtool library is created, only library objects ('.lo' files) may be specified, and '-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created using 'ar' and 'ranlib', or on Windows using 'lib'. If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode '$opt_mode'" ;; esac echo $ECHO "Try '$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test : = "$opt_help"; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $debug_cmd # The first argument is the command name. cmd=$nonopt test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "'$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "'$file' was not linked with '-export-dynamic'" continue fi func_dirname "$file" "" "." dir=$func_dirname_result if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir=$func_dirname_result ;; *) func_warning "'-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir=$absdir # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic=$magic # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file=$progdir/$program elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file=$progdir/$program fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if $opt_dry_run; then # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS else if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd=\$cmd$args fi } test execute = "$opt_mode" && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $debug_cmd libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "'$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument '$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and '=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_quiet && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the '-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the '$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the '$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the '$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test finish = "$opt_mode" && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $debug_cmd # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=false stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=: ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test X-m = "X$prev" && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the '$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=: if $isdir; then destdir=$dest destname= else func_dirname_and_basename "$dest" "" "." destdir=$func_dirname_result destname=$func_basename_result # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "'$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "'$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir=$func_dirname_result func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking '$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname=$1 shift srcname=$realname test -n "$relink_command" && srcname=${realname}T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme=$stripme case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme= ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try 'ln -sf' first, because the 'ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib=$destdir/$realname func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name=$func_basename_result instname=$dir/${name}i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest=$destfile destfile= ;; *) func_fatal_help "cannot copy a libtool object to '$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test yes = "$build_old_libs"; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext= case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=.exe fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script '$wrapper'" finalize=: for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` if test -n "$libdir" && test ! -f "$libfile"; then func_warning "'$lib' has not been installed in '$libdir'" finalize=false fi done relink_command= func_source "$wrapper" outputname= if test no = "$fast_install" && test -n "$relink_command"; then $opt_dry_run || { if $finalize; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file=$func_basename_result outputname=$tmpdir/$file # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_quiet || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink '$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file=$outputname else func_warning "cannot relink '$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name=$func_basename_result # Set up the ranlib parameters. oldlib=$destdir/$name func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run '$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test install = "$opt_mode" && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $debug_cmd my_outputname=$1 my_originator=$2 my_pic_p=${3-false} my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms=${my_outputname}S.c else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist=$output_objdir/$my_outputname.nm func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* External symbol declarations for the compiler. */\ " if test yes = "$dlself"; then func_verbose "generating symbol list for '$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from '$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols=$output_objdir/$outputname.exp $opt_dry_run || { $RM $export_symbols eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from '$dlprefile'" func_basename "$dlprefile" name=$func_basename_result case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename= if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname"; then func_basename "$dlprefile_dlname" dlprefile_dlbasename=$func_basename_result else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename"; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi func_show_eval '$RM "${nlist}I"' if test -n "$global_symbol_to_import"; then eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[];\ " if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ static void lt_syminit(void) { LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; for (; symbol->name; ++symbol) {" $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" echo >> "$output_objdir/$my_dlsyms" "\ } }" fi echo >> "$output_objdir/$my_dlsyms" "\ LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = { {\"$my_originator\", (void *) 0}," if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ {\"@INIT@\", (void *) <_syminit}," fi case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) $my_pic_p && pic_flag_for_symtable=" $pic_flag" ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' # Transform the symbol file into the correct name. symfileobj=$output_objdir/${my_outputname}S.$objext case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for '$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $debug_cmd win32_libid_type=unknown win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then case $nm_interface in "MS dumpbin") if func_cygming_ms_implib_p "$1" || func_cygming_gnu_implib_p "$1" then win32_nmres=import else win32_nmres= fi ;; *) func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s|.*|import| p q } }'` ;; esac case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $debug_cmd sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $debug_cmd match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive that possess that section. Heuristic: eliminate # all those that have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $debug_cmd if func_cygming_gnu_implib_p "$1"; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1"; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result= fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $debug_cmd f_ex_an_ar_dir=$1; shift f_ex_an_ar_oldlib=$1 if test yes = "$lock_old_archive_extraction"; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test yes = "$lock_old_archive_extraction"; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $debug_cmd my_gentop=$1; shift my_oldlibs=${1+"$@"} my_oldobjs= my_xlib= my_xabs= my_xdir= for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib=$func_basename_result my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir=$my_gentop/$my_xlib_u func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` func_basename "$darwin_archive" darwin_base_archive=$func_basename_result darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches; do func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" cd "unfat-$$/$darwin_base_archive-$darwin_arch" func_extract_an_archive "`pwd`" "$darwin_base_archive" cd "$darwin_curdir" $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result=$my_oldobjs } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory where it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ that is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options that match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test yes = "$fast_install"; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* declarations of non-ANSI functions */ #if defined __MINGW32__ # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined other_platform || defined ... */ #endif /* portability defines, excluding path handling macros */ #if defined _MSC_VER # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC #elif defined __MINGW32__ # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined __CYGWIN__ # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined other platforms ... */ #endif #if defined PATH_MAX # define LT_PATHMAX PATH_MAX #elif defined MAXPATHLEN # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ defined __OS2__ # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free (stale); stale = 0; } \ } while (0) #if defined LT_DEBUGWRAPPER static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; size_t tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined HAVE_DOS_BASED_FILE_SYSTEM if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined HAVE_DOS_BASED_FILE_SYSTEM } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = (size_t) (q - p); p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (STREQ (str, pat)) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else size_t len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { size_t orig_value_len = strlen (orig_value); size_t add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ size_t len = strlen (new_value); while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[--len] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $debug_cmd case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $debug_cmd case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # what system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll that has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=false prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module=$wl-single_module func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test yes != "$build_libtool_libs" \ && func_fatal_configuration "cannot build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg=$1 shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir=$arg prev= continue ;; dlfiles|dlprefiles) $preload || { # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=: } case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test no = "$dlself"; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test dlprefiles = "$prev"; then dlself=yes elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test dlfiles = "$prev"; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols=$arg test -f "$arg" \ || func_fatal_error "symbol file '$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex=$arg prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir=$arg prev= continue ;; mllvm) # Clang does not use LLVM to link, so we can simply discard any # '-mllvm $arg' options when doing the link step. prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result if test none != "$pic_object"; then # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object fi # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file '$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex=$arg prev= continue ;; release) release=-$arg prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test rpath = "$prev"; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds=$arg prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg=$arg case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "'-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test X-export-symbols = "X$arg"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between '-L' and '$1'" else func_fatal_error "need path for '-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of '$dir'" dir=$absdir ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test X-lc = "X$arg" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test X-lc = "X$arg" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test X-lc = "X$arg" && continue ;; esac elif test X-lc_r = "X$arg"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -mllvm) prev=mllvm continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module=$wl-multi_module continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "'-no-install' is ignored for $host" func_warning "assuming '-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization # -stdlib=* select c++ std lib with clang -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-stdlib=*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result test none = "$pic_object" || { # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object } # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test dlfiles = "$prev"; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test dlprefiles = "$prev"; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the '$prevarg' option requires an argument" if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname=$func_basename_result libobjs_save=$libobjs if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir=$func_dirname_result$objdir func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test lib = "$linkmode"; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=false newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test lib,link = "$linkmode,$pass"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs=$tmp_deplibs fi if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass"; then libs=$deplibs deplibs= fi if test prog = "$linkmode"; then case $pass in dlopen) libs=$dlfiles ;; dlpreopen) libs=$dlprefiles ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test lib,dlpreopen = "$linkmode,$pass"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs=$dlprefiles fi if test dlopen = "$pass"; then # Collect dlpreopened libraries save_deplibs=$deplibs deplibs= fi for deplib in $libs; do lib= found=false case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test lib != "$linkmode" && test prog != "$linkmode"; then func_warning "'-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test lib = "$linkmode"; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib=$searchdir/lib$name$search_ext if test -f "$lib"; then if test .la = "$search_ext"; then found=: else found=false fi break 2 fi done done if $found; then # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll=$l done if test "X$ll" = "X$old_library"; then # only static version available found=false func_dirname "$lib" "" "." ladir=$func_dirname_result lib=$ladir/$old_library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi else # deplib doesn't seem to be a libtool library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi ;; # -l *.ltframework) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test conv = "$pass" && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi if test scan = "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "'-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test link = "$pass"; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=false case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=: fi ;; pass_all) valid_a_lib=: ;; esac if $valid_a_lib; then echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" else echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." fi ;; esac continue ;; prog) if test link != "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test conv = "$pass"; then deplibs="$deplib $deplibs" elif test prog = "$linkmode"; then if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=: continue ;; esac # case $deplib $found || test -f "$lib" \ || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "'$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir=$func_dirname_result dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass" || { test prog != "$linkmode" && test lib != "$linkmode"; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test conv = "$pass"; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for '$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" elif test prog != "$linkmode" && test lib != "$linkmode"; then func_fatal_error "'$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test yes = "$prefer_static_libs" || test built,no = "$prefer_static_libs,$installed"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib=$l done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for '$lib'" fi # This library was specified with -dlopen. if test dlopen = "$pass"; then test -z "$libdir" \ && func_fatal_error "cannot -dlopen a convenience library: '$lib'" if test -z "$dlname" || test yes != "$dlopen_support" || test no = "$build_libtool_libs" then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of '$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir=$ladir fi ;; esac func_basename "$lib" laname=$func_basename_result # Find the relevant object directory and library name. if test yes = "$installed"; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library '$lib' was moved." dir=$ladir absdir=$abs_ladir libdir=$abs_ladir else dir=$lt_sysroot$libdir absdir=$lt_sysroot$libdir fi test yes = "$hardcode_automatic" && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir=$ladir absdir=$abs_ladir # Remove this search path later func_append notinst_path " $abs_ladir" else dir=$ladir/$objdir absdir=$abs_ladir/$objdir # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test dlpreopen = "$pass"; then if test -z "$libdir" && test prog = "$linkmode"; then func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" fi case $host in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test lib = "$linkmode"; then deplibs="$dir/$old_library $deplibs" elif test prog,link = "$linkmode,$pass"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test prog = "$linkmode" && test link != "$pass"; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=false if test no != "$link_all_deplibs" || test -z "$library_names" || test no = "$build_libtool_libs"; then linkalldeplibs=: fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if $linkalldeplibs; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test prog,link = "$linkmode,$pass"; then if test -n "$library_names" && { { test no = "$prefer_static_libs" || test built,yes = "$prefer_static_libs,$installed"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then # Make sure the rpath contains only unique directories. case $temp_rpath: in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if $alldeplibs && { test pass_all = "$deplibs_check_method" || { test yes = "$build_libtool_libs" && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test built = "$use_static_libs" && test yes = "$installed"; then use_static_libs=no fi if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test no = "$installed"; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule= for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule=$dlpremoduletest break fi done if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then echo if test prog = "$linkmode"; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test lib = "$linkmode" && test yes = "$hardcode_into_libs"; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname=$1 shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname=$dlname elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix=-$major ;; esac eval soname=\"$soname_spec\" else soname=$realname fi # Make a new name for the extract_expsyms_cmds to use soroot=$soname func_basename "$soroot" soname=$func_basename_result func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from '$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for '$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test prog = "$linkmode" || test relink != "$opt_mode"; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test no = "$hardcode_direct"; then add=$dir/$linklib case $host in *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; *-*-sysv4*uw2*) add_dir=-L$dir ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir=-L$dir ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we cannot # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library"; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add=$dir/$old_library fi elif test -n "$old_library"; then add=$dir/$old_library fi fi esac elif test no = "$hardcode_minus_L"; then case $host in *-*-sunos*) add_shlibpath=$dir ;; esac add_dir=-L$dir add=-l$name elif test no = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; relink) if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$dir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$absdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name elif test yes = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; *) lib_linked=no ;; esac if test yes != "$lib_linked"; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test prog = "$linkmode"; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test yes != "$hardcode_direct" && test yes != "$hardcode_minus_L" && test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test prog = "$linkmode" || test relink = "$opt_mode"; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$libdir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$libdir add=-l$name elif test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add=-l$name elif test yes = "$hardcode_automatic"; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib"; then add=$inst_prefix_dir$libdir/$linklib else add=$libdir/$linklib fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir=-L$libdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name fi if test prog = "$linkmode"; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test prog = "$linkmode"; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test unsupported != "$hardcode_direct"; then test -n "$old_library" && linklib=$old_library compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test yes = "$build_libtool_libs"; then # Not a shared library if test pass_all != "$deplibs_check_method"; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system cannot link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test yes = "$module"; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test lib = "$linkmode"; then if test -n "$dependency_libs" && { test yes != "$hardcode_into_libs" || test yes = "$build_old_libs" || test yes = "$link_static"; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs=$temp_deplibs fi func_append newlib_search_path " $absdir" # Link against this library test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test no != "$link_all_deplibs"; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path=$deplib ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of '$dir'" absdir=$dir fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names"; then for tmp in $deplibrary_names; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl"; then depdepl=$absdir/$objdir/$depdepl darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" path= fi fi ;; *) path=-L$absdir/$objdir ;; esac else eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "'$deplib' seems to be moved" path=-L$absdir fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test link = "$pass"; then if test prog = "$linkmode"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs=$newdependency_libs if test dlpreopen = "$pass"; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test dlopen != "$pass"; then test conv = "$pass" || { # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= } if test prog,link = "$linkmode,$pass"; then vars="compile_deplibs finalize_deplibs" else vars=deplibs fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i= ;; esac if test -n "$i"; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test prog = "$linkmode"; then dlfiles=$newdlfiles fi if test prog = "$linkmode" || test lib = "$linkmode"; then dlprefiles=$newdlprefiles fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "'-R' is ignored for archives" test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "'-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "'-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs=$output func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form 'libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test no = "$module" \ && func_fatal_help "libtool library '$output' must begin with 'lib'" if test no != "$need_lib_prefix"; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test pass_all != "$deplibs_check_method"; then func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test no = "$dlself" \ || func_warning "'-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test 1 -lt "$#" \ && func_warning "ignoring multiple '-rpath's for a libtool library" install_libdir=$1 oldlibs= if test -z "$rpath"; then if test yes = "$build_libtool_libs"; then # Building a libtool convenience library. # Some compilers have problems with a '.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "'-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs=$IFS; IFS=: set dummy $vinfo 0 0 0 shift IFS=$save_ifs test -n "$7" && \ func_fatal_help "too many parameters to '-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major=$1 number_minor=$2 number_revision=$3 # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # that has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_revision ;; freebsd-aout|freebsd-elf|qnx|sunos) current=$number_major revision=$number_minor age=0 ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_minor lt_irix_increment=no ;; esac ;; no) current=$1 revision=$2 age=$3 ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT '$current' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION '$revision' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE '$age' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE '$age' is greater than the current interface number '$current'" func_fatal_error "'$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" # On Darwin other compilers case $CC in nagfor*) verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" ;; *) verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; esac ;; freebsd-aout) major=.$current versuffix=.$current.$revision ;; freebsd-elf) major=.$current versuffix=.$current ;; irix | nonstopux) if test no = "$lt_irix_increment"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring=$verstring_prefix$major.$revision # Add in all the interfaces that we are compatible with. loop=$revision while test 0 -ne "$loop"; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring_prefix$major.$iface:$verstring done # Before this point, $major must not contain '.'. major=.$major versuffix=$major.$revision ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=.$current.$age.$revision verstring=$current.$age.$revision # Add in all the interfaces that we are compatible with. loop=$age while test 0 -ne "$loop"; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring:$iface.0 done # Make executables depend on our current version. func_append verstring ":$current.0" ;; qnx) major=.$current versuffix=.$current ;; sunos) major=.$current versuffix=.$current.$revision ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 file systems. func_arith $current - $age major=$func_arith_result versuffix=-$major ;; *) func_fatal_configuration "unknown library version type '$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring=0.0 ;; esac if test no = "$need_version"; then versuffix= else versuffix=.0.0 fi fi # Remove version info from name if versioning should be avoided if test yes,no = "$avoid_version,$need_version"; then major= versuffix= verstring= fi # Check to see if the archive will have undefined symbols. if test yes = "$allow_undefined"; then if test unsupported = "$allow_undefined_flag"; then if test yes = "$build_old_libs"; then func_warning "undefined symbols not allowed in $host shared libraries; building static only" build_libtool_libs=no else func_fatal_error "can't build $host shared library unless -no-undefined is specified" fi fi else # Don't allow undefined symbols. allow_undefined_flag=$no_undefined_flag fi fi func_generate_dlsyms "$libname" "$libname" : func_append libobjs " $symfileobj" test " " = "$libobjs" && libobjs= if test relink != "$opt_mode"; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) if test -n "$precious_files_regex"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles=$dlfiles dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles=$dlprefiles dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test yes = "$build_libtool_libs"; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test yes = "$build_libtool_need_lc"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release= versuffix= major= newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib=$potent_lib while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | $SED 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib= ;; esac fi if test -n "$a_deplib"; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib=$potent_lib # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs= tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test yes = "$allow_libtool_libs_with_static_runtimes"; then for i in $predeps $postdeps; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test none = "$deplibs_check_method"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test yes = "$droppeddeps"; then if test yes = "$module"; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test no = "$allow_undefined"; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs=$new_libs # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test yes = "$build_libtool_libs"; then # Remove $wl instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test yes = "$hardcode_into_libs"; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath=$finalize_rpath test relink = "$opt_mode" || rpath=$compile_rpath$rpath for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath=$finalize_shlibpath test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname=$1 shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname=$realname fi if test -z "$dlname"; then dlname=$soname fi lib=$output_objdir/$realname linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols=$output_objdir/$libname.uexp func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile func_dll_def_p "$export_symbols" || { # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols=$export_symbols export_symbols= always_export_symbols=yes } fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs=$IFS; IFS='~' for cmd1 in $cmds; do IFS=$save_ifs # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test yes = "$try_normal_branch" \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=$output_objdir/$output_la.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS=$save_ifs if test -n "$export_symbols_regex" && test : != "$skipped_export"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test : != "$skipped_export" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs=$tmp_deplibs if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test yes = "$compiler_needs_object" && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test : != "$skipped_export" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then output=$output_objdir/$output_la.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then output=$output_objdir/$output_la.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test yes = "$compiler_needs_object"; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-$k.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test -z "$objlist" || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test 1 -eq "$k"; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-$k.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-$k.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi ${skipped_export-false} && { func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi } test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs=$IFS; IFS='~' for cmd in $concat_cmds; do IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi ${skipped_export-false} && { if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi } libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs=$IFS; IFS='~' for cmd in $cmds; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs # Restore the uninstalled library and exit if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test yes = "$module" || test yes = "$export_dynamic"; then # On all known operating systems, these are identical. dlname=$soname fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "'-R' is ignored for objects" test -n "$vinfo" && \ func_warning "'-version-info' is ignored for objects" test -n "$release" && \ func_warning "'-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object '$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj=$output ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop=$output_objdir/${obj}x func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test yes = "$build_libtool_libs" || libobjs=$non_pic_objects # Create the old-style object. reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs output=$obj func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi test yes = "$build_libtool_libs" || { if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS } if test -n "$pic_flag" || test default != "$pic_mode"; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output=$libobj func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "'-version-info' is ignored for programs" test -n "$release" && \ func_warning "'-release' is ignored for programs" $preload \ && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test CXX = "$tagname"; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " $wl-bind_at_load" func_append finalize_command " $wl-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs=$new_libs func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath=$rpath rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath=$rpath if test -n "$libobjs" && test yes = "$build_old_libs"; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" false # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=: case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=false ;; *cygwin* | *mingw* ) test yes = "$build_libtool_libs" || wrappers_required=false ;; *) if test no = "$need_relink" || test yes != "$build_libtool_libs"; then wrappers_required=false fi ;; esac $wrappers_required || { # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command=$compile_command$compile_rpath # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.$objext"; then func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' fi exit $exit_status } if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test yes = "$no_install"; then # We don't need to create a wrapper script. link_command=$compile_var$compile_command$compile_rpath # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi case $hardcode_action,$fast_install in relink,*) # Fast installation is not supported link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath func_warning "this platform does not like uninstalled shared libraries" func_warning "'$output' will be relinked during installation" ;; *,yes) link_command=$finalize_var$compile_command$finalize_rpath relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` ;; *,no) link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath ;; *,needless) link_command=$finalize_var$compile_command$finalize_rpath relink_command= ;; esac # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource=$output_path/$objdir/lt-$output_name.c cwrapper=$output_path/$output_name.exe $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host"; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do case $build_libtool_libs in convenience) oldobjs="$libobjs_save $symfileobj" addlibs=$convenience build_libtool_libs=no ;; module) oldobjs=$libobjs_save addlibs=$old_convenience build_libtool_libs=no ;; *) oldobjs="$old_deplibs $non_pic_objects" $preload && test -f "$symfileobj" \ && func_append oldobjs " $symfileobj" addlibs=$old_convenience ;; esac if test -n "$addlibs"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase=$func_basename_result case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj"; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test -z "$oldobjs"; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test yes = "$build_old_libs" && old_library=$libname.$libext func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test yes = "$hardcode_automatic"; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test yes = "$installed"; then if test -z "$install_libdir"; then break fi output=$output_objdir/${outputname}i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name=$func_basename_result func_resolve_sysroot "$deplib" eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs=$newdependency_libs newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles=$newdlprefiles else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles=$newdlprefiles fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test -n "$bindir"; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result/$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that cannot go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test no,yes = "$installed,$need_relink"; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } if test link = "$opt_mode" || test relink = "$opt_mode"; then func_mode_link ${1+"$@"} fi # func_mode_uninstall arg... func_mode_uninstall () { $debug_cmd RM=$nonopt files= rmforce=false exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic for arg do case $arg in -f) func_append RM " $arg"; rmforce=: ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir=$func_dirname_result if test . = "$dir"; then odir=$objdir else odir=$dir/$objdir fi func_basename "$file" name=$func_basename_result test uninstall = "$opt_mode" && odir=$dir # Remember odir for removal later, being careful to avoid duplicates if test clean = "$opt_mode"; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif $rmforce; then continue fi rmfiles=$file case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case $opt_mode in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test none != "$pic_object"; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test none != "$non_pic_object"; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test clean = "$opt_mode"; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.$objext" if test yes = "$fast_install" && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name"; then func_append rmfiles " $odir/lt-$noexename.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the $objdir's in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then func_mode_uninstall ${1+"$@"} fi test -z "$opt_mode" && { help=$generic_help func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode '$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # where we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: lftp-4.6.3a/configure0000755000015000007670000541400712540277163011504 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for lftp 4.6.3a. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: lftp-bugs@lftp.yar.ru about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='lftp' PACKAGE_TARNAME='lftp' PACKAGE_VERSION='4.6.3a' PACKAGE_STRING='lftp 4.6.3a' PACKAGE_BUGREPORT='lftp-bugs@lftp.yar.ru' PACKAGE_URL='' ac_config_libobj_dir=lib ac_unique_file="src/ftpclass.cc" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" gl_use_threads_default= gt_needs= ac_header_list= ac_func_list= with_openssl_default='no' LIB_CRYPTO= gl_fnmatch_required=POSIX gl_getopt_required=POSIX gl_getopt_required=POSIX ac_subst_vars='gltests_LTLIBOBJS gltests_LIBOBJS gl_LTLIBOBJS gl_LIBOBJS am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS NEED_TRIO_FALSE NEED_TRIO_TRUE EXPAT_LIBS ZLIB_CPPFLAGS ZLIB_LDFLAGS ZLIB OPENSSL_CPPFLAGS OPENSSL_LDFLAGS OPENSSL_LIBS LIBGNUTLS_LIBS LIBGNUTLS_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG READLINE READLINE_DEPEND READLINE_DIR COMPILE_READLINE gltests_WITNESS REPLACE_TOWLOWER REPLACE_ISWCNTRL HAVE_WCTYPE_H NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H NEXT_WCTYPE_H HAVE_ISWCNTRL REPLACE_ISWBLANK HAVE_WCTRANS_T HAVE_WCTYPE_T HAVE_ISWBLANK GNULIB_TOWCTRANS GNULIB_WCTRANS GNULIB_ISWCTYPE GNULIB_WCTYPE GNULIB_ISWBLANK HAVE_WINT_T NEXT_AS_FIRST_DIRECTIVE_WCHAR_H NEXT_WCHAR_H LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_FALSE LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE LIBUNISTRING_UNIWIDTH_H LIBUNISTRING_UNITYPES_H LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_FALSE LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_TRUE LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_FALSE LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_TRUE LIBUNISTRING_UNISTR_H HAVE_UNISTD_H NEXT_AS_FIRST_DIRECTIVE_UNISTD_H NEXT_UNISTD_H UNISTD_H_DEFINES_STRUCT_TIMESPEC PTHREAD_H_DEFINES_STRUCT_TIMESPEC SYS_TIME_H_DEFINES_STRUCT_TIMESPEC TIME_H_DEFINES_STRUCT_TIMESPEC NEXT_AS_FIRST_DIRECTIVE_TIME_H NEXT_TIME_H HAVE_SYS_UIO_H NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H NEXT_SYS_UIO_H WINDOWS_64_BIT_OFF_T NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H NEXT_SYS_TYPES_H HAVE_STRINGS_H NEXT_AS_FIRST_DIRECTIVE_STRINGS_H NEXT_STRINGS_H NEXT_AS_FIRST_DIRECTIVE_STRING_H NEXT_STRING_H HAVE_DECL_STRNCASECMP HAVE_STRCASECMP HAVE_FFS GNULIB_FFS NEXT_AS_FIRST_DIRECTIVE_STDLIB_H NEXT_STDLIB_H NEXT_AS_FIRST_DIRECTIVE_STDIO_H NEXT_STDIO_H REPLACE_VSPRINTF REPLACE_VSNPRINTF REPLACE_VPRINTF REPLACE_VFPRINTF REPLACE_VDPRINTF REPLACE_VASPRINTF REPLACE_TMPFILE REPLACE_STDIO_WRITE_FUNCS REPLACE_STDIO_READ_FUNCS REPLACE_SPRINTF REPLACE_SNPRINTF REPLACE_RENAMEAT REPLACE_RENAME REPLACE_REMOVE REPLACE_PRINTF REPLACE_POPEN REPLACE_PERROR REPLACE_OBSTACK_PRINTF REPLACE_GETLINE REPLACE_GETDELIM REPLACE_FTELLO REPLACE_FTELL REPLACE_FSEEKO REPLACE_FSEEK REPLACE_FREOPEN REPLACE_FPURGE REPLACE_FPRINTF REPLACE_FOPEN REPLACE_FFLUSH REPLACE_FDOPEN REPLACE_FCLOSE REPLACE_DPRINTF HAVE_VDPRINTF HAVE_VASPRINTF HAVE_RENAMEAT HAVE_POPEN HAVE_PCLOSE HAVE_FTELLO HAVE_FSEEKO HAVE_DPRINTF HAVE_DECL_VSNPRINTF HAVE_DECL_SNPRINTF HAVE_DECL_OBSTACK_PRINTF HAVE_DECL_GETLINE HAVE_DECL_GETDELIM HAVE_DECL_FTELLO HAVE_DECL_FSEEKO HAVE_DECL_FPURGE GNULIB_VSPRINTF_POSIX GNULIB_VSNPRINTF GNULIB_VPRINTF_POSIX GNULIB_VPRINTF GNULIB_VFPRINTF_POSIX GNULIB_VFPRINTF GNULIB_VDPRINTF GNULIB_VSCANF GNULIB_VFSCANF GNULIB_VASPRINTF GNULIB_TMPFILE GNULIB_STDIO_H_SIGPIPE GNULIB_STDIO_H_NONBLOCKING GNULIB_SPRINTF_POSIX GNULIB_SNPRINTF GNULIB_SCANF GNULIB_RENAMEAT GNULIB_RENAME GNULIB_REMOVE GNULIB_PUTS GNULIB_PUTCHAR GNULIB_PUTC GNULIB_PRINTF_POSIX GNULIB_PRINTF GNULIB_POPEN GNULIB_PERROR GNULIB_PCLOSE GNULIB_OBSTACK_PRINTF_POSIX GNULIB_OBSTACK_PRINTF GNULIB_GETLINE GNULIB_GETDELIM GNULIB_GETCHAR GNULIB_GETC GNULIB_FWRITE GNULIB_FTELLO GNULIB_FTELL GNULIB_FSEEKO GNULIB_FSEEK GNULIB_FSCANF GNULIB_FREOPEN GNULIB_FREAD GNULIB_FPUTS GNULIB_FPUTC GNULIB_FPURGE GNULIB_FPRINTF_POSIX GNULIB_FPRINTF GNULIB_FOPEN GNULIB_FGETS GNULIB_FGETC GNULIB_FFLUSH GNULIB_FDOPEN GNULIB_FCLOSE GNULIB_DPRINTF GL_GENERATE_STDALIGN_H_FALSE GL_GENERATE_STDALIGN_H_TRUE STDALIGN_H NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H NEXT_SIGNAL_H REPLACE_RAISE REPLACE_PTHREAD_SIGMASK HAVE_SIGHANDLER_T HAVE_TYPE_VOLATILE_SIG_ATOMIC_T HAVE_STRUCT_SIGACTION_SA_SIGACTION HAVE_SIGACTION HAVE_SIGINFO_T HAVE_SIGSET_T HAVE_RAISE HAVE_PTHREAD_SIGMASK HAVE_POSIX_SIGNALBLOCKING GNULIB_SIGACTION GNULIB_SIGPROCMASK GNULIB_SIGNAL_H_SIGPIPE GNULIB_RAISE GNULIB_PTHREAD_SIGMASK LIB_SELECT HAVE_SYS_SELECT_H NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H NEXT_SYS_SELECT_H REPLACE_SELECT REPLACE_PSELECT HAVE_PSELECT GNULIB_SELECT GNULIB_PSELECT LIB_POLL LIBSOCKET NEXT_AS_FIRST_DIRECTIVE_POLL_H NEXT_POLL_H HAVE_POLL_H REPLACE_POLL HAVE_POLL GNULIB_POLL HAVE__BOOL GL_GENERATE_STDBOOL_H_FALSE GL_GENERATE_STDBOOL_H_TRUE STDBOOL_H GL_GENERATE_NETINET_IN_H_FALSE GL_GENERATE_NETINET_IN_H_TRUE NETINET_IN_H HAVE_NETINET_IN_H NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H NEXT_NETINET_IN_H REPLACE_LOCALTIME REPLACE_GMTIME REPLACE_TIMEGM REPLACE_NANOSLEEP REPLACE_MKTIME REPLACE_LOCALTIME_R HAVE_TIMEGM HAVE_STRPTIME HAVE_NANOSLEEP HAVE_DECL_LOCALTIME_R GNULIB_TIME_R GNULIB_TIMEGM GNULIB_STRPTIME GNULIB_NANOSLEEP GNULIB_MKTIME UNDEFINE_STRTOK_R REPLACE_STRTOK_R REPLACE_STRSIGNAL REPLACE_STRNLEN REPLACE_STRNDUP REPLACE_STRNCAT REPLACE_STRERROR_R REPLACE_STRERROR REPLACE_STRCHRNUL REPLACE_STRCASESTR REPLACE_STRSTR REPLACE_STRDUP REPLACE_STPNCPY REPLACE_MEMMEM REPLACE_MEMCHR HAVE_STRVERSCMP HAVE_DECL_STRSIGNAL HAVE_DECL_STRERROR_R HAVE_DECL_STRTOK_R HAVE_STRCASESTR HAVE_STRSEP HAVE_STRPBRK HAVE_DECL_STRNLEN HAVE_DECL_STRNDUP HAVE_DECL_STRDUP HAVE_STRCHRNUL HAVE_STPNCPY HAVE_STPCPY HAVE_RAWMEMCHR HAVE_DECL_MEMRCHR HAVE_MEMPCPY HAVE_DECL_MEMMEM HAVE_MEMCHR HAVE_FFSLL HAVE_FFSL HAVE_MBSLEN GNULIB_STRVERSCMP GNULIB_STRSIGNAL GNULIB_STRERROR_R GNULIB_STRERROR GNULIB_MBSTOK_R GNULIB_MBSSEP GNULIB_MBSSPN GNULIB_MBSPBRK GNULIB_MBSCSPN GNULIB_MBSCASESTR GNULIB_MBSPCASECMP GNULIB_MBSNCASECMP GNULIB_MBSCASECMP GNULIB_MBSSTR GNULIB_MBSRCHR GNULIB_MBSCHR GNULIB_MBSNLEN GNULIB_MBSLEN GNULIB_STRTOK_R GNULIB_STRCASESTR GNULIB_STRSTR GNULIB_STRSEP GNULIB_STRPBRK GNULIB_STRNLEN GNULIB_STRNDUP GNULIB_STRNCAT GNULIB_STRDUP GNULIB_STRCHRNUL GNULIB_STPNCPY GNULIB_STPCPY GNULIB_RAWMEMCHR GNULIB_MEMRCHR GNULIB_MEMPCPY GNULIB_MEMMEM GNULIB_MEMCHR GNULIB_FFSLL GNULIB_FFSL LOCALE_FR_UTF8 LOCALE_ZH_CN LOCALE_JA NEXT_AS_FIRST_DIRECTIVE_MATH_H NEXT_MATH_H REPLACE_WCTOMB REPLACE_UNSETENV REPLACE_STRTOD REPLACE_SETENV REPLACE_REALPATH REPLACE_REALLOC REPLACE_RANDOM_R REPLACE_QSORT_R REPLACE_PUTENV REPLACE_PTSNAME_R REPLACE_PTSNAME REPLACE_MKSTEMP REPLACE_MBTOWC REPLACE_MALLOC REPLACE_CANONICALIZE_FILE_NAME REPLACE_CALLOC HAVE_DECL_UNSETENV HAVE_UNLOCKPT HAVE_SYS_LOADAVG_H HAVE_STRUCT_RANDOM_DATA HAVE_STRTOULL HAVE_STRTOLL HAVE_STRTOD HAVE_DECL_SETENV HAVE_SETENV HAVE_SECURE_GETENV HAVE_RPMATCH HAVE_REALPATH HAVE_RANDOM_R HAVE_RANDOM_H HAVE_RANDOM HAVE_PTSNAME_R HAVE_PTSNAME HAVE_POSIX_OPENPT HAVE_MKSTEMPS HAVE_MKSTEMP HAVE_MKOSTEMPS HAVE_MKOSTEMP HAVE_MKDTEMP HAVE_GRANTPT HAVE_GETSUBOPT HAVE_DECL_GETLOADAVG HAVE_CANONICALIZE_FILE_NAME HAVE_ATOLL HAVE__EXIT GNULIB_WCTOMB GNULIB_UNSETENV GNULIB_UNLOCKPT GNULIB_SYSTEM_POSIX GNULIB_STRTOULL GNULIB_STRTOLL GNULIB_STRTOD GNULIB_SETENV GNULIB_SECURE_GETENV GNULIB_RPMATCH GNULIB_REALPATH GNULIB_REALLOC_POSIX GNULIB_RANDOM_R GNULIB_RANDOM GNULIB_QSORT_R GNULIB_PUTENV GNULIB_PTSNAME_R GNULIB_PTSNAME GNULIB_POSIX_OPENPT GNULIB_MKSTEMPS GNULIB_MKSTEMP GNULIB_MKOSTEMPS GNULIB_MKOSTEMP GNULIB_MKDTEMP GNULIB_MBTOWC GNULIB_MALLOC_POSIX GNULIB_GRANTPT GNULIB_GETSUBOPT GNULIB_GETLOADAVG GNULIB_CANONICALIZE_FILE_NAME GNULIB_CALLOC_POSIX GNULIB_ATOLL GNULIB__EXIT LTLIBMULTITHREAD LIBMULTITHREAD LTLIBTHREAD LIBTHREAD LIBPTH_PREFIX LTLIBPTH LIBPTH NEXT_AS_FIRST_DIRECTIVE_LOCALE_H NEXT_LOCALE_H HAVE_XLOCALE_H NEXT_AS_FIRST_DIRECTIVE_STDDEF_H NEXT_STDDEF_H GL_GENERATE_STDDEF_H_FALSE GL_GENERATE_STDDEF_H_TRUE STDDEF_H HAVE_WCHAR_T HAVE_MAX_ALIGN_T REPLACE_NULL REPLACE_STRUCT_LCONV REPLACE_DUPLOCALE REPLACE_SETLOCALE REPLACE_LOCALECONV HAVE_DUPLOCALE GNULIB_DUPLOCALE GNULIB_SETLOCALE GNULIB_LOCALECONV LOCALCHARSET_TESTS_ENVIRONMENT GLIBC21 HAVE_LANGINFO_YESEXPR HAVE_LANGINFO_ERA HAVE_LANGINFO_T_FMT_AMPM HAVE_LANGINFO_CODESET HAVE_LANGINFO_H NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H NEXT_LANGINFO_H REPLACE_NL_LANGINFO HAVE_NL_LANGINFO GNULIB_NL_LANGINFO NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H NEXT_INTTYPES_H UINT64_MAX_EQ_ULONG_MAX UINT32_MAX_LT_UINTMAX_MAX PRIPTR_PREFIX PRI_MACROS_BROKEN INT64_MAX_EQ_LONG_MAX INT32_MAX_LT_INTMAX_MAX REPLACE_STRTOUMAX REPLACE_STRTOIMAX HAVE_DECL_STRTOUMAX HAVE_DECL_STRTOIMAX HAVE_DECL_IMAXDIV HAVE_DECL_IMAXABS GNULIB_STRTOUMAX GNULIB_STRTOIMAX GNULIB_IMAXDIV GNULIB_IMAXABS GL_GENERATE_STDINT_H_FALSE GL_GENERATE_STDINT_H_TRUE STDINT_H WINT_T_SUFFIX WCHAR_T_SUFFIX SIG_ATOMIC_T_SUFFIX SIZE_T_SUFFIX PTRDIFF_T_SUFFIX HAVE_SIGNED_WINT_T HAVE_SIGNED_WCHAR_T HAVE_SIGNED_SIG_ATOMIC_T BITSIZEOF_WINT_T BITSIZEOF_WCHAR_T BITSIZEOF_SIG_ATOMIC_T BITSIZEOF_SIZE_T BITSIZEOF_PTRDIFF_T APPLE_UNIVERSAL_BUILD HAVE_SYS_BITYPES_H HAVE_SYS_INTTYPES_H HAVE_STDINT_H NEXT_AS_FIRST_DIRECTIVE_STDINT_H NEXT_STDINT_H HAVE_SYS_TYPES_H HAVE_INTTYPES_H HAVE_WCHAR_H HAVE_UNSIGNED_LONG_LONG_INT HAVE_LONG_LONG_INT HAVE_WS2TCPIP_H HAVE_SYS_SOCKET_H NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H NEXT_SYS_SOCKET_H HAVE_ACCEPT4 HAVE_SA_FAMILY_T HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY HAVE_STRUCT_SOCKADDR_STORAGE GNULIB_ACCEPT4 GNULIB_SHUTDOWN GNULIB_SETSOCKOPT GNULIB_SENDTO GNULIB_RECVFROM GNULIB_SEND GNULIB_RECV GNULIB_LISTEN GNULIB_GETSOCKOPT GNULIB_GETSOCKNAME GNULIB_GETPEERNAME GNULIB_BIND GNULIB_ACCEPT GNULIB_CONNECT GNULIB_SOCKET INET_PTON_LIB NEXT_AS_FIRST_DIRECTIVE_ICONV_H NEXT_ICONV_H HAVE_SYS_CDEFS_H GL_GENERATE_GLOB_H_FALSE GL_GENERATE_GLOB_H_TRUE GLOB_H NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H NEXT_SYS_TIME_H REPLACE_STRUCT_TIMEVAL REPLACE_GETTIMEOFDAY HAVE_SYS_TIME_H HAVE_STRUCT_TIMEVAL HAVE_GETTIMEOFDAY GNULIB_GETTIMEOFDAY GNULIB_GL_UNISTD_H_GETOPT GETOPT_H HAVE_GETOPT_H NEXT_AS_FIRST_DIRECTIVE_GETOPT_H NEXT_GETOPT_H WINDOWS_64_BIT_ST_SIZE NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H NEXT_SYS_STAT_H REPLACE_UTIMENSAT REPLACE_STAT REPLACE_MKNOD REPLACE_MKFIFO REPLACE_MKDIR REPLACE_LSTAT REPLACE_FUTIMENS REPLACE_FSTATAT REPLACE_FSTAT HAVE_UTIMENSAT HAVE_MKNODAT HAVE_MKNOD HAVE_MKFIFOAT HAVE_MKFIFO HAVE_MKDIRAT HAVE_LSTAT HAVE_LCHMOD HAVE_FUTIMENS HAVE_FSTATAT HAVE_FCHMODAT GNULIB_UTIMENSAT GNULIB_STAT GNULIB_MKNODAT GNULIB_MKNOD GNULIB_MKFIFOAT GNULIB_MKFIFO GNULIB_MKDIRAT GNULIB_LSTAT GNULIB_LCHMOD GNULIB_FUTIMENS GNULIB_FSTATAT GNULIB_FSTAT GNULIB_FCHMODAT HAVE_SAME_LONG_DOUBLE_AS_DOUBLE REPLACE_TRUNCL REPLACE_TRUNCF REPLACE_TRUNC REPLACE_SQRTL REPLACE_SIGNBIT_USING_GCC REPLACE_SIGNBIT REPLACE_ROUNDL REPLACE_ROUNDF REPLACE_ROUND REPLACE_REMAINDERL REPLACE_REMAINDERF REPLACE_REMAINDER REPLACE_NAN REPLACE_MODFL REPLACE_MODFF REPLACE_MODF REPLACE_LOGBL REPLACE_LOGBF REPLACE_LOGB REPLACE_LOG2L REPLACE_LOG2F REPLACE_LOG2 REPLACE_LOG1PL REPLACE_LOG1PF REPLACE_LOG1P REPLACE_LOG10L REPLACE_LOG10F REPLACE_LOG10 REPLACE_LOGL REPLACE_LOGF REPLACE_LOG REPLACE_LDEXPL REPLACE_ISNAN REPLACE_ISINF REPLACE_ISFINITE REPLACE_ILOGBF REPLACE_ILOGB REPLACE_HYPOTL REPLACE_HYPOTF REPLACE_HYPOT REPLACE_HUGE_VAL REPLACE_FREXPL REPLACE_FREXP REPLACE_FREXPF REPLACE_FMODL REPLACE_FMODF REPLACE_FMOD REPLACE_FMAL REPLACE_FMAF REPLACE_FMA REPLACE_FLOORL REPLACE_FLOORF REPLACE_FLOOR REPLACE_FABSL REPLACE_EXP2L REPLACE_EXP2 REPLACE_EXPM1F REPLACE_EXPM1 REPLACE_CEILL REPLACE_CEILF REPLACE_CEIL REPLACE_CBRTL REPLACE_CBRTF HAVE_DECL_TRUNCL HAVE_DECL_TRUNCF HAVE_DECL_TRUNC HAVE_DECL_TANL HAVE_DECL_SQRTL HAVE_DECL_SINL HAVE_DECL_ROUNDL HAVE_DECL_ROUNDF HAVE_DECL_ROUND HAVE_DECL_RINTF HAVE_DECL_REMAINDERL HAVE_DECL_REMAINDER HAVE_DECL_LOGB HAVE_DECL_LOG2L HAVE_DECL_LOG2F HAVE_DECL_LOG2 HAVE_DECL_LOG10L HAVE_DECL_LOGL HAVE_DECL_LDEXPL HAVE_DECL_FREXPL HAVE_DECL_FLOORL HAVE_DECL_FLOORF HAVE_DECL_EXPM1L HAVE_DECL_EXP2L HAVE_DECL_EXP2F HAVE_DECL_EXP2 HAVE_DECL_EXPL HAVE_DECL_COSL HAVE_DECL_COPYSIGNF HAVE_DECL_CEILL HAVE_DECL_CEILF HAVE_DECL_CBRTL HAVE_DECL_CBRTF HAVE_DECL_ATANL HAVE_DECL_ASINL HAVE_DECL_ACOSL HAVE_TANHF HAVE_TANL HAVE_TANF HAVE_SQRTL HAVE_SQRTF HAVE_SINHF HAVE_SINL HAVE_SINF HAVE_RINTL HAVE_RINT HAVE_REMAINDERF HAVE_REMAINDER HAVE_POWF HAVE_MODFL HAVE_MODFF HAVE_LOGBL HAVE_LOGBF HAVE_LOG1PL HAVE_LOG1PF HAVE_LOG1P HAVE_LOG10L HAVE_LOG10F HAVE_LOGL HAVE_LOGF HAVE_LDEXPF HAVE_ISNANL HAVE_ISNAND HAVE_ISNANF HAVE_ILOGBL HAVE_ILOGBF HAVE_ILOGB HAVE_HYPOTL HAVE_HYPOTF HAVE_FREXPF HAVE_FMODL HAVE_FMODF HAVE_FMAL HAVE_FMAF HAVE_FMA HAVE_FABSL HAVE_FABSF HAVE_EXPM1F HAVE_EXPM1 HAVE_EXPL HAVE_EXPF HAVE_COSHF HAVE_COSL HAVE_COSF HAVE_COPYSIGNL HAVE_COPYSIGN HAVE_CBRTL HAVE_CBRTF HAVE_CBRT HAVE_ATAN2F HAVE_ATANL HAVE_ATANF HAVE_ASINL HAVE_ASINF HAVE_ACOSL HAVE_ACOSF GNULIB_TRUNCL GNULIB_TRUNCF GNULIB_TRUNC GNULIB_TANHF GNULIB_TANL GNULIB_TANF GNULIB_SQRTL GNULIB_SQRTF GNULIB_SINHF GNULIB_SINL GNULIB_SINF GNULIB_SIGNBIT GNULIB_ROUNDL GNULIB_ROUNDF GNULIB_ROUND GNULIB_RINTL GNULIB_RINTF GNULIB_RINT GNULIB_REMAINDERL GNULIB_REMAINDERF GNULIB_REMAINDER GNULIB_POWF GNULIB_MODFL GNULIB_MODFF GNULIB_MODF GNULIB_LOGBL GNULIB_LOGBF GNULIB_LOGB GNULIB_LOG2L GNULIB_LOG2F GNULIB_LOG2 GNULIB_LOG1PL GNULIB_LOG1PF GNULIB_LOG1P GNULIB_LOG10L GNULIB_LOG10F GNULIB_LOG10 GNULIB_LOGL GNULIB_LOGF GNULIB_LOG GNULIB_LDEXPL GNULIB_LDEXPF GNULIB_ISNANL GNULIB_ISNAND GNULIB_ISNANF GNULIB_ISNAN GNULIB_ISINF GNULIB_ISFINITE GNULIB_ILOGBL GNULIB_ILOGBF GNULIB_ILOGB GNULIB_HYPOTL GNULIB_HYPOTF GNULIB_HYPOT GNULIB_FREXPL GNULIB_FREXP GNULIB_FREXPF GNULIB_FMODL GNULIB_FMODF GNULIB_FMOD GNULIB_FMAL GNULIB_FMAF GNULIB_FMA GNULIB_FLOORL GNULIB_FLOORF GNULIB_FLOOR GNULIB_FABSL GNULIB_FABSF GNULIB_EXPM1L GNULIB_EXPM1F GNULIB_EXPM1 GNULIB_EXP2L GNULIB_EXP2F GNULIB_EXP2 GNULIB_EXPL GNULIB_EXPF GNULIB_COSHF GNULIB_COSL GNULIB_COSF GNULIB_COPYSIGNL GNULIB_COPYSIGNF GNULIB_COPYSIGN GNULIB_CEILL GNULIB_CEILF GNULIB_CEIL GNULIB_CBRTL GNULIB_CBRTF GNULIB_CBRT GNULIB_ATAN2F GNULIB_ATANL GNULIB_ATANF GNULIB_ASINL GNULIB_ASINF GNULIB_ACOSL GNULIB_ACOSF GL_GENERATE_FNMATCH_H_FALSE GL_GENERATE_FNMATCH_H_TRUE FNMATCH_H REPLACE_ITOLD GL_GENERATE_FLOAT_H_FALSE GL_GENERATE_FLOAT_H_TRUE FLOAT_H NEXT_AS_FIRST_DIRECTIVE_FLOAT_H NEXT_FLOAT_H NEXT_AS_FIRST_DIRECTIVE_FCNTL_H NEXT_FCNTL_H REPLACE_OPENAT REPLACE_OPEN REPLACE_FCNTL HAVE_OPENAT HAVE_FCNTL GNULIB_OPENAT GNULIB_OPEN GNULIB_NONBLOCKING GNULIB_FCNTL EOVERFLOW_VALUE EOVERFLOW_HIDDEN ENOLINK_VALUE ENOLINK_HIDDEN EMULTIHOP_VALUE EMULTIHOP_HIDDEN GL_GENERATE_ERRNO_H_FALSE GL_GENERATE_ERRNO_H_TRUE ERRNO_H NEXT_AS_FIRST_DIRECTIVE_ERRNO_H NEXT_ERRNO_H HAVE_DIRENT_H NEXT_AS_FIRST_DIRECTIVE_DIRENT_H NEXT_DIRENT_H LIB_CRYPTO pkglibexecdir runstatedir lispdir REPLACE_FDOPENDIR REPLACE_DIRFD REPLACE_CLOSEDIR REPLACE_OPENDIR HAVE_ALPHASORT HAVE_SCANDIR HAVE_FDOPENDIR HAVE_DECL_FDOPENDIR HAVE_DECL_DIRFD HAVE_CLOSEDIR HAVE_REWINDDIR HAVE_READDIR HAVE_OPENDIR GNULIB_ALPHASORT GNULIB_SCANDIR GNULIB_FDOPENDIR GNULIB_DIRFD GNULIB_CLOSEDIR GNULIB_REWINDDIR GNULIB_READDIR GNULIB_OPENDIR HAVE_WINSOCK2_H HAVE_MSVC_INVALID_PARAMETER_HANDLER LIB_CLOCK_GETTIME UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS UNISTD_H_HAVE_WINSOCK2_H REPLACE_WRITE REPLACE_USLEEP REPLACE_UNLINKAT REPLACE_UNLINK REPLACE_TTYNAME_R REPLACE_SYMLINKAT REPLACE_SYMLINK REPLACE_SLEEP REPLACE_RMDIR REPLACE_READLINKAT REPLACE_READLINK REPLACE_READ REPLACE_PWRITE REPLACE_PREAD REPLACE_LSEEK REPLACE_LINKAT REPLACE_LINK REPLACE_LCHOWN REPLACE_ISATTY REPLACE_GETPAGESIZE REPLACE_GETGROUPS REPLACE_GETLOGIN_R REPLACE_GETDTABLESIZE REPLACE_GETDOMAINNAME REPLACE_GETCWD REPLACE_FTRUNCATE REPLACE_FCHOWNAT REPLACE_DUP2 REPLACE_DUP REPLACE_CLOSE REPLACE_CHOWN HAVE_SYS_PARAM_H HAVE_OS_H HAVE_DECL_TTYNAME_R HAVE_DECL_SETHOSTNAME HAVE_DECL_GETUSERSHELL HAVE_DECL_GETPAGESIZE HAVE_DECL_GETLOGIN_R HAVE_DECL_GETDOMAINNAME HAVE_DECL_FDATASYNC HAVE_DECL_FCHDIR HAVE_DECL_ENVIRON HAVE_USLEEP HAVE_UNLINKAT HAVE_SYMLINKAT HAVE_SYMLINK HAVE_SLEEP HAVE_SETHOSTNAME HAVE_READLINKAT HAVE_READLINK HAVE_PWRITE HAVE_PREAD HAVE_PIPE2 HAVE_PIPE HAVE_LINKAT HAVE_LINK HAVE_LCHOWN HAVE_GROUP_MEMBER HAVE_GETPAGESIZE HAVE_GETLOGIN HAVE_GETHOSTNAME HAVE_GETGROUPS HAVE_GETDTABLESIZE HAVE_FTRUNCATE HAVE_FSYNC HAVE_FDATASYNC HAVE_FCHOWNAT HAVE_FCHDIR HAVE_FACCESSAT HAVE_EUIDACCESS HAVE_DUP3 HAVE_DUP2 HAVE_CHOWN GNULIB_WRITE GNULIB_USLEEP GNULIB_UNLINKAT GNULIB_UNLINK GNULIB_UNISTD_H_SIGPIPE GNULIB_UNISTD_H_NONBLOCKING GNULIB_TTYNAME_R GNULIB_SYMLINKAT GNULIB_SYMLINK GNULIB_SLEEP GNULIB_SETHOSTNAME GNULIB_RMDIR GNULIB_READLINKAT GNULIB_READLINK GNULIB_READ GNULIB_PWRITE GNULIB_PREAD GNULIB_PIPE2 GNULIB_PIPE GNULIB_LSEEK GNULIB_LINKAT GNULIB_LINK GNULIB_LCHOWN GNULIB_ISATTY GNULIB_GROUP_MEMBER GNULIB_GETUSERSHELL GNULIB_GETPAGESIZE GNULIB_GETLOGIN_R GNULIB_GETLOGIN GNULIB_GETHOSTNAME GNULIB_GETGROUPS GNULIB_GETDTABLESIZE GNULIB_GETDOMAINNAME GNULIB_GETCWD GNULIB_FTRUNCATE GNULIB_FSYNC GNULIB_FDATASYNC GNULIB_FCHOWNAT GNULIB_FCHDIR GNULIB_FACCESSAT GNULIB_EUIDACCESS GNULIB_ENVIRON GNULIB_DUP3 GNULIB_DUP2 GNULIB_DUP GNULIB_CLOSE GNULIB_CHOWN GNULIB_CHDIR LOCALE_FR REPLACE_WCSWIDTH REPLACE_WCWIDTH REPLACE_WCSNRTOMBS REPLACE_WCSRTOMBS REPLACE_WCRTOMB REPLACE_MBSNRTOWCS REPLACE_MBSRTOWCS REPLACE_MBRLEN REPLACE_MBRTOWC REPLACE_MBSINIT REPLACE_WCTOB REPLACE_BTOWC REPLACE_MBSTATE_T HAVE_DECL_WCWIDTH HAVE_DECL_WCTOB HAVE_WCSWIDTH HAVE_WCSTOK HAVE_WCSSTR HAVE_WCSPBRK HAVE_WCSSPN HAVE_WCSCSPN HAVE_WCSRCHR HAVE_WCSCHR HAVE_WCSDUP HAVE_WCSXFRM HAVE_WCSCOLL HAVE_WCSNCASECMP HAVE_WCSCASECMP HAVE_WCSNCMP HAVE_WCSCMP HAVE_WCSNCAT HAVE_WCSCAT HAVE_WCPNCPY HAVE_WCSNCPY HAVE_WCPCPY HAVE_WCSCPY HAVE_WCSNLEN HAVE_WCSLEN HAVE_WMEMSET HAVE_WMEMMOVE HAVE_WMEMCPY HAVE_WMEMCMP HAVE_WMEMCHR HAVE_WCSNRTOMBS HAVE_WCSRTOMBS HAVE_WCRTOMB HAVE_MBSNRTOWCS HAVE_MBSRTOWCS HAVE_MBRLEN HAVE_MBRTOWC HAVE_MBSINIT HAVE_BTOWC GNULIB_WCSWIDTH GNULIB_WCSTOK GNULIB_WCSSTR GNULIB_WCSPBRK GNULIB_WCSSPN GNULIB_WCSCSPN GNULIB_WCSRCHR GNULIB_WCSCHR GNULIB_WCSDUP GNULIB_WCSXFRM GNULIB_WCSCOLL GNULIB_WCSNCASECMP GNULIB_WCSCASECMP GNULIB_WCSNCMP GNULIB_WCSCMP GNULIB_WCSNCAT GNULIB_WCSCAT GNULIB_WCPNCPY GNULIB_WCSNCPY GNULIB_WCPCPY GNULIB_WCSCPY GNULIB_WCSNLEN GNULIB_WCSLEN GNULIB_WMEMSET GNULIB_WMEMMOVE GNULIB_WMEMCPY GNULIB_WMEMCMP GNULIB_WMEMCHR GNULIB_WCWIDTH GNULIB_WCSNRTOMBS GNULIB_WCSRTOMBS GNULIB_WCRTOMB GNULIB_MBSNRTOWCS GNULIB_MBSRTOWCS GNULIB_MBRLEN GNULIB_MBRTOWC GNULIB_MBSINIT GNULIB_WCTOB GNULIB_BTOWC HAVE_FEATURES_H NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H NEXT_ARPA_INET_H PRAGMA_COLUMNS PRAGMA_SYSTEM_HEADER INCLUDE_NEXT_AS_FIRST_DIRECTIVE INCLUDE_NEXT HAVE_ARPA_INET_H REPLACE_INET_PTON REPLACE_INET_NTOP HAVE_DECL_INET_PTON HAVE_DECL_INET_NTOP GNULIB_INET_PTON GNULIB_INET_NTOP GL_GENERATE_ALLOCA_H_FALSE GL_GENERATE_ALLOCA_H_TRUE ALLOCA_H ALLOCA LTALLOCA GL_COND_LIBTOOL_FALSE GL_COND_LIBTOOL_TRUE CXXCPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL ac_ct_AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP LIBTOOL WITH_MODULES_FALSE WITH_MODULES_TRUE SOCKSLIBS POSUB LTLIBINTL LIBINTL INTLLIBS INTL_MACOSX_LIBS XGETTEXT_EXTRA_OPTIONS MSGMERGE XGETTEXT_015 XGETTEXT GMSGFMT_015 MSGFMT_015 GMSGFMT MSGFMT GETTEXT_MACRO_VERSION USE_NLS SED GL_GENERATE_ICONV_H_FALSE GL_GENERATE_ICONV_H_TRUE ICONV_H REPLACE_ICONV_UTF REPLACE_ICONV_OPEN REPLACE_ICONV ICONV_CONST GNULIB_ICONV LTLIBICONV LIBICONV YFLAGS YACC am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX host_os host_vendor host_cpu host build_os build_vendor build_cpu build RANLIB ARFLAGS AR EGREP GREP CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_largefile enable_threads with_debug with_profiling enable_packager_mode with_gnu_ld enable_rpath with_libiconv_prefix enable_nls with_libintl_prefix with_pager with_socks with_socks5 with_socksdante with_modules enable_shared enable_static with_pic enable_fast_install with_sysroot enable_libtool_lock with_openssl with_libpth_prefix with_included_regex with_libresolv with_gnutls with_zlib with_dnssec_local_validation with_libidn ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC YACC YFLAGS CXXCPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR LIBGNUTLS_CFLAGS LIBGNUTLS_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures lftp 4.6.3a to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/lftp] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of lftp 4.6.3a:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --disable-largefile omit support for large files --enable-threads={posix|solaris|pth|windows} specify multithreading API --disable-threads build without multithread safety --enable-packager-mode Change configuration behavior to ease packaging --disable-rpath do not hardcode runtime library paths --disable-nls do not use Native Language Support --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-debug enable debug info --with-profiling enable profiling --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib --without-libintl-prefix don't search for libintl in includedir and libdir --with-pager=/path use specified pager by default --with-socks[=/path] build with SOCKSv4 library --with-socks5[=/path] build with SOCKSv5 library --with-socksdante[=/path] build with SOCKS-Dante library --with-modules build modular lftp (protocols become dll's) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-openssl use libcrypto hash routines. Valid ARGs are: 'yes', 'no', 'auto' => use if available, 'optional' => use if available and warn if not available; default is 'no' --with-libpth-prefix[=DIR] search for libpth in DIR/include and DIR/lib --without-libpth-prefix don't search for libpth in includedir and libdir --without-included-regex don't compile regex; this is the default on systems with recent-enough versions of the GNU C Library (use with caution on other systems). --without-libresolv don't use libresolv --without-gnutls don't use GNUTLS library --with-openssl[=/path] use OpenSSL [at /path] --without-openssl don't use OpenSSL (default) --with-zlib=/path use zlib at /path --with-dnssec-local-validation Enable local DNSSEC validation using libval (default=no) --with-libidn[=DIR] Support IDN (needs GNU Libidn) Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags YACC The `Yet Another Compiler Compiler' implementation to use. Defaults to the first program found out of: `bison -y', `byacc', `yacc'. YFLAGS The list of arguments that will be passed by default to $YACC. This script will default YFLAGS to the empty string to avoid a default value of `-d' given by some make applications. CXXCPP C++ preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path LIBGNUTLS_CFLAGS C compiler flags for LIBGNUTLS, overriding pkg-config LIBGNUTLS_LIBS linker flags for LIBGNUTLS, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF lftp configure 4.6.3a generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------ ## ## Report this to lftp-bugs@lftp.yar.ru ## ## ------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 &5 $as_echo_n "checking for $2.$3... " >&6; } if eval \${$4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main () { static $2 ac_aggr; if (ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main () { static $2 ac_aggr; if (sizeof ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else eval "$4=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by lftp $as_me 4.6.3a, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi gt_needs="$gt_needs " as_fn_append ac_header_list " arpa/inet.h" as_fn_append ac_header_list " features.h" as_fn_append ac_func_list " btowc" as_fn_append ac_func_list " chown" as_fn_append ac_func_list " fchown" as_fn_append ac_func_list " _set_invalid_parameter_handler" as_fn_append ac_header_list " sys/socket.h" as_fn_append ac_header_list " dirent.h" as_fn_append ac_header_list " unistd.h" as_fn_append ac_func_list " fcntl" as_fn_append ac_func_list " symlink" as_fn_append ac_func_list " isblank" as_fn_append ac_func_list " iswctype" as_fn_append ac_func_list " mbsrtowcs" as_fn_append ac_func_list " mempcpy" as_fn_append ac_func_list " wmemchr" as_fn_append ac_func_list " wmemcpy" as_fn_append ac_func_list " wmempcpy" as_fn_append ac_header_list " wctype.h" gl_fnmatch_required=GNU as_fn_append ac_header_list " sys/stat.h" as_fn_append ac_func_list " getdtablesize" as_fn_append ac_func_list " getlogin_r" gl_getopt_required=GNU as_fn_append ac_header_list " getopt.h" as_fn_append ac_func_list " gettimeofday" as_fn_append ac_func_list " nanotime" as_fn_append ac_header_list " sys/time.h" as_fn_append ac_header_list " sys/cdefs.h" as_fn_append ac_func_list " fstatat" as_fn_append ac_func_list " getpwnam_r" as_fn_append ac_header_list " iconv.h" as_fn_append ac_header_list " netdb.h" as_fn_append ac_header_list " netinet/in.h" as_fn_append ac_header_list " wchar.h" as_fn_append ac_header_list " stdint.h" as_fn_append ac_header_list " inttypes.h" as_fn_append ac_header_list " langinfo.h" as_fn_append ac_func_list " lchmod" as_fn_append ac_header_list " xlocale.h" as_fn_append ac_func_list " lstat" as_fn_append ac_header_list " math.h" as_fn_append ac_func_list " mbsinit" as_fn_append ac_func_list " mbrtowc" as_fn_append ac_func_list " isascii" as_fn_append ac_header_list " sys/mman.h" as_fn_append ac_func_list " mprotect" as_fn_append ac_func_list " nl_langinfo" as_fn_append ac_func_list " recvmsg" as_fn_append ac_func_list " sendmsg" as_fn_append ac_header_list " sys/param.h" as_fn_append ac_header_list " poll.h" as_fn_append ac_header_list " sys/ioctl.h" as_fn_append ac_header_list " sys/filio.h" gl_printf_safe=yes as_fn_append ac_func_list " readlink" as_fn_append ac_header_list " malloc.h" as_fn_append ac_header_list " sys/select.h" as_fn_append ac_func_list " setenv" as_fn_append ac_func_list " strdup" as_fn_append ac_func_list " tzset" as_fn_append ac_header_list " strings.h" as_fn_append ac_func_list " strptime" as_fn_append ac_func_list " strtoumax" as_fn_append ac_header_list " sys/uio.h" as_fn_append ac_func_list " localtime_r" as_fn_append ac_func_list " vasnprintf" as_fn_append ac_func_list " snprintf" as_fn_append ac_func_list " wcrtomb" as_fn_append ac_func_list " iswcntrl" as_fn_append ac_func_list " wcwidth" as_fn_append ac_header_list " utime.h" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in build-aux "$srcdir"/build-aux; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in build-aux \"$srcdir\"/build-aux" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. ac_config_headers="$ac_config_headers lib/config.h" am__api_version='1.14' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='lftp' VERSION='4.6.3a' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" if test "x$ac_cv_header_minix_config_h" = xyes; then : MINIX=yes else MINIX= fi if test "$MINIX" = yes; then $as_echo "#define _POSIX_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h $as_echo "#define _MINIX 1" >>confdefs.h $as_echo "#define _NETBSD_SOURCE 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } if ${ac_cv_safe_to_define___extensions__+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # define __EXTENSIONS__ 1 $ac_includes_default int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_define___extensions__=yes else ac_cv_safe_to_define___extensions__=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } test $ac_cv_safe_to_define___extensions__ = yes && $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h $as_echo "#define _ALL_SOURCE 1" >>confdefs.h $as_echo "#define _DARWIN_C_SOURCE 1" >>confdefs.h $as_echo "#define _GNU_SOURCE 1" >>confdefs.h $as_echo "#define __USE_MINGW_ANSI_STDIO 1" >>confdefs.h $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE should be defined" >&5 $as_echo_n "checking whether _XOPEN_SOURCE should be defined... " >&6; } if ${ac_cv_should_define__xopen_source+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_should_define__xopen_source=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include mbstate_t x; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 500 #include mbstate_t x; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_should_define__xopen_source=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_should_define__xopen_source" >&5 $as_echo "$ac_cv_should_define__xopen_source" >&6; } test $ac_cv_should_define__xopen_source = yes && $as_echo "#define _XOPEN_SOURCE 500" >>confdefs.h test -z "$CXX" && DEFAULT_CXX=yes test -z "$CFLAGS" && DEFAULT_CFLAGS=yes test -z "$CXXFLAGS" && DEFAULT_CXXFLAGS=yes test -z "$LDFLAGS" && DEFAULT_LDFLAGS=yes ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Minix Amsterdam compiler" >&5 $as_echo_n "checking for Minix Amsterdam compiler... " >&6; } if ${gl_cv_c_amsterdam_compiler+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __ACK__ Amsterdam #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Amsterdam" >/dev/null 2>&1; then : gl_cv_c_amsterdam_compiler=yes else gl_cv_c_amsterdam_compiler=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_c_amsterdam_compiler" >&5 $as_echo "$gl_cv_c_amsterdam_compiler" >&6; } if test -z "$AR"; then if test $gl_cv_c_amsterdam_compiler = yes; then AR='cc -c.a' if test -z "$ARFLAGS"; then ARFLAGS='-o' fi else if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="${ac_tool_prefix}ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AR" = x; then AR="ar" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi else AR="$ac_cv_prog_AR" fi if test -z "$ARFLAGS"; then ARFLAGS='cru' fi fi else if test -z "$ARFLAGS"; then ARFLAGS='cru' fi fi if test -z "$RANLIB"; then if test $gl_cv_c_amsterdam_compiler = yes; then RANLIB=':' else if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi fi fi # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # IEEE behaviour is the default on all CPUs except Alpha and SH # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4 # and the GCC 4.1.2 manual). case "$host_cpu" in alpha*) # On Alpha systems, a compiler option provides the behaviour. # See the ieee(3) manual page, also available at # if test -n "$GCC"; then # GCC has the option -mieee. # For full IEEE compliance (rarely needed), use option -mieee-with-inexact. CPPFLAGS="$CPPFLAGS -mieee" else # Compaq (ex-DEC) C has the option -ieee, equivalent to -ieee_with_no_inexact. # For full IEEE compliance (rarely needed), use option -ieee_with_inexact. CPPFLAGS="$CPPFLAGS -ieee" fi ;; sh*) if test -n "$GCC"; then # GCC has the option -mieee. CPPFLAGS="$CPPFLAGS -mieee" fi ;; esac # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } if ${ac_cv_sys_largefile_CC+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if ${ac_cv_sys_file_offset_bits+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if ${ac_cv_sys_large_files+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi $as_echo "#define _DARWIN_USE_64_BIT_INODE 1" >>confdefs.h fi # Check whether --enable-threads was given. if test "${enable_threads+set}" = set; then : enableval=$enable_threads; gl_use_threads=$enableval else if test -n "$gl_use_threads_default"; then gl_use_threads="$gl_use_threads_default" else case "$host_os" in osf*) gl_use_threads=no ;; cygwin*) case `uname -r` in 1.[0-5].*) gl_use_threads=no ;; *) gl_use_threads=yes ;; esac ;; *) gl_use_threads=yes ;; esac fi fi if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then # For using : case "$host_os" in osf*) # On OSF/1, the compiler needs the flag -D_REENTRANT so that it # groks . cc also understands the flag -pthread, but # we don't use it because 1. gcc-2.95 doesn't understand -pthread, # 2. putting a flag into CPPFLAGS that has an effect on the linker # causes the AC_LINK_IFELSE test below to succeed unexpectedly, # leading to wrong values of LIBTHREAD and LTLIBTHREAD. CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; esac # Some systems optimize for single-threaded programs by default, and # need special flags to disable these optimizations. For example, the # definition of 'errno' in . case "$host_os" in aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; esac fi # Code from module absolute-header: # Code from module alloca: # Code from module alloca-opt: # Code from module argmatch: # Code from module arpa_inet: # Code from module assure: # Code from module btowc: # Code from module c-ctype: # Code from module c-strcase: # Code from module c-strcaseeq: # Code from module chown: # Code from module clock-time: # Code from module cloexec: # Code from module close: # Code from module closedir: # Code from module configmake: # Code from module crypto/md5: # Code from module crypto/sha1: # Code from module d-type: # Code from module dirent: # Code from module dirfd: # Code from module dosname: # Code from module dup2: # Code from module environ: # Code from module errno: # Code from module error: # Code from module exitfail: # Code from module extensions: # Code from module extern-inline: # Code from module fcntl: # Code from module fcntl-h: # Code from module fd-hook: # Code from module filemode: # Code from module filename: # Code from module float: # Code from module fnmatch: # Code from module fnmatch-gnu: # Code from module fpieee: # Code from module fpucw: # Code from module frexp-nolibm: # Code from module frexpl-nolibm: # Code from module fstat: # Code from module getdtablesize: # Code from module getlogin_r: # Code from module getopt-gnu: # Code from module getopt-posix: # Code from module gettext: # Code from module gettext-h: # Code from module gettime: # Code from module gettimeofday: # Code from module glob: # Code from module gperf: # Code from module havelib: # Code from module human: # Code from module iconv: # Code from module iconv-h: # Code from module iconv_open: # Code from module include_next: # Code from module inet_pton: # Code from module inline: # Code from module intprops: # Code from module inttypes-incomplete: # Code from module isnand-nolibm: # Code from module isnanf-nolibm: # Code from module isnanl-nolibm: # Code from module langinfo: # Code from module largefile: # Code from module lchown: # Code from module localcharset: # Code from module locale: # Code from module localeconv: # Code from module lock: # Code from module longlong: # Code from module lstat: # Code from module malloc-posix: # Code from module malloca: # Code from module math: # Code from module mbrtowc: # Code from module mbsinit: # Code from module mbsrtowcs: # Code from module mbswidth: # Code from module mbtowc: # Code from module memchr: # Code from module memmem: # Code from module memmem-simple: # Code from module mempcpy: # Code from module mktime: # Code from module modechange: # Code from module msvc-inval: # Code from module msvc-nothrow: # Code from module multiarch: # Code from module netinet_in: # Code from module nl_langinfo: # Code from module nocrash: # Code from module open: # Code from module opendir: # Code from module parse-datetime: # Code from module passfd: # Code from module pathmax: # Code from module poll: # Code from module poll-h: # Code from module printf-frexp: # Code from module printf-frexpl: # Code from module printf-safe: # Code from module quote: # Code from module quotearg: # Code from module quotearg-simple: # Code from module readdir: # Code from module readlink: # Code from module regex: # Code from module select: # Code from module setenv: # Code from module signal-h: # Code from module signbit: # Code from module size_max: # Code from module snippet/_Noreturn: # Code from module snippet/arg-nonnull: # Code from module snippet/c++defs: # Code from module snippet/unused-parameter: # Code from module snippet/warn-on-use: # Code from module socketlib: # Code from module sockets: # Code from module socklen: # Code from module ssize_t: # Code from module stat: # Code from module stat-macros: # Code from module stdalign: # Code from module stdbool: # Code from module stddef: # Code from module stdint: # Code from module stdio: # Code from module stdlib: # Code from module strcase: # Code from module strdup-posix: # Code from module streq: # Code from module strerror: # Code from module strerror-override: # Code from module strftime: # Code from module string: # Code from module strings: # Code from module strnlen1: # Code from module strptime: # Code from module strstr: # Code from module strstr-simple: # Code from module strtok_r: # Code from module strtoull: # Code from module strtoumax: # Code from module sys_select: # Code from module sys_socket: # Code from module sys_stat: # Code from module sys_time: # Code from module sys_types: # Code from module sys_uio: # Code from module threadlib: # Code from module time: # Code from module time_r: # Code from module timespec: # Code from module unistd: # Code from module unistr/base: # Code from module unistr/u8-mbtoucr: # Code from module unistr/u8-uctomb: # Code from module unitypes: # Code from module uniwidth/base: # Code from module uniwidth/width: # Code from module unsetenv: # Code from module vasnprintf: # Code from module verify: # Code from module vsnprintf: # Code from module vsnprintf-posix: # Code from module wchar: # Code from module wcrtomb: # Code from module wctype-h: # Code from module wcwidth: # Code from module xalloc: # Code from module xalloc-die: # Code from module xalloc-oversized: # Code from module xsize: # Code from module xstrtol: # Code from module xstrtoumax: ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_YACC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_YACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 $as_echo "$YACC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$YACC" && break done test -n "$YACC" || YACC="yacc" if test x$ac_cv_lib_fl_yywrap = xno; then $as_echo "#define NEED_YYWRAP 1" >>confdefs.h fi # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } if ${ac_cv_sys_largefile_CC+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if ${ac_cv_sys_file_offset_bits+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if ${ac_cv_sys_large_files+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi $as_echo "#define _DARWIN_USE_64_BIT_INODE 1" >>confdefs.h fi # Check whether --with-debug was given. if test "${with_debug+set}" = set; then : withval=$with_debug; with_debug=$withval; else with_debug=no; fi # Check whether --with-profiling was given. if test "${with_profiling+set}" = set; then : withval=$with_profiling; with_profiling=$withval; else with_profiling=no; fi # Check whether --enable-packager-mode was given. if test "${enable_packager_mode+set}" = set; then : enableval=$enable_packager_mode; if test x"${enableval}" = xyes then DEFAULT_CXX=no DEFAULT_CFLAGS=no DEFAULT_CXXFLAGS=no DEFAULT_LDFLAGS=no fi fi if test x$with_debug = xno; then if test x$DEFAULT_CFLAGS = xyes; then CFLAGS="`echo $CFLAGS | sed 's/-g//'`" if test -z "$CFLAGS"; then CFLAGS=-O fi fi if test x$DEFAULT_CXXFLAGS = xyes; then CXXFLAGS="`echo $CXXFLAGS | sed 's/-g//'`" if test -z "$CXXFLAGS"; then CXXFLAGS=-O fi fi # don't strip when profiling if test x$DEFAULT_LDFLAGS = xyes -a x$with_profiling != xyes; then case "`uname -s`" in Darwin) ;; *) LDFLAGS="$LDFLAGS -s";; esac fi fi if test x$with_debug = xyes; then if test x$DEFAULT_CFLAGS = xyes; then CFLAGS="`echo $CFLAGS | sed 's/-O[0-9]\?//'`" fi if test x$DEFAULT_CXXFLAGS = xyes; then CXXFLAGS="`echo $CXXFLAGS | sed 's/-O[0-9]\?//'`" fi fi if test x$with_profiling = xyes; then CFLAGS="$CFLAGS -pg" CXXFLAGS="$CXXFLAGS -pg" # profiling requires debugging, too, but don't nuke -O # if test x$with_debug != xyes; then # CFLAGS="$CFLAGS -g" # CXXFLAGS="$CXXFLAGS -g" # fi fi if test x$GCC = xyes; then CFLAGS="$CFLAGS -Wall" fi if test x$GXX = xyes; then CXXFLAGS="$CXXFLAGS -Wall -Wwrite-strings -Woverloaded-virtual" # save some bytes flags="-fno-exceptions -fno-rtti" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CXX supports $flags" >&5 $as_echo_n "checking if $CXX supports $flags... " >&6; } ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu old_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $flags" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ class aaa { int var; public: virtual void func() { var=1; } aaa(); virtual ~aaa(); }; aaa::aaa() { var=0; } aaa::~aaa() {} int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : support=yes else support=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="$old_CXXFLAGS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: result: $support" >&5 $as_echo "$support" >&6; } if test x$support = xyes; then CXXFLAGS="$CXXFLAGS $flags" fi # check for -fno-implement-inline (doesn't work without -O in gcc 2.95.4; functions are never inlined) if test x$with_debug = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -fno-implement-inlines implements virtual functions" >&5 $as_echo_n "checking if -fno-implement-inlines implements virtual functions... " >&6; } flags="-fno-implement-inlines" if ${lftp_cv_noimplementinline+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu old_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $flags" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ class aaa { int var; public: virtual void func() { var=1; } aaa(); virtual ~aaa(); }; aaa::aaa() { var=0; } aaa::~aaa() {} int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lftp_cv_noimplementinline=yes else lftp_cv_noimplementinline=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CXXFLAGS="$old_CXXFLAGS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_noimplementinline" >&5 $as_echo "$lftp_cv_noimplementinline" >&6; } if test x$lftp_cv_noimplementinline = xyes; then CXXFLAGS="$CXXFLAGS $flags" fi fi fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking if c++ compiler works" >&5 $as_echo_n "checking if c++ compiler works... " >&6; } if test "$cross_compiling" = yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: cross-compiling" >&5 $as_echo "cross-compiling" >&6; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main() { return(0); } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "C++ test compile failed; check your C++ compiler" "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking if c++ compiler can handle dynamic initializers" >&5 $as_echo_n "checking if c++ compiler can handle dynamic initializers... " >&6; } if test "$cross_compiling" = yes; then : cxx_dynamic_init=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int f() { return 1; } int a=f(); int main() { return(1-a); } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : cxx_dynamic_init=yes else cxx_dynamic_init=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cxx_dynamic_init" >&5 $as_echo "$cxx_dynamic_init" >&6; } if test x$cxx_dynamic_init = xno; then as_fn_error $? "C++ compiler cannot handle dynamic initializers of static objects" "$LINENO" 5 fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports bool type" >&5 $as_echo_n "checking whether $CXX supports bool type... " >&6; } if ${lftp_cv_cxx_bool+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ bool t=true;bool f=false; int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : lftp_cv_cxx_bool=yes else lftp_cv_cxx_bool=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_cxx_bool" >&5 $as_echo "$lftp_cv_cxx_bool" >&6; } if test x$lftp_cv_cxx_bool = xyes; then $as_echo "#define HAVE_CXX_BOOL 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports _Bool type" >&5 $as_echo_n "checking whether $CXX supports _Bool type... " >&6; } if ${lftp_cv_cxx__Bool+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _Bool t=true;bool f=false; int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : lftp_cv_cxx__Bool=yes else lftp_cv_cxx__Bool=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_cxx__Bool" >&5 $as_echo "$lftp_cv_cxx__Bool" >&6; } if test x$lftp_cv_cxx__Bool = xyes; then $as_echo "#define HAVE_CXX__BOOL 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX understands ANSI scoping rules" >&5 $as_echo_n "checking whether $CXX understands ANSI scoping rules... " >&6; } if ${lftp_cv_cxx_ansi_scope+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { for (int i = 0; i < 4; i++) ; for (int i = 0; i < 4; i++) ; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : lftp_cv_cxx_ansi_scope=yes else # IRIX C++ needs -LANG:ansi-for-init-scope=ON if # -LANG:std not used _cxxflags=$CXXFLAGS CXXFLAGS="$CXXFLAGS -LANG:ansi-for-init-scope=ON" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { for (int i = 0; i < 4; i++) ; for (int i = 0; i < 4; i++) ; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : lftp_cv_cxx_ansi_scope="-LANG:ansi-for-init-scope=ON" else lftp_cv_cxx_ansi_scope=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS=$_cxxflags fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi if test x$lftp_cv_cxx_ansi_scope = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_cxx_ansi_scope" >&5 $as_echo "$lftp_cv_cxx_ansi_scope" >&6; } as_fn_error $? "C++ compiler does not understand ANSI scoping rules" "$LINENO" 5 elif test x$lftp_cv_cxx_ansi_scope != xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_cxx_ansi_scope added to \$CXXFLAGS" >&5 $as_echo "$lftp_cv_cxx_ansi_scope added to \$CXXFLAGS" >&6; } CXXFLAGS="$CXXFLAGS $lftp_cv_cxx_ansi_scope" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_cxx_ansi_scope" >&5 $as_echo "$lftp_cv_cxx_ansi_scope" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stdint.h needs __STDC_LIMIT_MACROS in C++ mode" >&5 $as_echo_n "checking whether stdint.h needs __STDC_LIMIT_MACROS in C++ mode... " >&6; } if ${lftp_cv_cxx_stdc_limit_macros+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int i = INT_MIN==INT32_MIN && INT_MAX == INT32_MAX; int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : lftp_cv_cxx_stdc_limit_macros=no else lftp_cv_cxx_stdc_limit_macros=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_cxx_stdc_limit_macros" >&5 $as_echo "$lftp_cv_cxx_stdc_limit_macros" >&6; } if test x$lftp_cv_cxx_stdc_limit_macros = xyes; then $as_echo "#define __STDC_LIMIT_MACROS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } if ${ac_cv_search_strerror+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char strerror (); int main () { return strerror (); ; return 0; } _ACEOF for ac_lib in '' cposix; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_strerror=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_strerror+:} false; then : break fi done if ${ac_cv_search_strerror+:} false; then : else ac_cv_search_strerror=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5 $as_echo "$ac_cv_search_strerror" >&6; } ac_res=$ac_cv_search_strerror if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi case "`uname -sr`" in # Linux-2.2.x and older don't support fcntl64. Linux\ 2.012.*) enable_largefile=no;; esac if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${acl_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$acl_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${acl_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$acl_cv_prog_gnu_ld" >&6; } with_gnu_ld=$acl_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 $as_echo_n "checking for shared library run path origin... " >&6; } if ${acl_cv_rpath+:} false; then : $as_echo_n "(cached) " >&6 else CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 $as_echo "$acl_cv_rpath" >&6; } wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" # Check whether --enable-rpath was given. if test "${enable_rpath+set}" = set; then : enableval=$enable_rpath; : else enable_rpath=yes fi acl_libdirstem=lib acl_libdirstem2= case "$host_os" in solaris*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 $as_echo_n "checking for 64-bit host... " >&6; } if ${gl_cv_solaris_64bit+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _LP64 sixtyfour bits #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "sixtyfour bits" >/dev/null 2>&1; then : gl_cv_solaris_64bit=yes else gl_cv_solaris_64bit=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 $as_echo "$gl_cv_solaris_64bit" >&6; } if test $gl_cv_solaris_64bit = yes; then acl_libdirstem=lib/64 case "$host_cpu" in sparc*) acl_libdirstem2=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; esac fi ;; *) searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libiconv-prefix was given. if test "${with_libiconv_prefix+set}" = set; then : withval=$with_libiconv_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBICONV= LTLIBICONV= INCICONV= LIBICONV_PREFIX= HAVE_LIBICONV= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='iconv ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" else LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'iconv'; then LIBICONV_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'iconv'; then LIBICONV_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" ;; esac done fi else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" done fi GNULIB_ICONV=0; ICONV_CONST=; REPLACE_ICONV=0; REPLACE_ICONV_OPEN=0; REPLACE_ICONV_UTF=0; ICONV_H=''; if test -n "$ICONV_H"; then GL_GENERATE_ICONV_H_TRUE= GL_GENERATE_ICONV_H_FALSE='#' else GL_GENERATE_ICONV_H_TRUE='#' GL_GENERATE_ICONV_H_FALSE= fi am_save_CPPFLAGS="$CPPFLAGS" for element in $INCICONV; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if ${am_cv_func_iconv+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_lib_iconv=yes am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$am_save_LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 $as_echo "$am_cv_func_iconv" >&6; } if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 $as_echo_n "checking for working iconv... " >&6; } if ${am_cv_func_iconv_works+:} false; then : $as_echo_n "(cached) " >&6 else am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi am_cv_func_iconv_works=no for ac_iconv_const in '' 'const'; do if test "$cross_compiling" = yes; then : case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef ICONV_CONST # define ICONV_CONST $ac_iconv_const #endif int main () { int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 1; iconv_close (cd_utf8_to_88591); } } /* Test against Solaris 10 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\263"; char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 2; iconv_close (cd_ascii_to_88591); } } /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ { iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304"; static char buf[2] = { (char)0xDE, (char)0xAD }; ICONV_CONST char *inptr = input; size_t inbytesleft = 1; char *outptr = buf; size_t outbytesleft = 1; size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) result |= 4; iconv_close (cd_88591_to_utf8); } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) result |= 8; iconv_close (cd_88591_to_utf8); } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) result |= 16; return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : am_cv_func_iconv_works=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi test "$am_cv_func_iconv_works" = no || break done LIBS="$am_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 $as_echo "$am_cv_func_iconv_works" >&6; } case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5 $as_echo_n "checking for iconv declaration... " >&6; } if ${am_cv_proto_iconv+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : am_cv_proto_iconv_arg1="" else am_cv_proto_iconv_arg1="const" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);" fi am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_proto_iconv" >&5 $as_echo " $am_cv_proto_iconv" >&6; } cat >>confdefs.h <<_ACEOF #define ICONV_CONST $am_cv_proto_iconv_arg1 _ACEOF if test -n "$am_cv_proto_iconv_arg1"; then ICONV_CONST="const" fi fi ALL_LINGUAS="de es fr it ja ko pl pt_BR ru uk zh_CN zh_TW zh_HK cs" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 $as_echo_n "checking whether NLS is requested... " >&6; } # Check whether --enable-nls was given. if test "${enable_nls+set}" = set; then : enableval=$enable_nls; USE_NLS=$enableval else USE_NLS=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 $as_echo "$USE_NLS" >&6; } GETTEXT_MACRO_VERSION=0.19 # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MSGFMT+:} false; then : $as_echo_n "(cached) " >&6 else case "$MSGFMT" in [\\/]* | ?:[\\/]*) ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 && (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" ;; esac fi MSGFMT="$ac_cv_path_MSGFMT" if test "$MSGFMT" != ":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 $as_echo "$MSGFMT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GMSGFMT+:} false; then : $as_echo_n "(cached) " >&6 else case $GMSGFMT in [\\/]* | ?:[\\/]*) ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" ;; esac fi GMSGFMT=$ac_cv_path_GMSGFMT if test -n "$GMSGFMT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 $as_echo "$GMSGFMT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; *) MSGFMT_015=$MSGFMT ;; esac case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; *) GMSGFMT_015=$GMSGFMT ;; esac # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_XGETTEXT+:} false; then : $as_echo_n "(cached) " >&6 else case "$XGETTEXT" in [\\/]* | ?:[\\/]*) ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 && (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" ;; esac fi XGETTEXT="$ac_cv_path_XGETTEXT" if test "$XGETTEXT" != ":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 $as_echo "$XGETTEXT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f messages.po case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; *) XGETTEXT_015=$XGETTEXT ;; esac # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "msgmerge", so it can be a program name with args. set dummy msgmerge; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MSGMERGE+:} false; then : $as_echo_n "(cached) " >&6 else case "$MSGMERGE" in [\\/]* | ?:[\\/]*) ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" ;; esac fi MSGMERGE="$ac_cv_path_MSGMERGE" if test "$MSGMERGE" != ":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 $as_echo "$MSGMERGE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$localedir" || localedir='${datadir}/locale' test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= ac_config_commands="$ac_config_commands po-directories" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFPreferencesCopyAppValue" >&5 $as_echo_n "checking for CFPreferencesCopyAppValue... " >&6; } if ${gt_cv_func_CFPreferencesCopyAppValue+:} false; then : $as_echo_n "(cached) " >&6 else gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { CFPreferencesCopyAppValue(NULL, NULL) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gt_cv_func_CFPreferencesCopyAppValue=yes else gt_cv_func_CFPreferencesCopyAppValue=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$gt_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 $as_echo "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then $as_echo "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5 $as_echo_n "checking for CFLocaleCopyCurrent... " >&6; } if ${gt_cv_func_CFLocaleCopyCurrent+:} false; then : $as_echo_n "(cached) " >&6 else gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { CFLocaleCopyCurrent(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gt_cv_func_CFLocaleCopyCurrent=yes else gt_cv_func_CFLocaleCopyCurrent=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$gt_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 $as_echo "$gt_cv_func_CFLocaleCopyCurrent" >&6; } if test $gt_cv_func_CFLocaleCopyCurrent = yes; then $as_echo "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h fi INTL_MACOSX_LIBS= if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" fi LIBINTL= LTLIBINTL= POSUB= case " $gt_needs " in *" need-formatstring-macros "*) gt_api_version=3 ;; *" need-ngettext "*) gt_api_version=2 ;; *) gt_api_version=1 ;; esac gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" if test "$USE_NLS" = "yes"; then gt_use_preinstalled_gnugettext=no if test $gt_api_version -ge 3; then gt_revision_test_code=' #ifndef __GNU_GETTEXT_SUPPORTED_REVISION #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) #endif typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; ' else gt_revision_test_code= fi if test $gt_api_version -ge 2; then gt_expression_test_code=' + * ngettext ("", "", 0)' else gt_expression_test_code= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libc" >&5 $as_echo_n "checking for GNU gettext in libc... " >&6; } if eval \${$gt_func_gnugettext_libc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern int *_nl_domain_bindings; int main () { bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$gt_func_gnugettext_libc=yes" else eval "$gt_func_gnugettext_libc=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$gt_func_gnugettext_libc { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then am_save_CPPFLAGS="$CPPFLAGS" for element in $INCICONV; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if ${am_cv_func_iconv+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_lib_iconv=yes am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$am_save_LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 $as_echo "$am_cv_func_iconv" >&6; } if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 $as_echo_n "checking for working iconv... " >&6; } if ${am_cv_func_iconv_works+:} false; then : $as_echo_n "(cached) " >&6 else am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi am_cv_func_iconv_works=no for ac_iconv_const in '' 'const'; do if test "$cross_compiling" = yes; then : case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef ICONV_CONST # define ICONV_CONST $ac_iconv_const #endif int main () { int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 1; iconv_close (cd_utf8_to_88591); } } /* Test against Solaris 10 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\263"; char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 2; iconv_close (cd_ascii_to_88591); } } /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ { iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304"; static char buf[2] = { (char)0xDE, (char)0xAD }; ICONV_CONST char *inptr = input; size_t inbytesleft = 1; char *outptr = buf; size_t outbytesleft = 1; size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) result |= 4; iconv_close (cd_88591_to_utf8); } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) result |= 8; iconv_close (cd_88591_to_utf8); } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) result |= 16; return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : am_cv_func_iconv_works=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi test "$am_cv_func_iconv_works" = no || break done LIBS="$am_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 $as_echo "$am_cv_func_iconv_works" >&6; } case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libintl-prefix was given. if test "${with_libintl_prefix+set}" = set; then : withval=$with_libintl_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBINTL= LTLIBINTL= INCINTL= LIBINTL_PREFIX= HAVE_LIBINTL= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='intl ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a" else LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'intl'; then LIBINTL_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'intl'; then LIBINTL_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBINTL="${LIBINTL}${LIBINTL:+ }$dep" LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep" ;; esac done fi else LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir" done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libintl" >&5 $as_echo_n "checking for GNU gettext in libintl... " >&6; } if eval \${$gt_func_gnugettext_libintl+:} false; then : $as_echo_n "(cached) " >&6 else gt_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $INCINTL" gt_save_LIBS="$LIBS" LIBS="$LIBS $LIBINTL" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *); int main () { bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$gt_func_gnugettext_libintl=yes" else eval "$gt_func_gnugettext_libintl=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then LIBS="$LIBS $LIBICONV" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *); int main () { bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : LIBINTL="$LIBINTL $LIBICONV" LTLIBINTL="$LTLIBINTL $LTLIBICONV" eval "$gt_func_gnugettext_libintl=yes" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi CPPFLAGS="$gt_save_CPPFLAGS" LIBS="$gt_save_LIBS" fi eval ac_res=\$$gt_func_gnugettext_libintl { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ && test "$PACKAGE" != gettext-runtime \ && test "$PACKAGE" != gettext-tools; }; then gt_use_preinstalled_gnugettext=yes else LIBINTL= LTLIBINTL= INCINTL= fi if test -n "$INTL_MACOSX_LIBS"; then if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" fi fi if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then $as_echo "#define ENABLE_NLS 1" >>confdefs.h else USE_NLS=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use NLS" >&5 $as_echo_n "checking whether to use NLS... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 $as_echo "$USE_NLS" >&6; } if test "$USE_NLS" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking where the gettext function comes from" >&5 $as_echo_n "checking where the gettext function comes from... " >&6; } if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then gt_source="external libintl" else gt_source="libc" fi else gt_source="included intl directory" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_source" >&5 $as_echo "$gt_source" >&6; } fi if test "$USE_NLS" = "yes"; then if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libintl" >&5 $as_echo_n "checking how to link with libintl... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBINTL" >&5 $as_echo "$LIBINTL" >&6; } for element in $INCINTL; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done fi $as_echo "#define HAVE_GETTEXT 1" >>confdefs.h $as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h fi POSUB=po fi INTLLIBS="$LIBINTL" test "$MSGFMT" = "no" && MSGFMT ="$missing_dir/missing msgfmt" test "$GMSGFMT" = "no" && GMSGFMT ="$missing_dir/missing msgfmt" test "$XGETTEXT" = ":" && XGETTEXT="$missing_dir/missing xgettext" if test x$gt_cv_func_gettext_libintl = xyes; then case "$LIBS" in *-lintl*) ;; *) LIBS="$LIBS -lintl";; esac fi # Check whether --with-pager was given. if test "${with_pager+set}" = set; then : withval=$with_pager; with_pager=$withval; else with_pager="exec more"; fi cat >>confdefs.h <<_ACEOF #define DEFAULT_PAGER "$with_pager" _ACEOF # Check whether --with-socks was given. if test "${with_socks+set}" = set; then : withval=$with_socks; with_socks=$withval; else with_socks=no; fi # Check whether --with-socks5 was given. if test "${with_socks5+set}" = set; then : withval=$with_socks5; with_socks5=$withval; else with_socks5=no; fi # Check whether --with-socksdante was given. if test "${with_socksdante+set}" = set; then : withval=$with_socksdante; with_socksdante=$withval; else with_socksdante=no; fi case "$with_socks" in yes|no|"") ;; *) socks_loc=$with_socks with_socks=yes;; esac case "$with_socks5" in yes|no|"") ;; *) socks_loc=$with_socks5 with_socks5=yes;; esac case "$with_socksdante" in yes|no|"") ;; *) socks_loc=$with_socksdante with_socksdante=yes;; esac if test x$socks_loc != x; then LDFLAGS="$LDFLAGS -L$socks_loc/lib" CPPFLAGS="$CPPFLAGS -I$socks_loc/include" fi if test x$with_socks = xyes; then $as_echo "#define SOCKS4 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocks" >&5 $as_echo_n "checking for main in -lsocks... " >&6; } if ${ac_cv_lib_socks_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocks $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socks_main=yes else ac_cv_lib_socks_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socks_main" >&5 $as_echo "$ac_cv_lib_socks_main" >&6; } if test "x$ac_cv_lib_socks_main" = xyes; then : SOCKSLIBS=-lsocks else as_fn_error $? "cannot find -lsocks library" "$LINENO" 5 fi fi if test x$with_socks5 = xyes; then $as_echo "#define SOCKS5 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocks5" >&5 $as_echo_n "checking for main in -lsocks5... " >&6; } if ${ac_cv_lib_socks5_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocks5 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socks5_main=yes else ac_cv_lib_socks5_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socks5_main" >&5 $as_echo "$ac_cv_lib_socks5_main" >&6; } if test "x$ac_cv_lib_socks5_main" = xyes; then : SOCKSLIBS=-lsocks5 else as_fn_error $? "cannot find -lsocks5 library" "$LINENO" 5 fi fi if test x$with_socksdante = xyes; then $as_echo "#define SOCKS_DANTE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocks" >&5 $as_echo_n "checking for main in -lsocks... " >&6; } if ${ac_cv_lib_socks_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocks $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socks_main=yes else ac_cv_lib_socks_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socks_main" >&5 $as_echo "$ac_cv_lib_socks_main" >&6; } if test "x$ac_cv_lib_socks_main" = xyes; then : SOCKSLIBS=-lsocks else as_fn_error $? "cannot find -lsocks library" "$LINENO" 5 fi fi if test -n "$SOCKSLIBS"; then old_LIBS="$LIBS" LIBS="$LIBS $SOCKSLIBS" for ac_func in Rpoll do : ac_fn_c_check_func "$LINENO" "Rpoll" "ac_cv_func_Rpoll" if test "x$ac_cv_func_Rpoll" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_RPOLL 1 _ACEOF fi done if test "$ac_cv_func_Rpoll" != yes; then gl_cv_func_poll=no fi LIBS="$old_LIBS" fi # Check whether --with-modules was given. if test "${with_modules+set}" = set; then : withval=$with_modules; with_modules=$withval; else with_modules=no; fi if test "$with_modules" = yes; then WITH_MODULES_TRUE= WITH_MODULES_FALSE='#' else WITH_MODULES_TRUE='#' WITH_MODULES_FALSE= fi if test "$with_modules" = yes; then enable_static=no enable_shared=yes $as_echo "#define WITH_MODULES 1" >>confdefs.h else enable_static=yes enable_shared=no fi #test -z "$enable_static" && enable_static=no case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2.418' macro_revision='2.4.2.418' ltmain=$ac_aux_dir/ltmain.sh # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case $ECHO in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n "$lt_cv_sys_max_cmd_len"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi ;; darwin*) if test yes = "$GCC"; then reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 $as_echo "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done func_stripname_cnf () { case $2 in .*) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%\\\\$2\$%%"`;; *) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%$2\$%%"`;; esac } # func_stripname_cnf # Set options enable_dlopen=yes enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac else pic_mode=default fi # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/${ac_tool_prefix}file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test yes = "$GCC"; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi lt_prog_compiler_pic='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test no = "$hard_links"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='$wl-f,' if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi fi fi export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test yes = "$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' $wl-bernotok' allow_undefined_flag=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $wl-bnoentry $compiler_flags $wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test yes = "$GCC"; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' else archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test yes = "$GCC"; then wlarc='$wl' archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='$wl-z,text' allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test yes = "$aix_use_runtimelinking"; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' shrext_cmds=.dll need_lib_prefix=no library_names_spec='$libname$shared_ext $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen=shl_load else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen=dlopen else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi fi fi fi fi fi ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report what library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test ia64 != "$host_cpu" && test no = "$aix_use_runtimelinking"; then test yes = "$enable_shared" && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC if test -n "$CXX" && ( test no != "$CXX" && ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || (test g++ != "$CXX"))); then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu else _lt_caught_CXX_error=yes fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= compiler_needs_object_CXX=no export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no inherit_rpath_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds reload_flag_CXX=$reload_flag reload_cmds_CXX=$reload_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_caught_CXX_error"; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC compiler_CXX=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test yes = "$GXX"; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test yes = "$GXX"; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test yes = "$with_gnu_ld"; then archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec_CXX= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes file_list_spec_CXX='$wl-f,' if test yes = "$GXX"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct_CXX=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= fi esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag=$shared_flag' $wl-G' fi else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi fi fi export_dynamic_flag_spec_CXX='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. always_export_symbols_CXX=yes if test yes = "$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_CXX='-berok' # Determine the default libpath from the value encoded in an empty # executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec_CXX='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_CXX=' $wl-bernotok' allow_undefined_flag_CXX=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' fi archive_cmds_need_lc_CXX=yes # This is similar to how AIX traditionally builds its shared # libraries. archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $wl-bnoentry $compiler_flags $wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec_CXX=' ' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=yes file_list_spec_CXX='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds_CXX='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true' enable_shared_with_static_runtimes_CXX=yes # Don't use ranlib old_postinstall_cmds_CXX='chmod 644 $oldlib' postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ func_to_tool_file "$lt_outputfile"~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' export_dynamic_flag_spec_CXX='$wl--export-all-symbols' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds_CXX='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec_CXX='' fi link_all_deplibs_CXX=yes allow_undefined_flag_CXX=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" if test yes != "$lt_cv_apple_cc_single_mod"; then archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi else ld_shlibs_CXX=no fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; haiku*) archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs_CXX=yes ;; hpux9*) hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='$wl-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) export_dynamic_flag_spec_CXX='$wl-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' export_dynamic_flag_spec_CXX='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5].* | *pgcpp\ [1-5].*) prelink_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='$wl--rpath $wl$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' whole_archive_flag_spec_CXX='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ;; cxx*) # Compaq C++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' whole_archive_flag_spec_CXX='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object_CXX=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) ld_shlibs_CXX=yes ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='$wl-E' whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else ld_shlibs_CXX=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) case $host in osf3*) allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*' archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ $RM $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes,no = "$GXX,$with_gnu_ld"; then allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*' case $host in osf3*) archive_cmds_CXX='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; *) archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs_CXX=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test yes,no = "$GXX,$with_gnu_ld"; then no_undefined_flag_CXX=' $wl-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. archive_cmds_CXX='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) whole_archive_flag_spec_CXX='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='$wl-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_CXX='$wl-z,text' allow_undefined_flag_CXX='$wl-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='$wl-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='$wl-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ '"$old_archive_cmds_CXX" reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ '"$reload_cmds_CXX" ;; *) archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test no = "$ld_shlibs_CXX" && can_build_shared=no GCC_CXX=$GXX LD_CXX=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $prev$p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test x-L = "$p" || test x-R = "$p"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test no = "$pre_test_object_deps_done"; then case $prev in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX=$prev$p else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} $prev$p" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$postdeps_CXX"; then postdeps_CXX=$prev$p else postdeps_CXX="${postdeps_CXX} $prev$p" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test no = "$pre_test_object_deps_done"; then if test -z "$predep_objects_CXX"; then predep_objects_CXX=$p else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX=$p else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken case $host_os in interix[3-9]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test yes != "$solaris_use_stlport4"; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test yes != "$solaris_use_stlport4"; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | $SED -e 's! -L! !g' -e 's!^ !!'` fi lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= # C++ specific cases for pic, static, wl, etc. if test yes = "$GXX"; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi lt_prog_compiler_pic_CXX='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic_CXX='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static_CXX= ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_CXX=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac else case $host_os in aix[4-9]*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='$wl-a ${wl}archive' if test ia64 != "$host_cpu"; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='$wl-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler lt_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64, which still supported -KPIC. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) # IBM XL 8.0, 9.0 on PPC and BlueGene lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-qpic' lt_prog_compiler_static_CXX='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works_CXX=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works_CXX=yes fi else lt_cv_prog_compiler_static_works_CXX=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then : else lt_prog_compiler_static_CXX= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test no = "$hard_links"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' case $host_os in aix[4-9]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX=$ltdll_cmds ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' ;; esac ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test no = "$ld_shlibs_CXX" && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc_CXX=no else lt_cv_archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 $as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test yes = "$aix_use_runtimelinking"; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec_CXX='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' shrext_cmds=.dll need_lib_prefix=no library_names_spec='$libname$shared_ext $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || test yes = "$hardcode_automatic_CXX"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct_CXX" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" && test no != "$hardcode_minus_L_CXX"; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 $as_echo "$hardcode_action_CXX" >&6; } if test relink = "$hardcode_action_CXX" || test yes = "$inherit_rpath_CXX"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test yes != "$_lt_caught_CXX_error" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_commands="$ac_config_commands libtool" # Only expand once: LIBTOOL="$LIBTOOL --silent" LIBC_FATAL_STDERR_=1 export LIBC_FATAL_STDERR_ ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } if ${ac_cv_working_alloca_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char *p = (char *) alloca (2 * sizeof (int)); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_working_alloca_h=yes else ac_cv_working_alloca_h=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 $as_echo "$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then $as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } if ${ac_cv_func_alloca_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # ifdef _MSC_VER # include # define alloca _alloca # else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ void *alloca (size_t); # endif # endif # endif # endif #endif int main () { char *p = (char *) alloca (1); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_alloca_works=yes else ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 $as_echo "$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h else # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=\${LIBOBJDIR}alloca.$ac_objext $as_echo "#define C_ALLOCA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } if ${ac_cv_os_cray+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined CRAY && ! defined CRAY2 webecray #else wenotbecray #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "webecray" >/dev/null 2>&1; then : ac_cv_os_cray=yes else ac_cv_os_cray=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 $as_echo "$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } if ${ac_cv_c_stack_direction+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_c_stack_direction=0 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int find_stack_direction (int *addr, int depth) { int dir, dummy = 0; if (! addr) addr = &dummy; *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; dir = depth ? find_stack_direction (addr, depth - 1) : 0; return dir + dummy; } int main (int argc, char **argv) { return find_stack_direction (0, argc + !argv + 20) < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_stack_direction=1 else ac_cv_c_stack_direction=-1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 $as_echo "$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi GNULIB_INET_NTOP=0; GNULIB_INET_PTON=0; HAVE_DECL_INET_NTOP=1; HAVE_DECL_INET_PTON=1; REPLACE_INET_NTOP=0; REPLACE_INET_PTON=0; for ac_header in $ac_header_list do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5 $as_echo_n "checking whether the preprocessor supports include_next... " >&6; } if ${gl_cv_have_include_next+:} false; then : $as_echo_n "(cached) " >&6 else rm -rf conftestd1a conftestd1b conftestd2 mkdir conftestd1a conftestd1b conftestd2 cat < conftestd1a/conftest.h #define DEFINED_IN_CONFTESTD1 #include_next #ifdef DEFINED_IN_CONFTESTD2 int foo; #else #error "include_next doesn't work" #endif EOF cat < conftestd1b/conftest.h #define DEFINED_IN_CONFTESTD1 #include #include_next #ifdef DEFINED_IN_CONFTESTD2 int foo; #else #error "include_next doesn't work" #endif EOF cat < conftestd2/conftest.h #ifndef DEFINED_IN_CONFTESTD1 #error "include_next test doesn't work" #endif #define DEFINED_IN_CONFTESTD2 EOF gl_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_have_include_next=yes else CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_have_include_next=buggy else gl_cv_have_include_next=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CPPFLAGS="$gl_save_CPPFLAGS" rm -rf conftestd1a conftestd1b conftestd2 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5 $as_echo "$gl_cv_have_include_next" >&6; } PRAGMA_SYSTEM_HEADER= if test $gl_cv_have_include_next = yes; then INCLUDE_NEXT=include_next INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next if test -n "$GCC"; then PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' fi else if test $gl_cv_have_include_next = buggy; then INCLUDE_NEXT=include INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next else INCLUDE_NEXT=include INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5 $as_echo_n "checking whether system header files limit the line length... " >&6; } if ${gl_cv_pragma_columns+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __TANDEM choke me #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "choke me" >/dev/null 2>&1; then : gl_cv_pragma_columns=yes else gl_cv_pragma_columns=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5 $as_echo "$gl_cv_pragma_columns" >&6; } if test $gl_cv_pragma_columns = yes; then PRAGMA_COLUMNS="#pragma COLUMNS 10000" else PRAGMA_COLUMNS= fi if test $ac_cv_header_features_h = yes; then HAVE_FEATURES_H=1 else HAVE_FEATURES_H=0 fi GNULIB_BTOWC=0; GNULIB_WCTOB=0; GNULIB_MBSINIT=0; GNULIB_MBRTOWC=0; GNULIB_MBRLEN=0; GNULIB_MBSRTOWCS=0; GNULIB_MBSNRTOWCS=0; GNULIB_WCRTOMB=0; GNULIB_WCSRTOMBS=0; GNULIB_WCSNRTOMBS=0; GNULIB_WCWIDTH=0; GNULIB_WMEMCHR=0; GNULIB_WMEMCMP=0; GNULIB_WMEMCPY=0; GNULIB_WMEMMOVE=0; GNULIB_WMEMSET=0; GNULIB_WCSLEN=0; GNULIB_WCSNLEN=0; GNULIB_WCSCPY=0; GNULIB_WCPCPY=0; GNULIB_WCSNCPY=0; GNULIB_WCPNCPY=0; GNULIB_WCSCAT=0; GNULIB_WCSNCAT=0; GNULIB_WCSCMP=0; GNULIB_WCSNCMP=0; GNULIB_WCSCASECMP=0; GNULIB_WCSNCASECMP=0; GNULIB_WCSCOLL=0; GNULIB_WCSXFRM=0; GNULIB_WCSDUP=0; GNULIB_WCSCHR=0; GNULIB_WCSRCHR=0; GNULIB_WCSCSPN=0; GNULIB_WCSSPN=0; GNULIB_WCSPBRK=0; GNULIB_WCSSTR=0; GNULIB_WCSTOK=0; GNULIB_WCSWIDTH=0; HAVE_BTOWC=1; HAVE_MBSINIT=1; HAVE_MBRTOWC=1; HAVE_MBRLEN=1; HAVE_MBSRTOWCS=1; HAVE_MBSNRTOWCS=1; HAVE_WCRTOMB=1; HAVE_WCSRTOMBS=1; HAVE_WCSNRTOMBS=1; HAVE_WMEMCHR=1; HAVE_WMEMCMP=1; HAVE_WMEMCPY=1; HAVE_WMEMMOVE=1; HAVE_WMEMSET=1; HAVE_WCSLEN=1; HAVE_WCSNLEN=1; HAVE_WCSCPY=1; HAVE_WCPCPY=1; HAVE_WCSNCPY=1; HAVE_WCPNCPY=1; HAVE_WCSCAT=1; HAVE_WCSNCAT=1; HAVE_WCSCMP=1; HAVE_WCSNCMP=1; HAVE_WCSCASECMP=1; HAVE_WCSNCASECMP=1; HAVE_WCSCOLL=1; HAVE_WCSXFRM=1; HAVE_WCSDUP=1; HAVE_WCSCHR=1; HAVE_WCSRCHR=1; HAVE_WCSCSPN=1; HAVE_WCSSPN=1; HAVE_WCSPBRK=1; HAVE_WCSSTR=1; HAVE_WCSTOK=1; HAVE_WCSWIDTH=1; HAVE_DECL_WCTOB=1; HAVE_DECL_WCWIDTH=1; REPLACE_MBSTATE_T=0; REPLACE_BTOWC=0; REPLACE_WCTOB=0; REPLACE_MBSINIT=0; REPLACE_MBRTOWC=0; REPLACE_MBRLEN=0; REPLACE_MBSRTOWCS=0; REPLACE_MBSNRTOWCS=0; REPLACE_WCRTOMB=0; REPLACE_WCSRTOMBS=0; REPLACE_WCSNRTOMBS=0; REPLACE_WCWIDTH=0; REPLACE_WCSWIDTH=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether uses 'inline' correctly" >&5 $as_echo_n "checking whether uses 'inline' correctly... " >&6; } if ${gl_cv_header_wchar_h_correct_inline+:} false; then : $as_echo_n "(cached) " >&6 else gl_cv_header_wchar_h_correct_inline=yes cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define wcstod renamed_wcstod /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include extern int zero (void); int main () { return zero(); } _ACEOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then mv conftest.$ac_objext conftest1.$ac_objext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define wcstod renamed_wcstod /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int zero (void) { return 0; } _ACEOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then mv conftest.$ac_objext conftest2.$ac_objext if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&5 2>&1; then : else gl_cv_header_wchar_h_correct_inline=no fi fi fi rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_wchar_h_correct_inline" >&5 $as_echo "$gl_cv_header_wchar_h_correct_inline" >&6; } if test $gl_cv_header_wchar_h_correct_inline = no; then as_fn_error $? " cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS). This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in C99 mode. You have four options: - Add the flag -fgnu89-inline to CC and reconfigure, or - Fix your include files, using parts of , or - Use a gcc version older than 4.3, or - Don't use the flags -std=c99 or -std=gnu99. Configuration aborted." "$LINENO" 5 fi for ac_func in $ac_func_list do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5 $as_echo_n "checking for nl_langinfo and CODESET... " >&6; } if ${am_cv_langinfo_codeset+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char* cs = nl_langinfo(CODESET); return !cs; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_langinfo_codeset=yes else am_cv_langinfo_codeset=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_langinfo_codeset" >&5 $as_echo "$am_cv_langinfo_codeset" >&6; } if test $am_cv_langinfo_codeset = yes; then $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5 $as_echo_n "checking for a traditional french locale... " >&6; } if ${gt_cv_locale_fr+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_LANGINFO_CODESET # include #endif #include #include struct tm t; char buf[16]; int main () { /* Check whether the given locale name is recognized by the system. */ #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ /* On native Windows, setlocale(category, "") looks at the system settings, not at the environment variables. Also, when an encoding suffix such as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE category of the locale to "C". */ if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) return 1; #else if (setlocale (LC_ALL, "") == NULL) return 1; #endif /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) is empty, and the behaviour of Tcl 8.4 in this locale is not useful. On OpenBSD 4.0, when an unsupported locale is specified, setlocale() succeeds but then nl_langinfo(CODESET) is "646". In this situation, some unit tests fail. On MirBSD 10, when an unsupported locale is specified, setlocale() succeeds but then nl_langinfo(CODESET) is "UTF-8". */ #if HAVE_LANGINFO_CODESET { const char *cs = nl_langinfo (CODESET); if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 || strcmp (cs, "UTF-8") == 0) return 1; } #endif #ifdef __CYGWIN__ /* On Cygwin, avoid locale names without encoding suffix, because the locale_charset() function relies on the encoding suffix. Note that LC_ALL is set on the command line. */ if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; #endif /* Check whether in the abbreviation of the second month, the second character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only one byte long. This excludes the UTF-8 encoding. */ t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; #if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ /* Check whether the decimal separator is a comma. On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point are nl_langinfo(RADIXCHAR) are both ".". */ if (localeconv () ->decimal_point[0] != ',') return 1; #endif return 0; } _ACEOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then case "$host_os" in # Handle native Windows specially, because there setlocale() interprets # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", # "fr" or "fra" as "French" or "French_France.1252", # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", # "ja" as "Japanese" or "Japanese_Japan.932", # and similar. mingw*) # Test for the native Windows locale name. if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=French_France.1252 else # None found. gt_cv_locale_fr=none fi ;; *) # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the # configure script would override the LC_ALL setting. Likewise for # LC_CTYPE, which is also set at the beginning of the configure script. # Test for the usual locale name. if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=fr_FR else # Test for the locale name with explicit encoding suffix. if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=fr_FR.ISO-8859-1 else # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=fr_FR.ISO8859-1 else # Test for the HP-UX locale name. if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=fr_FR.iso88591 else # Test for the Solaris 7 locale name. if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr=fr else # None found. gt_cv_locale_fr=none fi fi fi fi fi ;; esac fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5 $as_echo "$gt_cv_locale_fr" >&6; } LOCALE_FR=$gt_cv_locale_fr GNULIB_CHDIR=0; GNULIB_CHOWN=0; GNULIB_CLOSE=0; GNULIB_DUP=0; GNULIB_DUP2=0; GNULIB_DUP3=0; GNULIB_ENVIRON=0; GNULIB_EUIDACCESS=0; GNULIB_FACCESSAT=0; GNULIB_FCHDIR=0; GNULIB_FCHOWNAT=0; GNULIB_FDATASYNC=0; GNULIB_FSYNC=0; GNULIB_FTRUNCATE=0; GNULIB_GETCWD=0; GNULIB_GETDOMAINNAME=0; GNULIB_GETDTABLESIZE=0; GNULIB_GETGROUPS=0; GNULIB_GETHOSTNAME=0; GNULIB_GETLOGIN=0; GNULIB_GETLOGIN_R=0; GNULIB_GETPAGESIZE=0; GNULIB_GETUSERSHELL=0; GNULIB_GROUP_MEMBER=0; GNULIB_ISATTY=0; GNULIB_LCHOWN=0; GNULIB_LINK=0; GNULIB_LINKAT=0; GNULIB_LSEEK=0; GNULIB_PIPE=0; GNULIB_PIPE2=0; GNULIB_PREAD=0; GNULIB_PWRITE=0; GNULIB_READ=0; GNULIB_READLINK=0; GNULIB_READLINKAT=0; GNULIB_RMDIR=0; GNULIB_SETHOSTNAME=0; GNULIB_SLEEP=0; GNULIB_SYMLINK=0; GNULIB_SYMLINKAT=0; GNULIB_TTYNAME_R=0; GNULIB_UNISTD_H_NONBLOCKING=0; GNULIB_UNISTD_H_SIGPIPE=0; GNULIB_UNLINK=0; GNULIB_UNLINKAT=0; GNULIB_USLEEP=0; GNULIB_WRITE=0; HAVE_CHOWN=1; HAVE_DUP2=1; HAVE_DUP3=1; HAVE_EUIDACCESS=1; HAVE_FACCESSAT=1; HAVE_FCHDIR=1; HAVE_FCHOWNAT=1; HAVE_FDATASYNC=1; HAVE_FSYNC=1; HAVE_FTRUNCATE=1; HAVE_GETDTABLESIZE=1; HAVE_GETGROUPS=1; HAVE_GETHOSTNAME=1; HAVE_GETLOGIN=1; HAVE_GETPAGESIZE=1; HAVE_GROUP_MEMBER=1; HAVE_LCHOWN=1; HAVE_LINK=1; HAVE_LINKAT=1; HAVE_PIPE=1; HAVE_PIPE2=1; HAVE_PREAD=1; HAVE_PWRITE=1; HAVE_READLINK=1; HAVE_READLINKAT=1; HAVE_SETHOSTNAME=1; HAVE_SLEEP=1; HAVE_SYMLINK=1; HAVE_SYMLINKAT=1; HAVE_UNLINKAT=1; HAVE_USLEEP=1; HAVE_DECL_ENVIRON=1; HAVE_DECL_FCHDIR=1; HAVE_DECL_FDATASYNC=1; HAVE_DECL_GETDOMAINNAME=1; HAVE_DECL_GETLOGIN_R=1; HAVE_DECL_GETPAGESIZE=1; HAVE_DECL_GETUSERSHELL=1; HAVE_DECL_SETHOSTNAME=1; HAVE_DECL_TTYNAME_R=1; HAVE_OS_H=0; HAVE_SYS_PARAM_H=0; REPLACE_CHOWN=0; REPLACE_CLOSE=0; REPLACE_DUP=0; REPLACE_DUP2=0; REPLACE_FCHOWNAT=0; REPLACE_FTRUNCATE=0; REPLACE_GETCWD=0; REPLACE_GETDOMAINNAME=0; REPLACE_GETDTABLESIZE=0; REPLACE_GETLOGIN_R=0; REPLACE_GETGROUPS=0; REPLACE_GETPAGESIZE=0; REPLACE_ISATTY=0; REPLACE_LCHOWN=0; REPLACE_LINK=0; REPLACE_LINKAT=0; REPLACE_LSEEK=0; REPLACE_PREAD=0; REPLACE_PWRITE=0; REPLACE_READ=0; REPLACE_READLINK=0; REPLACE_READLINKAT=0; REPLACE_RMDIR=0; REPLACE_SLEEP=0; REPLACE_SYMLINK=0; REPLACE_SYMLINKAT=0; REPLACE_TTYNAME_R=0; REPLACE_UNLINK=0; REPLACE_UNLINKAT=0; REPLACE_USLEEP=0; REPLACE_WRITE=0; UNISTD_H_HAVE_WINSOCK2_H=0; UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 $as_echo_n "checking for uid_t in sys/types.h... " >&6; } if ${ac_cv_type_uid_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "uid_t" >/dev/null 2>&1; then : ac_cv_type_uid_t=yes else ac_cv_type_uid_t=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 $as_echo "$ac_cv_type_uid_t" >&6; } if test $ac_cv_type_uid_t = no; then $as_echo "#define uid_t int" >>confdefs.h $as_echo "#define gid_t int" >>confdefs.h fi for ac_header in unistd.h do : ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" if test "x$ac_cv_header_unistd_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UNISTD_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working chown" >&5 $as_echo_n "checking for working chown... " >&6; } if ${ac_cv_func_chown_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # (( # Guess yes on glibc systems. *-gnu*) ac_cv_func_chown_works=yes ;; # If we don't know, assume the worst. *) ac_cv_func_chown_works=no ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #include int main () { char *f = "conftest.chown"; struct stat before, after; if (creat (f, 0600) < 0) return 1; if (stat (f, &before) < 0) return 1; if (chown (f, (uid_t) -1, (gid_t) -1) == -1) return 1; if (stat (f, &after) < 0) return 1; return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_chown_works=yes else ac_cv_func_chown_works=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 -f conftest.chown fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_chown_works" >&5 $as_echo "$ac_cv_func_chown_works" >&6; } if test $ac_cv_func_chown_works = yes; then $as_echo "#define HAVE_CHOWN 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown dereferences symlinks" >&5 $as_echo_n "checking whether chown dereferences symlinks... " >&6; } if ${gl_cv_func_chown_follows_symlink+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_func_chown_follows_symlink=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { int result = 0; char const *dangling_symlink = "conftest.dangle"; unlink (dangling_symlink); if (symlink ("conftest.no-such", dangling_symlink)) abort (); /* Exit successfully on a conforming system, i.e., where chown must fail with ENOENT. */ if (chown (dangling_symlink, getuid (), getgid ()) == 0) result |= 1; if (errno != ENOENT) result |= 2; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_chown_follows_symlink=yes else gl_cv_func_chown_follows_symlink=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_follows_symlink" >&5 $as_echo "$gl_cv_func_chown_follows_symlink" >&6; } if test $gl_cv_func_chown_follows_symlink = no; then $as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h fi if test $ac_cv_func_chown = no; then HAVE_CHOWN=0 else if test $gl_cv_func_chown_follows_symlink = no; then REPLACE_CHOWN=1 fi if test $ac_cv_func_chown_works = no; then $as_echo "#define CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE 1" >>confdefs.h REPLACE_CHOWN=1 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown honors trailing slash" >&5 $as_echo_n "checking whether chown honors trailing slash... " >&6; } if ${gl_cv_func_chown_slash_works+:} false; then : $as_echo_n "(cached) " >&6 else touch conftest.file && rm -f conftest.link if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_chown_slash_works="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_chown_slash_works="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if (symlink ("conftest.file", "conftest.link")) return 1; if (chown ("conftest.link/", getuid (), getgid ()) == 0) return 2; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_chown_slash_works=yes else gl_cv_func_chown_slash_works=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 -f conftest.link conftest.file fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_slash_works" >&5 $as_echo "$gl_cv_func_chown_slash_works" >&6; } case "$gl_cv_func_chown_slash_works" in *yes) ;; *) $as_echo "#define CHOWN_TRAILING_SLASH_BUG 1" >>confdefs.h REPLACE_CHOWN=1 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown always updates ctime" >&5 $as_echo_n "checking whether chown always updates ctime... " >&6; } if ${gl_cv_func_chown_ctime_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_chown_ctime_works="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_chown_ctime_works="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include int main () { struct stat st1, st2; if (close (creat ("conftest.file", 0600))) return 1; if (stat ("conftest.file", &st1)) return 2; sleep (1); if (chown ("conftest.file", st1.st_uid, st1.st_gid)) return 3; if (stat ("conftest.file", &st2)) return 4; if (st2.st_ctime <= st1.st_ctime) return 5; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_chown_ctime_works=yes else gl_cv_func_chown_ctime_works=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 -f conftest.file fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_ctime_works" >&5 $as_echo "$gl_cv_func_chown_ctime_works" >&6; } case "$gl_cv_func_chown_ctime_works" in *yes) ;; *) $as_echo "#define CHOWN_CHANGE_TIME_BUG 1" >>confdefs.h REPLACE_CHOWN=1 ;; esac fi if test $ac_cv_func__set_invalid_parameter_handler = yes; then HAVE_MSVC_INVALID_PARAMETER_HANDLER=1 $as_echo "#define HAVE_MSVC_INVALID_PARAMETER_HANDLER 1" >>confdefs.h else HAVE_MSVC_INVALID_PARAMETER_HANDLER=0 fi GNULIB_OPENDIR=0; GNULIB_READDIR=0; GNULIB_REWINDDIR=0; GNULIB_CLOSEDIR=0; GNULIB_DIRFD=0; GNULIB_FDOPENDIR=0; GNULIB_SCANDIR=0; GNULIB_ALPHASORT=0; HAVE_OPENDIR=1; HAVE_READDIR=1; HAVE_REWINDDIR=1; HAVE_CLOSEDIR=1; HAVE_DECL_DIRFD=1; HAVE_DECL_FDOPENDIR=1; HAVE_FDOPENDIR=1; HAVE_SCANDIR=1; HAVE_ALPHASORT=1; REPLACE_OPENDIR=0; REPLACE_CLOSEDIR=0; REPLACE_DIRFD=0; REPLACE_FDOPENDIR=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if environ is properly declared" >&5 $as_echo_n "checking if environ is properly declared... " >&6; } if ${gt_cv_var_environ_declaration+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_UNISTD_H #include #endif /* mingw, BeOS, Haiku declare environ in , not in . */ #include extern struct { int foo; } environ; int main () { environ.foo = 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gt_cv_var_environ_declaration=no else gt_cv_var_environ_declaration=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_var_environ_declaration" >&5 $as_echo "$gt_cv_var_environ_declaration" >&6; } if test $gt_cv_var_environ_declaration = yes; then $as_echo "#define HAVE_ENVIRON_DECL 1" >>confdefs.h fi if test $gt_cv_var_environ_declaration != yes; then HAVE_DECL_ENVIRON=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for complete errno.h" >&5 $as_echo_n "checking for complete errno.h... " >&6; } if ${gl_cv_header_errno_h_complete+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if !defined ETXTBSY booboo #endif #if !defined ENOMSG booboo #endif #if !defined EIDRM booboo #endif #if !defined ENOLINK booboo #endif #if !defined EPROTO booboo #endif #if !defined EMULTIHOP booboo #endif #if !defined EBADMSG booboo #endif #if !defined EOVERFLOW booboo #endif #if !defined ENOTSUP booboo #endif #if !defined ENETRESET booboo #endif #if !defined ECONNABORTED booboo #endif #if !defined ESTALE booboo #endif #if !defined EDQUOT booboo #endif #if !defined ECANCELED booboo #endif #if !defined EOWNERDEAD booboo #endif #if !defined ENOTRECOVERABLE booboo #endif #if !defined EILSEQ booboo #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "booboo" >/dev/null 2>&1; then : gl_cv_header_errno_h_complete=no else gl_cv_header_errno_h_complete=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_complete" >&5 $as_echo "$gl_cv_header_errno_h_complete" >&6; } if test $gl_cv_header_errno_h_complete = yes; then ERRNO_H='' else if test $gl_cv_have_include_next = yes; then gl_cv_next_errno_h='<'errno.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_errno_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'errno.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_errno_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_errno_h gl_cv_next_errno_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_errno_h" >&5 $as_echo "$gl_cv_next_errno_h" >&6; } fi NEXT_ERRNO_H=$gl_cv_next_errno_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'errno.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_errno_h fi NEXT_AS_FIRST_DIRECTIVE_ERRNO_H=$gl_next_as_first_directive ERRNO_H='errno.h' fi if test -n "$ERRNO_H"; then GL_GENERATE_ERRNO_H_TRUE= GL_GENERATE_ERRNO_H_FALSE='#' else GL_GENERATE_ERRNO_H_TRUE='#' GL_GENERATE_ERRNO_H_FALSE= fi if test -n "$ERRNO_H"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EMULTIHOP value" >&5 $as_echo_n "checking for EMULTIHOP value... " >&6; } if ${gl_cv_header_errno_h_EMULTIHOP+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef EMULTIHOP yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : gl_cv_header_errno_h_EMULTIHOP=yes else gl_cv_header_errno_h_EMULTIHOP=no fi rm -f conftest* if test $gl_cv_header_errno_h_EMULTIHOP = no; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE_EXTENDED 1 #include #ifdef EMULTIHOP yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : gl_cv_header_errno_h_EMULTIHOP=hidden fi rm -f conftest* if test $gl_cv_header_errno_h_EMULTIHOP = hidden; then if ac_fn_c_compute_int "$LINENO" "EMULTIHOP" "gl_cv_header_errno_h_EMULTIHOP" " #define _XOPEN_SOURCE_EXTENDED 1 #include /* The following two lines are a workaround against an autoconf-2.52 bug. */ #include #include "; then : fi fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_EMULTIHOP" >&5 $as_echo "$gl_cv_header_errno_h_EMULTIHOP" >&6; } case $gl_cv_header_errno_h_EMULTIHOP in yes | no) EMULTIHOP_HIDDEN=0; EMULTIHOP_VALUE= ;; *) EMULTIHOP_HIDDEN=1; EMULTIHOP_VALUE="$gl_cv_header_errno_h_EMULTIHOP" ;; esac fi if test -n "$ERRNO_H"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ENOLINK value" >&5 $as_echo_n "checking for ENOLINK value... " >&6; } if ${gl_cv_header_errno_h_ENOLINK+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef ENOLINK yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : gl_cv_header_errno_h_ENOLINK=yes else gl_cv_header_errno_h_ENOLINK=no fi rm -f conftest* if test $gl_cv_header_errno_h_ENOLINK = no; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE_EXTENDED 1 #include #ifdef ENOLINK yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : gl_cv_header_errno_h_ENOLINK=hidden fi rm -f conftest* if test $gl_cv_header_errno_h_ENOLINK = hidden; then if ac_fn_c_compute_int "$LINENO" "ENOLINK" "gl_cv_header_errno_h_ENOLINK" " #define _XOPEN_SOURCE_EXTENDED 1 #include /* The following two lines are a workaround against an autoconf-2.52 bug. */ #include #include "; then : fi fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_ENOLINK" >&5 $as_echo "$gl_cv_header_errno_h_ENOLINK" >&6; } case $gl_cv_header_errno_h_ENOLINK in yes | no) ENOLINK_HIDDEN=0; ENOLINK_VALUE= ;; *) ENOLINK_HIDDEN=1; ENOLINK_VALUE="$gl_cv_header_errno_h_ENOLINK" ;; esac fi if test -n "$ERRNO_H"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EOVERFLOW value" >&5 $as_echo_n "checking for EOVERFLOW value... " >&6; } if ${gl_cv_header_errno_h_EOVERFLOW+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef EOVERFLOW yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : gl_cv_header_errno_h_EOVERFLOW=yes else gl_cv_header_errno_h_EOVERFLOW=no fi rm -f conftest* if test $gl_cv_header_errno_h_EOVERFLOW = no; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE_EXTENDED 1 #include #ifdef EOVERFLOW yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : gl_cv_header_errno_h_EOVERFLOW=hidden fi rm -f conftest* if test $gl_cv_header_errno_h_EOVERFLOW = hidden; then if ac_fn_c_compute_int "$LINENO" "EOVERFLOW" "gl_cv_header_errno_h_EOVERFLOW" " #define _XOPEN_SOURCE_EXTENDED 1 #include /* The following two lines are a workaround against an autoconf-2.52 bug. */ #include #include "; then : fi fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_EOVERFLOW" >&5 $as_echo "$gl_cv_header_errno_h_EOVERFLOW" >&6; } case $gl_cv_header_errno_h_EOVERFLOW in yes | no) EOVERFLOW_HIDDEN=0; EOVERFLOW_VALUE= ;; *) EOVERFLOW_HIDDEN=1; EOVERFLOW_VALUE="$gl_cv_header_errno_h_EOVERFLOW" ;; esac fi ac_fn_c_check_decl "$LINENO" "strerror_r" "ac_cv_have_decl_strerror_r" "$ac_includes_default" if test "x$ac_cv_have_decl_strerror_r" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRERROR_R $ac_have_decl _ACEOF for ac_func in strerror_r do : ac_fn_c_check_func "$LINENO" "strerror_r" "ac_cv_func_strerror_r" if test "x$ac_cv_func_strerror_r" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRERROR_R 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror_r returns char *" >&5 $as_echo_n "checking whether strerror_r returns char *... " >&6; } if ${ac_cv_func_strerror_r_char_p+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_func_strerror_r_char_p=no if test $ac_cv_have_decl_strerror_r = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { char buf[100]; char x = *strerror_r (0, buf, sizeof buf); char *p = strerror_r (0, buf, sizeof buf); return !p || x; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_func_strerror_r_char_p=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else # strerror_r is not declared. Choose between # systems that have relatively inaccessible declarations for the # function. BeOS and DEC UNIX 4.0 fall in this category, but the # former has a strerror_r that returns char*, while the latter # has a strerror_r that returns `int'. # This test should segfault on the DEC system. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default extern char *strerror_r (); int main () { char buf[100]; char x = *strerror_r (0, buf, sizeof buf); return ! isalpha (x); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_strerror_r_char_p=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strerror_r_char_p" >&5 $as_echo "$ac_cv_func_strerror_r_char_p" >&6; } if test $ac_cv_func_strerror_r_char_p = yes; then $as_echo "#define STRERROR_R_CHAR_P 1" >>confdefs.h fi XGETTEXT_EXTRA_OPTIONS= GNULIB_FCNTL=0; GNULIB_NONBLOCKING=0; GNULIB_OPEN=0; GNULIB_OPENAT=0; HAVE_FCNTL=1; HAVE_OPENAT=1; REPLACE_FCNTL=0; REPLACE_OPEN=0; REPLACE_OPENAT=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fcntl.h" >&5 $as_echo_n "checking for working fcntl.h... " >&6; } if ${gl_cv_header_working_fcntl_h+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_header_working_fcntl_h=cross-compiling else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_UNISTD_H # include #else /* on Windows with MSVC */ # include # include # defined sleep(n) _sleep ((n) * 1000) #endif #include #ifndef O_NOATIME #define O_NOATIME 0 #endif #ifndef O_NOFOLLOW #define O_NOFOLLOW 0 #endif static int const constants[] = { O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY }; int main () { int result = !constants; #if HAVE_SYMLINK { static char const sym[] = "conftest.sym"; if (symlink ("/dev/null", sym) != 0) result |= 2; else { int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0); if (fd >= 0) { close (fd); result |= 4; } } if (unlink (sym) != 0 || symlink (".", sym) != 0) result |= 2; else { int fd = open (sym, O_RDONLY | O_NOFOLLOW); if (fd >= 0) { close (fd); result |= 4; } } unlink (sym); } #endif { static char const file[] = "confdefs.h"; int fd = open (file, O_RDONLY | O_NOATIME); if (fd < 0) result |= 8; else { struct stat st0; if (fstat (fd, &st0) != 0) result |= 16; else { char c; sleep (1); if (read (fd, &c, 1) != 1) result |= 24; else { if (close (fd) != 0) result |= 32; else { struct stat st1; if (stat (file, &st1) != 0) result |= 40; else if (st0.st_atime != st1.st_atime) result |= 64; } } } } } return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_header_working_fcntl_h=yes else case $? in #( 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( *) gl_cv_header_working_fcntl_h='no';; esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_fcntl_h" >&5 $as_echo "$gl_cv_header_working_fcntl_h" >&6; } case $gl_cv_header_working_fcntl_h in #( *O_NOATIME* | no | cross-compiling) ac_val=0;; #( *) ac_val=1;; esac cat >>confdefs.h <<_ACEOF #define HAVE_WORKING_O_NOATIME $ac_val _ACEOF case $gl_cv_header_working_fcntl_h in #( *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( *) ac_val=1;; esac cat >>confdefs.h <<_ACEOF #define HAVE_WORKING_O_NOFOLLOW $ac_val _ACEOF ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" if test "x$ac_cv_type_mode_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define mode_t int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for st_dm_mode in struct stat" >&5 $as_echo_n "checking for st_dm_mode in struct stat... " >&6; } if ${ac_cv_struct_st_dm_mode+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct stat s; s.st_dm_mode; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_st_dm_mode=yes else ac_cv_struct_st_dm_mode=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_st_dm_mode" >&5 $as_echo "$ac_cv_struct_st_dm_mode" >&6; } if test $ac_cv_struct_st_dm_mode = yes; then $as_echo "#define HAVE_ST_DM_MODE 1" >>confdefs.h fi ac_fn_c_check_decl "$LINENO" "strmode" "ac_cv_have_decl_strmode" "$ac_includes_default" if test "x$ac_cv_have_decl_strmode" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRMODE $ac_have_decl _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mbstate_t" >&5 $as_echo_n "checking for mbstate_t... " >&6; } if ${ac_cv_type_mbstate_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { mbstate_t x; return sizeof x; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_mbstate_t=yes else ac_cv_type_mbstate_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_mbstate_t" >&5 $as_echo "$ac_cv_type_mbstate_t" >&6; } if test $ac_cv_type_mbstate_t = yes; then $as_echo "#define HAVE_MBSTATE_T 1" >>confdefs.h else $as_echo "#define mbstate_t int" >>confdefs.h fi GNULIB_ACOSF=0; GNULIB_ACOSL=0; GNULIB_ASINF=0; GNULIB_ASINL=0; GNULIB_ATANF=0; GNULIB_ATANL=0; GNULIB_ATAN2F=0; GNULIB_CBRT=0; GNULIB_CBRTF=0; GNULIB_CBRTL=0; GNULIB_CEIL=0; GNULIB_CEILF=0; GNULIB_CEILL=0; GNULIB_COPYSIGN=0; GNULIB_COPYSIGNF=0; GNULIB_COPYSIGNL=0; GNULIB_COSF=0; GNULIB_COSL=0; GNULIB_COSHF=0; GNULIB_EXPF=0; GNULIB_EXPL=0; GNULIB_EXP2=0; GNULIB_EXP2F=0; GNULIB_EXP2L=0; GNULIB_EXPM1=0; GNULIB_EXPM1F=0; GNULIB_EXPM1L=0; GNULIB_FABSF=0; GNULIB_FABSL=0; GNULIB_FLOOR=0; GNULIB_FLOORF=0; GNULIB_FLOORL=0; GNULIB_FMA=0; GNULIB_FMAF=0; GNULIB_FMAL=0; GNULIB_FMOD=0; GNULIB_FMODF=0; GNULIB_FMODL=0; GNULIB_FREXPF=0; GNULIB_FREXP=0; GNULIB_FREXPL=0; GNULIB_HYPOT=0; GNULIB_HYPOTF=0; GNULIB_HYPOTL=0; GNULIB_ILOGB=0; GNULIB_ILOGBF=0; GNULIB_ILOGBL=0; GNULIB_ISFINITE=0; GNULIB_ISINF=0; GNULIB_ISNAN=0; GNULIB_ISNANF=0; GNULIB_ISNAND=0; GNULIB_ISNANL=0; GNULIB_LDEXPF=0; GNULIB_LDEXPL=0; GNULIB_LOG=0; GNULIB_LOGF=0; GNULIB_LOGL=0; GNULIB_LOG10=0; GNULIB_LOG10F=0; GNULIB_LOG10L=0; GNULIB_LOG1P=0; GNULIB_LOG1PF=0; GNULIB_LOG1PL=0; GNULIB_LOG2=0; GNULIB_LOG2F=0; GNULIB_LOG2L=0; GNULIB_LOGB=0; GNULIB_LOGBF=0; GNULIB_LOGBL=0; GNULIB_MODF=0; GNULIB_MODFF=0; GNULIB_MODFL=0; GNULIB_POWF=0; GNULIB_REMAINDER=0; GNULIB_REMAINDERF=0; GNULIB_REMAINDERL=0; GNULIB_RINT=0; GNULIB_RINTF=0; GNULIB_RINTL=0; GNULIB_ROUND=0; GNULIB_ROUNDF=0; GNULIB_ROUNDL=0; GNULIB_SIGNBIT=0; GNULIB_SINF=0; GNULIB_SINL=0; GNULIB_SINHF=0; GNULIB_SQRTF=0; GNULIB_SQRTL=0; GNULIB_TANF=0; GNULIB_TANL=0; GNULIB_TANHF=0; GNULIB_TRUNC=0; GNULIB_TRUNCF=0; GNULIB_TRUNCL=0; HAVE_ACOSF=1; HAVE_ACOSL=1; HAVE_ASINF=1; HAVE_ASINL=1; HAVE_ATANF=1; HAVE_ATANL=1; HAVE_ATAN2F=1; HAVE_CBRT=1; HAVE_CBRTF=1; HAVE_CBRTL=1; HAVE_COPYSIGN=1; HAVE_COPYSIGNL=1; HAVE_COSF=1; HAVE_COSL=1; HAVE_COSHF=1; HAVE_EXPF=1; HAVE_EXPL=1; HAVE_EXPM1=1; HAVE_EXPM1F=1; HAVE_FABSF=1; HAVE_FABSL=1; HAVE_FMA=1; HAVE_FMAF=1; HAVE_FMAL=1; HAVE_FMODF=1; HAVE_FMODL=1; HAVE_FREXPF=1; HAVE_HYPOTF=1; HAVE_HYPOTL=1; HAVE_ILOGB=1; HAVE_ILOGBF=1; HAVE_ILOGBL=1; HAVE_ISNANF=1; HAVE_ISNAND=1; HAVE_ISNANL=1; HAVE_LDEXPF=1; HAVE_LOGF=1; HAVE_LOGL=1; HAVE_LOG10F=1; HAVE_LOG10L=1; HAVE_LOG1P=1; HAVE_LOG1PF=1; HAVE_LOG1PL=1; HAVE_LOGBF=1; HAVE_LOGBL=1; HAVE_MODFF=1; HAVE_MODFL=1; HAVE_POWF=1; HAVE_REMAINDER=1; HAVE_REMAINDERF=1; HAVE_RINT=1; HAVE_RINTL=1; HAVE_SINF=1; HAVE_SINL=1; HAVE_SINHF=1; HAVE_SQRTF=1; HAVE_SQRTL=1; HAVE_TANF=1; HAVE_TANL=1; HAVE_TANHF=1; HAVE_DECL_ACOSL=1; HAVE_DECL_ASINL=1; HAVE_DECL_ATANL=1; HAVE_DECL_CBRTF=1; HAVE_DECL_CBRTL=1; HAVE_DECL_CEILF=1; HAVE_DECL_CEILL=1; HAVE_DECL_COPYSIGNF=1; HAVE_DECL_COSL=1; HAVE_DECL_EXPL=1; HAVE_DECL_EXP2=1; HAVE_DECL_EXP2F=1; HAVE_DECL_EXP2L=1; HAVE_DECL_EXPM1L=1; HAVE_DECL_FLOORF=1; HAVE_DECL_FLOORL=1; HAVE_DECL_FREXPL=1; HAVE_DECL_LDEXPL=1; HAVE_DECL_LOGL=1; HAVE_DECL_LOG10L=1; HAVE_DECL_LOG2=1; HAVE_DECL_LOG2F=1; HAVE_DECL_LOG2L=1; HAVE_DECL_LOGB=1; HAVE_DECL_REMAINDER=1; HAVE_DECL_REMAINDERL=1; HAVE_DECL_RINTF=1; HAVE_DECL_ROUND=1; HAVE_DECL_ROUNDF=1; HAVE_DECL_ROUNDL=1; HAVE_DECL_SINL=1; HAVE_DECL_SQRTL=1; HAVE_DECL_TANL=1; HAVE_DECL_TRUNC=1; HAVE_DECL_TRUNCF=1; HAVE_DECL_TRUNCL=1; REPLACE_CBRTF=0; REPLACE_CBRTL=0; REPLACE_CEIL=0; REPLACE_CEILF=0; REPLACE_CEILL=0; REPLACE_EXPM1=0; REPLACE_EXPM1F=0; REPLACE_EXP2=0; REPLACE_EXP2L=0; REPLACE_FABSL=0; REPLACE_FLOOR=0; REPLACE_FLOORF=0; REPLACE_FLOORL=0; REPLACE_FMA=0; REPLACE_FMAF=0; REPLACE_FMAL=0; REPLACE_FMOD=0; REPLACE_FMODF=0; REPLACE_FMODL=0; REPLACE_FREXPF=0; REPLACE_FREXP=0; REPLACE_FREXPL=0; REPLACE_HUGE_VAL=0; REPLACE_HYPOT=0; REPLACE_HYPOTF=0; REPLACE_HYPOTL=0; REPLACE_ILOGB=0; REPLACE_ILOGBF=0; REPLACE_ISFINITE=0; REPLACE_ISINF=0; REPLACE_ISNAN=0; REPLACE_LDEXPL=0; REPLACE_LOG=0; REPLACE_LOGF=0; REPLACE_LOGL=0; REPLACE_LOG10=0; REPLACE_LOG10F=0; REPLACE_LOG10L=0; REPLACE_LOG1P=0; REPLACE_LOG1PF=0; REPLACE_LOG1PL=0; REPLACE_LOG2=0; REPLACE_LOG2F=0; REPLACE_LOG2L=0; REPLACE_LOGB=0; REPLACE_LOGBF=0; REPLACE_LOGBL=0; REPLACE_MODF=0; REPLACE_MODFF=0; REPLACE_MODFL=0; REPLACE_NAN=0; REPLACE_REMAINDER=0; REPLACE_REMAINDERF=0; REPLACE_REMAINDERL=0; REPLACE_ROUND=0; REPLACE_ROUNDF=0; REPLACE_ROUNDL=0; REPLACE_SIGNBIT=0; REPLACE_SIGNBIT_USING_GCC=0; REPLACE_SQRTL=0; REPLACE_TRUNC=0; REPLACE_TRUNCF=0; REPLACE_TRUNCL=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether frexp() can be used without linking with libm" >&5 $as_echo_n "checking whether frexp() can be used without linking with libm... " >&6; } if ${gl_cv_func_frexp_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include double x; int main () { int e; return frexp (x, &e) > 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_frexp_no_libm=yes else gl_cv_func_frexp_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_frexp_no_libm" >&5 $as_echo "$gl_cv_func_frexp_no_libm" >&6; } ac_fn_c_check_decl "$LINENO" "alarm" "ac_cv_have_decl_alarm" "$ac_includes_default" if test "x$ac_cv_have_decl_alarm" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ALARM $ac_have_decl _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long double and double are the same" >&5 $as_echo_n "checking whether long double and double are the same... " >&6; } if ${gl_cv_long_double_equals_double+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { typedef int check[sizeof (long double) == sizeof (double) && LDBL_MANT_DIG == DBL_MANT_DIG && LDBL_MAX_EXP == DBL_MAX_EXP && LDBL_MIN_EXP == DBL_MIN_EXP ? 1 : -1]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_long_double_equals_double=yes else gl_cv_long_double_equals_double=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_long_double_equals_double" >&5 $as_echo "$gl_cv_long_double_equals_double" >&6; } if test $gl_cv_long_double_equals_double = yes; then $as_echo "#define HAVE_SAME_LONG_DOUBLE_AS_DOUBLE 1" >>confdefs.h HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=1 else HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=0 fi GNULIB_FCHMODAT=0; GNULIB_FSTAT=0; GNULIB_FSTATAT=0; GNULIB_FUTIMENS=0; GNULIB_LCHMOD=0; GNULIB_LSTAT=0; GNULIB_MKDIRAT=0; GNULIB_MKFIFO=0; GNULIB_MKFIFOAT=0; GNULIB_MKNOD=0; GNULIB_MKNODAT=0; GNULIB_STAT=0; GNULIB_UTIMENSAT=0; HAVE_FCHMODAT=1; HAVE_FSTATAT=1; HAVE_FUTIMENS=1; HAVE_LCHMOD=1; HAVE_LSTAT=1; HAVE_MKDIRAT=1; HAVE_MKFIFO=1; HAVE_MKFIFOAT=1; HAVE_MKNOD=1; HAVE_MKNODAT=1; HAVE_UTIMENSAT=1; REPLACE_FSTAT=0; REPLACE_FSTATAT=0; REPLACE_FUTIMENS=0; REPLACE_LSTAT=0; REPLACE_MKDIR=0; REPLACE_MKFIFO=0; REPLACE_MKNOD=0; REPLACE_STAT=0; REPLACE_UTIMENSAT=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5 $as_echo_n "checking whether stat file-mode macros are broken... " >&6; } if ${ac_cv_header_stat_broken+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if defined S_ISBLK && defined S_IFDIR extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1]; #endif #if defined S_ISBLK && defined S_IFCHR extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1]; #endif #if defined S_ISLNK && defined S_IFREG extern char c3[S_ISLNK (S_IFREG) ? -1 : 1]; #endif #if defined S_ISSOCK && defined S_IFREG extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1]; #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stat_broken=no else ac_cv_header_stat_broken=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5 $as_echo "$ac_cv_header_stat_broken" >&6; } if test $ac_cv_header_stat_broken = yes; then $as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h fi case "$host_os" in mingw*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit off_t" >&5 $as_echo_n "checking for 64-bit off_t... " >&6; } if ${gl_cv_type_off_t_64+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_type_off_t_64=yes else gl_cv_type_off_t_64=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_off_t_64" >&5 $as_echo "$gl_cv_type_off_t_64" >&6; } if test $gl_cv_type_off_t_64 = no; then WINDOWS_64_BIT_OFF_T=1 else WINDOWS_64_BIT_OFF_T=0 fi WINDOWS_64_BIT_ST_SIZE=1 ;; *) WINDOWS_64_BIT_OFF_T=0 WINDOWS_64_BIT_ST_SIZE=0 ;; esac if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_stat_h='<'sys/stat.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_sys_stat_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_sys_stat_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'sys/stat.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_sys_stat_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_sys_stat_h gl_cv_next_sys_stat_h='"'$gl_header'"' else gl_cv_next_sys_stat_h='<'sys/stat.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_stat_h" >&5 $as_echo "$gl_cv_next_sys_stat_h" >&6; } fi NEXT_SYS_STAT_H=$gl_cv_next_sys_stat_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'sys/stat.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_sys_stat_h fi NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H=$gl_next_as_first_directive if test $WINDOWS_64_BIT_ST_SIZE = 1; then $as_echo "#define _GL_WINDOWS_64_BIT_ST_SIZE 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "nlink_t" "ac_cv_type_nlink_t" "#include #include " if test "x$ac_cv_type_nlink_t" = xyes; then : else $as_echo "#define nlink_t int" >>confdefs.h fi ac_fn_c_check_decl "$LINENO" "getdtablesize" "ac_cv_have_decl_getdtablesize" "$ac_includes_default" if test "x$ac_cv_have_decl_getdtablesize" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETDTABLESIZE $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "getlogin_r" "ac_cv_have_decl_getlogin_r" "$ac_includes_default" if test "x$ac_cv_have_decl_getlogin_r" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETLOGIN_R $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "getlogin" "ac_cv_have_decl_getlogin" "$ac_includes_default" if test "x$ac_cv_have_decl_getlogin" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETLOGIN $ac_have_decl _ACEOF if test $gl_cv_have_include_next = yes; then gl_cv_next_getopt_h='<'getopt.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_getopt_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_getopt_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'getopt.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_getopt_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_getopt_h gl_cv_next_getopt_h='"'$gl_header'"' else gl_cv_next_getopt_h='<'getopt.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_getopt_h" >&5 $as_echo "$gl_cv_next_getopt_h" >&6; } fi NEXT_GETOPT_H=$gl_cv_next_getopt_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'getopt.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_getopt_h fi NEXT_AS_FIRST_DIRECTIVE_GETOPT_H=$gl_next_as_first_directive if test $ac_cv_header_getopt_h = yes; then HAVE_GETOPT_H=1 else HAVE_GETOPT_H=0 fi gl_replace_getopt= if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then for ac_header in getopt.h do : ac_fn_c_check_header_mongrel "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default" if test "x$ac_cv_header_getopt_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETOPT_H 1 _ACEOF else gl_replace_getopt=yes fi done fi if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then for ac_func in getopt_long_only do : ac_fn_c_check_func "$LINENO" "getopt_long_only" "ac_cv_func_getopt_long_only" if test "x$ac_cv_func_getopt_long_only" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETOPT_LONG_ONLY 1 _ACEOF else gl_replace_getopt=yes fi done fi if test -z "$gl_replace_getopt"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getopt is POSIX compatible" >&5 $as_echo_n "checking whether getopt is POSIX compatible... " >&6; } if ${gl_cv_func_getopt_posix+:} false; then : $as_echo_n "(cached) " >&6 else if test $cross_compiling = no; then if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { static char program[] = "program"; static char a[] = "-a"; static char foo[] = "foo"; static char bar[] = "bar"; char *argv[] = { program, a, foo, bar, NULL }; int c; c = getopt (4, argv, "ab"); if (!(c == 'a')) return 1; c = getopt (4, argv, "ab"); if (!(c == -1)) return 2; if (!(optind == 2)) return 3; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_getopt_posix=maybe else gl_cv_func_getopt_posix=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $gl_cv_func_getopt_posix = maybe; then if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { static char program[] = "program"; static char donald[] = "donald"; static char p[] = "-p"; static char billy[] = "billy"; static char duck[] = "duck"; static char a[] = "-a"; static char bar[] = "bar"; char *argv[] = { program, donald, p, billy, duck, a, bar, NULL }; int c; c = getopt (7, argv, "+abp:q:"); if (!(c == -1)) return 4; if (!(strcmp (argv[0], "program") == 0)) return 5; if (!(strcmp (argv[1], "donald") == 0)) return 6; if (!(strcmp (argv[2], "-p") == 0)) return 7; if (!(strcmp (argv[3], "billy") == 0)) return 8; if (!(strcmp (argv[4], "duck") == 0)) return 9; if (!(strcmp (argv[5], "-a") == 0)) return 10; if (!(strcmp (argv[6], "bar") == 0)) return 11; if (!(optind == 1)) return 12; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_getopt_posix=maybe else gl_cv_func_getopt_posix=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi if test $gl_cv_func_getopt_posix = maybe; then if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { static char program[] = "program"; static char ab[] = "-ab"; char *argv[3] = { program, ab, NULL }; if (getopt (2, argv, "ab:") != 'a') return 13; if (getopt (2, argv, "ab:") != '?') return 14; if (optopt != 'b') return 15; if (optind != 2) return 16; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_getopt_posix=yes else gl_cv_func_getopt_posix=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi else case "$host_os" in darwin* | aix* | mingw*) gl_cv_func_getopt_posix="guessing no";; *) gl_cv_func_getopt_posix="guessing yes";; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_posix" >&5 $as_echo "$gl_cv_func_getopt_posix" >&6; } case "$gl_cv_func_getopt_posix" in *no) gl_replace_getopt=yes ;; esac fi if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working GNU getopt function" >&5 $as_echo_n "checking for working GNU getopt function... " >&6; } if ${gl_cv_func_getopt_gnu+:} false; then : $as_echo_n "(cached) " >&6 else # Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the # optstring is necessary for programs like m4 that have POSIX-mandated # semantics for supporting options interspersed with files. # Also, since getopt_long is a GNU extension, we require optind=0. # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT; # so take care to revert to the correct (non-)export state. gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }' case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #if defined __MACH__ && defined __APPLE__ /* Avoid a crash on Mac OS X. */ #include #include #include #include #include #include /* The exception port on which our thread listens. */ static mach_port_t our_exception_port; /* The main function of the thread listening for exceptions of type EXC_BAD_ACCESS. */ static void * mach_exception_thread (void *arg) { /* Buffer for a message to be received. */ struct { mach_msg_header_t head; mach_msg_body_t msgh_body; char data[1024]; } msg; mach_msg_return_t retval; /* Wait for a message on the exception port. */ retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (retval != MACH_MSG_SUCCESS) abort (); exit (1); } static void nocrash_init (void) { mach_port_t self = mach_task_self (); /* Allocate a port on which the thread shall listen for exceptions. */ if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) == KERN_SUCCESS) { /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ if (mach_port_insert_right (self, our_exception_port, our_exception_port, MACH_MSG_TYPE_MAKE_SEND) == KERN_SUCCESS) { /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting for us. */ exception_mask_t mask = EXC_MASK_BAD_ACCESS; /* Create the thread listening on the exception port. */ pthread_attr_t attr; pthread_t thread; if (pthread_attr_init (&attr) == 0 && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { pthread_attr_destroy (&attr); /* Replace the exception port info for these exceptions with our own. Note that we replace the exception port for the entire task, not only for a particular thread. This has the effect that when our exception port gets the message, the thread specific exception port has already been asked, and we don't need to bother about it. See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ task_set_exception_ports (self, mask, our_exception_port, EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); } } } } #elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Avoid a crash on native Windows. */ #define WIN32_LEAN_AND_MEAN #include #include static LONG WINAPI exception_filter (EXCEPTION_POINTERS *ExceptionInfo) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_IN_PAGE_ERROR: case EXCEPTION_STACK_OVERFLOW: case EXCEPTION_GUARD_PAGE: case EXCEPTION_PRIV_INSTRUCTION: case EXCEPTION_ILLEGAL_INSTRUCTION: case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: case EXCEPTION_NONCONTINUABLE_EXCEPTION: exit (1); } return EXCEPTION_CONTINUE_SEARCH; } static void nocrash_init (void) { SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); } #else /* Avoid a crash on POSIX systems. */ #include /* A POSIX signal handler. */ static void exception_handler (int sig) { exit (1); } static void nocrash_init (void) { #ifdef SIGSEGV signal (SIGSEGV, exception_handler); #endif #ifdef SIGBUS signal (SIGBUS, exception_handler); #endif } #endif int main () { int result = 0; nocrash_init(); /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw, and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10. */ { static char conftest[] = "conftest"; static char plus[] = "-+"; char *argv[3] = { conftest, plus, NULL }; opterr = 0; if (getopt (2, argv, "+a") != '?') result |= 1; } /* This code succeeds on glibc 2.8, mingw, and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ { static char program[] = "program"; static char p[] = "-p"; static char foo[] = "foo"; static char bar[] = "bar"; char *argv[] = { program, p, foo, bar, NULL }; optind = 1; if (getopt (4, argv, "p::") != 'p') result |= 2; else if (optarg != NULL) result |= 4; else if (getopt (4, argv, "p::") != -1) result |= 6; else if (optind != 2) result |= 8; } /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ { static char program[] = "program"; static char foo[] = "foo"; static char p[] = "-p"; char *argv[] = { program, foo, p, NULL }; optind = 0; if (getopt (3, argv, "-p") != 1) result |= 16; else if (getopt (3, argv, "-p") != 'p') result |= 16; } /* This code fails on glibc 2.11. */ { static char program[] = "program"; static char b[] = "-b"; static char a[] = "-a"; char *argv[] = { program, b, a, NULL }; optind = opterr = 0; if (getopt (3, argv, "+:a:b") != 'b') result |= 32; else if (getopt (3, argv, "+:a:b") != ':') result |= 32; } /* This code dumps core on glibc 2.14. */ { static char program[] = "program"; static char w[] = "-W"; static char dummy[] = "dummy"; char *argv[] = { program, w, dummy, NULL }; optind = opterr = 1; if (getopt (3, argv, "W;") != 'W') result |= 64; } return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_getopt_gnu=yes else gl_cv_func_getopt_gnu=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi case $gl_had_POSIXLY_CORRECT in exported) ;; yes) { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;}; POSIXLY_CORRECT=1 ;; *) { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;} ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_gnu" >&5 $as_echo "$gl_cv_func_getopt_gnu" >&6; } if test "$gl_cv_func_getopt_gnu" != yes; then gl_replace_getopt=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working GNU getopt_long function" >&5 $as_echo_n "checking for working GNU getopt_long function... " >&6; } if ${gl_cv_func_getopt_long_gnu+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in openbsd*) gl_cv_func_getopt_long_gnu="guessing no";; *) gl_cv_func_getopt_long_gnu="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { static const struct option long_options[] = { { "xtremely-",no_argument, NULL, 1003 }, { "xtra", no_argument, NULL, 1001 }, { "xtreme", no_argument, NULL, 1002 }, { "xtremely", no_argument, NULL, 1003 }, { NULL, 0, NULL, 0 } }; /* This code fails on OpenBSD 5.0. */ { static char program[] = "program"; static char xtremel[] = "--xtremel"; char *argv[] = { program, xtremel, NULL }; int option_index; optind = 1; opterr = 0; if (getopt_long (2, argv, "", long_options, &option_index) != 1003) return 1; } return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_getopt_long_gnu=yes else gl_cv_func_getopt_long_gnu=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_long_gnu" >&5 $as_echo "$gl_cv_func_getopt_long_gnu" >&6; } case "$gl_cv_func_getopt_long_gnu" in *yes) ;; *) gl_replace_getopt=yes ;; esac fi fi REPLACE_GETOPT=0 if test -n "$gl_replace_getopt"; then REPLACE_GETOPT=1 fi if test $REPLACE_GETOPT = 1; then GETOPT_H=getopt.h $as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h fi ac_fn_c_check_decl "$LINENO" "getenv" "ac_cv_have_decl_getenv" "$ac_includes_default" if test "x$ac_cv_have_decl_getenv" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETENV $ac_have_decl _ACEOF : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 $as_echo_n "checking for C/C++ restrict keyword... " >&6; } if ${ac_cv_c_restrict+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_restrict=no # The order here caters to the fact that C++ does not require restrict. for ac_kw in __restrict __restrict__ _Restrict restrict; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ typedef int *int_ptr; int foo (int_ptr $ac_kw ip) { return ip[0]; } int bar (int [$ac_kw]); /* Catch GCC bug 14050. */ int bar (int ip[$ac_kw]) { return ip[0]; } int main () { int s[1]; int *$ac_kw t = s; t[0] = 0; return foo (t) + bar (t); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_restrict=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_restrict" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 $as_echo "$ac_cv_c_restrict" >&6; } case $ac_cv_c_restrict in restrict) ;; no) $as_echo "#define restrict /**/" >>confdefs.h ;; *) cat >>confdefs.h <<_ACEOF #define restrict $ac_cv_c_restrict _ACEOF ;; esac GNULIB_GETTIMEOFDAY=0; HAVE_GETTIMEOFDAY=1; HAVE_STRUCT_TIMEVAL=1; HAVE_SYS_TIME_H=1; REPLACE_GETTIMEOFDAY=0; REPLACE_STRUCT_TIMEVAL=0; if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_time_h='<'sys/time.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_sys_time_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_sys_time_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'sys/time.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_sys_time_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_sys_time_h gl_cv_next_sys_time_h='"'$gl_header'"' else gl_cv_next_sys_time_h='<'sys/time.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_time_h" >&5 $as_echo "$gl_cv_next_sys_time_h" >&6; } fi NEXT_SYS_TIME_H=$gl_cv_next_sys_time_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'sys/time.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_sys_time_h fi NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H=$gl_next_as_first_directive if test $ac_cv_header_sys_time_h != yes; then HAVE_SYS_TIME_H=0 fi if test $ac_cv_header_sys_socket_h != yes; then for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF fi done fi if test "$ac_cv_header_winsock2_h" = yes; then HAVE_WINSOCK2_H=1 UNISTD_H_HAVE_WINSOCK2_H=1 SYS_IOCTL_H_HAVE_WINSOCK2_H=1 else HAVE_WINSOCK2_H=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timeval" >&5 $as_echo_n "checking for struct timeval... " >&6; } if ${gl_cv_sys_struct_timeval+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_TIME_H #include #endif #include #if HAVE_WINSOCK2_H # include #endif int main () { static struct timeval x; x.tv_sec = x.tv_usec; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_sys_struct_timeval=yes else gl_cv_sys_struct_timeval=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timeval" >&5 $as_echo "$gl_cv_sys_struct_timeval" >&6; } if test $gl_cv_sys_struct_timeval != yes; then HAVE_STRUCT_TIMEVAL=0 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wide-enough struct timeval.tv_sec member" >&5 $as_echo_n "checking for wide-enough struct timeval.tv_sec member... " >&6; } if ${gl_cv_sys_struct_timeval_tv_sec+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_TIME_H #include #endif #include #if HAVE_WINSOCK2_H # include #endif int main () { static struct timeval x; typedef int verify_tv_sec_type[ sizeof (time_t) <= sizeof x.tv_sec ? 1 : -1 ]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_sys_struct_timeval_tv_sec=yes else gl_cv_sys_struct_timeval_tv_sec=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timeval_tv_sec" >&5 $as_echo "$gl_cv_sys_struct_timeval_tv_sec" >&6; } if test $gl_cv_sys_struct_timeval_tv_sec != yes; then REPLACE_STRUCT_TIMEVAL=1 fi fi GNULIB_SOCKET=0; GNULIB_CONNECT=0; GNULIB_ACCEPT=0; GNULIB_BIND=0; GNULIB_GETPEERNAME=0; GNULIB_GETSOCKNAME=0; GNULIB_GETSOCKOPT=0; GNULIB_LISTEN=0; GNULIB_RECV=0; GNULIB_SEND=0; GNULIB_RECVFROM=0; GNULIB_SENDTO=0; GNULIB_SETSOCKOPT=0; GNULIB_SHUTDOWN=0; GNULIB_ACCEPT4=0; HAVE_STRUCT_SOCKADDR_STORAGE=1; HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; HAVE_SA_FAMILY_T=1; HAVE_ACCEPT4=1; if test $ac_cv_header_sys_socket_h = no; then for ac_header in ws2tcpip.h do : ac_fn_c_check_header_mongrel "$LINENO" "ws2tcpip.h" "ac_cv_header_ws2tcpip_h" "$ac_includes_default" if test "x$ac_cv_header_ws2tcpip_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WS2TCPIP_H 1 _ACEOF fi done fi case "$host_os" in osf*) $as_echo "#define _POSIX_PII_SOCKET 1" >>confdefs.h ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is self-contained" >&5 $as_echo_n "checking whether is self-contained... " >&6; } if ${gl_cv_header_sys_socket_h_selfcontained+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_sys_socket_h_selfcontained=yes else gl_cv_header_sys_socket_h_selfcontained=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_sys_socket_h_selfcontained" >&5 $as_echo "$gl_cv_header_sys_socket_h_selfcontained" >&6; } if test $gl_cv_header_sys_socket_h_selfcontained = yes; then for ac_func in shutdown do : ac_fn_c_check_func "$LINENO" "shutdown" "ac_cv_func_shutdown" if test "x$ac_cv_func_shutdown" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SHUTDOWN 1 _ACEOF fi done if test $ac_cv_func_shutdown = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether defines the SHUT_* macros" >&5 $as_echo_n "checking whether defines the SHUT_* macros... " >&6; } if ${gl_cv_header_sys_socket_h_shut+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR }; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_sys_socket_h_shut=yes else gl_cv_header_sys_socket_h_shut=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_sys_socket_h_shut" >&5 $as_echo "$gl_cv_header_sys_socket_h_shut" >&6; } if test $gl_cv_header_sys_socket_h_shut = no; then SYS_SOCKET_H='sys/socket.h' fi fi fi # We need to check for ws2tcpip.h now. if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_socket_h='<'sys/socket.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_sys_socket_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_sys_socket_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'sys/socket.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_sys_socket_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_sys_socket_h gl_cv_next_sys_socket_h='"'$gl_header'"' else gl_cv_next_sys_socket_h='<'sys/socket.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_socket_h" >&5 $as_echo "$gl_cv_next_sys_socket_h" >&6; } fi NEXT_SYS_SOCKET_H=$gl_cv_next_sys_socket_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'sys/socket.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_sys_socket_h fi NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H=$gl_next_as_first_directive if test $ac_cv_header_sys_socket_h = yes; then HAVE_SYS_SOCKET_H=1 HAVE_WS2TCPIP_H=0 else HAVE_SYS_SOCKET_H=0 if test $ac_cv_header_ws2tcpip_h = yes; then HAVE_WS2TCPIP_H=1 else HAVE_WS2TCPIP_H=0 fi fi ac_fn_c_check_type "$LINENO" "struct sockaddr_storage" "ac_cv_type_struct_sockaddr_storage" " /* sys/types.h is not needed according to POSIX, but the sys/socket.h in i386-unknown-freebsd4.10 and powerpc-apple-darwin5.5 required it. */ #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " if test "x$ac_cv_type_struct_sockaddr_storage" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_SOCKADDR_STORAGE 1 _ACEOF fi ac_fn_c_check_type "$LINENO" "sa_family_t" "ac_cv_type_sa_family_t" " /* sys/types.h is not needed according to POSIX, but the sys/socket.h in i386-unknown-freebsd4.10 and powerpc-apple-darwin5.5 required it. */ #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " if test "x$ac_cv_type_sa_family_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SA_FAMILY_T 1 _ACEOF fi if test $ac_cv_type_struct_sockaddr_storage = no; then HAVE_STRUCT_SOCKADDR_STORAGE=0 fi if test $ac_cv_type_sa_family_t = no; then HAVE_SA_FAMILY_T=0 fi if test $ac_cv_type_struct_sockaddr_storage != no; then ac_fn_c_check_member "$LINENO" "struct sockaddr_storage" "ss_family" "ac_cv_member_struct_sockaddr_storage_ss_family" "#include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " if test "x$ac_cv_member_struct_sockaddr_storage_ss_family" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 _ACEOF else HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=0 fi fi if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then SYS_SOCKET_H='sys/socket.h' fi if test $ac_cv_header_sys_socket_h != yes; then for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF fi done fi if test "$ac_cv_header_winsock2_h" = yes; then HAVE_WINSOCK2_H=1 UNISTD_H_HAVE_WINSOCK2_H=1 SYS_IOCTL_H_HAVE_WINSOCK2_H=1 else HAVE_WINSOCK2_H=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IPv4 sockets" >&5 $as_echo_n "checking for IPv4 sockets... " >&6; } if ${gl_cv_socket_ipv4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif int main () { int x = AF_INET; struct in_addr y; struct sockaddr_in z; if (&x && &y && &z) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_socket_ipv4=yes else gl_cv_socket_ipv4=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_socket_ipv4" >&5 $as_echo "$gl_cv_socket_ipv4" >&6; } if test $gl_cv_socket_ipv4 = yes; then $as_echo "#define HAVE_IPV4 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IPv6 sockets" >&5 $as_echo_n "checking for IPv6 sockets... " >&6; } if ${gl_cv_socket_ipv6+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif int main () { int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; if (&x && &y && &z) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_socket_ipv6=yes else gl_cv_socket_ipv6=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_socket_ipv6" >&5 $as_echo "$gl_cv_socket_ipv6" >&6; } if test $gl_cv_socket_ipv6 = yes; then $as_echo "#define HAVE_IPV6 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long int" >&5 $as_echo_n "checking for unsigned long long int... " >&6; } if ${ac_cv_type_unsigned_long_long_int+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_type_unsigned_long_long_int=yes if test "x${ac_cv_prog_cc_c99-no}" = xno; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* For now, do not test the preprocessor; as of 2007 there are too many implementations with broken preprocessors. Perhaps this can be revisited in 2012. In the meantime, code should not expect #if to work with literals wider than 32 bits. */ /* Test literals. */ long long int ll = 9223372036854775807ll; long long int nll = -9223372036854775807LL; unsigned long long int ull = 18446744073709551615ULL; /* Test constant expressions. */ typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) ? 1 : -1)]; typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 ? 1 : -1)]; int i = 63; int main () { /* Test availability of runtime routines for shift and division. */ long long int llmax = 9223372036854775807ll; unsigned long long int ullmax = 18446744073709551615ull; return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) | (llmax / ll) | (llmax % ll) | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) | (ullmax / ull) | (ullmax % ull)); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : else ac_cv_type_unsigned_long_long_int=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5 $as_echo "$ac_cv_type_unsigned_long_long_int" >&6; } if test $ac_cv_type_unsigned_long_long_int = yes; then $as_echo "#define HAVE_UNSIGNED_LONG_LONG_INT 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5 $as_echo_n "checking for long long int... " >&6; } if ${ac_cv_type_long_long_int+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_type_long_long_int=yes if test "x${ac_cv_prog_cc_c99-no}" = xno; then ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int if test $ac_cv_type_long_long_int = yes; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef LLONG_MAX # define HALF \ (1LL << (sizeof (long long int) * CHAR_BIT - 2)) # define LLONG_MAX (HALF - 1 + HALF) #endif int main () { long long int n = 1; int i; for (i = 0; ; i++) { long long int m = n << i; if (m >> i != n) return 1; if (LLONG_MAX / 2 < m) break; } return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_type_long_long_int=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5 $as_echo "$ac_cv_type_long_long_int" >&6; } if test $ac_cv_type_long_long_int = yes; then $as_echo "#define HAVE_LONG_LONG_INT 1" >>confdefs.h fi gl_cv_c_multiarch=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : arch= prev= for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do if test -n "$prev"; then case $word in i?86 | x86_64 | ppc | ppc64) if test -z "$arch" || test "$arch" = "$word"; then arch="$word" else gl_cv_c_multiarch=yes fi ;; esac prev= else if test "x$word" = "x-arch"; then prev=arch fi fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $gl_cv_c_multiarch = yes; then APPLE_UNIVERSAL_BUILD=1 else APPLE_UNIVERSAL_BUILD=0 fi if test $ac_cv_type_long_long_int = yes; then HAVE_LONG_LONG_INT=1 else HAVE_LONG_LONG_INT=0 fi if test $ac_cv_type_unsigned_long_long_int = yes; then HAVE_UNSIGNED_LONG_LONG_INT=1 else HAVE_UNSIGNED_LONG_LONG_INT=0 fi if test $ac_cv_header_wchar_h = yes; then HAVE_WCHAR_H=1 else HAVE_WCHAR_H=0 fi if test $ac_cv_header_inttypes_h = yes; then HAVE_INTTYPES_H=1 else HAVE_INTTYPES_H=0 fi if test $ac_cv_header_sys_types_h = yes; then HAVE_SYS_TYPES_H=1 else HAVE_SYS_TYPES_H=0 fi if test $gl_cv_have_include_next = yes; then gl_cv_next_stdint_h='<'stdint.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_stdint_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_stdint_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'stdint.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_stdint_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_stdint_h gl_cv_next_stdint_h='"'$gl_header'"' else gl_cv_next_stdint_h='<'stdint.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdint_h" >&5 $as_echo "$gl_cv_next_stdint_h" >&6; } fi NEXT_STDINT_H=$gl_cv_next_stdint_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'stdint.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_stdint_h fi NEXT_AS_FIRST_DIRECTIVE_STDINT_H=$gl_next_as_first_directive if test $ac_cv_header_stdint_h = yes; then HAVE_STDINT_H=1 else HAVE_STDINT_H=0 fi if test $ac_cv_header_stdint_h = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stdint.h conforms to C99" >&5 $as_echo_n "checking whether stdint.h conforms to C99... " >&6; } if ${gl_cv_header_working_stdint_h+:} false; then : $as_echo_n "(cached) " >&6 else gl_cv_header_working_stdint_h=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ #include /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in . */ #if !(defined WCHAR_MIN && defined WCHAR_MAX) #error "WCHAR_MIN, WCHAR_MAX not defined in " #endif /* BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #if HAVE_WCHAR_H # include # include # include #endif #ifdef INT8_MAX int8_t a1 = INT8_MAX; int8_t a1min = INT8_MIN; #endif #ifdef INT16_MAX int16_t a2 = INT16_MAX; int16_t a2min = INT16_MIN; #endif #ifdef INT32_MAX int32_t a3 = INT32_MAX; int32_t a3min = INT32_MIN; #endif #ifdef INT64_MAX int64_t a4 = INT64_MAX; int64_t a4min = INT64_MIN; #endif #ifdef UINT8_MAX uint8_t b1 = UINT8_MAX; #else typedef int b1[(unsigned char) -1 != 255 ? 1 : -1]; #endif #ifdef UINT16_MAX uint16_t b2 = UINT16_MAX; #endif #ifdef UINT32_MAX uint32_t b3 = UINT32_MAX; #endif #ifdef UINT64_MAX uint64_t b4 = UINT64_MAX; #endif int_least8_t c1 = INT8_C (0x7f); int_least8_t c1max = INT_LEAST8_MAX; int_least8_t c1min = INT_LEAST8_MIN; int_least16_t c2 = INT16_C (0x7fff); int_least16_t c2max = INT_LEAST16_MAX; int_least16_t c2min = INT_LEAST16_MIN; int_least32_t c3 = INT32_C (0x7fffffff); int_least32_t c3max = INT_LEAST32_MAX; int_least32_t c3min = INT_LEAST32_MIN; int_least64_t c4 = INT64_C (0x7fffffffffffffff); int_least64_t c4max = INT_LEAST64_MAX; int_least64_t c4min = INT_LEAST64_MIN; uint_least8_t d1 = UINT8_C (0xff); uint_least8_t d1max = UINT_LEAST8_MAX; uint_least16_t d2 = UINT16_C (0xffff); uint_least16_t d2max = UINT_LEAST16_MAX; uint_least32_t d3 = UINT32_C (0xffffffff); uint_least32_t d3max = UINT_LEAST32_MAX; uint_least64_t d4 = UINT64_C (0xffffffffffffffff); uint_least64_t d4max = UINT_LEAST64_MAX; int_fast8_t e1 = INT_FAST8_MAX; int_fast8_t e1min = INT_FAST8_MIN; int_fast16_t e2 = INT_FAST16_MAX; int_fast16_t e2min = INT_FAST16_MIN; int_fast32_t e3 = INT_FAST32_MAX; int_fast32_t e3min = INT_FAST32_MIN; int_fast64_t e4 = INT_FAST64_MAX; int_fast64_t e4min = INT_FAST64_MIN; uint_fast8_t f1 = UINT_FAST8_MAX; uint_fast16_t f2 = UINT_FAST16_MAX; uint_fast32_t f3 = UINT_FAST32_MAX; uint_fast64_t f4 = UINT_FAST64_MAX; #ifdef INTPTR_MAX intptr_t g = INTPTR_MAX; intptr_t gmin = INTPTR_MIN; #endif #ifdef UINTPTR_MAX uintptr_t h = UINTPTR_MAX; #endif intmax_t i = INTMAX_MAX; uintmax_t j = UINTMAX_MAX; #include /* for CHAR_BIT */ #define TYPE_MINIMUM(t) \ ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) #define TYPE_MAXIMUM(t) \ ((t) ((t) 0 < (t) -1 \ ? (t) -1 \ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) struct s { int check_PTRDIFF: PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) ? 1 : -1; /* Detect bug in FreeBSD 6.0 / ia64. */ int check_SIG_ATOMIC: SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) ? 1 : -1; int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1; int check_WCHAR: WCHAR_MIN == TYPE_MINIMUM (wchar_t) && WCHAR_MAX == TYPE_MAXIMUM (wchar_t) ? 1 : -1; /* Detect bug in mingw. */ int check_WINT: WINT_MIN == TYPE_MINIMUM (wint_t) && WINT_MAX == TYPE_MAXIMUM (wint_t) ? 1 : -1; /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ int check_UINT8_C: (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; int check_UINT16_C: (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; /* Detect bugs in OpenBSD 3.9 stdint.h. */ #ifdef UINT8_MAX int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1; #endif #ifdef UINT16_MAX int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1; #endif #ifdef UINT32_MAX int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1; #endif #ifdef UINT64_MAX int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1; #endif int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1; int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1; int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1; int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1; int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1; int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1; int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1; int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1; int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1; int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1; int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1; }; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if test "$cross_compiling" = yes; then : gl_cv_header_working_stdint_h=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ #include /* BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #if HAVE_WCHAR_H # include # include # include #endif #include #include #define MVAL(macro) MVAL1(macro) #define MVAL1(expression) #expression static const char *macro_values[] = { #ifdef INT8_MAX MVAL (INT8_MAX), #endif #ifdef INT16_MAX MVAL (INT16_MAX), #endif #ifdef INT32_MAX MVAL (INT32_MAX), #endif #ifdef INT64_MAX MVAL (INT64_MAX), #endif #ifdef UINT8_MAX MVAL (UINT8_MAX), #endif #ifdef UINT16_MAX MVAL (UINT16_MAX), #endif #ifdef UINT32_MAX MVAL (UINT32_MAX), #endif #ifdef UINT64_MAX MVAL (UINT64_MAX), #endif NULL }; int main () { const char **mv; for (mv = macro_values; *mv != NULL; mv++) { const char *value = *mv; /* Test whether it looks like a cast expression. */ if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0 || strncmp (value, "((unsigned short)"/*)*/, 17) == 0 || strncmp (value, "((unsigned char)"/*)*/, 16) == 0 || strncmp (value, "((int)"/*)*/, 6) == 0 || strncmp (value, "((signed short)"/*)*/, 15) == 0 || strncmp (value, "((signed char)"/*)*/, 14) == 0) return mv - macro_values + 1; } return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_header_working_stdint_h=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdint_h" >&5 $as_echo "$gl_cv_header_working_stdint_h" >&6; } fi if test "$gl_cv_header_working_stdint_h" = yes; then STDINT_H= else for ac_header in sys/inttypes.h sys/bitypes.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done if test $ac_cv_header_sys_inttypes_h = yes; then HAVE_SYS_INTTYPES_H=1 else HAVE_SYS_INTTYPES_H=0 fi if test $ac_cv_header_sys_bitypes_h = yes; then HAVE_SYS_BITYPES_H=1 else HAVE_SYS_BITYPES_H=0 fi if test $APPLE_UNIVERSAL_BUILD = 0; then for gltype in ptrdiff_t size_t ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bit size of $gltype" >&5 $as_echo_n "checking for bit size of $gltype... " >&6; } if eval \${gl_cv_bitsizeof_${gltype}+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "sizeof ($gltype) * CHAR_BIT" "result" " /* BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #if HAVE_WCHAR_H # include # include # include #endif #include "; then : else result=unknown fi eval gl_cv_bitsizeof_${gltype}=\$result fi eval ac_res=\$gl_cv_bitsizeof_${gltype} { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval result=\$gl_cv_bitsizeof_${gltype} if test $result = unknown; then result=0 fi GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` cat >>confdefs.h <<_ACEOF #define BITSIZEOF_${GLTYPE} $result _ACEOF eval BITSIZEOF_${GLTYPE}=\$result done fi for gltype in sig_atomic_t wchar_t wint_t ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bit size of $gltype" >&5 $as_echo_n "checking for bit size of $gltype... " >&6; } if eval \${gl_cv_bitsizeof_${gltype}+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "sizeof ($gltype) * CHAR_BIT" "result" " /* BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #if HAVE_WCHAR_H # include # include # include #endif #include "; then : else result=unknown fi eval gl_cv_bitsizeof_${gltype}=\$result fi eval ac_res=\$gl_cv_bitsizeof_${gltype} { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval result=\$gl_cv_bitsizeof_${gltype} if test $result = unknown; then result=0 fi GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` cat >>confdefs.h <<_ACEOF #define BITSIZEOF_${GLTYPE} $result _ACEOF eval BITSIZEOF_${GLTYPE}=\$result done for gltype in sig_atomic_t wchar_t wint_t ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gltype is signed" >&5 $as_echo_n "checking whether $gltype is signed... " >&6; } if eval \${gl_cv_type_${gltype}_signed+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #if HAVE_WCHAR_H # include # include # include #endif int verify[2 * (($gltype) -1 < ($gltype) 0) - 1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : result=yes else result=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext eval gl_cv_type_${gltype}_signed=\$result fi eval ac_res=\$gl_cv_type_${gltype}_signed { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval result=\$gl_cv_type_${gltype}_signed GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` if test "$result" = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_SIGNED_${GLTYPE} 1 _ACEOF eval HAVE_SIGNED_${GLTYPE}=1 else eval HAVE_SIGNED_${GLTYPE}=0 fi done gl_cv_type_ptrdiff_t_signed=yes gl_cv_type_size_t_signed=no if test $APPLE_UNIVERSAL_BUILD = 0; then for gltype in ptrdiff_t size_t ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $gltype integer literal suffix" >&5 $as_echo_n "checking for $gltype integer literal suffix... " >&6; } if eval \${gl_cv_type_${gltype}_suffix+:} false; then : $as_echo_n "(cached) " >&6 else eval gl_cv_type_${gltype}_suffix=no eval result=\$gl_cv_type_${gltype}_signed if test "$result" = yes; then glsufu= else glsufu=u fi for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do case $glsuf in '') gltype1='int';; l) gltype1='long int';; ll) gltype1='long long int';; i64) gltype1='__int64';; u) gltype1='unsigned int';; ul) gltype1='unsigned long int';; ull) gltype1='unsigned long long int';; ui64)gltype1='unsigned __int64';; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #if HAVE_WCHAR_H # include # include # include #endif extern $gltype foo; extern $gltype1 foo; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval gl_cv_type_${gltype}_suffix=\$glsuf fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext eval result=\$gl_cv_type_${gltype}_suffix test "$result" != no && break done fi eval ac_res=\$gl_cv_type_${gltype}_suffix { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` eval result=\$gl_cv_type_${gltype}_suffix test "$result" = no && result= eval ${GLTYPE}_SUFFIX=\$result cat >>confdefs.h <<_ACEOF #define ${GLTYPE}_SUFFIX $result _ACEOF done fi for gltype in sig_atomic_t wchar_t wint_t ; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $gltype integer literal suffix" >&5 $as_echo_n "checking for $gltype integer literal suffix... " >&6; } if eval \${gl_cv_type_${gltype}_suffix+:} false; then : $as_echo_n "(cached) " >&6 else eval gl_cv_type_${gltype}_suffix=no eval result=\$gl_cv_type_${gltype}_signed if test "$result" = yes; then glsufu= else glsufu=u fi for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do case $glsuf in '') gltype1='int';; l) gltype1='long int';; ll) gltype1='long long int';; i64) gltype1='__int64';; u) gltype1='unsigned int';; ul) gltype1='unsigned long int';; ull) gltype1='unsigned long long int';; ui64)gltype1='unsigned __int64';; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #if HAVE_WCHAR_H # include # include # include #endif extern $gltype foo; extern $gltype1 foo; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval gl_cv_type_${gltype}_suffix=\$glsuf fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext eval result=\$gl_cv_type_${gltype}_suffix test "$result" != no && break done fi eval ac_res=\$gl_cv_type_${gltype}_suffix { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` eval result=\$gl_cv_type_${gltype}_suffix test "$result" = no && result= eval ${GLTYPE}_SUFFIX=\$result cat >>confdefs.h <<_ACEOF #define ${GLTYPE}_SUFFIX $result _ACEOF done if test $BITSIZEOF_WINT_T -lt 32; then BITSIZEOF_WINT_T=32 fi STDINT_H=stdint.h fi if test -n "$STDINT_H"; then GL_GENERATE_STDINT_H_TRUE= GL_GENERATE_STDINT_H_FALSE='#' else GL_GENERATE_STDINT_H_TRUE='#' GL_GENERATE_STDINT_H_FALSE= fi GNULIB_IMAXABS=0; GNULIB_IMAXDIV=0; GNULIB_STRTOIMAX=0; GNULIB_STRTOUMAX=0; HAVE_DECL_IMAXABS=1; HAVE_DECL_IMAXDIV=1; HAVE_DECL_STRTOIMAX=1; HAVE_DECL_STRTOUMAX=1; REPLACE_STRTOIMAX=0; REPLACE_STRTOUMAX=0; INT32_MAX_LT_INTMAX_MAX=1; INT64_MAX_EQ_LONG_MAX='defined _LP64'; PRI_MACROS_BROKEN=0; PRIPTR_PREFIX=__PRIPTR_PREFIX; UINT32_MAX_LT_UINTMAX_MAX=1; UINT64_MAX_EQ_ULONG_MAX='defined _LP64'; if test $gl_cv_have_include_next = yes; then gl_cv_next_inttypes_h='<'inttypes.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_inttypes_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_inttypes_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'inttypes.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_inttypes_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_inttypes_h gl_cv_next_inttypes_h='"'$gl_header'"' else gl_cv_next_inttypes_h='<'inttypes.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_inttypes_h" >&5 $as_echo "$gl_cv_next_inttypes_h" >&6; } fi NEXT_INTTYPES_H=$gl_cv_next_inttypes_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'inttypes.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_inttypes_h fi NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H=$gl_next_as_first_directive { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the exponent in a 'double'" >&5 $as_echo_n "checking where to find the exponent in a 'double'... " >&6; } if ${gl_cv_cc_double_expbit0+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined arm || defined __arm || defined __arm__ mixed_endianness #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "mixed_endianness" >/dev/null 2>&1; then : gl_cv_cc_double_expbit0="unknown" else : if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi : case $ac_cv_c_bigendian in #( yes) gl_cv_cc_double_expbit0="word 0 bit 20";; #( no) gl_cv_cc_double_expbit0="word 1 bit 20" ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) gl_cv_cc_double_expbit0="unknown" ;; esac fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #define NWORDS \ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { double value; unsigned int word[NWORDS]; } memory_double; static unsigned int ored_words[NWORDS]; static unsigned int anded_words[NWORDS]; static void add_to_ored_words (double x) { memory_double m; size_t i; /* Clear it first, in case sizeof (double) < sizeof (memory_double). */ memset (&m, 0, sizeof (memory_double)); m.value = x; for (i = 0; i < NWORDS; i++) { ored_words[i] |= m.word[i]; anded_words[i] &= m.word[i]; } } int main () { size_t j; FILE *fp = fopen ("conftest.out", "w"); if (fp == NULL) return 1; for (j = 0; j < NWORDS; j++) anded_words[j] = ~ (unsigned int) 0; add_to_ored_words (0.25); add_to_ored_words (0.5); add_to_ored_words (1.0); add_to_ored_words (2.0); add_to_ored_words (4.0); /* Remove bits that are common (e.g. if representation of the first mantissa bit is explicit). */ for (j = 0; j < NWORDS; j++) ored_words[j] &= ~anded_words[j]; /* Now find the nonzero word. */ for (j = 0; j < NWORDS; j++) if (ored_words[j] != 0) break; if (j < NWORDS) { size_t i; for (i = j + 1; i < NWORDS; i++) if (ored_words[i] != 0) { fprintf (fp, "unknown"); return (fclose (fp) != 0); } for (i = 0; ; i++) if ((ored_words[j] >> i) & 1) { fprintf (fp, "word %d bit %d", (int) j, (int) i); return (fclose (fp) != 0); } } fprintf (fp, "unknown"); return (fclose (fp) != 0); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_cc_double_expbit0=`cat conftest.out` else gl_cv_cc_double_expbit0="unknown" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_double_expbit0" >&5 $as_echo "$gl_cv_cc_double_expbit0" >&6; } case "$gl_cv_cc_double_expbit0" in word*bit*) word=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` bit=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word.*bit //'` cat >>confdefs.h <<_ACEOF #define DBL_EXPBIT0_WORD $word _ACEOF cat >>confdefs.h <<_ACEOF #define DBL_EXPBIT0_BIT $bit _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the exponent in a 'float'" >&5 $as_echo_n "checking where to find the exponent in a 'float'... " >&6; } if ${gl_cv_cc_float_expbit0+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_cc_float_expbit0="word 0 bit 23" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #define NWORDS \ ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { float value; unsigned int word[NWORDS]; } memory_float; static unsigned int ored_words[NWORDS]; static unsigned int anded_words[NWORDS]; static void add_to_ored_words (float x) { memory_float m; size_t i; /* Clear it first, in case sizeof (float) < sizeof (memory_float). */ memset (&m, 0, sizeof (memory_float)); m.value = x; for (i = 0; i < NWORDS; i++) { ored_words[i] |= m.word[i]; anded_words[i] &= m.word[i]; } } int main () { size_t j; FILE *fp = fopen ("conftest.out", "w"); if (fp == NULL) return 1; for (j = 0; j < NWORDS; j++) anded_words[j] = ~ (unsigned int) 0; add_to_ored_words (0.25f); add_to_ored_words (0.5f); add_to_ored_words (1.0f); add_to_ored_words (2.0f); add_to_ored_words (4.0f); /* Remove bits that are common (e.g. if representation of the first mantissa bit is explicit). */ for (j = 0; j < NWORDS; j++) ored_words[j] &= ~anded_words[j]; /* Now find the nonzero word. */ for (j = 0; j < NWORDS; j++) if (ored_words[j] != 0) break; if (j < NWORDS) { size_t i; for (i = j + 1; i < NWORDS; i++) if (ored_words[i] != 0) { fprintf (fp, "unknown"); return (fclose (fp) != 0); } for (i = 0; ; i++) if ((ored_words[j] >> i) & 1) { fprintf (fp, "word %d bit %d", (int) j, (int) i); return (fclose (fp) != 0); } } fprintf (fp, "unknown"); return (fclose (fp) != 0); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_cc_float_expbit0=`cat conftest.out` else gl_cv_cc_float_expbit0="unknown" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_float_expbit0" >&5 $as_echo "$gl_cv_cc_float_expbit0" >&6; } case "$gl_cv_cc_float_expbit0" in word*bit*) word=`echo "$gl_cv_cc_float_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` bit=`echo "$gl_cv_cc_float_expbit0" | sed -e 's/word.*bit //'` cat >>confdefs.h <<_ACEOF #define FLT_EXPBIT0_WORD $word _ACEOF cat >>confdefs.h <<_ACEOF #define FLT_EXPBIT0_BIT $bit _ACEOF ;; esac GNULIB_NL_LANGINFO=0; HAVE_NL_LANGINFO=1; REPLACE_NL_LANGINFO=0; ac_fn_c_check_decl "$LINENO" "getc_unlocked" "ac_cv_have_decl_getc_unlocked" "$ac_includes_default" if test "x$ac_cv_have_decl_getc_unlocked" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETC_UNLOCKED $ac_have_decl _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C Library >= 2.1 or uClibc" >&5 $as_echo_n "checking whether we are using the GNU C Library >= 2.1 or uClibc... " >&6; } if ${ac_cv_gnu_library_2_1+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __GNU_LIBRARY__ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) Lucky GNU user #endif #endif #ifdef __UCLIBC__ Lucky user #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Lucky" >/dev/null 2>&1; then : ac_cv_gnu_library_2_1=yes else ac_cv_gnu_library_2_1=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gnu_library_2_1" >&5 $as_echo "$ac_cv_gnu_library_2_1" >&6; } GLIBC21="$ac_cv_gnu_library_2_1" GNULIB_LOCALECONV=0; GNULIB_SETLOCALE=0; GNULIB_DUPLOCALE=0; HAVE_DUPLOCALE=1; REPLACE_LOCALECONV=0; REPLACE_SETLOCALE=0; REPLACE_DUPLOCALE=0; REPLACE_STRUCT_LCONV=0; REPLACE_NULL=0; HAVE_MAX_ALIGN_T=1; HAVE_WCHAR_T=1; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t" >&5 $as_echo_n "checking for wchar_t... " >&6; } if ${gt_cv_c_wchar_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include wchar_t foo = (wchar_t)'\0'; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gt_cv_c_wchar_t=yes else gt_cv_c_wchar_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wchar_t" >&5 $as_echo "$gt_cv_c_wchar_t" >&6; } if test $gt_cv_c_wchar_t = yes; then $as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h fi STDDEF_H= ac_fn_c_check_type "$LINENO" "max_align_t" "ac_cv_type_max_align_t" "#include " if test "x$ac_cv_type_max_align_t" = xyes; then : else HAVE_MAX_ALIGN_T=0; STDDEF_H=stddef.h fi if test $gt_cv_c_wchar_t = no; then HAVE_WCHAR_T=0 STDDEF_H=stddef.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NULL can be used in arbitrary expressions" >&5 $as_echo_n "checking whether NULL can be used in arbitrary expressions... " >&6; } if ${gl_cv_decl_null_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int test[2 * (sizeof NULL == sizeof (void *)) -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_decl_null_works=yes else gl_cv_decl_null_works=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_null_works" >&5 $as_echo "$gl_cv_decl_null_works" >&6; } if test $gl_cv_decl_null_works = no; then REPLACE_NULL=1 STDDEF_H=stddef.h fi if test -n "$STDDEF_H"; then GL_GENERATE_STDDEF_H_TRUE= GL_GENERATE_STDDEF_H_FALSE='#' else GL_GENERATE_STDDEF_H_TRUE='#' GL_GENERATE_STDDEF_H_FALSE= fi if test -n "$STDDEF_H"; then if test $gl_cv_have_include_next = yes; then gl_cv_next_stddef_h='<'stddef.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_stddef_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'stddef.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_stddef_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_stddef_h gl_cv_next_stddef_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5 $as_echo "$gl_cv_next_stddef_h" >&6; } fi NEXT_STDDEF_H=$gl_cv_next_stddef_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'stddef.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_stddef_h fi NEXT_AS_FIRST_DIRECTIVE_STDDEF_H=$gl_next_as_first_directive fi gl_threads_api=none LIBTHREAD= LTLIBTHREAD= LIBMULTITHREAD= LTLIBMULTITHREAD= if test "$gl_use_threads" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether imported symbols can be declared weak" >&5 $as_echo_n "checking whether imported symbols can be declared weak... " >&6; } if ${gl_cv_have_weak+:} false; then : $as_echo_n "(cached) " >&6 else gl_cv_have_weak=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ extern void xyzzy (); #pragma weak xyzzy int main () { xyzzy(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_have_weak=maybe fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test $gl_cv_have_weak = maybe; then if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __ELF__ Extensible Linking Format #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Extensible Linking Format" >/dev/null 2>&1; then : gl_cv_have_weak="guessing yes" else gl_cv_have_weak="guessing no" fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #pragma weak fputs int main () { return (fputs == NULL); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_have_weak=yes else gl_cv_have_weak=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_weak" >&5 $as_echo "$gl_cv_have_weak" >&6; } if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : gl_have_pthread_h=yes else gl_have_pthread_h=no fi if test "$gl_have_pthread_h" = yes; then # Other possible tests: # -lpthreads (FSU threads, PCthreads) # -lgthreads gl_have_pthread= # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist # in libc. IRIX 6.5 has the first one in both libc and libpthread, but # the second one only in libpthread, and lock.c needs it. # # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 # needs -pthread for some reason. See: # http://lists.gnu.org/archive/html/bug-gnulib/2014-09/msg00023.html save_LIBS=$LIBS for gl_pthread in '' '-pthread'; do LIBS="$LIBS $gl_pthread" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include pthread_mutex_t m; pthread_mutexattr_t ma; int main () { pthread_mutex_lock (&m); pthread_mutexattr_init (&ma); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_have_pthread=yes LIBTHREAD=$gl_pthread LTLIBTHREAD=$gl_pthread LIBMULTITHREAD=$gl_pthread LTLIBMULTITHREAD=$gl_pthread fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$save_LIBS test -n "$gl_have_pthread" && break done # Test for libpthread by looking for pthread_kill. (Not pthread_self, # since it is defined as a macro on OSF/1.) if test -n "$gl_have_pthread" && test -z "$LIBTHREAD"; then # The program links fine without libpthread. But it may actually # need to link with libpthread in order to create multiple threads. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 $as_echo_n "checking for pthread_kill in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_kill+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_kill (); int main () { return pthread_kill (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_kill=yes else ac_cv_lib_pthread_pthread_kill=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 $as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; } if test "x$ac_cv_lib_pthread_pthread_kill" = xyes; then : LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread # On Solaris and HP-UX, most pthread functions exist also in libc. # Therefore pthread_in_use() needs to actually try to create a # thread: pthread_create from libc will fail, whereas # pthread_create will actually create a thread. case "$host_os" in solaris* | hpux*) $as_echo "#define PTHREAD_IN_USE_DETECTION_HARD 1" >>confdefs.h esac fi elif test -z "$gl_have_pthread"; then # Some library is needed. Try libpthread and libc_r. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 $as_echo_n "checking for pthread_kill in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_kill+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_kill (); int main () { return pthread_kill (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_kill=yes else ac_cv_lib_pthread_pthread_kill=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 $as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; } if test "x$ac_cv_lib_pthread_pthread_kill" = xyes; then : gl_have_pthread=yes LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread fi if test -z "$gl_have_pthread"; then # For FreeBSD 4. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lc_r" >&5 $as_echo_n "checking for pthread_kill in -lc_r... " >&6; } if ${ac_cv_lib_c_r_pthread_kill+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lc_r $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_kill (); int main () { return pthread_kill (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_c_r_pthread_kill=yes else ac_cv_lib_c_r_pthread_kill=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_kill" >&5 $as_echo "$ac_cv_lib_c_r_pthread_kill" >&6; } if test "x$ac_cv_lib_c_r_pthread_kill" = xyes; then : gl_have_pthread=yes LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r fi fi fi if test -n "$gl_have_pthread"; then gl_threads_api=posix $as_echo "#define USE_POSIX_THREADS 1" >>confdefs.h if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then $as_echo "#define USE_POSIX_THREADS_WEAK 1" >>confdefs.h LIBTHREAD= LTLIBTHREAD= fi fi fi fi fi if test -z "$gl_have_pthread"; then if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then gl_have_solaristhread= gl_save_LIBS="$LIBS" LIBS="$LIBS -lthread" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { thr_self(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_have_solaristhread=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$gl_save_LIBS" if test -n "$gl_have_solaristhread"; then gl_threads_api=solaris LIBTHREAD=-lthread LTLIBTHREAD=-lthread LIBMULTITHREAD="$LIBTHREAD" LTLIBMULTITHREAD="$LTLIBTHREAD" $as_echo "#define USE_SOLARIS_THREADS 1" >>confdefs.h if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then $as_echo "#define USE_SOLARIS_THREADS_WEAK 1" >>confdefs.h LIBTHREAD= LTLIBTHREAD= fi fi fi fi if test "$gl_use_threads" = pth; then gl_save_CPPFLAGS="$CPPFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libpth" >&5 $as_echo_n "checking how to link with libpth... " >&6; } if ${ac_cv_libpth_libs+:} false; then : $as_echo_n "(cached) " >&6 else use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libpth-prefix was given. if test "${with_libpth_prefix+set}" = set; then : withval=$with_libpth_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBPTH= LTLIBPTH= INCPTH= LIBPTH_PREFIX= HAVE_LIBPTH= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='pth ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBPTH="${LIBPTH}${LIBPTH:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBPTH; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBPTH; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBPTH="${LIBPTH}${LIBPTH:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" else LIBPTH="${LIBPTH}${LIBPTH:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBPTH="${LIBPTH}${LIBPTH:+ }$found_a" else LIBPTH="${LIBPTH}${LIBPTH:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'pth'; then LIBPTH_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'pth'; then LIBPTH_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCPTH; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCPTH="${INCPTH}${INCPTH:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBPTH; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBPTH="${LIBPTH}${LIBPTH:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBPTH; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBPTH="${LIBPTH}${LIBPTH:+ }$dep" LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }$dep" ;; esac done fi else LIBPTH="${LIBPTH}${LIBPTH:+ }-l$name" LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBPTH="${LIBPTH}${LIBPTH:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBPTH="${LIBPTH}${LIBPTH:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-R$found_dir" done fi ac_cv_libpth_libs="$LIBPTH" ac_cv_libpth_ltlibs="$LTLIBPTH" ac_cv_libpth_cppflags="$INCPTH" ac_cv_libpth_prefix="$LIBPTH_PREFIX" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libpth_libs" >&5 $as_echo "$ac_cv_libpth_libs" >&6; } LIBPTH="$ac_cv_libpth_libs" LTLIBPTH="$ac_cv_libpth_ltlibs" INCPTH="$ac_cv_libpth_cppflags" LIBPTH_PREFIX="$ac_cv_libpth_prefix" for element in $INCPTH; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done HAVE_LIBPTH=yes gl_have_pth= gl_save_LIBS="$LIBS" LIBS="$LIBS $LIBPTH" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { pth_self(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_have_pth=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$gl_save_LIBS" if test -n "$gl_have_pth"; then gl_threads_api=pth LIBTHREAD="$LIBPTH" LTLIBTHREAD="$LTLIBPTH" LIBMULTITHREAD="$LIBTHREAD" LTLIBMULTITHREAD="$LTLIBTHREAD" $as_echo "#define USE_PTH_THREADS 1" >>confdefs.h if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then $as_echo "#define USE_PTH_THREADS_WEAK 1" >>confdefs.h LIBTHREAD= LTLIBTHREAD= fi fi else CPPFLAGS="$gl_save_CPPFLAGS" fi fi if test -z "$gl_have_pthread"; then case "$gl_use_threads" in yes | windows | win32) # The 'win32' is for backward compatibility. if { case "$host_os" in mingw*) true;; *) false;; esac }; then gl_threads_api=windows $as_echo "#define USE_WINDOWS_THREADS 1" >>confdefs.h fi ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for multithread API to use" >&5 $as_echo_n "checking for multithread API to use... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_threads_api" >&5 $as_echo "$gl_threads_api" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 $as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } if ${gl_cv_func_lstat_dereferences_slashed_symlink+:} false; then : $as_echo_n "(cached) " >&6 else rm -f conftest.sym conftest.file echo >conftest.file if test "$cross_compiling" = yes; then : case "$host_os" in *-gnu*) # Guess yes on glibc systems. gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;; *) # If we don't know, assume the worst. gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { struct stat sbuf; if (symlink ("conftest.file", "conftest.sym") != 0) return 1; /* Linux will dereference the symlink and fail, as required by POSIX. That is better in the sense that it means we will not have to compile and use the lstat wrapper. */ return lstat ("conftest.sym/", &sbuf) == 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_lstat_dereferences_slashed_symlink=yes else gl_cv_func_lstat_dereferences_slashed_symlink=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 -f conftest.sym conftest.file fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_lstat_dereferences_slashed_symlink" >&5 $as_echo "$gl_cv_func_lstat_dereferences_slashed_symlink" >&6; } case "$gl_cv_func_lstat_dereferences_slashed_symlink" in *yes) cat >>confdefs.h <<_ACEOF #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 _ACEOF ;; esac GNULIB__EXIT=0; GNULIB_ATOLL=0; GNULIB_CALLOC_POSIX=0; GNULIB_CANONICALIZE_FILE_NAME=0; GNULIB_GETLOADAVG=0; GNULIB_GETSUBOPT=0; GNULIB_GRANTPT=0; GNULIB_MALLOC_POSIX=0; GNULIB_MBTOWC=0; GNULIB_MKDTEMP=0; GNULIB_MKOSTEMP=0; GNULIB_MKOSTEMPS=0; GNULIB_MKSTEMP=0; GNULIB_MKSTEMPS=0; GNULIB_POSIX_OPENPT=0; GNULIB_PTSNAME=0; GNULIB_PTSNAME_R=0; GNULIB_PUTENV=0; GNULIB_QSORT_R=0; GNULIB_RANDOM=0; GNULIB_RANDOM_R=0; GNULIB_REALLOC_POSIX=0; GNULIB_REALPATH=0; GNULIB_RPMATCH=0; GNULIB_SECURE_GETENV=0; GNULIB_SETENV=0; GNULIB_STRTOD=0; GNULIB_STRTOLL=0; GNULIB_STRTOULL=0; GNULIB_SYSTEM_POSIX=0; GNULIB_UNLOCKPT=0; GNULIB_UNSETENV=0; GNULIB_WCTOMB=0; HAVE__EXIT=1; HAVE_ATOLL=1; HAVE_CANONICALIZE_FILE_NAME=1; HAVE_DECL_GETLOADAVG=1; HAVE_GETSUBOPT=1; HAVE_GRANTPT=1; HAVE_MKDTEMP=1; HAVE_MKOSTEMP=1; HAVE_MKOSTEMPS=1; HAVE_MKSTEMP=1; HAVE_MKSTEMPS=1; HAVE_POSIX_OPENPT=1; HAVE_PTSNAME=1; HAVE_PTSNAME_R=1; HAVE_RANDOM=1; HAVE_RANDOM_H=1; HAVE_RANDOM_R=1; HAVE_REALPATH=1; HAVE_RPMATCH=1; HAVE_SECURE_GETENV=1; HAVE_SETENV=1; HAVE_DECL_SETENV=1; HAVE_STRTOD=1; HAVE_STRTOLL=1; HAVE_STRTOULL=1; HAVE_STRUCT_RANDOM_DATA=1; HAVE_SYS_LOADAVG_H=0; HAVE_UNLOCKPT=1; HAVE_DECL_UNSETENV=1; REPLACE_CALLOC=0; REPLACE_CANONICALIZE_FILE_NAME=0; REPLACE_MALLOC=0; REPLACE_MBTOWC=0; REPLACE_MKSTEMP=0; REPLACE_PTSNAME=0; REPLACE_PTSNAME_R=0; REPLACE_PUTENV=0; REPLACE_QSORT_R=0; REPLACE_RANDOM_R=0; REPLACE_REALLOC=0; REPLACE_REALPATH=0; REPLACE_SETENV=0; REPLACE_STRTOD=0; REPLACE_UNSETENV=0; REPLACE_WCTOMB=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether malloc, realloc, calloc are POSIX compliant" >&5 $as_echo_n "checking whether malloc, realloc, calloc are POSIX compliant... " >&6; } if ${gl_cv_func_malloc_posix+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_func_malloc_posix=yes else gl_cv_func_malloc_posix=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_malloc_posix" >&5 $as_echo "$gl_cv_func_malloc_posix" >&6; } for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on platforms where we know the result. *-gnu* | freebsd* | netbsd* | openbsd* \ | hpux* | solaris* | cygwin* | mingw*) ac_cv_func_malloc_0_nonnull=yes ;; # If we don't know, assume the worst. *) ac_cv_func_malloc_0_nonnull=no ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then : gl_cv_func_malloc_0_nonnull=1 else gl_cv_func_malloc_0_nonnull=0 fi cat >>confdefs.h <<_ACEOF #define MALLOC_0_IS_NONNULL $gl_cv_func_malloc_0_nonnull _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional japanese locale" >&5 $as_echo_n "checking for a traditional japanese locale... " >&6; } if ${gt_cv_locale_ja+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_LANGINFO_CODESET # include #endif #include #include struct tm t; char buf[16]; int main () { const char *p; /* Check whether the given locale name is recognized by the system. */ #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ /* On native Windows, setlocale(category, "") looks at the system settings, not at the environment variables. Also, when an encoding suffix such as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE category of the locale to "C". */ if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) return 1; #else if (setlocale (LC_ALL, "") == NULL) return 1; #endif /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) is empty, and the behaviour of Tcl 8.4 in this locale is not useful. On OpenBSD 4.0, when an unsupported locale is specified, setlocale() succeeds but then nl_langinfo(CODESET) is "646". In this situation, some unit tests fail. On MirBSD 10, when an unsupported locale is specified, setlocale() succeeds but then nl_langinfo(CODESET) is "UTF-8". */ #if HAVE_LANGINFO_CODESET { const char *cs = nl_langinfo (CODESET); if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 || strcmp (cs, "UTF-8") == 0) return 1; } #endif #ifdef __CYGWIN__ /* On Cygwin, avoid locale names without encoding suffix, because the locale_charset() function relies on the encoding suffix. Note that LC_ALL is set on the command line. */ if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; #endif /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales on Cygwin 1.5.x. */ if (MB_CUR_MAX == 1) return 1; /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. This excludes the UTF-8 encoding (except on MirBSD). */ t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; for (p = buf; *p != '\0'; p++) if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) return 1; return 0; } _ACEOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then case "$host_os" in # Handle native Windows specially, because there setlocale() interprets # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", # "fr" or "fra" as "French" or "French_France.1252", # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", # "ja" as "Japanese" or "Japanese_Japan.932", # and similar. mingw*) # Note that on native Windows, the Japanese locale is # Japanese_Japan.932, and CP932 is very different from EUC-JP, so we # cannot use it here. gt_cv_locale_ja=none ;; *) # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the # configure script would override the LC_ALL setting. Likewise for # LC_CTYPE, which is also set at the beginning of the configure script. # Test for the AIX locale name. if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_ja=ja_JP else # Test for the locale name with explicit encoding suffix. if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_ja=ja_JP.EUC-JP else # Test for the HP-UX, OSF/1, NetBSD locale name. if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_ja=ja_JP.eucJP else # Test for the IRIX, FreeBSD locale name. if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_ja=ja_JP.EUC else # Test for the Solaris 7 locale name. if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_ja=ja else # Special test for NetBSD 1.6. if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then gt_cv_locale_ja=ja_JP.eucJP else # None found. gt_cv_locale_ja=none fi fi fi fi fi fi ;; esac fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_ja" >&5 $as_echo "$gt_cv_locale_ja" >&6; } LOCALE_JA=$gt_cv_locale_ja { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a transitional chinese locale" >&5 $as_echo_n "checking for a transitional chinese locale... " >&6; } if ${gt_cv_locale_zh_CN+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #if HAVE_LANGINFO_CODESET # include #endif #include #include struct tm t; char buf[16]; int main () { const char *p; /* Check whether the given locale name is recognized by the system. */ #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ /* On native Windows, setlocale(category, "") looks at the system settings, not at the environment variables. Also, when an encoding suffix such as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE category of the locale to "C". */ if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) return 1; #else if (setlocale (LC_ALL, "") == NULL) return 1; #endif /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) is empty, and the behaviour of Tcl 8.4 in this locale is not useful. On OpenBSD 4.0, when an unsupported locale is specified, setlocale() succeeds but then nl_langinfo(CODESET) is "646". In this situation, some unit tests fail. On MirBSD 10, when an unsupported locale is specified, setlocale() succeeds but then nl_langinfo(CODESET) is "UTF-8". */ #if HAVE_LANGINFO_CODESET { const char *cs = nl_langinfo (CODESET); if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 || strcmp (cs, "UTF-8") == 0) return 1; } #endif #ifdef __CYGWIN__ /* On Cygwin, avoid locale names without encoding suffix, because the locale_charset() function relies on the encoding suffix. Note that LC_ALL is set on the command line. */ if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; #endif /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. This excludes the UTF-8 encoding (except on MirBSD). */ t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; for (p = buf; *p != '\0'; p++) if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) return 1; /* Check whether a typical GB18030 multibyte sequence is recognized as a single wide character. This excludes the GB2312 and GBK encodings. */ if (mblen ("\203\062\332\066", 5) != 4) return 1; return 0; } _ACEOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then case "$host_os" in # Handle native Windows specially, because there setlocale() interprets # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", # "fr" or "fra" as "French" or "French_France.1252", # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", # "ja" as "Japanese" or "Japanese_Japan.932", # and similar. mingw*) # Test for the hypothetical native Windows locale name. if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_zh_CN=Chinese_China.54936 else # None found. gt_cv_locale_zh_CN=none fi ;; solaris2.8) # On Solaris 8, the locales zh_CN.GB18030, zh_CN.GBK, zh.GBK are # broken. One witness is the test case in gl_MBRTOWC_SANITYCHECK. # Another witness is that "LC_ALL=zh_CN.GB18030 bash -c true" dumps core. gt_cv_locale_zh_CN=none ;; *) # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the # configure script would override the LC_ALL setting. Likewise for # LC_CTYPE, which is also set at the beginning of the configure script. # Test for the locale name without encoding suffix. if (LC_ALL=zh_CN LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_zh_CN=zh_CN else # Test for the locale name with explicit encoding suffix. if (LC_ALL=zh_CN.GB18030 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_zh_CN=zh_CN.GB18030 else # None found. gt_cv_locale_zh_CN=none fi fi ;; esac else # If there was a link error, due to mblen(), the system is so old that # it certainly doesn't have a chinese locale. gt_cv_locale_zh_CN=none fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_zh_CN" >&5 $as_echo "$gt_cv_locale_zh_CN" >&6; } LOCALE_ZH_CN=$gt_cv_locale_zh_CN { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5 $as_echo_n "checking for a french Unicode locale... " >&6; } if ${gt_cv_locale_fr_utf8+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_LANGINFO_CODESET # include #endif #include #include struct tm t; char buf[16]; int main () { /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl imitates locale dependent behaviour by looking at the environment variables, and all locales use the UTF-8 encoding. */ #if !(defined __BEOS__ || defined __HAIKU__) /* Check whether the given locale name is recognized by the system. */ # if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ /* On native Windows, setlocale(category, "") looks at the system settings, not at the environment variables. Also, when an encoding suffix such as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE category of the locale to "C". */ if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) return 1; # else if (setlocale (LC_ALL, "") == NULL) return 1; # endif /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) is empty, and the behaviour of Tcl 8.4 in this locale is not useful. On OpenBSD 4.0, when an unsupported locale is specified, setlocale() succeeds but then nl_langinfo(CODESET) is "646". In this situation, some unit tests fail. */ # if HAVE_LANGINFO_CODESET { const char *cs = nl_langinfo (CODESET); if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) return 1; } # endif # ifdef __CYGWIN__ /* On Cygwin, avoid locale names without encoding suffix, because the locale_charset() function relies on the encoding suffix. Note that LC_ALL is set on the command line. */ if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; # endif /* Check whether in the abbreviation of the second month, the second character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is two bytes long, with UTF-8 encoding. */ t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; if (strftime (buf, sizeof (buf), "%b", &t) < 4 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') return 1; #endif #if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ /* Check whether the decimal separator is a comma. On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point are nl_langinfo(RADIXCHAR) are both ".". */ if (localeconv () ->decimal_point[0] != ',') return 1; #endif return 0; } _ACEOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then case "$host_os" in # Handle native Windows specially, because there setlocale() interprets # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", # "fr" or "fra" as "French" or "French_France.1252", # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", # "ja" as "Japanese" or "Japanese_Japan.932", # and similar. mingw*) # Test for the hypothetical native Windows locale name. if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr_utf8=French_France.65001 else # None found. gt_cv_locale_fr_utf8=none fi ;; *) # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the # configure script would override the LC_ALL setting. Likewise for # LC_CTYPE, which is also set at the beginning of the configure script. # Test for the usual locale name. if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr_utf8=fr_FR else # Test for the locale name with explicit encoding suffix. if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr_utf8=fr_FR.UTF-8 else # Test for the Solaris 7 locale name. if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then gt_cv_locale_fr_utf8=fr.UTF-8 else # None found. gt_cv_locale_fr_utf8=none fi fi fi ;; esac fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5 $as_echo "$gt_cv_locale_fr_utf8" >&6; } LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 GNULIB_FFSL=0; GNULIB_FFSLL=0; GNULIB_MEMCHR=0; GNULIB_MEMMEM=0; GNULIB_MEMPCPY=0; GNULIB_MEMRCHR=0; GNULIB_RAWMEMCHR=0; GNULIB_STPCPY=0; GNULIB_STPNCPY=0; GNULIB_STRCHRNUL=0; GNULIB_STRDUP=0; GNULIB_STRNCAT=0; GNULIB_STRNDUP=0; GNULIB_STRNLEN=0; GNULIB_STRPBRK=0; GNULIB_STRSEP=0; GNULIB_STRSTR=0; GNULIB_STRCASESTR=0; GNULIB_STRTOK_R=0; GNULIB_MBSLEN=0; GNULIB_MBSNLEN=0; GNULIB_MBSCHR=0; GNULIB_MBSRCHR=0; GNULIB_MBSSTR=0; GNULIB_MBSCASECMP=0; GNULIB_MBSNCASECMP=0; GNULIB_MBSPCASECMP=0; GNULIB_MBSCASESTR=0; GNULIB_MBSCSPN=0; GNULIB_MBSPBRK=0; GNULIB_MBSSPN=0; GNULIB_MBSSEP=0; GNULIB_MBSTOK_R=0; GNULIB_STRERROR=0; GNULIB_STRERROR_R=0; GNULIB_STRSIGNAL=0; GNULIB_STRVERSCMP=0; HAVE_MBSLEN=0; HAVE_FFSL=1; HAVE_FFSLL=1; HAVE_MEMCHR=1; HAVE_DECL_MEMMEM=1; HAVE_MEMPCPY=1; HAVE_DECL_MEMRCHR=1; HAVE_RAWMEMCHR=1; HAVE_STPCPY=1; HAVE_STPNCPY=1; HAVE_STRCHRNUL=1; HAVE_DECL_STRDUP=1; HAVE_DECL_STRNDUP=1; HAVE_DECL_STRNLEN=1; HAVE_STRPBRK=1; HAVE_STRSEP=1; HAVE_STRCASESTR=1; HAVE_DECL_STRTOK_R=1; HAVE_DECL_STRERROR_R=1; HAVE_DECL_STRSIGNAL=1; HAVE_STRVERSCMP=1; REPLACE_MEMCHR=0; REPLACE_MEMMEM=0; REPLACE_STPNCPY=0; REPLACE_STRDUP=0; REPLACE_STRSTR=0; REPLACE_STRCASESTR=0; REPLACE_STRCHRNUL=0; REPLACE_STRERROR=0; REPLACE_STRERROR_R=0; REPLACE_STRNCAT=0; REPLACE_STRNDUP=0; REPLACE_STRNLEN=0; REPLACE_STRSIGNAL=0; REPLACE_STRTOK_R=0; UNDEFINE_STRTOK_R=0; # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is # irrelevant for anonymous mappings. ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap" if test "x$ac_cv_func_mmap" = xyes; then : gl_have_mmap=yes else gl_have_mmap=no fi # Try to allow MAP_ANONYMOUS. gl_have_mmap_anonymous=no if test $gl_have_mmap = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MAP_ANONYMOUS" >&5 $as_echo_n "checking for MAP_ANONYMOUS... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef MAP_ANONYMOUS I cannot identify this map #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "I cannot identify this map" >/dev/null 2>&1; then : gl_have_mmap_anonymous=yes fi rm -f conftest* if test $gl_have_mmap_anonymous != yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef MAP_ANON I cannot identify this map #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "I cannot identify this map" >/dev/null 2>&1; then : $as_echo "#define MAP_ANONYMOUS MAP_ANON" >>confdefs.h gl_have_mmap_anonymous=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_have_mmap_anonymous" >&5 $as_echo "$gl_have_mmap_anonymous" >&6; } if test $gl_have_mmap_anonymous = yes; then $as_echo "#define HAVE_MAP_ANONYMOUS 1" >>confdefs.h fi fi if test $HAVE_MEMCHR = 1; then # Detect platform-specific bugs in some versions of glibc: # memchr should not dereference anything with length 0 # http://bugzilla.redhat.com/499689 # memchr should not dereference overestimated length after a match # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 # http://sourceware.org/bugzilla/show_bug.cgi?id=10162 # Assume that memchr works on platforms that lack mprotect. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memchr works" >&5 $as_echo_n "checking whether memchr works... " >&6; } if ${gl_cv_func_memchr_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_func_memchr_works="guessing no" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_SYS_MMAN_H # include # include # include # include # ifndef MAP_FILE # define MAP_FILE 0 # endif #endif int main () { int result = 0; char *fence = NULL; #if HAVE_SYS_MMAN_H && HAVE_MPROTECT # if HAVE_MAP_ANONYMOUS const int flags = MAP_ANONYMOUS | MAP_PRIVATE; const int fd = -1; # else /* !HAVE_MAP_ANONYMOUS */ const int flags = MAP_FILE | MAP_PRIVATE; int fd = open ("/dev/zero", O_RDONLY, 0666); if (fd >= 0) # endif { int pagesize = getpagesize (); char *two_pages = (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, flags, fd, 0); if (two_pages != (char *)(-1) && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) fence = two_pages + pagesize; } #endif if (fence) { if (memchr (fence, 0, 0)) result |= 1; strcpy (fence - 9, "12345678"); if (memchr (fence - 9, 0, 79) != fence - 1) result |= 2; if (memchr (fence - 1, 0, 3) != fence - 1) result |= 4; } return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_memchr_works=yes else gl_cv_func_memchr_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_memchr_works" >&5 $as_echo "$gl_cv_func_memchr_works" >&6; } if test "$gl_cv_func_memchr_works" != yes; then REPLACE_MEMCHR=1 fi fi ac_fn_c_check_decl "$LINENO" "memmem" "ac_cv_have_decl_memmem" "$ac_includes_default" if test "x$ac_cv_have_decl_memmem" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_MEMMEM $ac_have_decl _ACEOF for ac_func in memmem do : ac_fn_c_check_func "$LINENO" "memmem" "ac_cv_func_memmem" if test "x$ac_cv_func_memmem" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMMEM 1 _ACEOF fi done if test $ac_cv_func_memmem = yes; then HAVE_MEMMEM=1 else HAVE_MEMMEM=0 fi if test $ac_cv_have_decl_memmem = no; then HAVE_DECL_MEMMEM=0 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memmem works" >&5 $as_echo_n "checking whether memmem works... " >&6; } if ${gl_cv_func_memmem_works_always+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNU_LIBRARY__ #include #if ((__GLIBC__ == 2 && ((__GLIBC_MINOR > 0 && __GLIBC_MINOR__ < 9) \ || __GLIBC_MINOR__ > 12)) \ || (__GLIBC__ > 2)) \ || defined __UCLIBC__ Lucky user #endif #elif defined __CYGWIN__ #include #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7) Lucky user #endif #else Lucky user #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Lucky user" >/dev/null 2>&1; then : gl_cv_func_memmem_works_always="guessing yes" else gl_cv_func_memmem_works_always="guessing no" fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for memmem */ #define P "_EF_BF_BD" #define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P #define NEEDLE P P P P P int main () { int result = 0; if (memmem (HAYSTACK, strlen (HAYSTACK), NEEDLE, strlen (NEEDLE))) result |= 1; /* Check for empty needle behavior. */ { const char *haystack = "AAA"; if (memmem (haystack, 3, NULL, 0) != haystack) result |= 2; } return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_memmem_works_always=yes else gl_cv_func_memmem_works_always=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_memmem_works_always" >&5 $as_echo "$gl_cv_func_memmem_works_always" >&6; } case "$gl_cv_func_memmem_works_always" in *yes) ;; *) REPLACE_MEMMEM=1 ;; esac fi : GNULIB_MKTIME=0; GNULIB_NANOSLEEP=0; GNULIB_STRPTIME=0; GNULIB_TIMEGM=0; GNULIB_TIME_R=0; HAVE_DECL_LOCALTIME_R=1; HAVE_NANOSLEEP=1; HAVE_STRPTIME=1; HAVE_TIMEGM=1; REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; REPLACE_MKTIME=GNULIB_PORTCHECK; REPLACE_NANOSLEEP=GNULIB_PORTCHECK; REPLACE_TIMEGM=GNULIB_PORTCHECK; : ${GNULIB_GETTIMEOFDAY=0}; REPLACE_GMTIME=0; REPLACE_LOCALTIME=0; { $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 ${gl_cv_promoted_mode_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_promoted_mode_t='int' else gl_cv_promoted_mode_t='mode_t' fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_promoted_mode_t" >&5 $as_echo "$gl_cv_promoted_mode_t" >&6; } cat >>confdefs.h <<_ACEOF #define PROMOTED_MODE_T $gl_cv_promoted_mode_t _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi # Define two additional variables used in the Makefile substitution. if test "$ac_cv_header_stdbool_h" = yes; then STDBOOL_H='' else STDBOOL_H='stdbool.h' fi if test -n "$STDBOOL_H"; then GL_GENERATE_STDBOOL_H_TRUE= GL_GENERATE_STDBOOL_H_FALSE='#' else GL_GENERATE_STDBOOL_H_TRUE='#' GL_GENERATE_STDBOOL_H_FALSE= fi if test "$ac_cv_type__Bool" = yes; then HAVE__BOOL=1 else HAVE__BOOL=0 fi # parse-datetime.y works with bison only. : ${YACC='bison -y'} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compound literals" >&5 $as_echo_n "checking for compound literals... " >&6; } if ${gl_cv_compound_literals+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ struct s { int i, j; }; int main () { struct s t = (struct s) { 3, 4 }; if (t.i != 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_compound_literals=yes else gl_cv_compound_literals=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_compound_literals" >&5 $as_echo "$gl_cv_compound_literals" >&6; } if test $gl_cv_compound_literals = yes; then $as_echo "#define HAVE_COMPOUND_LITERALS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct tm tm; int *p = &tm.tm_sec; return !p; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_tm=time.h else ac_cv_struct_tm=sys/time.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 $as_echo "$ac_cv_struct_tm" >&6; } if test $ac_cv_struct_tm = sys/time.h; then $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct tm" "tm_gmtoff" "ac_cv_member_struct_tm_tm_gmtoff" "#include " if test "x$ac_cv_member_struct_tm_tm_gmtoff" = xyes; then : $as_echo "#define HAVE_TM_GMTOFF 1" >>confdefs.h fi GNULIB_POLL=0; HAVE_POLL=1; REPLACE_POLL=0; if test $ac_cv_header_poll_h = yes; then HAVE_POLL_H=1 else HAVE_POLL_H=0 fi if test $gl_cv_have_include_next = yes; then gl_cv_next_poll_h='<'poll.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_poll_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_poll_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'poll.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_poll_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_poll_h gl_cv_next_poll_h='"'$gl_header'"' else gl_cv_next_poll_h='<'poll.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_poll_h" >&5 $as_echo "$gl_cv_next_poll_h" >&6; } fi NEXT_POLL_H=$gl_cv_next_poll_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'poll.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_poll_h fi NEXT_AS_FIRST_DIRECTIVE_POLL_H=$gl_next_as_first_directive if test $ac_cv_header_sys_socket_h != yes; then for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF fi done fi if test "$ac_cv_header_winsock2_h" = yes; then HAVE_WINSOCK2_H=1 UNISTD_H_HAVE_WINSOCK2_H=1 SYS_IOCTL_H_HAVE_WINSOCK2_H=1 else HAVE_WINSOCK2_H=0 fi LIBSOCKET= if test $HAVE_WINSOCK2_H = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need to call WSAStartup in winsock2.h and -lws2_32" >&5 $as_echo_n "checking if we need to call WSAStartup in winsock2.h and -lws2_32... " >&6; } if ${gl_cv_func_wsastartup+:} false; then : $as_echo_n "(cached) " >&6 else gl_save_LIBS="$LIBS" LIBS="$LIBS -lws2_32" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_WINSOCK2_H # include #endif int main () { WORD wVersionRequested = MAKEWORD(1, 1); WSADATA wsaData; int err = WSAStartup(wVersionRequested, &wsaData); WSACleanup (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_wsastartup=yes else gl_cv_func_wsastartup=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$gl_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_wsastartup" >&5 $as_echo "$gl_cv_func_wsastartup" >&6; } if test "$gl_cv_func_wsastartup" = "yes"; then $as_echo "#define WINDOWS_SOCKETS 1" >>confdefs.h LIBSOCKET='-lws2_32' fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing setsockopt" >&5 $as_echo_n "checking for library containing setsockopt... " >&6; } if ${gl_cv_lib_socket+:} false; then : $as_echo_n "(cached) " >&6 else gl_cv_lib_socket= cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ extern #ifdef __cplusplus "C" #endif char setsockopt(); int main () { setsockopt(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : else gl_save_LIBS="$LIBS" LIBS="$gl_save_LIBS -lsocket" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ extern #ifdef __cplusplus "C" #endif char setsockopt(); int main () { setsockopt(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_lib_socket="-lsocket" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$gl_cv_lib_socket"; then LIBS="$gl_save_LIBS -lnetwork" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ extern #ifdef __cplusplus "C" #endif char setsockopt(); int main () { setsockopt(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_lib_socket="-lnetwork" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$gl_cv_lib_socket"; then LIBS="$gl_save_LIBS -lnet" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ extern #ifdef __cplusplus "C" #endif char setsockopt(); int main () { setsockopt(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_lib_socket="-lnet" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi fi LIBS="$gl_save_LIBS" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$gl_cv_lib_socket"; then gl_cv_lib_socket="none needed" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_lib_socket" >&5 $as_echo "$gl_cv_lib_socket" >&6; } if test "$gl_cv_lib_socket" != "none needed"; then LIBSOCKET="$gl_cv_lib_socket" fi fi : GNULIB_PSELECT=0; GNULIB_SELECT=0; HAVE_PSELECT=1; REPLACE_PSELECT=0; REPLACE_SELECT=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is self-contained" >&5 $as_echo_n "checking whether is self-contained... " >&6; } if ${gl_cv_header_sys_select_h_selfcontained+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct timeval b; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_sys_select_h_selfcontained=yes else gl_cv_header_sys_select_h_selfcontained=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $gl_cv_header_sys_select_h_selfcontained = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int memset; int bzero; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #undef memset #define memset nonexistent_memset extern #ifdef __cplusplus "C" #endif void *memset (void *, int, unsigned long); #undef bzero #define bzero nonexistent_bzero extern #ifdef __cplusplus "C" #endif void bzero (void *, unsigned long); fd_set fds; FD_ZERO (&fds); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : else gl_cv_header_sys_select_h_selfcontained=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_sys_select_h_selfcontained" >&5 $as_echo "$gl_cv_header_sys_select_h_selfcontained" >&6; } if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_select_h='<'sys/select.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_sys_select_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_sys_select_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'sys/select.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_sys_select_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_sys_select_h gl_cv_next_sys_select_h='"'$gl_header'"' else gl_cv_next_sys_select_h='<'sys/select.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_select_h" >&5 $as_echo "$gl_cv_next_sys_select_h" >&6; } fi NEXT_SYS_SELECT_H=$gl_cv_next_sys_select_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'sys/select.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_sys_select_h fi NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H=$gl_next_as_first_directive if test $ac_cv_header_sys_select_h = yes; then HAVE_SYS_SELECT_H=1 else HAVE_SYS_SELECT_H=0 fi if test $ac_cv_header_sys_socket_h != yes; then for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF fi done fi if test "$ac_cv_header_winsock2_h" = yes; then HAVE_WINSOCK2_H=1 UNISTD_H_HAVE_WINSOCK2_H=1 SYS_IOCTL_H_HAVE_WINSOCK2_H=1 else HAVE_WINSOCK2_H=0 fi ac_fn_c_check_decl "$LINENO" "setenv" "ac_cv_have_decl_setenv" "$ac_includes_default" if test "x$ac_cv_have_decl_setenv" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SETENV $ac_have_decl _ACEOF if test $ac_cv_have_decl_setenv = no; then HAVE_DECL_SETENV=0 fi for ac_header in search.h do : ac_fn_c_check_header_mongrel "$LINENO" "search.h" "ac_cv_header_search_h" "$ac_includes_default" if test "x$ac_cv_header_search_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SEARCH_H 1 _ACEOF fi done for ac_func in tsearch do : ac_fn_c_check_func "$LINENO" "tsearch" "ac_cv_func_tsearch" if test "x$ac_cv_func_tsearch" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TSEARCH 1 _ACEOF fi done GNULIB_PTHREAD_SIGMASK=0; GNULIB_RAISE=0; GNULIB_SIGNAL_H_SIGPIPE=0; GNULIB_SIGPROCMASK=0; GNULIB_SIGACTION=0; HAVE_POSIX_SIGNALBLOCKING=1; HAVE_PTHREAD_SIGMASK=1; HAVE_RAISE=1; HAVE_SIGSET_T=1; HAVE_SIGINFO_T=1; HAVE_SIGACTION=1; HAVE_STRUCT_SIGACTION_SA_SIGACTION=1; HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1; HAVE_SIGHANDLER_T=1; REPLACE_PTHREAD_SIGMASK=0; REPLACE_RAISE=0; ac_fn_c_check_type "$LINENO" "sigset_t" "ac_cv_type_sigset_t" " #include /* Mingw defines sigset_t not in , but in . */ #include " if test "x$ac_cv_type_sigset_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SIGSET_T 1 _ACEOF gl_cv_type_sigset_t=yes else gl_cv_type_sigset_t=no fi if test $gl_cv_type_sigset_t != yes; then HAVE_SIGSET_T=0 fi GNULIB_DPRINTF=0; GNULIB_FCLOSE=0; GNULIB_FDOPEN=0; GNULIB_FFLUSH=0; GNULIB_FGETC=0; GNULIB_FGETS=0; GNULIB_FOPEN=0; GNULIB_FPRINTF=0; GNULIB_FPRINTF_POSIX=0; GNULIB_FPURGE=0; GNULIB_FPUTC=0; GNULIB_FPUTS=0; GNULIB_FREAD=0; GNULIB_FREOPEN=0; GNULIB_FSCANF=0; GNULIB_FSEEK=0; GNULIB_FSEEKO=0; GNULIB_FTELL=0; GNULIB_FTELLO=0; GNULIB_FWRITE=0; GNULIB_GETC=0; GNULIB_GETCHAR=0; GNULIB_GETDELIM=0; GNULIB_GETLINE=0; GNULIB_OBSTACK_PRINTF=0; GNULIB_OBSTACK_PRINTF_POSIX=0; GNULIB_PCLOSE=0; GNULIB_PERROR=0; GNULIB_POPEN=0; GNULIB_PRINTF=0; GNULIB_PRINTF_POSIX=0; GNULIB_PUTC=0; GNULIB_PUTCHAR=0; GNULIB_PUTS=0; GNULIB_REMOVE=0; GNULIB_RENAME=0; GNULIB_RENAMEAT=0; GNULIB_SCANF=0; GNULIB_SNPRINTF=0; GNULIB_SPRINTF_POSIX=0; GNULIB_STDIO_H_NONBLOCKING=0; GNULIB_STDIO_H_SIGPIPE=0; GNULIB_TMPFILE=0; GNULIB_VASPRINTF=0; GNULIB_VFSCANF=0; GNULIB_VSCANF=0; GNULIB_VDPRINTF=0; GNULIB_VFPRINTF=0; GNULIB_VFPRINTF_POSIX=0; GNULIB_VPRINTF=0; GNULIB_VPRINTF_POSIX=0; GNULIB_VSNPRINTF=0; GNULIB_VSPRINTF_POSIX=0; HAVE_DECL_FPURGE=1; HAVE_DECL_FSEEKO=1; HAVE_DECL_FTELLO=1; HAVE_DECL_GETDELIM=1; HAVE_DECL_GETLINE=1; HAVE_DECL_OBSTACK_PRINTF=1; HAVE_DECL_SNPRINTF=1; HAVE_DECL_VSNPRINTF=1; HAVE_DPRINTF=1; HAVE_FSEEKO=1; HAVE_FTELLO=1; HAVE_PCLOSE=1; HAVE_POPEN=1; HAVE_RENAMEAT=1; HAVE_VASPRINTF=1; HAVE_VDPRINTF=1; REPLACE_DPRINTF=0; REPLACE_FCLOSE=0; REPLACE_FDOPEN=0; REPLACE_FFLUSH=0; REPLACE_FOPEN=0; REPLACE_FPRINTF=0; REPLACE_FPURGE=0; REPLACE_FREOPEN=0; REPLACE_FSEEK=0; REPLACE_FSEEKO=0; REPLACE_FTELL=0; REPLACE_FTELLO=0; REPLACE_GETDELIM=0; REPLACE_GETLINE=0; REPLACE_OBSTACK_PRINTF=0; REPLACE_PERROR=0; REPLACE_POPEN=0; REPLACE_PRINTF=0; REPLACE_REMOVE=0; REPLACE_RENAME=0; REPLACE_RENAMEAT=0; REPLACE_SNPRINTF=0; REPLACE_SPRINTF=0; REPLACE_STDIO_READ_FUNCS=0; REPLACE_STDIO_WRITE_FUNCS=0; REPLACE_TMPFILE=0; REPLACE_VASPRINTF=0; REPLACE_VDPRINTF=0; REPLACE_VFPRINTF=0; REPLACE_VPRINTF=0; REPLACE_VSNPRINTF=0; REPLACE_VSPRINTF=0; GNULIB_FFS=0; HAVE_FFS=1; HAVE_STRCASECMP=1; HAVE_DECL_STRNCASECMP=1; ac_fn_c_check_decl "$LINENO" "strdup" "ac_cv_have_decl_strdup" "$ac_includes_default" if test "x$ac_cv_have_decl_strdup" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRDUP $ac_have_decl _ACEOF REPLACE_STRERROR_0=0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror(0) succeeds" >&5 $as_echo_n "checking whether strerror(0) succeeds... " >&6; } if ${gl_cv_func_strerror_0_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_strerror_0_works="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { int result = 0; char *str; errno = 0; str = strerror (0); if (!*str) result |= 1; if (errno) result |= 2; if (strstr (str, "nknown") || strstr (str, "ndefined")) result |= 4; return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_strerror_0_works=yes else gl_cv_func_strerror_0_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strerror_0_works" >&5 $as_echo "$gl_cv_func_strerror_0_works" >&6; } case "$gl_cv_func_strerror_0_works" in *yes) ;; *) REPLACE_STRERROR_0=1 $as_echo "#define REPLACE_STRERROR_0 1" >>confdefs.h ;; esac if test $gl_cv_have_include_next = yes; then gl_cv_next_string_h='<'string.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_string_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'string.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_string_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_string_h gl_cv_next_string_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_string_h" >&5 $as_echo "$gl_cv_next_string_h" >&6; } fi NEXT_STRING_H=$gl_cv_next_string_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'string.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_string_h fi NEXT_AS_FIRST_DIRECTIVE_STRING_H=$gl_next_as_first_directive if test $gl_cv_have_include_next = yes; then gl_cv_next_strings_h='<'strings.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_strings_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_strings_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'strings.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_strings_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_strings_h gl_cv_next_strings_h='"'$gl_header'"' else gl_cv_next_strings_h='<'strings.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_strings_h" >&5 $as_echo "$gl_cv_next_strings_h" >&6; } fi NEXT_STRINGS_H=$gl_cv_next_strings_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'strings.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_strings_h fi NEXT_AS_FIRST_DIRECTIVE_STRINGS_H=$gl_next_as_first_directive if test $ac_cv_header_strings_h = yes; then HAVE_STRINGS_H=1 else HAVE_STRINGS_H=0 fi if test "$gl_cv_func_memchr_works" != yes; then REPLACE_STRSTR=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strstr works" >&5 $as_echo_n "checking whether strstr works... " >&6; } if ${gl_cv_func_strstr_works_always+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNU_LIBRARY__ #include #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ || defined __UCLIBC__ Lucky user #endif #elif defined __CYGWIN__ #include #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7) Lucky user #endif #else Lucky user #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Lucky user" >/dev/null 2>&1; then : gl_cv_func_strstr_works_always="guessing yes" else gl_cv_func_strstr_works_always="guessing no" fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for strstr */ #define P "_EF_BF_BD" #define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P #define NEEDLE P P P P P int main () { return !!strstr (HAYSTACK, NEEDLE); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_strstr_works_always=yes else gl_cv_func_strstr_works_always=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strstr_works_always" >&5 $as_echo "$gl_cv_func_strstr_works_always" >&6; } case "$gl_cv_func_strstr_works_always" in *yes) ;; *) REPLACE_STRSTR=1 ;; esac fi ac_fn_c_check_decl "$LINENO" "strtok_r" "ac_cv_have_decl_strtok_r" "$ac_includes_default" if test "x$ac_cv_have_decl_strtok_r" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRTOK_R $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "strtoumax" "ac_cv_have_decl_strtoumax" "$ac_includes_default" if test "x$ac_cv_have_decl_strtoumax" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRTOUMAX $ac_have_decl _ACEOF if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_types_h='<'sys/types.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_sys_types_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'sys/types.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_sys_types_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_sys_types_h gl_cv_next_sys_types_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_types_h" >&5 $as_echo "$gl_cv_next_sys_types_h" >&6; } fi NEXT_SYS_TYPES_H=$gl_cv_next_sys_types_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'sys/types.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_sys_types_h fi NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H=$gl_next_as_first_directive { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in " >&5 $as_echo_n "checking for struct timespec in ... " >&6; } if ${gl_cv_sys_struct_timespec_in_time_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { static struct timespec x; x.tv_sec = x.tv_nsec; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_sys_struct_timespec_in_time_h=yes else gl_cv_sys_struct_timespec_in_time_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_time_h" >&5 $as_echo "$gl_cv_sys_struct_timespec_in_time_h" >&6; } TIME_H_DEFINES_STRUCT_TIMESPEC=0 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 UNISTD_H_DEFINES_STRUCT_TIMESPEC=0 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then TIME_H_DEFINES_STRUCT_TIMESPEC=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in " >&5 $as_echo_n "checking for struct timespec in ... " >&6; } if ${gl_cv_sys_struct_timespec_in_sys_time_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { static struct timespec x; x.tv_sec = x.tv_nsec; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_sys_struct_timespec_in_sys_time_h=yes else gl_cv_sys_struct_timespec_in_sys_time_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_sys_time_h" >&5 $as_echo "$gl_cv_sys_struct_timespec_in_sys_time_h" >&6; } if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in " >&5 $as_echo_n "checking for struct timespec in ... " >&6; } if ${gl_cv_sys_struct_timespec_in_pthread_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { static struct timespec x; x.tv_sec = x.tv_nsec; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_sys_struct_timespec_in_pthread_h=yes else gl_cv_sys_struct_timespec_in_pthread_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_pthread_h" >&5 $as_echo "$gl_cv_sys_struct_timespec_in_pthread_h" >&6; } if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in " >&5 $as_echo_n "checking for struct timespec in ... " >&6; } if ${gl_cv_sys_struct_timespec_in_unistd_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { static struct timespec x; x.tv_sec = x.tv_nsec; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_sys_struct_timespec_in_unistd_h=yes else gl_cv_sys_struct_timespec_in_unistd_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_unistd_h" >&5 $as_echo "$gl_cv_sys_struct_timespec_in_unistd_h" >&6; } if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then UNISTD_H_DEFINES_STRUCT_TIMESPEC=1 fi fi fi fi if test $gl_cv_have_include_next = yes; then gl_cv_next_time_h='<'time.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_time_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'time.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_time_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_time_h gl_cv_next_time_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_time_h" >&5 $as_echo "$gl_cv_next_time_h" >&6; } fi NEXT_TIME_H=$gl_cv_next_time_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'time.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_time_h fi NEXT_AS_FIRST_DIRECTIVE_TIME_H=$gl_next_as_first_directive gl_libunistring_sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;} i\ 0 q ' gl_libunistring_sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;} i\ 0 q ' gl_libunistring_sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p;q;} i\ 0 q ' if test "$HAVE_LIBUNISTRING" = yes; then LIBUNISTRING_VERSION_MAJOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_major"` LIBUNISTRING_VERSION_MINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_minor"` LIBUNISTRING_VERSION_SUBMINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_subminor"` fi ac_fn_c_check_decl "$LINENO" "unsetenv" "ac_cv_have_decl_unsetenv" "$ac_includes_default" if test "x$ac_cv_have_decl_unsetenv" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_UNSETENV $ac_have_decl _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wint_t" >&5 $as_echo_n "checking for wint_t... " >&6; } if ${gt_cv_c_wint_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include wint_t foo = (wchar_t)'\0'; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gt_cv_c_wint_t=yes else gt_cv_c_wint_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wint_t" >&5 $as_echo "$gt_cv_c_wint_t" >&6; } if test $gt_cv_c_wint_t = yes; then $as_echo "#define HAVE_WINT_T 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inttypes.h" >&5 $as_echo_n "checking for inttypes.h... " >&6; } if ${gl_cv_header_inttypes_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { uintmax_t i = (uintmax_t) -1; return !i; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_inttypes_h=yes else gl_cv_header_inttypes_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_inttypes_h" >&5 $as_echo "$gl_cv_header_inttypes_h" >&6; } if test $gl_cv_header_inttypes_h = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_INTTYPES_H_WITH_UINTMAX 1 _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint.h" >&5 $as_echo_n "checking for stdint.h... " >&6; } if ${gl_cv_header_stdint_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { uintmax_t i = (uintmax_t) -1; return !i; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_stdint_h=yes else gl_cv_header_stdint_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_stdint_h" >&5 $as_echo "$gl_cv_header_stdint_h" >&6; } if test $gl_cv_header_stdint_h = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_STDINT_H_WITH_UINTMAX 1 _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for intmax_t" >&5 $as_echo_n "checking for intmax_t... " >&6; } if ${gt_cv_c_intmax_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_STDINT_H_WITH_UINTMAX #include #endif #if HAVE_INTTYPES_H_WITH_UINTMAX #include #endif int main () { intmax_t x = -1; return !x; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gt_cv_c_intmax_t=yes else gt_cv_c_intmax_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_intmax_t" >&5 $as_echo "$gt_cv_c_intmax_t" >&6; } if test $gt_cv_c_intmax_t = yes; then $as_echo "#define HAVE_INTMAX_T 1" >>confdefs.h else test $ac_cv_type_long_long_int = yes \ && ac_type='long long' \ || ac_type='long' cat >>confdefs.h <<_ACEOF #define intmax_t $ac_type _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf returns a byte count as in C99" >&5 $as_echo_n "checking whether snprintf returns a byte count as in C99... " >&6; } if ${gl_cv_func_snprintf_retval_c99+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";; freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; # Guess yes on Mac OS X >= 10.3. darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; # Guess yes on OpenBSD >= 3.9. openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) gl_cv_func_snprintf_retval_c99="guessing no";; openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; # Guess yes on Solaris >= 2.10. solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; solaris*) gl_cv_func_printf_sizes_c99="guessing no";; # Guess yes on AIX >= 4. aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; # Guess yes on NetBSD >= 3. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) gl_cv_func_snprintf_retval_c99="guessing no";; netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; # Guess yes on BeOS. beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_snprintf_retval_c99="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_SNPRINTF # define my_snprintf snprintf #else # include static int my_snprintf (char *buf, int size, const char *format, ...) { va_list args; int ret; va_start (args, format); ret = vsnprintf (buf, size, format, args); va_end (args); return ret; } #endif static char buf[100]; int main () { strcpy (buf, "ABCDEF"); if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7) return 1; if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7) return 2; if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7) return 3; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_snprintf_retval_c99=yes else gl_cv_func_snprintf_retval_c99=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_snprintf_retval_c99" >&5 $as_echo "$gl_cv_func_snprintf_retval_c99" >&6; } for ac_func in snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_decl "$LINENO" "_snprintf" "ac_cv_have_decl__snprintf" "#include " if test "x$ac_cv_have_decl__snprintf" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL__SNPRINTF $ac_have_decl _ACEOF case "$gl_cv_func_snprintf_retval_c99" in *yes) $as_echo "#define HAVE_SNPRINTF_RETVAL_C99 1" >>confdefs.h ;; esac ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default" if test "x$ac_cv_have_decl_vsnprintf" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_VSNPRINTF $ac_have_decl _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports size specifiers as in C99" >&5 $as_echo_n "checking whether printf supports size specifiers as in C99... " >&6; } if ${gl_cv_func_printf_sizes_c99+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; # Guess yes on Mac OS X >= 10.3. darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; # Guess yes on OpenBSD >= 3.9. openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) gl_cv_func_printf_sizes_c99="guessing no";; openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; # Guess yes on Solaris >= 2.10. solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; solaris*) gl_cv_func_printf_sizes_c99="guessing no";; # Guess yes on NetBSD >= 3. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) gl_cv_func_printf_sizes_c99="guessing no";; netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_printf_sizes_c99="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #if HAVE_STDINT_H_WITH_UINTMAX # include #endif #if HAVE_INTTYPES_H_WITH_UINTMAX # include #endif static char buf[100]; int main () { int result = 0; #if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX buf[0] = '\0'; if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 || strcmp (buf, "12345671 33") != 0) result |= 1; #endif buf[0] = '\0'; if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 || strcmp (buf, "12345672 33") != 0) result |= 2; buf[0] = '\0'; if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0 || strcmp (buf, "12345673 33") != 0) result |= 4; buf[0] = '\0'; if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0 || strcmp (buf, "1.5 33") != 0) result |= 8; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_sizes_c99=yes else gl_cv_func_printf_sizes_c99=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_sizes_c99" >&5 $as_echo "$gl_cv_func_printf_sizes_c99" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports 'long double' arguments" >&5 $as_echo_n "checking whether printf supports 'long double' arguments... " >&6; } if ${gl_cv_func_printf_long_double+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in beos*) gl_cv_func_printf_long_double="guessing no";; mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; *) gl_cv_func_printf_long_double="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static char buf[10000]; int main () { int result = 0; buf[0] = '\0'; if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0 || strcmp (buf, "1.750000 33") != 0) result |= 1; buf[0] = '\0'; if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0 || strcmp (buf, "1.750000e+00 33") != 0) result |= 2; buf[0] = '\0'; if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0 || strcmp (buf, "1.75 33") != 0) result |= 4; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_long_double=yes else gl_cv_func_printf_long_double=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_long_double" >&5 $as_echo "$gl_cv_func_printf_long_double" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports infinite 'double' arguments" >&5 $as_echo_n "checking whether printf supports infinite 'double' arguments... " >&6; } if ${gl_cv_func_printf_infinite+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_printf_infinite="guessing yes";; # Guess yes on FreeBSD >= 6. freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; # Guess yes on Mac OS X >= 10.3. darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; darwin*) gl_cv_func_printf_infinite="guessing yes";; # Guess yes on HP-UX >= 11. hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; hpux*) gl_cv_func_printf_infinite="guessing yes";; # Guess yes on NetBSD >= 3. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) gl_cv_func_printf_infinite="guessing no";; netbsd*) gl_cv_func_printf_infinite="guessing yes";; # Guess yes on BeOS. beos*) gl_cv_func_printf_infinite="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_printf_infinite="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static int strisnan (const char *string, size_t start_index, size_t end_index) { if (start_index < end_index) { if (string[start_index] == '-') start_index++; if (start_index + 3 <= end_index && memcmp (string + start_index, "nan", 3) == 0) { start_index += 3; if (start_index == end_index || (string[start_index] == '(' && string[end_index - 1] == ')')) return 1; } } return 0; } static int have_minus_zero () { static double plus_zero = 0.0; double minus_zero = - plus_zero; return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; } static char buf[10000]; static double zero = 0.0; int main () { int result = 0; if (sprintf (buf, "%f", 1.0 / zero) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 1; if (sprintf (buf, "%f", -1.0 / zero) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 1; if (sprintf (buf, "%f", zero / zero) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%e", 1.0 / zero) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 4; if (sprintf (buf, "%e", -1.0 / zero) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 4; if (sprintf (buf, "%e", zero / zero) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 8; if (sprintf (buf, "%g", 1.0 / zero) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 16; if (sprintf (buf, "%g", -1.0 / zero) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 16; if (sprintf (buf, "%g", zero / zero) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 32; /* This test fails on HP-UX 10.20. */ if (have_minus_zero ()) if (sprintf (buf, "%g", - zero) < 0 || strcmp (buf, "-0") != 0) result |= 64; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_infinite=yes else gl_cv_func_printf_infinite=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_infinite" >&5 $as_echo "$gl_cv_func_printf_infinite" >&6; } if test -n "$gl_printf_safe"; then $as_echo "#define CHECK_PRINTF_SAFE 1" >>confdefs.h fi case "$gl_cv_func_printf_long_double" in *yes) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports infinite 'long double' arguments" >&5 $as_echo_n "checking whether printf supports infinite 'long double' arguments... " >&6; } if ${gl_cv_func_printf_infinite_long_double+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_cpu" in # Guess no on ia64, x86_64, i386. ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; *) case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; # Guess yes on FreeBSD >= 6. freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; # Guess yes on HP-UX >= 11. hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_printf_infinite_long_double="guessing no";; esac ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if defined __MACH__ && defined __APPLE__ /* Avoid a crash on Mac OS X. */ #include #include #include #include #include #include /* The exception port on which our thread listens. */ static mach_port_t our_exception_port; /* The main function of the thread listening for exceptions of type EXC_BAD_ACCESS. */ static void * mach_exception_thread (void *arg) { /* Buffer for a message to be received. */ struct { mach_msg_header_t head; mach_msg_body_t msgh_body; char data[1024]; } msg; mach_msg_return_t retval; /* Wait for a message on the exception port. */ retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (retval != MACH_MSG_SUCCESS) abort (); exit (1); } static void nocrash_init (void) { mach_port_t self = mach_task_self (); /* Allocate a port on which the thread shall listen for exceptions. */ if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) == KERN_SUCCESS) { /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ if (mach_port_insert_right (self, our_exception_port, our_exception_port, MACH_MSG_TYPE_MAKE_SEND) == KERN_SUCCESS) { /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting for us. */ exception_mask_t mask = EXC_MASK_BAD_ACCESS; /* Create the thread listening on the exception port. */ pthread_attr_t attr; pthread_t thread; if (pthread_attr_init (&attr) == 0 && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { pthread_attr_destroy (&attr); /* Replace the exception port info for these exceptions with our own. Note that we replace the exception port for the entire task, not only for a particular thread. This has the effect that when our exception port gets the message, the thread specific exception port has already been asked, and we don't need to bother about it. See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ task_set_exception_ports (self, mask, our_exception_port, EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); } } } } #elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Avoid a crash on native Windows. */ #define WIN32_LEAN_AND_MEAN #include #include static LONG WINAPI exception_filter (EXCEPTION_POINTERS *ExceptionInfo) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_IN_PAGE_ERROR: case EXCEPTION_STACK_OVERFLOW: case EXCEPTION_GUARD_PAGE: case EXCEPTION_PRIV_INSTRUCTION: case EXCEPTION_ILLEGAL_INSTRUCTION: case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: case EXCEPTION_NONCONTINUABLE_EXCEPTION: exit (1); } return EXCEPTION_CONTINUE_SEARCH; } static void nocrash_init (void) { SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); } #else /* Avoid a crash on POSIX systems. */ #include /* A POSIX signal handler. */ static void exception_handler (int sig) { exit (1); } static void nocrash_init (void) { #ifdef SIGSEGV signal (SIGSEGV, exception_handler); #endif #ifdef SIGBUS signal (SIGBUS, exception_handler); #endif } #endif #include #include #include static int strisnan (const char *string, size_t start_index, size_t end_index) { if (start_index < end_index) { if (string[start_index] == '-') start_index++; if (start_index + 3 <= end_index && memcmp (string + start_index, "nan", 3) == 0) { start_index += 3; if (start_index == end_index || (string[start_index] == '(' && string[end_index - 1] == ')')) return 1; } } return 0; } static char buf[10000]; static long double zeroL = 0.0L; int main () { int result = 0; nocrash_init(); if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 1; if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 1; if (sprintf (buf, "%Lf", zeroL / zeroL) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 1; if (sprintf (buf, "%Le", 1.0L / zeroL) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 1; if (sprintf (buf, "%Le", -1.0L / zeroL) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 1; if (sprintf (buf, "%Le", zeroL / zeroL) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 1; if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 1; if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 1; if (sprintf (buf, "%Lg", zeroL / zeroL) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 1; #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ # ifdef WORDS_BIGENDIAN # define LDBL80_WORDS(exponent,manthi,mantlo) \ { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ (unsigned int) (mantlo) << 16 \ } # else # define LDBL80_WORDS(exponent,manthi,mantlo) \ { mantlo, manthi, exponent } # endif { /* Quiet NaN. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; } { /* Signalling NaN. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; } { /* Pseudo-NaN. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) <= 0) result |= 4; if (sprintf (buf, "%Le", x.value) <= 0) result |= 4; if (sprintf (buf, "%Lg", x.value) <= 0) result |= 4; } { /* Pseudo-Infinity. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) <= 0) result |= 8; if (sprintf (buf, "%Le", x.value) <= 0) result |= 8; if (sprintf (buf, "%Lg", x.value) <= 0) result |= 8; } { /* Pseudo-Zero. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) <= 0) result |= 16; if (sprintf (buf, "%Le", x.value) <= 0) result |= 16; if (sprintf (buf, "%Lg", x.value) <= 0) result |= 16; } { /* Unnormalized number. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) <= 0) result |= 32; if (sprintf (buf, "%Le", x.value) <= 0) result |= 32; if (sprintf (buf, "%Lg", x.value) <= 0) result |= 32; } { /* Pseudo-Denormal. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) <= 0) result |= 64; if (sprintf (buf, "%Le", x.value) <= 0) result |= 64; if (sprintf (buf, "%Lg", x.value) <= 0) result |= 64; } #endif return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_infinite_long_double=yes else gl_cv_func_printf_infinite_long_double=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_infinite_long_double" >&5 $as_echo "$gl_cv_func_printf_infinite_long_double" >&6; } ;; *) gl_cv_func_printf_infinite_long_double="irrelevant" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports the 'a' and 'A' directives" >&5 $as_echo_n "checking whether printf supports the 'a' and 'A' directives... " >&6; } if ${gl_cv_func_printf_directive_a+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc >= 2.5 systems. *-gnu*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __GNU_LIBRARY__ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__ BZ2908 #endif #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "BZ2908" >/dev/null 2>&1; then : gl_cv_func_printf_directive_a="guessing yes" else gl_cv_func_printf_directive_a="guessing no" fi rm -f conftest* ;; # If we don't know, assume the worst. *) gl_cv_func_printf_directive_a="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static char buf[100]; static double zero = 0.0; int main () { int result = 0; if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0 || (strcmp (buf, "0x1.922p+1 33") != 0 && strcmp (buf, "0x3.244p+0 33") != 0 && strcmp (buf, "0x6.488p-1 33") != 0 && strcmp (buf, "0xc.91p-2 33") != 0)) result |= 1; if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0 || (strcmp (buf, "-0X1.922P+1 33") != 0 && strcmp (buf, "-0X3.244P+0 33") != 0 && strcmp (buf, "-0X6.488P-1 33") != 0 && strcmp (buf, "-0XC.91P-2 33") != 0)) result |= 2; /* This catches a FreeBSD 6.1 bug: it doesn't round. */ if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 || (strcmp (buf, "0x1.83p+0 33") != 0 && strcmp (buf, "0x3.05p-1 33") != 0 && strcmp (buf, "0x6.0ap-2 33") != 0 && strcmp (buf, "0xc.14p-3 33") != 0)) result |= 4; /* This catches a FreeBSD 6.1 bug. See */ if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 || buf[0] == '0') result |= 8; /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug. */ if (sprintf (buf, "%.1a", 1.999) < 0 || (strcmp (buf, "0x1.0p+1") != 0 && strcmp (buf, "0x2.0p+0") != 0 && strcmp (buf, "0x4.0p-1") != 0 && strcmp (buf, "0x8.0p-2") != 0)) result |= 16; /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a glibc 2.4 bug . */ if (sprintf (buf, "%.1La", 1.999L) < 0 || (strcmp (buf, "0x1.0p+1") != 0 && strcmp (buf, "0x2.0p+0") != 0 && strcmp (buf, "0x4.0p-1") != 0 && strcmp (buf, "0x8.0p-2") != 0)) result |= 32; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_directive_a=yes else gl_cv_func_printf_directive_a=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_directive_a" >&5 $as_echo "$gl_cv_func_printf_directive_a" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports the 'F' directive" >&5 $as_echo_n "checking whether printf supports the 'F' directive... " >&6; } if ${gl_cv_func_printf_directive_f+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; # Guess yes on FreeBSD >= 6. freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; # Guess yes on Mac OS X >= 10.3. darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; darwin*) gl_cv_func_printf_directive_f="guessing yes";; # Guess yes on Solaris >= 2.10. solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; solaris*) gl_cv_func_printf_sizes_c99="guessing no";; # If we don't know, assume the worst. *) gl_cv_func_printf_directive_f="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static char buf[100]; static double zero = 0.0; int main () { int result = 0; if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0 || strcmp (buf, "1234567.000000 33") != 0) result |= 1; if (sprintf (buf, "%F", 1.0 / zero) < 0 || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0)) result |= 2; /* This catches a Cygwin 1.5.x bug. */ if (sprintf (buf, "%.F", 1234.0) < 0 || strcmp (buf, "1234") != 0) result |= 4; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_directive_f=yes else gl_cv_func_printf_directive_f=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_directive_f" >&5 $as_echo "$gl_cv_func_printf_directive_f" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports the 'n' directive" >&5 $as_echo_n "checking whether printf supports the 'n' directive... " >&6; } if ${gl_cv_func_printf_directive_n+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in mingw*) gl_cv_func_printf_directive_n="guessing no";; *) gl_cv_func_printf_directive_n="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #ifdef _MSC_VER /* See page about "Parameter Validation" on msdn.microsoft.com. */ static void cdecl invalid_parameter_handler (const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t dummy) { exit (1); } #endif static char fmtstring[10]; static char buf[100]; int main () { int count = -1; #ifdef _MSC_VER _set_invalid_parameter_handler (invalid_parameter_handler); #endif /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) support %n in format strings in read-only memory but not in writable memory. */ strcpy (fmtstring, "%d %n"); if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0 || strcmp (buf, "123 ") != 0 || count != 4) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_directive_n=yes else gl_cv_func_printf_directive_n=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_directive_n" >&5 $as_echo "$gl_cv_func_printf_directive_n" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports the 'ls' directive" >&5 $as_echo_n "checking whether printf supports the 'ls' directive... " >&6; } if ${gl_cv_func_printf_directive_ls+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in openbsd*) gl_cv_func_printf_directive_ls="guessing no";; irix*) gl_cv_func_printf_directive_ls="guessing no";; solaris*) gl_cv_func_printf_directive_ls="guessing no";; cygwin*) gl_cv_func_printf_directive_ls="guessing no";; beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; *) gl_cv_func_printf_directive_ls="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include #include int main () { int result = 0; char buf[100]; /* Test whether %ls works at all. This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on Cygwin 1.5. */ { static const wchar_t wstring[] = { 'a', 'b', 'c', 0 }; buf[0] = '\0'; if (sprintf (buf, "%ls", wstring) < 0 || strcmp (buf, "abc") != 0) result |= 1; } /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an assertion failure inside libc), but not on OpenBSD 4.0. */ { static const wchar_t wstring[] = { 'a', 0 }; buf[0] = '\0'; if (sprintf (buf, "%ls", wstring) < 0 || strcmp (buf, "a") != 0) result |= 2; } /* Test whether precisions in %ls are supported as specified in ISO C 99 section 7.19.6.1: "If a precision is specified, no more than that many bytes are written (including shift sequences, if any), and the array shall contain a null wide character if, to equal the multibyte character sequence length given by the precision, the function would need to access a wide character one past the end of the array." This test fails on Solaris 10. */ { static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 }; buf[0] = '\0'; if (sprintf (buf, "%.2ls", wstring) < 0 || strcmp (buf, "ab") != 0) result |= 8; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_directive_ls=yes else gl_cv_func_printf_directive_ls=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_directive_ls" >&5 $as_echo "$gl_cv_func_printf_directive_ls" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports the grouping flag" >&5 $as_echo_n "checking whether printf supports the grouping flag... " >&6; } if ${gl_cv_func_printf_flag_grouping+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; *) gl_cv_func_printf_flag_grouping="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static char buf[100]; int main () { if (sprintf (buf, "%'d %d", 1234567, 99) < 0 || buf[strlen (buf) - 1] != '9') return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_flag_grouping=yes else gl_cv_func_printf_flag_grouping=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_flag_grouping" >&5 $as_echo "$gl_cv_func_printf_flag_grouping" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports the left-adjust flag correctly" >&5 $as_echo_n "checking whether printf supports the left-adjust flag correctly... " >&6; } if ${gl_cv_func_printf_flag_leftadjust+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on HP-UX 11. hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; # Guess no on HP-UX 10 and older. hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; # Guess yes otherwise. *) gl_cv_func_printf_flag_leftadjust="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static char buf[100]; int main () { /* Check that a '-' flag is not annihilated by a negative width. */ if (sprintf (buf, "a%-*sc", -3, "b") < 0 || strcmp (buf, "ab c") != 0) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_flag_leftadjust=yes else gl_cv_func_printf_flag_leftadjust=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_flag_leftadjust" >&5 $as_echo "$gl_cv_func_printf_flag_leftadjust" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports the zero flag correctly" >&5 $as_echo_n "checking whether printf supports the zero flag correctly... " >&6; } if ${gl_cv_func_printf_flag_zero+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; # Guess yes on BeOS. beos*) gl_cv_func_printf_flag_zero="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_printf_flag_zero="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static char buf[100]; static double zero = 0.0; int main () { if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 || (strcmp (buf, " inf") != 0 && strcmp (buf, " infinity") != 0)) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_flag_zero=yes else gl_cv_func_printf_flag_zero=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_flag_zero" >&5 $as_echo "$gl_cv_func_printf_flag_zero" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports large precisions" >&5 $as_echo_n "checking whether printf supports large precisions... " >&6; } if ${gl_cv_func_printf_precision+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess no only on Solaris, native Windows, and BeOS systems. solaris*) gl_cv_func_printf_precision="guessing no" ;; mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; beos*) gl_cv_func_printf_precision="guessing no" ;; *) gl_cv_func_printf_precision="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static char buf[5000]; int main () { int result = 0; #ifdef __BEOS__ /* On BeOS, this would crash and show a dialog box. Avoid the crash. */ return 1; #endif if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) result |= 1; if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5) result |= 2; if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5 || buf[0] != '1') result |= 4; if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5 || buf[0] != '1') result |= 4; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_precision=yes else gl_cv_func_printf_precision=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_precision" >&5 $as_echo "$gl_cv_func_printf_precision" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf survives out-of-memory conditions" >&5 $as_echo_n "checking whether printf survives out-of-memory conditions... " >&6; } if ${gl_cv_func_printf_enomem+:} false; then : $as_echo_n "(cached) " >&6 else gl_cv_func_printf_enomem="guessing no" if test "$cross_compiling" = no; then if test $APPLE_UNIVERSAL_BUILD = 0; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if defined __MACH__ && defined __APPLE__ /* Avoid a crash on Mac OS X. */ #include #include #include #include #include #include /* The exception port on which our thread listens. */ static mach_port_t our_exception_port; /* The main function of the thread listening for exceptions of type EXC_BAD_ACCESS. */ static void * mach_exception_thread (void *arg) { /* Buffer for a message to be received. */ struct { mach_msg_header_t head; mach_msg_body_t msgh_body; char data1024; } msg; mach_msg_return_t retval; /* Wait for a message on the exception port. */ retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (retval != MACH_MSG_SUCCESS) abort (); exit (1); } static void nocrash_init (void) { mach_port_t self = mach_task_self (); /* Allocate a port on which the thread shall listen for exceptions. */ if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) == KERN_SUCCESS) { /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ if (mach_port_insert_right (self, our_exception_port, our_exception_port, MACH_MSG_TYPE_MAKE_SEND) == KERN_SUCCESS) { /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting for us. */ exception_mask_t mask = EXC_MASK_BAD_ACCESS; /* Create the thread listening on the exception port. */ pthread_attr_t attr; pthread_t thread; if (pthread_attr_init (&attr) == 0 && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { pthread_attr_destroy (&attr); /* Replace the exception port info for these exceptions with our own. Note that we replace the exception port for the entire task, not only for a particular thread. This has the effect that when our exception port gets the message, the thread specific exception port has already been asked, and we don't need to bother about it. See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ task_set_exception_ports (self, mask, our_exception_port, EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); } } } } #elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Avoid a crash on native Windows. */ #define WIN32_LEAN_AND_MEAN #include #include static LONG WINAPI exception_filter (EXCEPTION_POINTERS *ExceptionInfo) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_IN_PAGE_ERROR: case EXCEPTION_STACK_OVERFLOW: case EXCEPTION_GUARD_PAGE: case EXCEPTION_PRIV_INSTRUCTION: case EXCEPTION_ILLEGAL_INSTRUCTION: case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: case EXCEPTION_NONCONTINUABLE_EXCEPTION: exit (1); } return EXCEPTION_CONTINUE_SEARCH; } static void nocrash_init (void) { SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); } #else /* Avoid a crash on POSIX systems. */ #include /* A POSIX signal handler. */ static void exception_handler (int sig) { exit (1); } static void nocrash_init (void) { #ifdef SIGSEGV signal (SIGSEGV, exception_handler); #endif #ifdef SIGBUS signal (SIGBUS, exception_handler); #endif } #endif #include #include #include #include #include int main() { struct rlimit limit; int ret; nocrash_init (); /* Some printf implementations allocate temporary space with malloc. */ /* On BSD systems, malloc() is limited by RLIMIT_DATA. */ #ifdef RLIMIT_DATA if (getrlimit (RLIMIT_DATA, &limit) < 0) return 77; if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) limit.rlim_max = 5000000; limit.rlim_cur = limit.rlim_max; if (setrlimit (RLIMIT_DATA, &limit) < 0) return 77; #endif /* On Linux systems, malloc() is limited by RLIMIT_AS. */ #ifdef RLIMIT_AS if (getrlimit (RLIMIT_AS, &limit) < 0) return 77; if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) limit.rlim_max = 5000000; limit.rlim_cur = limit.rlim_max; if (setrlimit (RLIMIT_AS, &limit) < 0) return 77; #endif /* Some printf implementations allocate temporary space on the stack. */ #ifdef RLIMIT_STACK if (getrlimit (RLIMIT_STACK, &limit) < 0) return 77; if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) limit.rlim_max = 5000000; limit.rlim_cur = limit.rlim_max; if (setrlimit (RLIMIT_STACK, &limit) < 0) return 77; #endif ret = printf ("%.5000000f", 1.0); return !(ret == 5000002 || (ret < 0 && errno == ENOMEM)); } _ACEOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then (./conftest 2>&5 result=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $result" >&5 if test $result != 0 && test $result != 77; then result=1; fi exit $result ) >/dev/null 2>/dev/null case $? in 0) gl_cv_func_printf_enomem="yes" ;; 77) gl_cv_func_printf_enomem="guessing no" ;; *) gl_cv_func_printf_enomem="no" ;; esac else gl_cv_func_printf_enomem="guessing no" fi rm -fr conftest* else gl_cv_func_printf_enomem="guessing no" fi fi if test "$gl_cv_func_printf_enomem" = "guessing no"; then case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_printf_enomem="guessing yes";; # Guess yes on Solaris. solaris*) gl_cv_func_printf_enomem="guessing yes";; # Guess yes on AIX. aix*) gl_cv_func_printf_enomem="guessing yes";; # Guess yes on HP-UX/hppa. hpux*) case "$host_cpu" in hppa*) gl_cv_func_printf_enomem="guessing yes";; *) gl_cv_func_printf_enomem="guessing no";; esac ;; # Guess yes on IRIX. irix*) gl_cv_func_printf_enomem="guessing yes";; # Guess yes on OSF/1. osf*) gl_cv_func_printf_enomem="guessing yes";; # Guess yes on BeOS. beos*) gl_cv_func_printf_enomem="guessing yes";; # Guess yes on Haiku. haiku*) gl_cv_func_printf_enomem="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_printf_enomem="guessing no";; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_enomem" >&5 $as_echo "$gl_cv_func_printf_enomem" >&6; } case "$gl_cv_func_printf_long_double" in *yes) ;; *) $as_echo "#define NEED_PRINTF_LONG_DOUBLE 1" >>confdefs.h ;; esac GNULIB_ISWBLANK=0; GNULIB_WCTYPE=0; GNULIB_ISWCTYPE=0; GNULIB_WCTRANS=0; GNULIB_TOWCTRANS=0; HAVE_ISWBLANK=1; HAVE_WCTYPE_T=1; HAVE_WCTRANS_T=1; REPLACE_ISWBLANK=0; if true; then GL_COND_LIBTOOL_TRUE= GL_COND_LIBTOOL_FALSE='#' else GL_COND_LIBTOOL_TRUE='#' GL_COND_LIBTOOL_FALSE= fi gl_cond_libtool=true gl_m4_base='m4' gl_source_base='lib' LTALLOCA=`echo "$ALLOCA" | sed -e 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'` if test $ac_cv_func_alloca_works = no; then : fi # Define an additional variable used in the Makefile substitution. if test $ac_cv_working_alloca_h = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca as a compiler built-in" >&5 $as_echo_n "checking for alloca as a compiler built-in... " >&6; } if ${gl_cv_rpl_alloca+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined __GNUC__ || defined _AIX || defined _MSC_VER Need own alloca #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Need own alloca" >/dev/null 2>&1; then : gl_cv_rpl_alloca=yes else gl_cv_rpl_alloca=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_rpl_alloca" >&5 $as_echo "$gl_cv_rpl_alloca" >&6; } if test $gl_cv_rpl_alloca = yes; then $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h ALLOCA_H=alloca.h else ALLOCA_H= fi else ALLOCA_H=alloca.h fi if test -n "$ALLOCA_H"; then GL_GENERATE_ALLOCA_H_TRUE= GL_GENERATE_ALLOCA_H_FALSE='#' else GL_GENERATE_ALLOCA_H_TRUE='#' GL_GENERATE_ALLOCA_H_FALSE= fi if test $ac_cv_header_arpa_inet_h = yes; then HAVE_ARPA_INET_H=1 else HAVE_ARPA_INET_H=0 fi if test $gl_cv_have_include_next = yes; then gl_cv_next_arpa_inet_h='<'arpa/inet.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_arpa_inet_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_arpa_inet_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'arpa/inet.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_arpa_inet_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_arpa_inet_h gl_cv_next_arpa_inet_h='"'$gl_header'"' else gl_cv_next_arpa_inet_h='<'arpa/inet.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_arpa_inet_h" >&5 $as_echo "$gl_cv_next_arpa_inet_h" >&6; } fi NEXT_ARPA_INET_H=$gl_cv_next_arpa_inet_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'arpa/inet.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_arpa_inet_h fi NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H=$gl_next_as_first_directive if test $ac_cv_func_btowc = no; then HAVE_BTOWC=0 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether btowc(0) is correct" >&5 $as_echo_n "checking whether btowc(0) is correct... " >&6; } if ${gl_cv_func_btowc_nul+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess no on Cygwin. cygwin*) gl_cv_func_btowc_nul="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_btowc_nul="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { if (btowc ('\0') != 0) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_btowc_nul=yes else gl_cv_func_btowc_nul=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_btowc_nul" >&5 $as_echo "$gl_cv_func_btowc_nul" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether btowc(EOF) is correct" >&5 $as_echo_n "checking whether btowc(EOF) is correct... " >&6; } if ${gl_cv_func_btowc_eof+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on IRIX. irix*) gl_cv_func_btowc_eof="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_btowc_eof="guessing yes" ;; esac if test $LOCALE_FR != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) { if (btowc (EOF) != WEOF) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_btowc_eof=yes else gl_cv_func_btowc_eof=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_btowc_eof" >&5 $as_echo "$gl_cv_func_btowc_eof" >&6; } case "$gl_cv_func_btowc_nul" in *yes) ;; *) REPLACE_BTOWC=1 ;; esac case "$gl_cv_func_btowc_eof" in *yes) ;; *) REPLACE_BTOWC=1 ;; esac fi if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then gl_LIBOBJS="$gl_LIBOBJS btowc.$ac_objext" : fi GNULIB_BTOWC=1 $as_echo "#define GNULIB_TEST_BTOWC 1" >>confdefs.h if test $HAVE_CHOWN = 0 || test $REPLACE_CHOWN = 1; then gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext" fi if test $REPLACE_CHOWN = 1 && test $ac_cv_func_fchown = no; then gl_LIBOBJS="$gl_LIBOBJS fchown-stub.$ac_objext" fi GNULIB_CHOWN=1 $as_echo "#define GNULIB_TEST_CHOWN 1" >>confdefs.h # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all* # programs in the package would end up linked with that potentially-shared # library, inducing unnecessary run-time overhead. LIB_CLOCK_GETTIME= gl_saved_libs=$LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 $as_echo_n "checking for library containing clock_gettime... " >&6; } if ${ac_cv_search_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF for ac_lib in '' rt posix4; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_clock_gettime+:} false; then : break fi done if ${ac_cv_search_clock_gettime+:} false; then : else ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 $as_echo "$ac_cv_search_clock_gettime" >&6; } ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" test "$ac_cv_search_clock_gettime" = "none required" || LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime fi for ac_func in clock_gettime clock_settime do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done LIBS=$gl_saved_libs $as_echo "#define GNULIB_TEST_CLOEXEC 1" >>confdefs.h if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then REPLACE_CLOSE=1 fi if test $ac_cv_header_sys_socket_h != yes; then for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF fi done fi if test "$ac_cv_header_winsock2_h" = yes; then HAVE_WINSOCK2_H=1 UNISTD_H_HAVE_WINSOCK2_H=1 SYS_IOCTL_H_HAVE_WINSOCK2_H=1 else HAVE_WINSOCK2_H=0 fi if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then REPLACE_CLOSE=1 fi if test $REPLACE_CLOSE = 1; then gl_LIBOBJS="$gl_LIBOBJS close.$ac_objext" fi GNULIB_CLOSE=1 $as_echo "#define GNULIB_TEST_CLOSE 1" >>confdefs.h for ac_func in closedir do : ac_fn_c_check_func "$LINENO" "closedir" "ac_cv_func_closedir" if test "x$ac_cv_func_closedir" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CLOSEDIR 1 _ACEOF fi done if test $ac_cv_func_closedir = no; then HAVE_CLOSEDIR=0 fi if test $HAVE_CLOSEDIR = 0 || test $REPLACE_CLOSEDIR = 1; then gl_LIBOBJS="$gl_LIBOBJS closedir.$ac_objext" fi GNULIB_CLOSEDIR=1 $as_echo "#define GNULIB_TEST_CLOSEDIR 1" >>confdefs.h if test "x$datarootdir" = x; then datarootdir='${datadir}' fi if test "x$docdir" = x; then docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' fi if test "x$htmldir" = x; then htmldir='${docdir}' fi if test "x$dvidir" = x; then dvidir='${docdir}' fi if test "x$pdfdir" = x; then pdfdir='${docdir}' fi if test "x$psdir" = x; then psdir='${docdir}' fi if test "x$lispdir" = x; then lispdir='${datarootdir}/emacs/site-lisp' fi if test "x$localedir" = x; then localedir='${datarootdir}/locale' fi if test "x$runstatedir" = x; then runstatedir='${localstatedir}/run' fi pkglibexecdir='${libexecdir}/${PACKAGE}' # Check whether --with-openssl was given. if test "${with_openssl+set}" = set; then : withval=$with_openssl; else with_openssl=$with_openssl_default fi if test "xMD5" = xMD5; then ALG_header=md5.h else ALG_header=sha.h fi if test "x$with_openssl" != xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lcrypto" >&5 $as_echo_n "checking for MD5 in -lcrypto... " >&6; } if ${ac_cv_lib_crypto_MD5+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char MD5 (); int main () { return MD5 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypto_MD5=yes else ac_cv_lib_crypto_MD5=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_MD5" >&5 $as_echo "$ac_cv_lib_crypto_MD5" >&6; } if test "x$ac_cv_lib_crypto_MD5" = xyes; then : for ac_header in openssl/$ALG_header do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF LIB_CRYPTO=-lcrypto $as_echo "#define HAVE_OPENSSL_MD5 1" >>confdefs.h fi done fi if test "x$LIB_CRYPTO" = x; then if test "x$with_openssl" = xyes; then as_fn_error $? "openssl development library not found for MD5" "$LINENO" 5 elif test "x$with_openssl" = xoptional; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: openssl development library not found for MD5" >&5 $as_echo "$as_me: WARNING: openssl development library not found for MD5" >&2;} fi fi fi # Check whether --with-openssl was given. if test "${with_openssl+set}" = set; then : withval=$with_openssl; else with_openssl=$with_openssl_default fi if test "xSHA1" = xMD5; then ALG_header=md5.h else ALG_header=sha.h fi if test "x$with_openssl" != xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SHA1 in -lcrypto" >&5 $as_echo_n "checking for SHA1 in -lcrypto... " >&6; } if ${ac_cv_lib_crypto_SHA1+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char SHA1 (); int main () { return SHA1 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypto_SHA1=yes else ac_cv_lib_crypto_SHA1=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_SHA1" >&5 $as_echo "$ac_cv_lib_crypto_SHA1" >&6; } if test "x$ac_cv_lib_crypto_SHA1" = xyes; then : for ac_header in openssl/$ALG_header do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF LIB_CRYPTO=-lcrypto $as_echo "#define HAVE_OPENSSL_SHA1 1" >>confdefs.h fi done fi if test "x$LIB_CRYPTO" = x; then if test "x$with_openssl" = xyes; then as_fn_error $? "openssl development library not found for SHA1" "$LINENO" 5 elif test "x$with_openssl" = xoptional; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: openssl development library not found for SHA1" >&5 $as_echo "$as_me: WARNING: openssl development library not found for SHA1" >&2;} fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for d_type member in directory struct" >&5 $as_echo_n "checking for d_type member in directory struct... " >&6; } if ${gl_cv_struct_dirent_d_type+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct dirent dp; dp.d_type = 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_struct_dirent_d_type=yes else gl_cv_struct_dirent_d_type=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_struct_dirent_d_type" >&5 $as_echo "$gl_cv_struct_dirent_d_type" >&6; } if test $gl_cv_struct_dirent_d_type = yes; then $as_echo "#define HAVE_STRUCT_DIRENT_D_TYPE 1" >>confdefs.h fi if test $gl_cv_have_include_next = yes; then gl_cv_next_dirent_h='<'dirent.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_dirent_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_dirent_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'dirent.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_dirent_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_dirent_h gl_cv_next_dirent_h='"'$gl_header'"' else gl_cv_next_dirent_h='<'dirent.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_dirent_h" >&5 $as_echo "$gl_cv_next_dirent_h" >&6; } fi NEXT_DIRENT_H=$gl_cv_next_dirent_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'dirent.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_dirent_h fi NEXT_AS_FIRST_DIRECTIVE_DIRENT_H=$gl_next_as_first_directive if test $ac_cv_header_dirent_h = yes; then HAVE_DIRENT_H=1 else HAVE_DIRENT_H=0 fi for ac_func in dirfd do : ac_fn_c_check_func "$LINENO" "dirfd" "ac_cv_func_dirfd" if test "x$ac_cv_func_dirfd" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DIRFD 1 _ACEOF fi done ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "#include #include " if test "x$ac_cv_have_decl_dirfd" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_DIRFD $ac_have_decl _ACEOF if test $ac_cv_have_decl_dirfd = no; then HAVE_DECL_DIRFD=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether dirfd is a macro" >&5 $as_echo_n "checking whether dirfd is a macro... " >&6; } if ${gl_cv_func_dirfd_macro+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifdef dirfd dirent_header_defines_dirfd #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "dirent_header_defines_dirfd" >/dev/null 2>&1; then : gl_cv_func_dirfd_macro=yes else gl_cv_func_dirfd_macro=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_dirfd_macro" >&5 $as_echo "$gl_cv_func_dirfd_macro" >&6; } # Use the replacement only if we have no function or macro with that name. if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then if test $ac_cv_have_decl_dirfd = yes; then # If the system declares dirfd already, let's declare rpl_dirfd instead. REPLACE_DIRFD=1 fi fi if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then gl_LIBOBJS="$gl_LIBOBJS dirfd.$ac_objext" { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to get the file descriptor associated with an open DIR*" >&5 $as_echo_n "checking how to get the file descriptor associated with an open DIR*... " >&6; } if ${gl_cv_sys_dir_fd_member_name+:} false; then : $as_echo_n "(cached) " >&6 else dirfd_save_CFLAGS=$CFLAGS for ac_expr in d_fd dd_fd; do CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : dir_fd_found=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS=$dirfd_save_CFLAGS test "$dir_fd_found" = yes && break done test "$dir_fd_found" = yes || ac_expr=no_such_member gl_cv_sys_dir_fd_member_name=$ac_expr fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_dir_fd_member_name" >&5 $as_echo "$gl_cv_sys_dir_fd_member_name" >&6; } if test $gl_cv_sys_dir_fd_member_name != no_such_member; then cat >>confdefs.h <<_ACEOF #define DIR_FD_MEMBER_NAME $gl_cv_sys_dir_fd_member_name _ACEOF fi fi GNULIB_DIRFD=1 $as_echo "#define GNULIB_TEST_DIRFD 1" >>confdefs.h $as_echo "#define HAVE_DUP2 1" >>confdefs.h if test $HAVE_DUP2 = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether dup2 works" >&5 $as_echo_n "checking whether dup2 works... " >&6; } if ${gl_cv_func_dup2_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in mingw*) # on this platform, dup2 always returns 0 for success gl_cv_func_dup2_works="guessing no" ;; cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 gl_cv_func_dup2_works="guessing no" ;; aix* | freebsd*) # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE, # not EBADF. gl_cv_func_dup2_works="guessing no" ;; haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC. gl_cv_func_dup2_works="guessing no" ;; *-android*) # implemented using dup3(), which fails if oldfd == newfd gl_cv_func_dup2_works="guessing no" ;; *) gl_cv_func_dup2_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include #ifndef RLIM_SAVED_CUR # define RLIM_SAVED_CUR RLIM_INFINITY #endif #ifndef RLIM_SAVED_MAX # define RLIM_SAVED_MAX RLIM_INFINITY #endif int main () { int result = 0; int bad_fd = INT_MAX; struct rlimit rlim; if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX && rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur != RLIM_SAVED_MAX && rlim.rlim_cur != RLIM_SAVED_CUR) bad_fd = rlim.rlim_cur; #ifdef FD_CLOEXEC if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1) result |= 1; #endif if (dup2 (1, 1) != 1) result |= 2; #ifdef FD_CLOEXEC if (fcntl (1, F_GETFD) != FD_CLOEXEC) result |= 4; #endif close (0); if (dup2 (0, 0) != -1) result |= 8; /* Many gnulib modules require POSIX conformance of EBADF. */ if (dup2 (2, bad_fd) == -1 && errno != EBADF) result |= 16; /* Flush out some cygwin core dumps. */ if (dup2 (2, -1) != -1 || errno != EBADF) result |= 32; dup2 (2, 255); dup2 (2, 256); return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_dup2_works=yes else gl_cv_func_dup2_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_dup2_works" >&5 $as_echo "$gl_cv_func_dup2_works" >&6; } case "$gl_cv_func_dup2_works" in *yes) ;; *) REPLACE_DUP2=1 for ac_func in setdtablesize do : ac_fn_c_check_func "$LINENO" "setdtablesize" "ac_cv_func_setdtablesize" if test "x$ac_cv_func_setdtablesize" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SETDTABLESIZE 1 _ACEOF fi done ;; esac fi if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then gl_LIBOBJS="$gl_LIBOBJS dup2.$ac_objext" fi GNULIB_DUP2=1 $as_echo "#define GNULIB_TEST_DUP2 1" >>confdefs.h GNULIB_ENVIRON=1 $as_echo "#define GNULIB_TEST_ENVIRON 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for error_at_line" >&5 $as_echo_n "checking for error_at_line... " >&6; } if ${ac_cv_lib_error_at_line+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { error_at_line (0, 0, "", 0, "an error occurred"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_error_at_line=yes else ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_error_at_line" >&5 $as_echo "$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then gl_LIBOBJS="$gl_LIBOBJS error.$ac_objext" : fi XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS --flag=error:3:c-format" XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS --flag=error_at_line:5:c-format" if test $ac_cv_func_fcntl = no; then if test $ac_cv_func_fcntl = no; then HAVE_FCNTL=0 else REPLACE_FCNTL=1 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl handles F_DUPFD correctly" >&5 $as_echo_n "checking whether fcntl handles F_DUPFD correctly... " >&6; } if ${gl_cv_func_fcntl_f_dupfd_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case $host_os in aix* | cygwin* | haiku*) gl_cv_func_fcntl_f_dupfd_works="guessing no" ;; *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include #ifndef RLIM_SAVED_CUR # define RLIM_SAVED_CUR RLIM_INFINITY #endif #ifndef RLIM_SAVED_MAX # define RLIM_SAVED_MAX RLIM_INFINITY #endif int main () { int result = 0; int bad_fd = INT_MAX; struct rlimit rlim; if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX && rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur != RLIM_SAVED_MAX && rlim.rlim_cur != RLIM_SAVED_CUR) bad_fd = rlim.rlim_cur; if (fcntl (0, F_DUPFD, -1) != -1) result |= 1; if (errno != EINVAL) result |= 2; if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4; if (errno != EINVAL) result |= 8; return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_fcntl_f_dupfd_works=yes else gl_cv_func_fcntl_f_dupfd_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_works" >&5 $as_echo "$gl_cv_func_fcntl_f_dupfd_works" >&6; } case $gl_cv_func_fcntl_f_dupfd_works in *yes) ;; *) if test $ac_cv_func_fcntl = no; then HAVE_FCNTL=0 else REPLACE_FCNTL=1 fi $as_echo "#define FCNTL_DUPFD_BUGGY 1" >>confdefs.h ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl understands F_DUPFD_CLOEXEC" >&5 $as_echo_n "checking whether fcntl understands F_DUPFD_CLOEXEC... " >&6; } if ${gl_cv_func_fcntl_f_dupfd_cloexec+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef F_DUPFD_CLOEXEC choke me #endif int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __linux__ /* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace it to support the semantics on older kernels that failed with EINVAL. */ choke me #endif int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_func_fcntl_f_dupfd_cloexec=yes else gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else gl_cv_func_fcntl_f_dupfd_cloexec=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_cloexec" >&5 $as_echo "$gl_cv_func_fcntl_f_dupfd_cloexec" >&6; } if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then if test $ac_cv_func_fcntl = no; then HAVE_FCNTL=0 else REPLACE_FCNTL=1 fi fi fi if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext" fi GNULIB_FCNTL=1 $as_echo "#define GNULIB_TEST_FCNTL 1" >>confdefs.h if test $gl_cv_have_include_next = yes; then gl_cv_next_fcntl_h='<'fcntl.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_fcntl_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'fcntl.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_fcntl_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_fcntl_h gl_cv_next_fcntl_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_fcntl_h" >&5 $as_echo "$gl_cv_next_fcntl_h" >&6; } fi NEXT_FCNTL_H=$gl_cv_next_fcntl_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'fcntl.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_fcntl_h fi NEXT_AS_FIRST_DIRECTIVE_FCNTL_H=$gl_next_as_first_directive FLOAT_H= REPLACE_FLOAT_LDBL=0 case "$host_os" in aix* | beos* | openbsd* | mirbsd* | irix*) FLOAT_H=float.h ;; freebsd*) case "$host_cpu" in i[34567]86 ) FLOAT_H=float.h ;; x86_64 ) # On x86_64 systems, the C compiler may still be generating # 32-bit code. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined __LP64__ || defined __x86_64__ || defined __amd64__ yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : else FLOAT_H=float.h fi rm -f conftest* ;; esac ;; linux*) case "$host_cpu" in powerpc*) FLOAT_H=float.h ;; esac ;; esac case "$host_os" in aix* | freebsd* | linux*) if test -n "$FLOAT_H"; then REPLACE_FLOAT_LDBL=1 fi ;; esac REPLACE_ITOLD=0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether conversion from 'int' to 'long double' works" >&5 $as_echo_n "checking whether conversion from 'int' to 'long double' works... " >&6; } if ${gl_cv_func_itold_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host" in sparc*-*-linux*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined __LP64__ || defined __arch64__ yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : gl_cv_func_itold_works="guessing no" else gl_cv_func_itold_works="guessing yes" fi rm -f conftest* ;; *) gl_cv_func_itold_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int i = -1; volatile long double ld; int main () { ld += i * 1.0L; if (ld > 0) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_itold_works=yes else gl_cv_func_itold_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_itold_works" >&5 $as_echo "$gl_cv_func_itold_works" >&6; } case "$gl_cv_func_itold_works" in *no) REPLACE_ITOLD=1 FLOAT_H=float.h ;; esac if test -n "$FLOAT_H"; then if test $gl_cv_have_include_next = yes; then gl_cv_next_float_h='<'float.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_float_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'float.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_float_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_float_h gl_cv_next_float_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_float_h" >&5 $as_echo "$gl_cv_next_float_h" >&6; } fi NEXT_FLOAT_H=$gl_cv_next_float_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'float.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_float_h fi NEXT_AS_FIRST_DIRECTIVE_FLOAT_H=$gl_next_as_first_directive fi if test -n "$FLOAT_H"; then GL_GENERATE_FLOAT_H_TRUE= GL_GENERATE_FLOAT_H_FALSE='#' else GL_GENERATE_FLOAT_H_TRUE='#' GL_GENERATE_FLOAT_H_FALSE= fi if test $REPLACE_FLOAT_LDBL = 1; then gl_LIBOBJS="$gl_LIBOBJS float.$ac_objext" fi if test $REPLACE_ITOLD = 1; then gl_LIBOBJS="$gl_LIBOBJS itold.$ac_objext" fi FNMATCH_H= gl_fnmatch_required_lowercase=` echo $gl_fnmatch_required | LC_ALL=C tr '[A-Z]' '[a-z]' ` gl_fnmatch_cache_var="gl_cv_func_fnmatch_${gl_fnmatch_required_lowercase}" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working $gl_fnmatch_required fnmatch" >&5 $as_echo_n "checking for working $gl_fnmatch_required fnmatch... " >&6; } if eval \${$gl_fnmatch_cache_var+:} false; then : $as_echo_n "(cached) " >&6 else if test $gl_fnmatch_required = GNU; then gl_fnmatch_gnu_start= gl_fnmatch_gnu_end= else gl_fnmatch_gnu_start='#if 0' gl_fnmatch_gnu_end='#endif' fi if test "$cross_compiling" = yes; then : eval "$gl_fnmatch_cache_var=\"guessing no\"" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include static int y (char const *pattern, char const *string, int flags) { return fnmatch (pattern, string, flags) == 0; } static int n (char const *pattern, char const *string, int flags) { return fnmatch (pattern, string, flags) == FNM_NOMATCH; } int main () { char const *Apat = 'A' < '\\\\' ? "[A-\\\\\\\\]" : "[\\\\\\\\-A]"; char const *apat = 'a' < '\\\\' ? "[a-\\\\\\\\]" : "[\\\\\\\\-a]"; static char const A_1[] = { 'A' - 1, 0 }; static char const A01[] = { 'A' + 1, 0 }; static char const a_1[] = { 'a' - 1, 0 }; static char const a01[] = { 'a' + 1, 0 }; static char const bs_1[] = { '\\\\' - 1, 0 }; static char const bs01[] = { '\\\\' + 1, 0 }; int result = 0; if (!n ("a*", "", 0)) return 1; if (!y ("a*", "abc", 0)) return 1; if (!y ("[/b", "[/b", 0)) /*"]]"*/ /* glibc Bugzilla bug 12378 */ return 1; if (!n ("d*/*1", "d/s/1", FNM_PATHNAME)) return 2; if (!y ("a\\\\bc", "abc", 0)) return 3; if (!n ("a\\\\bc", "abc", FNM_NOESCAPE)) return 3; if (!y ("*x", ".x", 0)) return 4; if (!n ("*x", ".x", FNM_PERIOD)) return 4; if (!y (Apat, "\\\\", 0)) return 5; if (!y (Apat, "A", 0)) return 5; if (!y (apat, "\\\\", 0)) return 5; if (!y (apat, "a", 0)) return 5; if (!(n (Apat, A_1, 0) == ('A' < '\\\\'))) return 5; if (!(n (apat, a_1, 0) == ('a' < '\\\\'))) return 5; if (!(y (Apat, A01, 0) == ('A' < '\\\\'))) return 5; if (!(y (apat, a01, 0) == ('a' < '\\\\'))) return 5; if (!(y (Apat, bs_1, 0) == ('A' < '\\\\'))) return 5; if (!(y (apat, bs_1, 0) == ('a' < '\\\\'))) return 5; if (!(n (Apat, bs01, 0) == ('A' < '\\\\'))) return 5; if (!(n (apat, bs01, 0) == ('a' < '\\\\'))) return 5; $gl_fnmatch_gnu_start if (!y ("xxXX", "xXxX", FNM_CASEFOLD)) result |= 8; if (!y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)) result |= 16; if (!n ("d*/*1", "d/s/1", FNM_FILE_NAME)) result |= 32; if (!y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)) result |= 64; if (!y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)) result |= 64; if (!y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)) result |= 64; $gl_fnmatch_gnu_end return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : eval "$gl_fnmatch_cache_var=yes" else eval "$gl_fnmatch_cache_var=no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi eval ac_res=\$$gl_fnmatch_cache_var { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval "gl_fnmatch_result=\"\$$gl_fnmatch_cache_var\"" if test "$gl_fnmatch_result" = yes; then rm -f "$gl_source_base/fnmatch.h" else FNMATCH_H=fnmatch.h fi if test -n "$FNMATCH_H"; then GL_GENERATE_FNMATCH_H_TRUE= GL_GENERATE_FNMATCH_H_FALSE='#' else GL_GENERATE_FNMATCH_H_TRUE='#' GL_GENERATE_FNMATCH_H_FALSE= fi if test -n "$FNMATCH_H"; then gl_LIBOBJS="$gl_LIBOBJS fnmatch.$ac_objext" cat >>confdefs.h <<_ACEOF #define fnmatch ${gl_fnmatch_required_lowercase}_fnmatch _ACEOF ac_fn_c_check_decl "$LINENO" "isblank" "ac_cv_have_decl_isblank" "#include " if test "x$ac_cv_have_decl_isblank" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ISBLANK $ac_have_decl _ACEOF fi if test -n "$FNMATCH_H"; then gl_LIBOBJS="$gl_LIBOBJS fnmatch.$ac_objext" cat >>confdefs.h <<_ACEOF #define fnmatch ${gl_fnmatch_required_lowercase}_fnmatch _ACEOF ac_fn_c_check_decl "$LINENO" "isblank" "ac_cv_have_decl_isblank" "#include " if test "x$ac_cv_have_decl_isblank" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ISBLANK $ac_have_decl _ACEOF fi if test $gl_cv_func_frexp_no_libm = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether frexp works" >&5 $as_echo_n "checking whether frexp works... " >&6; } if ${gl_cv_func_frexp_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in netbsd* | irix* | mingw*) gl_cv_func_frexp_works="guessing no";; *) gl_cv_func_frexp_works="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #if HAVE_DECL_ALARM # include # include #endif /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. ICC 10.0 has a bug when optimizing the expression -zero. The expression -DBL_MIN * DBL_MIN does not work when cross-compiling to PowerPC on Mac OS X 10.5. */ #if defined __hpux || defined __sgi || defined __ICC static double compute_minus_zero (void) { return -DBL_MIN * DBL_MIN; } # define minus_zero compute_minus_zero () #else double minus_zero = -0.0; #endif int main() { int result = 0; int i; volatile double x; double zero = 0.0; #if HAVE_DECL_ALARM /* NeXTstep 3.3 frexp() runs into an endless loop when called on an infinite number. Let the test fail in this case. */ signal (SIGALRM, SIG_DFL); alarm (5); #endif /* Test on denormalized numbers. */ for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5) ; if (x > 0.0) { int exp; double y = frexp (x, &exp); /* On machines with IEEE754 arithmetic: x = 1.11254e-308, exp = -1022. On NetBSD: y = 0.75. Correct: y = 0.5. */ if (y != 0.5) result |= 1; } /* Test on infinite numbers. */ x = 1.0 / zero; { int exp; double y = frexp (x, &exp); if (y != x) result |= 2; } /* Test on negative zero. */ x = minus_zero; { int exp; double y = frexp (x, &exp); if (memcmp (&y, &x, sizeof x)) result |= 4; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_frexp_works=yes else gl_cv_func_frexp_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_frexp_works" >&5 $as_echo "$gl_cv_func_frexp_works" >&6; } case "$gl_cv_func_frexp_works" in *yes) gl_func_frexp_no_libm=yes ;; *) gl_func_frexp_no_libm=no; REPLACE_FREXP=1 ;; esac else gl_func_frexp_no_libm=no REPLACE_FREXP=1 fi if test $gl_func_frexp_no_libm = yes; then $as_echo "#define HAVE_FREXP_IN_LIBC 1" >>confdefs.h fi if test $gl_func_frexp_no_libm != yes; then gl_LIBOBJS="$gl_LIBOBJS frexp.$ac_objext" fi GNULIB_FREXP=1 $as_echo "#define GNULIB_TEST_FREXP 1" >>confdefs.h ac_fn_c_check_decl "$LINENO" "frexpl" "ac_cv_have_decl_frexpl" "#include " if test "x$ac_cv_have_decl_frexpl" = xyes; then : else HAVE_DECL_FREXPL=0 fi if test $HAVE_DECL_FREXPL = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether frexpl() can be used without linking with libm" >&5 $as_echo_n "checking whether frexpl() can be used without linking with libm... " >&6; } if ${gl_cv_func_frexpl_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include long double x; int main () { int e; return frexpl (x, &e) > 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_frexpl_no_libm=yes else gl_cv_func_frexpl_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_frexpl_no_libm" >&5 $as_echo "$gl_cv_func_frexpl_no_libm" >&6; } if test $gl_cv_func_frexpl_no_libm = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether frexpl works" >&5 $as_echo_n "checking whether frexpl works... " >&6; } if ${gl_cv_func_frexpl_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in aix | aix[3-6]* | beos* | darwin* | irix* | mingw* | pw*) gl_cv_func_frexpl_works="guessing no";; *) gl_cv_func_frexpl_works="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Override the values of , like done in float.in.h. */ #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) # undef LDBL_MIN_EXP # define LDBL_MIN_EXP (-16381) #endif #if defined __i386__ && defined __FreeBSD__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP (-16381) #endif #if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP #endif #if defined __sgi && (LDBL_MANT_DIG >= 106) # if defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP # endif #endif extern #ifdef __cplusplus "C" #endif long double frexpl (long double, int *); int main() { int result = 0; volatile long double x; /* Test on finite numbers that fails on AIX 5.1. */ x = 16.0L; { int exp = -9999; frexpl (x, &exp); if (exp != 5) result |= 1; } /* Test on finite numbers that fails on Mac OS X 10.4, because its frexpl function returns an invalid (incorrectly normalized) value: it returns y = { 0x3fe028f5, 0xc28f5c28, 0x3c9eb851, 0xeb851eb8 } but the correct result is 0.505L = { 0x3fe028f5, 0xc28f5c29, 0xbc547ae1, 0x47ae1480 } */ x = 1.01L; { int exp = -9999; long double y = frexpl (x, &exp); if (!(exp == 1 && y == 0.505L)) result |= 2; } /* Test on large finite numbers. This fails on BeOS at i = 16322, while LDBL_MAX_EXP = 16384. In the loop end test, we test x against Infinity, rather than comparing i with LDBL_MAX_EXP, because BeOS has a wrong LDBL_MAX_EXP. */ { int i; for (i = 1, x = 1.0L; x != x + x; i++, x *= 2.0L) { int exp = -9999; frexpl (x, &exp); if (exp != i) { result |= 4; break; } } } /* Test on denormalized numbers. */ { int i; for (i = 1, x = 1.0L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) ; if (x > 0.0L) { int exp; long double y = frexpl (x, &exp); /* On machines with IEEE854 arithmetic: x = 1.68105e-4932, exp = -16382, y = 0.5. On Mac OS X 10.5: exp = -16384, y = 0.5. */ if (exp != LDBL_MIN_EXP - 1) result |= 8; } } /* Test on infinite numbers. */ x = 1.0L / 0.0L; { int exp; long double y = frexpl (x, &exp); if (y != x) result |= 16; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_frexpl_works=yes else gl_cv_func_frexpl_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_frexpl_works" >&5 $as_echo "$gl_cv_func_frexpl_works" >&6; } case "$gl_cv_func_frexpl_works" in *yes) gl_func_frexpl_no_libm=yes ;; *) gl_func_frexpl_no_libm=no; REPLACE_FREXPL=1 ;; esac else gl_func_frexpl_no_libm=no REPLACE_FREXPL=1 fi if test $gl_func_frexpl_no_libm = yes; then $as_echo "#define HAVE_FREXPL_IN_LIBC 1" >>confdefs.h fi fi if test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl_no_libm = no; then gl_LIBOBJS="$gl_LIBOBJS frexpl.$ac_objext" fi GNULIB_FREXPL=1 $as_echo "#define GNULIB_TEST_FREXPL 1" >>confdefs.h if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then REPLACE_FSTAT=1 fi if test $WINDOWS_64_BIT_ST_SIZE = 1; then REPLACE_FSTAT=1 fi if test $REPLACE_FSTAT = 1; then gl_LIBOBJS="$gl_LIBOBJS fstat.$ac_objext" : fi GNULIB_FSTAT=1 $as_echo "#define GNULIB_TEST_FSTAT 1" >>confdefs.h if test $ac_cv_func_getdtablesize = yes && test $ac_cv_have_decl_getdtablesize = yes; then # Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit # up to an unchangeable hard limit; all other platforms correctly # require setrlimit before getdtablesize() can report a larger value. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getdtablesize works" >&5 $as_echo_n "checking whether getdtablesize works... " >&6; } if ${gl_cv_func_getdtablesize_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows gl_cv_func_getdtablesize_works="guessing no" ;; *) gl_cv_func_getdtablesize_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int size = getdtablesize(); if (dup2 (0, getdtablesize()) != -1) return 1; if (size != getdtablesize()) return 2; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_getdtablesize_works=yes else gl_cv_func_getdtablesize_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getdtablesize_works" >&5 $as_echo "$gl_cv_func_getdtablesize_works" >&6; } case "$gl_cv_func_getdtablesize_works" in *yes) ;; *) REPLACE_GETDTABLESIZE=1 ;; esac else HAVE_GETDTABLESIZE=0 fi if test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1; then gl_LIBOBJS="$gl_LIBOBJS getdtablesize.$ac_objext" : fi GNULIB_GETDTABLESIZE=1 $as_echo "#define GNULIB_TEST_GETDTABLESIZE 1" >>confdefs.h if test $ac_cv_have_decl_getlogin_r = no; then HAVE_DECL_GETLOGIN_R=0 fi if test $ac_cv_func_getlogin_r = no; then HAVE_GETLOGIN_R=0 else HAVE_GETLOGIN_R=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getlogin_r works with small buffers" >&5 $as_echo_n "checking whether getlogin_r works with small buffers... " >&6; } if ${gl_cv_func_getlogin_r_works+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on OSF/1. osf*) gl_cv_func_getlogin_r_works="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_getlogin_r_works="guessing yes" ;; esac if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if !HAVE_DECL_GETLOGIN_R extern # ifdef __cplusplus "C" # endif int getlogin_r (char *, size_t); #endif int main (void) { int result = 0; char buf[100]; if (getlogin_r (buf, 0) == 0) result |= 16; if (getlogin_r (buf, 1) == 0) result |= 17; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_getlogin_r_works=yes else case $? in 16 | 17) gl_cv_func_getlogin_r_works=no ;; esac fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getlogin_r_works" >&5 $as_echo "$gl_cv_func_getlogin_r_works" >&6; } case "$gl_cv_func_getlogin_r_works" in *yes) ;; *) REPLACE_GETLOGIN_R=1 ;; esac fi if test $HAVE_GETLOGIN_R = 0 || test $REPLACE_GETLOGIN_R = 1; then gl_LIBOBJS="$gl_LIBOBJS getlogin_r.$ac_objext" fi GNULIB_GETLOGIN_R=1 $as_echo "#define GNULIB_TEST_GETLOGIN_R 1" >>confdefs.h if test $REPLACE_GETOPT = 1; then gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext" GNULIB_GL_UNISTD_H_GETOPT=1 fi $as_echo "#define GNULIB_TEST_GETOPT_GNU 1" >>confdefs.h REPLACE_GETOPT=0 if test -n "$gl_replace_getopt"; then REPLACE_GETOPT=1 fi if test $REPLACE_GETOPT = 1; then GETOPT_H=getopt.h $as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h fi if test $REPLACE_GETOPT = 1; then gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext" GNULIB_GL_UNISTD_H_GETOPT=1 fi gl_gettimeofday_timezone=void if test $ac_cv_func_gettimeofday != yes; then HAVE_GETTIMEOFDAY=0 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gettimeofday clobbers localtime buffer" >&5 $as_echo_n "checking whether gettimeofday clobbers localtime buffer... " >&6; } if ${gl_cv_func_gettimeofday_clobber+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : # When cross-compiling: case "$host_os" in # Guess all is fine on glibc systems. *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;; # If we don't know, assume the worst. *) gl_cv_func_gettimeofday_clobber="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { time_t t = 0; struct tm *lt; struct tm saved_lt; struct timeval tv; lt = localtime (&t); saved_lt = *lt; gettimeofday (&tv, NULL); return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_gettimeofday_clobber=no else gl_cv_func_gettimeofday_clobber=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_gettimeofday_clobber" >&5 $as_echo "$gl_cv_func_gettimeofday_clobber" >&6; } case "$gl_cv_func_gettimeofday_clobber" in *yes) REPLACE_GETTIMEOFDAY=1 REPLACE_GMTIME=1 REPLACE_LOCALTIME=1 $as_echo "#define GETTIMEOFDAY_CLOBBERS_LOCALTIME 1" >>confdefs.h ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettimeofday with POSIX signature" >&5 $as_echo_n "checking for gettimeofday with POSIX signature... " >&6; } if ${gl_cv_func_gettimeofday_posix_signature+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include struct timeval c; int gettimeofday (struct timeval *restrict, void *restrict); int main () { /* glibc uses struct timezone * rather than the POSIX void * if _GNU_SOURCE is defined. However, since the only portable use of gettimeofday uses NULL as the second parameter, and since the glibc definition is actually more typesafe, it is not worth wrapping this to get a compliant signature. */ int (*f) (struct timeval *restrict, void *restrict) = gettimeofday; int x = f (&c, 0); return !(x | c.tv_sec | c.tv_usec); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_func_gettimeofday_posix_signature=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int gettimeofday (struct timeval *restrict, struct timezone *restrict); int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_func_gettimeofday_posix_signature=almost else gl_cv_func_gettimeofday_posix_signature=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_gettimeofday_posix_signature" >&5 $as_echo "$gl_cv_func_gettimeofday_posix_signature" >&6; } if test $gl_cv_func_gettimeofday_posix_signature = almost; then gl_gettimeofday_timezone='struct timezone' elif test $gl_cv_func_gettimeofday_posix_signature != yes; then REPLACE_GETTIMEOFDAY=1 fi if test $REPLACE_STRUCT_TIMEVAL = 1; then REPLACE_GETTIMEOFDAY=1 fi fi cat >>confdefs.h <<_ACEOF #define GETTIMEOFDAY_TIMEZONE $gl_gettimeofday_timezone _ACEOF if test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1; then gl_LIBOBJS="$gl_LIBOBJS gettimeofday.$ac_objext" for ac_header in sys/timeb.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/timeb.h" "ac_cv_header_sys_timeb_h" "$ac_includes_default" if test "x$ac_cv_header_sys_timeb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_TIMEB_H 1 _ACEOF fi done for ac_func in _ftime do : ac_fn_c_check_func "$LINENO" "_ftime" "ac_cv_func__ftime" if test "x$ac_cv_func__ftime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__FTIME 1 _ACEOF fi done fi GNULIB_GETTIMEOFDAY=1 $as_echo "#define GNULIB_TEST_GETTIMEOFDAY 1" >>confdefs.h GLOB_H= for ac_header in glob.h do : ac_fn_c_check_header_mongrel "$LINENO" "glob.h" "ac_cv_header_glob_h" "$ac_includes_default" if test "x$ac_cv_header_glob_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GLOB_H 1 _ACEOF else GLOB_H=glob.h fi done if test -z "$GLOB_H"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU glob interface version 1" >&5 $as_echo_n "checking for GNU glob interface version 1... " >&6; } if ${gl_cv_gnu_glob_interface_version_1+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1]; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_gnu_glob_interface_version_1=yes else gl_cv_gnu_glob_interface_version_1=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_gnu_glob_interface_version_1" >&5 $as_echo "$gl_cv_gnu_glob_interface_version_1" >&6; } if test "$gl_cv_gnu_glob_interface_version_1" = "no"; then GLOB_H=glob.h fi fi if test -z "$GLOB_H"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether glob lists broken symlinks" >&5 $as_echo_n "checking whether glob lists broken symlinks... " >&6; } if ${gl_cv_glob_lists_symlinks+:} false; then : $as_echo_n "(cached) " >&6 else if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then gl_cv_glob_lists_symlinks=maybe else # If we can't make a symlink, then we cannot test this issue. Be # pessimistic about this. gl_cv_glob_lists_symlinks=no fi if test $gl_cv_glob_lists_symlinks = maybe; then if test "$cross_compiling" = yes; then : gl_cv_glob_lists_symlinks=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { glob_t found; if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_glob_lists_symlinks=yes else gl_cv_glob_lists_symlinks=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_glob_lists_symlinks" >&5 $as_echo "$gl_cv_glob_lists_symlinks" >&6; } if test $gl_cv_glob_lists_symlinks = no; then GLOB_H=glob.h fi fi rm -f conf$$-globtest if test -n "$GLOB_H"; then GL_GENERATE_GLOB_H_TRUE= GL_GENERATE_GLOB_H_FALSE='#' else GL_GENERATE_GLOB_H_TRUE='#' GL_GENERATE_GLOB_H_FALSE= fi if test -n "$GLOB_H"; then gl_LIBOBJS="$gl_LIBOBJS glob.$ac_objext" if test $ac_cv_header_sys_cdefs_h = yes; then HAVE_SYS_CDEFS_H=1 else HAVE_SYS_CDEFS_H=0 fi fi : GNULIB_ICONV=1 if test $gl_cv_have_include_next = yes; then gl_cv_next_iconv_h='<'iconv.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_iconv_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_iconv_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'iconv.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_iconv_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_iconv_h gl_cv_next_iconv_h='"'$gl_header'"' else gl_cv_next_iconv_h='<'iconv.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_iconv_h" >&5 $as_echo "$gl_cv_next_iconv_h" >&6; } fi NEXT_ICONV_H=$gl_cv_next_iconv_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'iconv.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_iconv_h fi NEXT_AS_FIRST_DIRECTIVE_ICONV_H=$gl_next_as_first_directive if test "$am_cv_func_iconv" = yes; then ICONV_H='iconv.h' if test -n "$ICONV_H"; then GL_GENERATE_ICONV_H_TRUE= GL_GENERATE_ICONV_H_FALSE='#' else GL_GENERATE_ICONV_H_TRUE='#' GL_GENERATE_ICONV_H_FALSE= fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) gnu_iconv #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "gnu_iconv" >/dev/null 2>&1; then : gl_func_iconv_gnu=yes else gl_func_iconv_gnu=no fi rm -f conftest* if test $gl_func_iconv_gnu = no; then iconv_flavor= case "$host_os" in aix*) iconv_flavor=ICONV_FLAVOR_AIX ;; irix*) iconv_flavor=ICONV_FLAVOR_IRIX ;; hpux*) iconv_flavor=ICONV_FLAVOR_HPUX ;; osf*) iconv_flavor=ICONV_FLAVOR_OSF ;; solaris*) iconv_flavor=ICONV_FLAVOR_SOLARIS ;; esac if test -n "$iconv_flavor"; then cat >>confdefs.h <<_ACEOF #define ICONV_FLAVOR $iconv_flavor _ACEOF ICONV_H='iconv.h' if test -n "$ICONV_H"; then GL_GENERATE_ICONV_H_TRUE= GL_GENERATE_ICONV_H_FALSE='#' else GL_GENERATE_ICONV_H_TRUE='#' GL_GENERATE_ICONV_H_FALSE= fi REPLACE_ICONV_OPEN=1 fi fi fi if test $REPLACE_ICONV_OPEN = 1; then gl_LIBOBJS="$gl_LIBOBJS iconv_open.$ac_objext" fi if test $REPLACE_ICONV = 1; then gl_LIBOBJS="$gl_LIBOBJS iconv.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS iconv_close.$ac_objext" fi HAVE_INET_PTON=1 INET_PTON_LIB= if test $ac_cv_header_sys_socket_h != yes; then for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF fi done fi if test "$ac_cv_header_winsock2_h" = yes; then HAVE_WINSOCK2_H=1 UNISTD_H_HAVE_WINSOCK2_H=1 SYS_IOCTL_H_HAVE_WINSOCK2_H=1 else HAVE_WINSOCK2_H=0 fi if test $HAVE_WINSOCK2_H = 1; then ac_fn_c_check_decl "$LINENO" "inet_pton" "ac_cv_have_decl_inet_pton" "#include " if test "x$ac_cv_have_decl_inet_pton" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_INET_PTON $ac_have_decl _ACEOF if test $ac_cv_have_decl_inet_pton = yes; then REPLACE_INET_PTON=1 INET_PTON_LIB="-lws2_32" else HAVE_DECL_INET_PTON=0 HAVE_INET_PTON=0 fi else gl_save_LIBS=$LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_pton" >&5 $as_echo_n "checking for library containing inet_pton... " >&6; } if ${ac_cv_search_inet_pton+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char inet_pton (); int main () { return inet_pton (); ; return 0; } _ACEOF for ac_lib in '' nsl resolv; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_inet_pton=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_inet_pton+:} false; then : break fi done if ${ac_cv_search_inet_pton+:} false; then : else ac_cv_search_inet_pton=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_pton" >&5 $as_echo "$ac_cv_search_inet_pton" >&6; } ac_res=$ac_cv_search_inet_pton if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else for ac_func in inet_pton do : ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton" if test "x$ac_cv_func_inet_pton" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_INET_PTON 1 _ACEOF fi done if test $ac_cv_func_inet_pton = no; then HAVE_INET_PTON=0 fi fi LIBS=$gl_save_LIBS if test "$ac_cv_search_inet_pton" != "no" \ && test "$ac_cv_search_inet_pton" != "none required"; then INET_PTON_LIB="$ac_cv_search_inet_pton" fi ac_fn_c_check_decl "$LINENO" "inet_pton" "ac_cv_have_decl_inet_pton" "#include #if HAVE_NETDB_H # include #endif " if test "x$ac_cv_have_decl_inet_pton" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_INET_PTON $ac_have_decl _ACEOF if test $ac_cv_have_decl_inet_pton = no; then HAVE_DECL_INET_PTON=0 fi fi if test $HAVE_INET_PTON = 0 || test $REPLACE_INET_NTOP = 1; then gl_LIBOBJS="$gl_LIBOBJS inet_pton.$ac_objext" fi GNULIB_INET_PTON=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler generally respects inline" >&5 $as_echo_n "checking whether the compiler generally respects inline... " >&6; } if ${gl_cv_c_inline_effective+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_c_inline = no; then gl_cv_c_inline_effective=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifdef __NO_INLINE__ #error "inline is not effective" #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_c_inline_effective=yes else gl_cv_c_inline_effective=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_c_inline_effective" >&5 $as_echo "$gl_cv_c_inline_effective" >&6; } if test $gl_cv_c_inline_effective = yes; then $as_echo "#define HAVE_INLINE 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether isnan(double) can be used without linking with libm" >&5 $as_echo_n "checking whether isnan(double) can be used without linking with libm... " >&6; } if ${gl_cv_func_isnand_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if __GNUC__ >= 4 # undef isnand # define isnand(x) __builtin_isnan ((double)(x)) #else # undef isnand # define isnand(x) isnan ((double)(x)) #endif double x; int main () { return isnand (x); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_isnand_no_libm=yes else gl_cv_func_isnand_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_isnand_no_libm" >&5 $as_echo "$gl_cv_func_isnand_no_libm" >&6; } gl_func_isnand_no_libm=$gl_cv_func_isnand_no_libm if test $gl_cv_func_isnand_no_libm = yes; then $as_echo "#define HAVE_ISNAND_IN_LIBC 1" >>confdefs.h fi if test $gl_func_isnand_no_libm != yes; then gl_LIBOBJS="$gl_LIBOBJS isnand.$ac_objext" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether isnan(float) can be used without linking with libm" >&5 $as_echo_n "checking whether isnan(float) can be used without linking with libm... " >&6; } if ${gl_cv_func_isnanf_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if __GNUC__ >= 4 # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) #elif defined isnan # undef isnanf # define isnanf(x) isnan ((float)(x)) #endif float x; int main () { return isnanf (x); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_isnanf_no_libm=yes else gl_cv_func_isnanf_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_isnanf_no_libm" >&5 $as_echo "$gl_cv_func_isnanf_no_libm" >&6; } if test $gl_cv_func_isnanf_no_libm = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether isnan(float) works" >&5 $as_echo_n "checking whether isnan(float) works... " >&6; } if ${gl_cv_func_isnanf_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in irix* | solaris*) gl_cv_func_isnanf_works="guessing no";; *) gl_cv_func_isnanf_works="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if __GNUC__ >= 4 # undef isnanf # define isnanf(x) __builtin_isnanf ((float)(x)) #elif defined isnan # undef isnanf # define isnanf(x) isnan ((float)(x)) #endif /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ #ifdef __DECC static float NaN () { static float zero = 0.0f; return zero / zero; } #else # define NaN() (0.0f / 0.0f) #endif #define NWORDS \ ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { unsigned int word[NWORDS]; float value; } memory_float; int main() { int result = 0; if (isnanf (1.0f / 0.0f)) result |= 1; if (!isnanf (NaN ())) result |= 2; #if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT /* The isnanf function should be immune against changes in the sign bit and in the mantissa bits. The xor operation twiddles a bit that can only be a sign bit or a mantissa bit. */ if (FLT_EXPBIT0_WORD == 0 && FLT_EXPBIT0_BIT > 0) { memory_float m; m.value = NaN (); /* Set the bits below the exponent to 01111...111. */ m.word[0] &= -1U << FLT_EXPBIT0_BIT; m.word[0] |= 1U << (FLT_EXPBIT0_BIT - 1) - 1; if (!isnanf (m.value)) result |= 4; } #endif return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_isnanf_works=yes else gl_cv_func_isnanf_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_isnanf_works" >&5 $as_echo "$gl_cv_func_isnanf_works" >&6; } fi if test $gl_cv_func_isnanf_no_libm = yes \ && { case "$gl_cv_func_isnanf_works" in *yes) true;; *) false;; esac }; then gl_func_isnanf_no_libm=yes $as_echo "#define HAVE_ISNANF_IN_LIBC 1" >>confdefs.h else gl_func_isnanf_no_libm=no fi if test $gl_func_isnanf_no_libm != yes; then gl_LIBOBJS="$gl_LIBOBJS isnanf.$ac_objext" { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the exponent in a 'float'" >&5 $as_echo_n "checking where to find the exponent in a 'float'... " >&6; } if ${gl_cv_cc_float_expbit0+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_cc_float_expbit0="word 0 bit 23" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #define NWORDS \ ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { float value; unsigned int word[NWORDS]; } memory_float; static unsigned int ored_words[NWORDS]; static unsigned int anded_words[NWORDS]; static void add_to_ored_words (float x) { memory_float m; size_t i; /* Clear it first, in case sizeof (float) < sizeof (memory_float). */ memset (&m, 0, sizeof (memory_float)); m.value = x; for (i = 0; i < NWORDS; i++) { ored_words[i] |= m.word[i]; anded_words[i] &= m.word[i]; } } int main () { size_t j; FILE *fp = fopen ("conftest.out", "w"); if (fp == NULL) return 1; for (j = 0; j < NWORDS; j++) anded_words[j] = ~ (unsigned int) 0; add_to_ored_words (0.25f); add_to_ored_words (0.5f); add_to_ored_words (1.0f); add_to_ored_words (2.0f); add_to_ored_words (4.0f); /* Remove bits that are common (e.g. if representation of the first mantissa bit is explicit). */ for (j = 0; j < NWORDS; j++) ored_words[j] &= ~anded_words[j]; /* Now find the nonzero word. */ for (j = 0; j < NWORDS; j++) if (ored_words[j] != 0) break; if (j < NWORDS) { size_t i; for (i = j + 1; i < NWORDS; i++) if (ored_words[i] != 0) { fprintf (fp, "unknown"); return (fclose (fp) != 0); } for (i = 0; ; i++) if ((ored_words[j] >> i) & 1) { fprintf (fp, "word %d bit %d", (int) j, (int) i); return (fclose (fp) != 0); } } fprintf (fp, "unknown"); return (fclose (fp) != 0); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_cc_float_expbit0=`cat conftest.out` else gl_cv_cc_float_expbit0="unknown" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_float_expbit0" >&5 $as_echo "$gl_cv_cc_float_expbit0" >&6; } case "$gl_cv_cc_float_expbit0" in word*bit*) word=`echo "$gl_cv_cc_float_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` bit=`echo "$gl_cv_cc_float_expbit0" | sed -e 's/word.*bit //'` cat >>confdefs.h <<_ACEOF #define FLT_EXPBIT0_WORD $word _ACEOF cat >>confdefs.h <<_ACEOF #define FLT_EXPBIT0_BIT $bit _ACEOF ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether isnan(long double) can be used without linking with libm" >&5 $as_echo_n "checking whether isnan(long double) can be used without linking with libm... " >&6; } if ${gl_cv_func_isnanl_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if __GNUC__ >= 4 # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) #elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) #endif long double x; int main () { return isnanl (x); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_isnanl_no_libm=yes else gl_cv_func_isnanl_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_isnanl_no_libm" >&5 $as_echo "$gl_cv_func_isnanl_no_libm" >&6; } gl_func_isnanl_no_libm=$gl_cv_func_isnanl_no_libm if test $gl_func_isnanl_no_libm = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether isnanl works" >&5 $as_echo_n "checking whether isnanl works... " >&6; } if ${gl_cv_func_isnanl_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_func_isnanl_works="guessing yes" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #if __GNUC__ >= 4 # undef isnanl # define isnanl(x) __builtin_isnanl ((long double)(x)) #elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) #endif #define NWORDS \ ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { unsigned int word[NWORDS]; long double value; } memory_long_double; /* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the runtime type conversion. */ #ifdef __sgi static long double NaNl () { double zero = 0.0; return zero / zero; } #else # define NaNl() (0.0L / 0.0L) #endif int main () { int result = 0; if (!isnanl (NaNl ())) result |= 1; { memory_long_double m; unsigned int i; /* The isnanl function should be immune against changes in the sign bit and in the mantissa bits. The xor operation twiddles a bit that can only be a sign bit or a mantissa bit (since the exponent never extends to bit 31). */ m.value = NaNl (); m.word[NWORDS / 2] ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); for (i = 0; i < NWORDS; i++) m.word[i] |= 1; if (!isnanl (m.value)) result |= 1; } #if ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ # ifdef WORDS_BIGENDIAN # define LDBL80_WORDS(exponent,manthi,mantlo) \ { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ (unsigned int) (mantlo) << 16 \ } # else # define LDBL80_WORDS(exponent,manthi,mantlo) \ { mantlo, manthi, exponent } # endif { /* Quiet NaN. */ static memory_long_double x = { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; if (!isnanl (x.value)) result |= 2; } { /* Signalling NaN. */ static memory_long_double x = { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; if (!isnanl (x.value)) result |= 2; } /* isnanl should return something even for noncanonical values. */ { /* Pseudo-NaN. */ static memory_long_double x = { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; if (isnanl (x.value) && !isnanl (x.value)) result |= 4; } { /* Pseudo-Infinity. */ static memory_long_double x = { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; if (isnanl (x.value) && !isnanl (x.value)) result |= 8; } { /* Pseudo-Zero. */ static memory_long_double x = { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; if (isnanl (x.value) && !isnanl (x.value)) result |= 16; } { /* Unnormalized number. */ static memory_long_double x = { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; if (isnanl (x.value) && !isnanl (x.value)) result |= 32; } { /* Pseudo-Denormal. */ static memory_long_double x = { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; if (isnanl (x.value) && !isnanl (x.value)) result |= 64; } #endif return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_isnanl_works=yes else gl_cv_func_isnanl_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_isnanl_works" >&5 $as_echo "$gl_cv_func_isnanl_works" >&6; } case "$gl_cv_func_isnanl_works" in *yes) ;; *) gl_func_isnanl_no_libm=no ;; esac fi if test $gl_func_isnanl_no_libm = yes; then $as_echo "#define HAVE_ISNANL_IN_LIBC 1" >>confdefs.h fi if test $gl_func_isnanl_no_libm != yes; then gl_LIBOBJS="$gl_LIBOBJS isnanl.$ac_objext" { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the exponent in a 'long double'" >&5 $as_echo_n "checking where to find the exponent in a 'long double'... " >&6; } if ${gl_cv_cc_long_double_expbit0+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_cc_long_double_expbit0="unknown" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #define NWORDS \ ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { long double value; unsigned int word[NWORDS]; } memory_long_double; static unsigned int ored_words[NWORDS]; static unsigned int anded_words[NWORDS]; static void add_to_ored_words (long double x) { memory_long_double m; size_t i; /* Clear it first, in case sizeof (long double) < sizeof (memory_long_double). */ memset (&m, 0, sizeof (memory_long_double)); m.value = x; for (i = 0; i < NWORDS; i++) { ored_words[i] |= m.word[i]; anded_words[i] &= m.word[i]; } } int main () { size_t j; FILE *fp = fopen ("conftest.out", "w"); if (fp == NULL) return 1; for (j = 0; j < NWORDS; j++) anded_words[j] = ~ (unsigned int) 0; add_to_ored_words (0.25L); add_to_ored_words (0.5L); add_to_ored_words (1.0L); add_to_ored_words (2.0L); add_to_ored_words (4.0L); /* Remove bits that are common (e.g. if representation of the first mantissa bit is explicit). */ for (j = 0; j < NWORDS; j++) ored_words[j] &= ~anded_words[j]; /* Now find the nonzero word. */ for (j = 0; j < NWORDS; j++) if (ored_words[j] != 0) break; if (j < NWORDS) { size_t i; for (i = j + 1; i < NWORDS; i++) if (ored_words[i] != 0) { fprintf (fp, "unknown"); return (fclose (fp) != 0); } for (i = 0; ; i++) if ((ored_words[j] >> i) & 1) { fprintf (fp, "word %d bit %d", (int) j, (int) i); return (fclose (fp) != 0); } } fprintf (fp, "unknown"); return (fclose (fp) != 0); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_cc_long_double_expbit0=`cat conftest.out` else gl_cv_cc_long_double_expbit0="unknown" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_long_double_expbit0" >&5 $as_echo "$gl_cv_cc_long_double_expbit0" >&6; } case "$gl_cv_cc_long_double_expbit0" in word*bit*) word=`echo "$gl_cv_cc_long_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` bit=`echo "$gl_cv_cc_long_double_expbit0" | sed -e 's/word.*bit //'` cat >>confdefs.h <<_ACEOF #define LDBL_EXPBIT0_WORD $word _ACEOF cat >>confdefs.h <<_ACEOF #define LDBL_EXPBIT0_BIT $bit _ACEOF ;; esac fi if test $gl_cv_have_include_next = yes; then gl_cv_next_langinfo_h='<'langinfo.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_langinfo_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_langinfo_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'langinfo.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_langinfo_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_langinfo_h gl_cv_next_langinfo_h='"'$gl_header'"' else gl_cv_next_langinfo_h='<'langinfo.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_langinfo_h" >&5 $as_echo "$gl_cv_next_langinfo_h" >&6; } fi NEXT_LANGINFO_H=$gl_cv_next_langinfo_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'langinfo.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_langinfo_h fi NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H=$gl_next_as_first_directive HAVE_LANGINFO_CODESET=0 HAVE_LANGINFO_T_FMT_AMPM=0 HAVE_LANGINFO_ERA=0 HAVE_LANGINFO_YESEXPR=0 if test $ac_cv_header_langinfo_h = yes; then HAVE_LANGINFO_H=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines CODESET" >&5 $as_echo_n "checking whether langinfo.h defines CODESET... " >&6; } if ${gl_cv_header_langinfo_codeset+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int a = CODESET; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_langinfo_codeset=yes else gl_cv_header_langinfo_codeset=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_codeset" >&5 $as_echo "$gl_cv_header_langinfo_codeset" >&6; } if test $gl_cv_header_langinfo_codeset = yes; then HAVE_LANGINFO_CODESET=1 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines T_FMT_AMPM" >&5 $as_echo_n "checking whether langinfo.h defines T_FMT_AMPM... " >&6; } if ${gl_cv_header_langinfo_t_fmt_ampm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int a = T_FMT_AMPM; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_langinfo_t_fmt_ampm=yes else gl_cv_header_langinfo_t_fmt_ampm=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_t_fmt_ampm" >&5 $as_echo "$gl_cv_header_langinfo_t_fmt_ampm" >&6; } if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then HAVE_LANGINFO_T_FMT_AMPM=1 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines ERA" >&5 $as_echo_n "checking whether langinfo.h defines ERA... " >&6; } if ${gl_cv_header_langinfo_era+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int a = ERA; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_langinfo_era=yes else gl_cv_header_langinfo_era=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_era" >&5 $as_echo "$gl_cv_header_langinfo_era" >&6; } if test $gl_cv_header_langinfo_era = yes; then HAVE_LANGINFO_ERA=1 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines YESEXPR" >&5 $as_echo_n "checking whether langinfo.h defines YESEXPR... " >&6; } if ${gl_cv_header_langinfo_yesexpr+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int a = YESEXPR; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_langinfo_yesexpr=yes else gl_cv_header_langinfo_yesexpr=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_yesexpr" >&5 $as_echo "$gl_cv_header_langinfo_yesexpr" >&6; } if test $gl_cv_header_langinfo_yesexpr = yes; then HAVE_LANGINFO_YESEXPR=1 fi else HAVE_LANGINFO_H=0 fi for ac_func in lchown do : ac_fn_c_check_func "$LINENO" "lchown" "ac_cv_func_lchown" if test "x$ac_cv_func_lchown" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LCHOWN 1 _ACEOF fi done if test $ac_cv_func_lchown = no; then HAVE_LCHOWN=0 else case "$gl_cv_func_chown_slash_works" in *yes) ;; *) REPLACE_LCHOWN=1 ;; esac case "$gl_cv_func_chown_ctime_works" in *yes) ;; *) REPLACE_LCHOWN=1 ;; esac fi if test $HAVE_LCHOWN = 0 || test $REPLACE_LCHOWN = 1; then gl_LIBOBJS="$gl_LIBOBJS lchown.$ac_objext" fi GNULIB_LCHOWN=1 $as_echo "#define GNULIB_TEST_LCHOWN 1" >>confdefs.h LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" case "$host_os" in solaris*) $as_echo "#define _LCONV_C99 1" >>confdefs.h ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether locale.h conforms to POSIX:2001" >&5 $as_echo_n "checking whether locale.h conforms to POSIX:2001... " >&6; } if ${gl_cv_header_locale_h_posix2001+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int x = LC_MESSAGES; int y = sizeof (((struct lconv *) 0)->decimal_point); int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_locale_h_posix2001=yes else gl_cv_header_locale_h_posix2001=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_locale_h_posix2001" >&5 $as_echo "$gl_cv_header_locale_h_posix2001" >&6; } if test $ac_cv_header_xlocale_h = yes; then HAVE_XLOCALE_H=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether locale.h defines locale_t" >&5 $as_echo_n "checking whether locale.h defines locale_t... " >&6; } if ${gl_cv_header_locale_has_locale_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include locale_t x; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_locale_has_locale_t=yes else gl_cv_header_locale_has_locale_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_locale_has_locale_t" >&5 $as_echo "$gl_cv_header_locale_has_locale_t" >&6; } if test $gl_cv_header_locale_has_locale_t = yes; then gl_cv_header_locale_h_needs_xlocale_h=no else gl_cv_header_locale_h_needs_xlocale_h=yes fi else HAVE_XLOCALE_H=0 gl_cv_header_locale_h_needs_xlocale_h=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct lconv is properly defined" >&5 $as_echo_n "checking whether struct lconv is properly defined... " >&6; } if ${gl_cv_sys_struct_lconv_ok+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include struct lconv l; int x = sizeof (l.decimal_point); int y = sizeof (l.int_p_cs_precedes); int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_sys_struct_lconv_ok=yes else gl_cv_sys_struct_lconv_ok=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_lconv_ok" >&5 $as_echo "$gl_cv_sys_struct_lconv_ok" >&6; } if test $gl_cv_sys_struct_lconv_ok = no; then REPLACE_STRUCT_LCONV=1 fi if test $gl_cv_have_include_next = yes; then gl_cv_next_locale_h='<'locale.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_locale_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'locale.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_locale_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_locale_h gl_cv_next_locale_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_locale_h" >&5 $as_echo "$gl_cv_next_locale_h" >&6; } fi NEXT_LOCALE_H=$gl_cv_next_locale_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'locale.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_locale_h fi NEXT_AS_FIRST_DIRECTIVE_LOCALE_H=$gl_next_as_first_directive if test $REPLACE_STRUCT_LCONV = 1; then REPLACE_LOCALECONV=1 fi if test $REPLACE_LOCALECONV = 1; then gl_LIBOBJS="$gl_LIBOBJS localeconv.$ac_objext" ac_fn_c_check_member "$LINENO" "struct lconv" "decimal_point" "ac_cv_member_struct_lconv_decimal_point" "#include " if test "x$ac_cv_member_struct_lconv_decimal_point" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_LCONV_DECIMAL_POINT 1 _ACEOF fi fi GNULIB_LOCALECONV=1 $as_echo "#define GNULIB_TEST_LOCALECONV 1" >>confdefs.h if test "$gl_threads_api" = posix; then # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the # pthread_rwlock_* functions. ac_fn_c_check_type "$LINENO" "pthread_rwlock_t" "ac_cv_type_pthread_rwlock_t" "#include " if test "x$ac_cv_type_pthread_rwlock_t" = xyes; then : $as_echo "#define HAVE_PTHREAD_RWLOCK 1" >>confdefs.h fi # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if __FreeBSD__ == 4 error "No, in FreeBSD 4.0 recursive mutexes actually don't work." #elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." #else int x = (int)PTHREAD_MUTEX_RECURSIVE; return !x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_PTHREAD_MUTEX_RECURSIVE 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi : cat >>confdefs.h <<_ACEOF #define GNULIB_LOCK 1 _ACEOF if test $ac_cv_func_lstat = yes; then case "$gl_cv_func_lstat_dereferences_slashed_symlink" in *no) REPLACE_LSTAT=1 ;; esac else HAVE_LSTAT=0 fi if test $REPLACE_LSTAT = 1; then gl_LIBOBJS="$gl_LIBOBJS lstat.$ac_objext" : fi GNULIB_LSTAT=1 $as_echo "#define GNULIB_TEST_LSTAT 1" >>confdefs.h if test $gl_cv_func_malloc_posix = yes; then $as_echo "#define HAVE_MALLOC_POSIX 1" >>confdefs.h else REPLACE_MALLOC=1 fi if test $REPLACE_MALLOC = 1; then gl_LIBOBJS="$gl_LIBOBJS malloc.$ac_objext" fi GNULIB_MALLOC_POSIX=1 $as_echo "#define GNULIB_TEST_MALLOC_POSIX 1" >>confdefs.h if test $gl_cv_have_include_next = yes; then gl_cv_next_math_h='<'math.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_math_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_math_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'math.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_math_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_math_h gl_cv_next_math_h='"'$gl_header'"' else gl_cv_next_math_h='<'math.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_math_h" >&5 $as_echo "$gl_cv_next_math_h" >&6; } fi NEXT_MATH_H=$gl_cv_next_math_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'math.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_math_h fi NEXT_AS_FIRST_DIRECTIVE_MATH_H=$gl_next_as_first_directive { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NAN macro works" >&5 $as_echo_n "checking whether NAN macro works... " >&6; } if ${gl_cv_header_math_nan_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { /* Solaris 10 has a broken definition of NAN. Other platforms fail to provide NAN, or provide it only in C99 mode; this test only needs to fail when NAN is provided but wrong. */ float f = 1.0f; #ifdef NAN f = NAN; #endif return f == 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_math_nan_works=yes else gl_cv_header_math_nan_works=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_math_nan_works" >&5 $as_echo "$gl_cv_header_math_nan_works" >&6; } if test $gl_cv_header_math_nan_works = no; then REPLACE_NAN=1 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether HUGE_VAL works" >&5 $as_echo_n "checking whether HUGE_VAL works... " >&6; } if ${gl_cv_header_math_huge_val_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { /* Solaris 10 has a broken definition of HUGE_VAL. */ double d = HUGE_VAL; return d == 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_math_huge_val_works=yes else gl_cv_header_math_huge_val_works=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_math_huge_val_works" >&5 $as_echo "$gl_cv_header_math_huge_val_works" >&6; } if test $gl_cv_header_math_huge_val_works = no; then REPLACE_HUGE_VAL=1 fi if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles incomplete characters" >&5 $as_echo_n "checking whether mbrtowc handles incomplete characters... " >&6; } if ${gl_cv_func_mbrtowc_incomplete_state+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on AIX and OSF/1. aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; esac if test $LOCALE_JA != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) { const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) if (mbsinit (&state)) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_incomplete_state=yes else gl_cv_func_mbrtowc_incomplete_state=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_incomplete_state" >&5 $as_echo "$gl_cv_func_mbrtowc_incomplete_state" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works as well as mbtowc" >&5 $as_echo_n "checking whether mbrtowc works as well as mbtowc... " >&6; } if ${gl_cv_func_mbrtowc_sanitycheck+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on Solaris 8. solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;; esac if test $LOCALE_ZH_CN != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { /* This fails on Solaris 8: mbrtowc returns 2, and sets wc to 0x00F0. mbtowc returns 4 (correct) and sets wc to 0x5EDC. */ if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) { char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 3, 6, &state) != 4 && mbtowc (&wc, input + 3, 6) == 4) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_sanitycheck=yes else gl_cv_func_mbrtowc_sanitycheck=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_sanitycheck" >&5 $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } REPLACE_MBSTATE_T=0 case "$gl_cv_func_mbrtowc_incomplete_state" in *yes) ;; *) REPLACE_MBSTATE_T=1 ;; esac case "$gl_cv_func_mbrtowc_sanitycheck" in *yes) ;; *) REPLACE_MBSTATE_T=1 ;; esac else REPLACE_MBSTATE_T=1 fi if test $ac_cv_func_mbrtowc = no; then HAVE_MBRTOWC=0 ac_fn_c_check_decl "$LINENO" "mbrtowc" "ac_cv_have_decl_mbrtowc" " /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include " if test "x$ac_cv_have_decl_mbrtowc" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_MBRTOWC $ac_have_decl _ACEOF if test $ac_cv_have_decl_mbrtowc = yes; then REPLACE_MBRTOWC=1 fi else if test $REPLACE_MBSTATE_T = 1; then REPLACE_MBRTOWC=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles a NULL pwc argument" >&5 $as_echo_n "checking whether mbrtowc handles a NULL pwc argument... " >&6; } if ${gl_cv_func_mbrtowc_null_arg1+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on Solaris. solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;; esac if test $LOCALE_FR_UTF8 != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { int result = 0; if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) { char input[] = "\303\237er"; mbstate_t state; wchar_t wc; size_t ret; memset (&state, '\0', sizeof (mbstate_t)); wc = (wchar_t) 0xBADFACE; ret = mbrtowc (&wc, input, 5, &state); if (ret != 2) result |= 1; if (!mbsinit (&state)) result |= 2; memset (&state, '\0', sizeof (mbstate_t)); ret = mbrtowc (NULL, input, 5, &state); if (ret != 2) /* Solaris 7 fails here: ret is -1. */ result |= 4; if (!mbsinit (&state)) result |= 8; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_null_arg1=yes else gl_cv_func_mbrtowc_null_arg1=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_null_arg1" >&5 $as_echo "$gl_cv_func_mbrtowc_null_arg1" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles a NULL string argument" >&5 $as_echo_n "checking whether mbrtowc handles a NULL string argument... " >&6; } if ${gl_cv_func_mbrtowc_null_arg2+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on OSF/1. osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;; esac if test $LOCALE_FR_UTF8 != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) { mbstate_t state; wchar_t wc; int ret; memset (&state, '\0', sizeof (mbstate_t)); wc = (wchar_t) 0xBADFACE; mbrtowc (&wc, NULL, 5, &state); /* Check that wc was not modified. */ if (wc != (wchar_t) 0xBADFACE) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_null_arg2=yes else gl_cv_func_mbrtowc_null_arg2=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_null_arg2" >&5 $as_echo "$gl_cv_func_mbrtowc_null_arg2" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc has a correct return value" >&5 $as_echo_n "checking whether mbrtowc has a correct return value... " >&6; } if ${gl_cv_func_mbrtowc_retval+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on HP-UX, Solaris, native Windows. hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_retval="guessing yes" ;; esac if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ || { case "$host_os" in mingw*) true;; *) false;; esac; }; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { int result = 0; int found_some_locale = 0; /* This fails on Solaris. */ if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) { char input[] = "B\303\274\303\237er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) { input[1] = '\0'; if (mbrtowc (&wc, input + 2, 5, &state) != 1) result |= 1; } found_some_locale = 1; } /* This fails on HP-UX 11.11. */ if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) { char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) { input[1] = '\0'; if (mbrtowc (&wc, input + 2, 5, &state) != 2) result |= 2; } found_some_locale = 1; } /* This fails on native Windows. */ if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL) { char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) { input[3] = '\0'; if (mbrtowc (&wc, input + 4, 4, &state) != 1) result |= 4; } found_some_locale = 1; } if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL) { char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) { input[3] = '\0'; if (mbrtowc (&wc, input + 4, 4, &state) != 1) result |= 8; } found_some_locale = 1; } if (setlocale (LC_ALL, "Chinese_China.936") != NULL) { char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) { input[3] = '\0'; if (mbrtowc (&wc, input + 4, 4, &state) != 1) result |= 16; } found_some_locale = 1; } return (found_some_locale ? result : 77); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_retval=yes else if test $? != 77; then gl_cv_func_mbrtowc_retval=no fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_retval" >&5 $as_echo "$gl_cv_func_mbrtowc_retval" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc returns 0 when parsing a NUL character" >&5 $as_echo_n "checking whether mbrtowc returns 0 when parsing a NUL character... " >&6; } if ${gl_cv_func_mbrtowc_nul_retval+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on Solaris 8 and 9. solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;; esac if test $LOCALE_ZH_CN != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { /* This fails on Solaris 8 and 9. */ if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) { mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, "", 1, &state) != 0) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_nul_retval=yes else gl_cv_func_mbrtowc_nul_retval=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_nul_retval" >&5 $as_echo "$gl_cv_func_mbrtowc_nul_retval" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works on empty input" >&5 $as_echo_n "checking whether mbrtowc works on empty input... " >&6; } if ${gl_cv_func_mbrtowc_empty_input+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on AIX and glibc systems. aix* | *-gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; esac if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include static wchar_t wc; static mbstate_t mbs; int main (void) { return mbrtowc (&wc, "", 0, &mbs) == (size_t) -2; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_empty_input=no else gl_cv_func_mbrtowc_empty_input=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_empty_input" >&5 $as_echo "$gl_cv_func_mbrtowc_empty_input" >&6; } case "$gl_cv_func_mbrtowc_null_arg1" in *yes) ;; *) $as_echo "#define MBRTOWC_NULL_ARG1_BUG 1" >>confdefs.h REPLACE_MBRTOWC=1 ;; esac case "$gl_cv_func_mbrtowc_null_arg2" in *yes) ;; *) $as_echo "#define MBRTOWC_NULL_ARG2_BUG 1" >>confdefs.h REPLACE_MBRTOWC=1 ;; esac case "$gl_cv_func_mbrtowc_retval" in *yes) ;; *) $as_echo "#define MBRTOWC_RETVAL_BUG 1" >>confdefs.h REPLACE_MBRTOWC=1 ;; esac case "$gl_cv_func_mbrtowc_nul_retval" in *yes) ;; *) $as_echo "#define MBRTOWC_NUL_RETVAL_BUG 1" >>confdefs.h REPLACE_MBRTOWC=1 ;; esac case "$gl_cv_func_mbrtowc_empty_input" in *yes) ;; *) $as_echo "#define MBRTOWC_EMPTY_INPUT_BUG 1" >>confdefs.h REPLACE_MBRTOWC=1 ;; esac fi fi if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then gl_LIBOBJS="$gl_LIBOBJS mbrtowc.$ac_objext" : fi GNULIB_MBRTOWC=1 $as_echo "#define GNULIB_TEST_MBRTOWC 1" >>confdefs.h if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles incomplete characters" >&5 $as_echo_n "checking whether mbrtowc handles incomplete characters... " >&6; } if ${gl_cv_func_mbrtowc_incomplete_state+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on AIX and OSF/1. aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; esac if test $LOCALE_JA != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) { const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) if (mbsinit (&state)) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_incomplete_state=yes else gl_cv_func_mbrtowc_incomplete_state=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_incomplete_state" >&5 $as_echo "$gl_cv_func_mbrtowc_incomplete_state" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works as well as mbtowc" >&5 $as_echo_n "checking whether mbrtowc works as well as mbtowc... " >&6; } if ${gl_cv_func_mbrtowc_sanitycheck+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on Solaris 8. solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;; esac if test $LOCALE_ZH_CN != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { /* This fails on Solaris 8: mbrtowc returns 2, and sets wc to 0x00F0. mbtowc returns 4 (correct) and sets wc to 0x5EDC. */ if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) { char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 3, 6, &state) != 4 && mbtowc (&wc, input + 3, 6) == 4) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_sanitycheck=yes else gl_cv_func_mbrtowc_sanitycheck=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_sanitycheck" >&5 $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } REPLACE_MBSTATE_T=0 case "$gl_cv_func_mbrtowc_incomplete_state" in *yes) ;; *) REPLACE_MBSTATE_T=1 ;; esac case "$gl_cv_func_mbrtowc_sanitycheck" in *yes) ;; *) REPLACE_MBSTATE_T=1 ;; esac else REPLACE_MBSTATE_T=1 fi if test $ac_cv_func_mbsinit = no; then HAVE_MBSINIT=0 ac_fn_c_check_decl "$LINENO" "mbsinit" "ac_cv_have_decl_mbsinit" " /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include " if test "x$ac_cv_have_decl_mbsinit" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_MBSINIT $ac_have_decl _ACEOF if test $ac_cv_have_decl_mbsinit = yes; then REPLACE_MBSINIT=1 fi else if test $REPLACE_MBSTATE_T = 1; then REPLACE_MBSINIT=1 else case "$host_os" in mingw*) REPLACE_MBSINIT=1 ;; esac fi fi if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then gl_LIBOBJS="$gl_LIBOBJS mbsinit.$ac_objext" : fi GNULIB_MBSINIT=1 $as_echo "#define GNULIB_TEST_MBSINIT 1" >>confdefs.h if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles incomplete characters" >&5 $as_echo_n "checking whether mbrtowc handles incomplete characters... " >&6; } if ${gl_cv_func_mbrtowc_incomplete_state+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on AIX and OSF/1. aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; esac if test $LOCALE_JA != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) { const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) if (mbsinit (&state)) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_incomplete_state=yes else gl_cv_func_mbrtowc_incomplete_state=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_incomplete_state" >&5 $as_echo "$gl_cv_func_mbrtowc_incomplete_state" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works as well as mbtowc" >&5 $as_echo_n "checking whether mbrtowc works as well as mbtowc... " >&6; } if ${gl_cv_func_mbrtowc_sanitycheck+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on Solaris 8. solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;; esac if test $LOCALE_ZH_CN != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { /* This fails on Solaris 8: mbrtowc returns 2, and sets wc to 0x00F0. mbtowc returns 4 (correct) and sets wc to 0x5EDC. */ if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) { char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 3, 6, &state) != 4 && mbtowc (&wc, input + 3, 6) == 4) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_sanitycheck=yes else gl_cv_func_mbrtowc_sanitycheck=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_sanitycheck" >&5 $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } REPLACE_MBSTATE_T=0 case "$gl_cv_func_mbrtowc_incomplete_state" in *yes) ;; *) REPLACE_MBSTATE_T=1 ;; esac case "$gl_cv_func_mbrtowc_sanitycheck" in *yes) ;; *) REPLACE_MBSTATE_T=1 ;; esac else REPLACE_MBSTATE_T=1 fi if test $ac_cv_func_mbsrtowcs = no; then HAVE_MBSRTOWCS=0 ac_fn_c_check_decl "$LINENO" "mbsrtowcs" "ac_cv_have_decl_mbsrtowcs" " /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include " if test "x$ac_cv_have_decl_mbsrtowcs" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_MBSRTOWCS $ac_have_decl _ACEOF if test $ac_cv_have_decl_mbsrtowcs = yes; then REPLACE_MBSRTOWCS=1 fi else if test $REPLACE_MBSTATE_T = 1; then REPLACE_MBSRTOWCS=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbsrtowcs works" >&5 $as_echo_n "checking whether mbsrtowcs works... " >&6; } if ${gl_cv_func_mbsrtowcs_works+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on HP-UX, Solaris, mingw. hpux* | solaris* | mingw*) gl_cv_func_mbsrtowcs_works="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbsrtowcs_works="guessing yes" ;; esac if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { int result = 0; /* Test whether the function supports a NULL destination argument. This fails on native Windows. */ if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) { const char input[] = "\337er"; const char *src = input; mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); if (mbsrtowcs (NULL, &src, 1, &state) != 3 || src != input) result |= 1; } /* Test whether the function works when started with a conversion state in non-initial state. This fails on HP-UX 11.11 and Solaris 10. */ if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) { const char input[] = "B\303\274\303\237er"; mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2)) if (!mbsinit (&state)) { const char *src = input + 2; if (mbsrtowcs (NULL, &src, 10, &state) != 4) result |= 2; } } if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) { const char input[] = "<\306\374\313\334\270\354>"; mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (NULL, input + 3, 1, &state) == (size_t)(-2)) if (!mbsinit (&state)) { const char *src = input + 4; if (mbsrtowcs (NULL, &src, 10, &state) != 3) result |= 4; } } if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) { const char input[] = "B\250\271\201\060\211\070er"; mbstate_t state; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2)) if (!mbsinit (&state)) { const char *src = input + 2; if (mbsrtowcs (NULL, &src, 10, &state) != 4) result |= 8; } } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbsrtowcs_works=yes else gl_cv_func_mbsrtowcs_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbsrtowcs_works" >&5 $as_echo "$gl_cv_func_mbsrtowcs_works" >&6; } case "$gl_cv_func_mbsrtowcs_works" in *yes) ;; *) REPLACE_MBSRTOWCS=1 ;; esac fi fi if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then gl_LIBOBJS="$gl_LIBOBJS mbsrtowcs.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS mbsrtowcs-state.$ac_objext" : fi GNULIB_MBSRTOWCS=1 $as_echo "#define GNULIB_TEST_MBSRTOWCS 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbswidth is declared in " >&5 $as_echo_n "checking whether mbswidth is declared in ... " >&6; } if ${ac_cv_have_decl_mbswidth+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { char *p = (char *) mbswidth; return !p; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_have_decl_mbswidth=yes else ac_cv_have_decl_mbswidth=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_decl_mbswidth" >&5 $as_echo "$ac_cv_have_decl_mbswidth" >&6; } if test $ac_cv_have_decl_mbswidth = yes; then ac_val=1 else ac_val=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_MBSWIDTH_IN_WCHAR_H $ac_val _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mbstate_t" >&5 $as_echo_n "checking for mbstate_t... " >&6; } if ${ac_cv_type_mbstate_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { mbstate_t x; return sizeof x; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_mbstate_t=yes else ac_cv_type_mbstate_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_mbstate_t" >&5 $as_echo "$ac_cv_type_mbstate_t" >&6; } if test $ac_cv_type_mbstate_t = yes; then $as_echo "#define HAVE_MBSTATE_T 1" >>confdefs.h else $as_echo "#define mbstate_t int" >>confdefs.h fi if false; then REPLACE_MBTOWC=1 fi if test $REPLACE_MBTOWC = 1; then gl_LIBOBJS="$gl_LIBOBJS mbtowc.$ac_objext" : fi GNULIB_MBTOWC=1 $as_echo "#define GNULIB_TEST_MBTOWC 1" >>confdefs.h if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then gl_LIBOBJS="$gl_LIBOBJS memchr.$ac_objext" for ac_header in bp-sym.h do : ac_fn_c_check_header_mongrel "$LINENO" "bp-sym.h" "ac_cv_header_bp_sym_h" "$ac_includes_default" if test "x$ac_cv_header_bp_sym_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_BP_SYM_H 1 _ACEOF fi done fi GNULIB_MEMCHR=1 $as_echo "#define GNULIB_TEST_MEMCHR 1" >>confdefs.h if test $HAVE_DECL_MEMMEM = 1 && test $REPLACE_MEMMEM = 0; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memmem works in linear time" >&5 $as_echo_n "checking whether memmem works in linear time... " >&6; } if ${gl_cv_func_memmem_works_fast+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __GNU_LIBRARY__ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9) || (__GLIBC__ > 2)) \ && !defined __UCLIBC__ Lucky user #endif #endif #ifdef __CYGWIN__ #include #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 0) Lucky user #endif #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Lucky user" >/dev/null 2>&1; then : gl_cv_func_memmem_works_fast="guessing yes" else gl_cv_func_memmem_works_fast="guessing no" fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for signal */ #include /* for memmem */ #include /* for malloc */ #include /* for alarm */ static void quit (int sig) { exit (sig + 128); } int main () { int result = 0; size_t m = 1000000; char *haystack = (char *) malloc (2 * m + 1); char *needle = (char *) malloc (m + 1); /* Failure to compile this test due to missing alarm is okay, since all such platforms (mingw) also lack memmem. */ signal (SIGALRM, quit); alarm (5); /* Check for quadratic performance. */ if (haystack && needle) { memset (haystack, 'A', 2 * m); haystack[2 * m] = 'B'; memset (needle, 'A', m); needle[m] = 'B'; if (!memmem (haystack, 2 * m + 1, needle, m + 1)) result |= 1; } return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_memmem_works_fast=yes else gl_cv_func_memmem_works_fast=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_memmem_works_fast" >&5 $as_echo "$gl_cv_func_memmem_works_fast" >&6; } case "$gl_cv_func_memmem_works_fast" in *yes) ;; *) REPLACE_MEMMEM=1 ;; esac fi if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then gl_LIBOBJS="$gl_LIBOBJS memmem.$ac_objext" fi for ac_func in memmem do : ac_fn_c_check_func "$LINENO" "memmem" "ac_cv_func_memmem" if test "x$ac_cv_func_memmem" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMMEM 1 _ACEOF fi done if test $ac_cv_func_memmem = yes; then HAVE_MEMMEM=1 else HAVE_MEMMEM=0 fi if test $ac_cv_have_decl_memmem = no; then HAVE_DECL_MEMMEM=0 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memmem works" >&5 $as_echo_n "checking whether memmem works... " >&6; } if ${gl_cv_func_memmem_works_always+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNU_LIBRARY__ #include #if ((__GLIBC__ == 2 && ((__GLIBC_MINOR > 0 && __GLIBC_MINOR__ < 9) \ || __GLIBC_MINOR__ > 12)) \ || (__GLIBC__ > 2)) \ || defined __UCLIBC__ Lucky user #endif #elif defined __CYGWIN__ #include #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7) Lucky user #endif #else Lucky user #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Lucky user" >/dev/null 2>&1; then : gl_cv_func_memmem_works_always="guessing yes" else gl_cv_func_memmem_works_always="guessing no" fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for memmem */ #define P "_EF_BF_BD" #define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P #define NEEDLE P P P P P int main () { int result = 0; if (memmem (HAYSTACK, strlen (HAYSTACK), NEEDLE, strlen (NEEDLE))) result |= 1; /* Check for empty needle behavior. */ { const char *haystack = "AAA"; if (memmem (haystack, 3, NULL, 0) != haystack) result |= 2; } return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_memmem_works_always=yes else gl_cv_func_memmem_works_always=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_memmem_works_always" >&5 $as_echo "$gl_cv_func_memmem_works_always" >&6; } case "$gl_cv_func_memmem_works_always" in *yes) ;; *) REPLACE_MEMMEM=1 ;; esac fi : if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then gl_LIBOBJS="$gl_LIBOBJS memmem.$ac_objext" fi GNULIB_MEMMEM=1 $as_echo "#define GNULIB_TEST_MEMMEM 1" >>confdefs.h for ac_func in mempcpy do : ac_fn_c_check_func "$LINENO" "mempcpy" "ac_cv_func_mempcpy" if test "x$ac_cv_func_mempcpy" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMPCPY 1 _ACEOF fi done if test $ac_cv_func_mempcpy = no; then HAVE_MEMPCPY=0 fi if test $HAVE_MEMPCPY = 0; then gl_LIBOBJS="$gl_LIBOBJS mempcpy.$ac_objext" : fi GNULIB_MEMPCPY=1 $as_echo "#define GNULIB_TEST_MEMPCPY 1" >>confdefs.h if test $APPLE_UNIVERSAL_BUILD = 1; then # A universal build on Apple Mac OS X platforms. # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode. # But we need a configuration result that is valid in both modes. gl_cv_func_working_mktime=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5 $as_echo_n "checking for working mktime... " >&6; } if ${gl_cv_func_working_mktime+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_func_working_mktime=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Test program from Paul Eggert and Tony Leneis. */ #include #include #include #ifdef HAVE_UNISTD_H # include #endif #if HAVE_DECL_ALARM # include #endif /* Work around redefinition to rpl_putenv by other config tests. */ #undef putenv static time_t time_t_max; static time_t time_t_min; /* Values we'll use to set the TZ environment variable. */ static char *tz_strings[] = { (char *) 0, "TZ=GMT0", "TZ=JST-9", "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" }; #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) /* Return 0 if mktime fails to convert a date in the spring-forward gap. Based on a problem report from Andreas Jaeger. */ static int spring_forward_gap () { /* glibc (up to about 1998-10-07) failed this test. */ struct tm tm; /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); tm.tm_year = 98; tm.tm_mon = 3; tm.tm_mday = 5; tm.tm_hour = 2; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; return mktime (&tm) != (time_t) -1; } static int mktime_test1 (time_t now) { struct tm *lt; return ! (lt = localtime (&now)) || mktime (lt) == now; } static int mktime_test (time_t now) { return (mktime_test1 (now) && mktime_test1 ((time_t) (time_t_max - now)) && mktime_test1 ((time_t) (time_t_min + now))); } static int irix_6_4_bug () { /* Based on code from Ariel Faigon. */ struct tm tm; tm.tm_year = 96; tm.tm_mon = 3; tm.tm_mday = 0; tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; mktime (&tm); return tm.tm_mon == 2 && tm.tm_mday == 31; } static int bigtime_test (int j) { struct tm tm; time_t now; tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; now = mktime (&tm); if (now != (time_t) -1) { struct tm *lt = localtime (&now); if (! (lt && lt->tm_year == tm.tm_year && lt->tm_mon == tm.tm_mon && lt->tm_mday == tm.tm_mday && lt->tm_hour == tm.tm_hour && lt->tm_min == tm.tm_min && lt->tm_sec == tm.tm_sec && lt->tm_yday == tm.tm_yday && lt->tm_wday == tm.tm_wday && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) return 0; } return 1; } static int year_2050_test () { /* The correct answer for 2050-02-01 00:00:00 in Pacific time, ignoring leap seconds. */ unsigned long int answer = 2527315200UL; struct tm tm; time_t t; tm.tm_year = 2050 - 1900; tm.tm_mon = 2 - 1; tm.tm_mday = 1; tm.tm_hour = tm.tm_min = tm.tm_sec = 0; tm.tm_isdst = -1; /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" instead of "TZ=America/Vancouver" in order to detect the bug even on systems that don't support the Olson extension, or don't have the full zoneinfo tables installed. */ putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); t = mktime (&tm); /* Check that the result is either a failure, or close enough to the correct answer that we can assume the discrepancy is due to leap seconds. */ return (t == (time_t) -1 || (0 < t && answer - 120 <= t && t <= answer + 120)); } int main () { int result = 0; time_t t, delta; int i, j; int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1; int time_t_signed = ! ((time_t) 0 < (time_t) -1); #if HAVE_DECL_ALARM /* This test makes some buggy mktime implementations loop. Give up after 60 seconds; a mktime slower than that isn't worth using anyway. */ signal (SIGALRM, SIG_DFL); alarm (60); #endif time_t_max = (! time_t_signed ? (time_t) -1 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1) * 2 + 1)); time_t_min = (! time_t_signed ? (time_t) 0 : time_t_signed_magnitude ? ~ (time_t) 0 : ~ time_t_max); delta = time_t_max / 997; /* a suitable prime number */ for (i = 0; i < N_STRINGS; i++) { if (tz_strings[i]) putenv (tz_strings[i]); for (t = 0; t <= time_t_max - delta && (result & 1) == 0; t += delta) if (! mktime_test (t)) result |= 1; if ((result & 2) == 0 && ! (mktime_test ((time_t) 1) && mktime_test ((time_t) (60 * 60)) && mktime_test ((time_t) (60 * 60 * 24)))) result |= 2; for (j = 1; (result & 4) == 0; j <<= 1) { if (! bigtime_test (j)) result |= 4; if (INT_MAX / 2 < j) break; } if ((result & 8) == 0 && ! bigtime_test (INT_MAX)) result |= 8; } if (! irix_6_4_bug ()) result |= 16; if (! spring_forward_gap ()) result |= 32; if (! year_2050_test ()) result |= 64; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_working_mktime=yes else gl_cv_func_working_mktime=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_mktime" >&5 $as_echo "$gl_cv_func_working_mktime" >&6; } if test $gl_cv_func_working_mktime = no; then REPLACE_MKTIME=1 else REPLACE_MKTIME=0 fi if test $REPLACE_MKTIME = 1; then gl_LIBOBJS="$gl_LIBOBJS mktime.$ac_objext" : fi GNULIB_MKTIME=1 $as_echo "#define GNULIB_TEST_MKTIME 1" >>confdefs.h : if test $ac_cv_func__set_invalid_parameter_handler = yes; then HAVE_MSVC_INVALID_PARAMETER_HANDLER=1 $as_echo "#define HAVE_MSVC_INVALID_PARAMETER_HANDLER 1" >>confdefs.h else HAVE_MSVC_INVALID_PARAMETER_HANDLER=0 fi if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then gl_LIBOBJS="$gl_LIBOBJS msvc-inval.$ac_objext" fi if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then gl_LIBOBJS="$gl_LIBOBJS msvc-nothrow.$ac_objext" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is self-contained" >&5 $as_echo_n "checking whether is self-contained... " >&6; } if ${gl_cv_header_netinet_in_h_selfcontained+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_netinet_in_h_selfcontained=yes else gl_cv_header_netinet_in_h_selfcontained=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_netinet_in_h_selfcontained" >&5 $as_echo "$gl_cv_header_netinet_in_h_selfcontained" >&6; } if test $gl_cv_header_netinet_in_h_selfcontained = yes; then NETINET_IN_H='' else NETINET_IN_H='netinet/in.h' for ac_header in netinet/in.h do : ac_fn_c_check_header_mongrel "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default" if test "x$ac_cv_header_netinet_in_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETINET_IN_H 1 _ACEOF fi done if test $gl_cv_have_include_next = yes; then gl_cv_next_netinet_in_h='<'netinet/in.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_netinet_in_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_netinet_in_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'netinet/in.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_netinet_in_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_netinet_in_h gl_cv_next_netinet_in_h='"'$gl_header'"' else gl_cv_next_netinet_in_h='<'netinet/in.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_netinet_in_h" >&5 $as_echo "$gl_cv_next_netinet_in_h" >&6; } fi NEXT_NETINET_IN_H=$gl_cv_next_netinet_in_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'netinet/in.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_netinet_in_h fi NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H=$gl_next_as_first_directive if test $ac_cv_header_netinet_in_h = yes; then HAVE_NETINET_IN_H=1 else HAVE_NETINET_IN_H=0 fi fi if test -n "$NETINET_IN_H"; then GL_GENERATE_NETINET_IN_H_TRUE= GL_GENERATE_NETINET_IN_H_FALSE='#' else GL_GENERATE_NETINET_IN_H_TRUE='#' GL_GENERATE_NETINET_IN_H_FALSE= fi if test $ac_cv_func_nl_langinfo = yes; then # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether YESEXPR works" >&5 $as_echo_n "checking whether YESEXPR works... " >&6; } if ${gl_cv_func_nl_langinfo_yesexpr_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess no on irix systems. irix*) gl_cv_func_nl_langinfo_yesexpr_works="guessing no";; # Guess yes elsewhere. *) gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { return !*nl_langinfo(YESEXPR); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_nl_langinfo_yesexpr_works=yes else gl_cv_func_nl_langinfo_yesexpr_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_nl_langinfo_yesexpr_works" >&5 $as_echo "$gl_cv_func_nl_langinfo_yesexpr_works" >&6; } case $gl_cv_func_nl_langinfo_yesexpr_works in *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;; *) FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;; esac cat >>confdefs.h <<_ACEOF #define FUNC_NL_LANGINFO_YESEXPR_WORKS $FUNC_NL_LANGINFO_YESEXPR_WORKS _ACEOF if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \ && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then : else REPLACE_NL_LANGINFO=1 $as_echo "#define REPLACE_NL_LANGINFO 1" >>confdefs.h fi else HAVE_NL_LANGINFO=0 fi if test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1; then gl_LIBOBJS="$gl_LIBOBJS nl_langinfo.$ac_objext" fi GNULIB_NL_LANGINFO=1 $as_echo "#define GNULIB_TEST_NL_LANGINFO 1" >>confdefs.h case "$host_os" in mingw* | pw*) REPLACE_OPEN=1 ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open recognizes a trailing slash" >&5 $as_echo_n "checking whether open recognizes a trailing slash... " >&6; } if ${gl_cv_func_open_slash+:} false; then : $as_echo_n "(cached) " >&6 else # Assume that if we have lstat, we can also check symlinks. if test $ac_cv_func_lstat = yes; then touch conftest.tmp ln -s conftest.tmp conftest.lnk fi if test "$cross_compiling" = yes; then : case "$host_os" in freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*) gl_cv_func_open_slash="guessing no" ;; *) gl_cv_func_open_slash="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_UNISTD_H # include #endif int main () { int result = 0; #if HAVE_LSTAT if (open ("conftest.lnk/", O_RDONLY) != -1) result |= 1; #endif if (open ("conftest.sl/", O_CREAT, 0600) >= 0) result |= 2; return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_open_slash=yes else gl_cv_func_open_slash=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 -f conftest.sl conftest.tmp conftest.lnk fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_open_slash" >&5 $as_echo "$gl_cv_func_open_slash" >&6; } case "$gl_cv_func_open_slash" in *no) $as_echo "#define OPEN_TRAILING_SLASH_BUG 1" >>confdefs.h REPLACE_OPEN=1 ;; esac ;; esac if test $REPLACE_OPEN = 1; then gl_LIBOBJS="$gl_LIBOBJS open.$ac_objext" : fi GNULIB_OPEN=1 $as_echo "#define GNULIB_TEST_OPEN 1" >>confdefs.h for ac_func in opendir do : ac_fn_c_check_func "$LINENO" "opendir" "ac_cv_func_opendir" if test "x$ac_cv_func_opendir" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENDIR 1 _ACEOF fi done if test $ac_cv_func_opendir = no; then HAVE_OPENDIR=0 fi if test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1; then gl_LIBOBJS="$gl_LIBOBJS opendir.$ac_objext" fi GNULIB_OPENDIR=1 $as_echo "#define GNULIB_TEST_OPENDIR 1" >>confdefs.h ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include #include <$ac_cv_struct_tm> " if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM_TM_ZONE 1 _ACEOF fi if test "$ac_cv_member_struct_tm_tm_zone" = yes; then $as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h else ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include " if test "x$ac_cv_have_decl_tzname" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_TZNAME $ac_have_decl _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5 $as_echo_n "checking for tzname... " >&6; } if ${ac_cv_var_tzname+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if !HAVE_DECL_TZNAME extern char *tzname[]; #endif int main () { return tzname[0][0]; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_var_tzname=yes else ac_cv_var_tzname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5 $as_echo "$ac_cv_var_tzname" >&6; } if test $ac_cv_var_tzname = yes; then $as_echo "#define HAVE_TZNAME 1" >>confdefs.h fi fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for time_t */ #include /* for CHAR_BIT, LONG_MIN, LONG_MAX */ #define TYPE_MINIMUM(t) \ ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) #define TYPE_MAXIMUM(t) \ ((t) ((t) 0 < (t) -1 \ ? (t) -1 \ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) typedef int verify_min[2 * (LONG_MIN <= TYPE_MINIMUM (time_t)) - 1]; typedef int verify_max[2 * (TYPE_MAXIMUM (time_t) <= LONG_MAX) - 1]; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define TIME_T_FITS_IN_LONG_INT 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext $as_echo "#define _LINUX_SOURCE_COMPAT 1" >>confdefs.h ac_fn_c_check_member "$LINENO" "struct msghdr" "msg_accrights" "ac_cv_member_struct_msghdr_msg_accrights" " #include #include " if test "x$ac_cv_member_struct_msghdr_msg_accrights" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS 1 _ACEOF fi if test $ac_cv_header_poll_h = no; then ac_cv_func_poll=no gl_cv_func_poll=no else ac_fn_c_check_func "$LINENO" "poll" "ac_cv_func_poll" if test "x$ac_cv_func_poll" = xyes; then : # Check whether poll() works on special files (like /dev/null) and # and ttys (like /dev/tty). On Mac OS X 10.4.0 and AIX 5.3, it doesn't. if test "$cross_compiling" = yes; then : # When cross-compiling, assume that poll() works everywhere except on # Mac OS X or AIX, regardless of its version. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if (defined(__APPLE__) && defined(__MACH__)) || defined(_AIX) This is MacOSX or AIX #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "MacOSX" >/dev/null 2>&1; then : gl_cv_func_poll=no else gl_cv_func_poll=yes fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main() { int result = 0; struct pollfd ufd; /* Try /dev/null for reading. */ ufd.fd = open ("/dev/null", O_RDONLY); /* If /dev/null does not exist, it's not Mac OS X nor AIX. */ if (ufd.fd >= 0) { ufd.events = POLLIN; ufd.revents = 0; if (!(poll (&ufd, 1, 0) == 1 && ufd.revents == POLLIN)) result |= 1; } /* Try /dev/null for writing. */ ufd.fd = open ("/dev/null", O_WRONLY); /* If /dev/null does not exist, it's not Mac OS X nor AIX. */ if (ufd.fd >= 0) { ufd.events = POLLOUT; ufd.revents = 0; if (!(poll (&ufd, 1, 0) == 1 && ufd.revents == POLLOUT)) result |= 2; } /* Trying /dev/tty may be too environment dependent. */ return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_poll=yes else gl_cv_func_poll=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi if test $gl_cv_func_poll != yes; then ac_fn_c_check_func "$LINENO" "poll" "ac_cv_func_poll" if test "x$ac_cv_func_poll" = xyes; then : ac_cv_func_poll=yes else ac_cv_func_poll=no fi if test $ac_cv_func_poll = no; then HAVE_POLL=0 else REPLACE_POLL=1 fi fi if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then : else $as_echo "#define HAVE_POLL 1" >>confdefs.h fi LIB_POLL="$LIBSOCKET" if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then case "$host_os" in mingw*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define WIN32_LEAN_AND_MEAN #include int main () { MsgWaitForMultipleObjects (0, NULL, 0, 0, 0); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : else LIB_POLL="$LIB_POLL -luser32" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ;; esac fi if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then gl_LIBOBJS="$gl_LIBOBJS poll.$ac_objext" fi GNULIB_POLL=1 $as_echo "#define GNULIB_TEST_POLL 1" >>confdefs.h if test $ac_cv_header_poll_h = yes; then HAVE_POLL_H=1 else HAVE_POLL_H=0 fi if test $gl_cv_have_include_next = yes; then gl_cv_next_poll_h='<'poll.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_poll_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_poll_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'poll.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_poll_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_poll_h gl_cv_next_poll_h='"'$gl_header'"' else gl_cv_next_poll_h='<'poll.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_poll_h" >&5 $as_echo "$gl_cv_next_poll_h" >&6; } fi NEXT_POLL_H=$gl_cv_next_poll_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'poll.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_poll_h fi NEXT_AS_FIRST_DIRECTIVE_POLL_H=$gl_next_as_first_directive if test $gl_cv_func_frexp_no_libm = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether frexp works" >&5 $as_echo_n "checking whether frexp works... " >&6; } if ${gl_cv_func_frexp_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in netbsd* | irix* | mingw*) gl_cv_func_frexp_works="guessing no";; *) gl_cv_func_frexp_works="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #if HAVE_DECL_ALARM # include # include #endif /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. ICC 10.0 has a bug when optimizing the expression -zero. The expression -DBL_MIN * DBL_MIN does not work when cross-compiling to PowerPC on Mac OS X 10.5. */ #if defined __hpux || defined __sgi || defined __ICC static double compute_minus_zero (void) { return -DBL_MIN * DBL_MIN; } # define minus_zero compute_minus_zero () #else double minus_zero = -0.0; #endif int main() { int result = 0; int i; volatile double x; double zero = 0.0; #if HAVE_DECL_ALARM /* NeXTstep 3.3 frexp() runs into an endless loop when called on an infinite number. Let the test fail in this case. */ signal (SIGALRM, SIG_DFL); alarm (5); #endif /* Test on denormalized numbers. */ for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5) ; if (x > 0.0) { int exp; double y = frexp (x, &exp); /* On machines with IEEE754 arithmetic: x = 1.11254e-308, exp = -1022. On NetBSD: y = 0.75. Correct: y = 0.5. */ if (y != 0.5) result |= 1; } /* Test on infinite numbers. */ x = 1.0 / zero; { int exp; double y = frexp (x, &exp); if (y != x) result |= 2; } /* Test on negative zero. */ x = minus_zero; { int exp; double y = frexp (x, &exp); if (memcmp (&y, &x, sizeof x)) result |= 4; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_frexp_works=yes else gl_cv_func_frexp_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_frexp_works" >&5 $as_echo "$gl_cv_func_frexp_works" >&6; } case "$gl_cv_func_frexp_works" in *yes) $as_echo "#define HAVE_FREXP_IN_LIBC 1" >>confdefs.h ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ldexp can be used without linking with libm" >&5 $as_echo_n "checking whether ldexp can be used without linking with libm... " >&6; } if ${gl_cv_func_ldexp_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include double x; int y; int main () { return ldexp (x, y) < 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_ldexp_no_libm=yes else gl_cv_func_ldexp_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_ldexp_no_libm" >&5 $as_echo "$gl_cv_func_ldexp_no_libm" >&6; } if test $gl_cv_func_ldexp_no_libm = yes; then $as_echo "#define HAVE_LDEXP_IN_LIBC 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether frexpl() can be used without linking with libm" >&5 $as_echo_n "checking whether frexpl() can be used without linking with libm... " >&6; } if ${gl_cv_func_frexpl_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include long double x; int main () { int e; return frexpl (x, &e) > 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_frexpl_no_libm=yes else gl_cv_func_frexpl_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_frexpl_no_libm" >&5 $as_echo "$gl_cv_func_frexpl_no_libm" >&6; } if test $gl_cv_func_frexpl_no_libm = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether frexpl works" >&5 $as_echo_n "checking whether frexpl works... " >&6; } if ${gl_cv_func_frexpl_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in aix | aix[3-6]* | beos* | darwin* | irix* | mingw* | pw*) gl_cv_func_frexpl_works="guessing no";; *) gl_cv_func_frexpl_works="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Override the values of , like done in float.in.h. */ #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) # undef LDBL_MIN_EXP # define LDBL_MIN_EXP (-16381) #endif #if defined __i386__ && defined __FreeBSD__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP (-16381) #endif #if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP #endif #if defined __sgi && (LDBL_MANT_DIG >= 106) # if defined __GNUC__ # undef LDBL_MIN_EXP # define LDBL_MIN_EXP DBL_MIN_EXP # endif #endif extern #ifdef __cplusplus "C" #endif long double frexpl (long double, int *); int main() { int result = 0; volatile long double x; /* Test on finite numbers that fails on AIX 5.1. */ x = 16.0L; { int exp = -9999; frexpl (x, &exp); if (exp != 5) result |= 1; } /* Test on finite numbers that fails on Mac OS X 10.4, because its frexpl function returns an invalid (incorrectly normalized) value: it returns y = { 0x3fe028f5, 0xc28f5c28, 0x3c9eb851, 0xeb851eb8 } but the correct result is 0.505L = { 0x3fe028f5, 0xc28f5c29, 0xbc547ae1, 0x47ae1480 } */ x = 1.01L; { int exp = -9999; long double y = frexpl (x, &exp); if (!(exp == 1 && y == 0.505L)) result |= 2; } /* Test on large finite numbers. This fails on BeOS at i = 16322, while LDBL_MAX_EXP = 16384. In the loop end test, we test x against Infinity, rather than comparing i with LDBL_MAX_EXP, because BeOS has a wrong LDBL_MAX_EXP. */ { int i; for (i = 1, x = 1.0L; x != x + x; i++, x *= 2.0L) { int exp = -9999; frexpl (x, &exp); if (exp != i) { result |= 4; break; } } } /* Test on denormalized numbers. */ { int i; for (i = 1, x = 1.0L; i >= LDBL_MIN_EXP; i--, x *= 0.5L) ; if (x > 0.0L) { int exp; long double y = frexpl (x, &exp); /* On machines with IEEE854 arithmetic: x = 1.68105e-4932, exp = -16382, y = 0.5. On Mac OS X 10.5: exp = -16384, y = 0.5. */ if (exp != LDBL_MIN_EXP - 1) result |= 8; } } /* Test on infinite numbers. */ x = 1.0L / 0.0L; { int exp; long double y = frexpl (x, &exp); if (y != x) result |= 16; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_frexpl_works=yes else gl_cv_func_frexpl_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_frexpl_works" >&5 $as_echo "$gl_cv_func_frexpl_works" >&6; } case "$gl_cv_func_frexpl_works" in *yes) gl_func_frexpl_no_libm=yes ;; *) gl_func_frexpl_no_libm=no; REPLACE_FREXPL=1 ;; esac else gl_func_frexpl_no_libm=no REPLACE_FREXPL=1 fi if test $gl_func_frexpl_no_libm = yes; then $as_echo "#define HAVE_FREXPL_IN_LIBC 1" >>confdefs.h ac_fn_c_check_decl "$LINENO" "frexpl" "ac_cv_have_decl_frexpl" "#include " if test "x$ac_cv_have_decl_frexpl" = xyes; then : else HAVE_DECL_FREXPL=0 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ldexpl() can be used without linking with libm" >&5 $as_echo_n "checking whether ldexpl() can be used without linking with libm... " >&6; } if ${gl_cv_func_ldexpl_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include long double x; int main () { return ldexpl (x, -1) > 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_ldexpl_no_libm=yes else gl_cv_func_ldexpl_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_ldexpl_no_libm" >&5 $as_echo "$gl_cv_func_ldexpl_no_libm" >&6; } if test $gl_cv_func_ldexpl_no_libm = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ldexpl works" >&5 $as_echo_n "checking whether ldexpl works... " >&6; } if ${gl_cv_func_ldexpl_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in aix | aix[3-6]*) gl_cv_func_ldexpl_works="guessing no";; *) gl_cv_func_ldexpl_works="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include extern #ifdef __cplusplus "C" #endif long double ldexpl (long double, int); int main() { int result = 0; { volatile long double x = 1.0; volatile long double y = ldexpl (x, -1); if (y != 0.5L) result |= 1; } { volatile long double x = 1.73205L; volatile long double y = ldexpl (x, 0); if (y != x) result |= 2; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_ldexpl_works=yes else gl_cv_func_ldexpl_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_ldexpl_works" >&5 $as_echo "$gl_cv_func_ldexpl_works" >&6; } case "$gl_cv_func_ldexpl_works" in *yes) $as_echo "#define HAVE_LDEXPL_IN_LIBC 1" >>confdefs.h ac_fn_c_check_decl "$LINENO" "ldexpl" "ac_cv_have_decl_ldexpl" "#include " if test "x$ac_cv_have_decl_ldexpl" = xyes; then : else HAVE_DECL_LDEXPL=0 fi ;; esac fi : : for ac_func in readdir do : ac_fn_c_check_func "$LINENO" "readdir" "ac_cv_func_readdir" if test "x$ac_cv_func_readdir" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_READDIR 1 _ACEOF fi done if test $ac_cv_func_readdir = no; then HAVE_READDIR=0 fi if test $HAVE_READDIR = 0; then gl_LIBOBJS="$gl_LIBOBJS readdir.$ac_objext" fi GNULIB_READDIR=1 $as_echo "#define GNULIB_TEST_READDIR 1" >>confdefs.h if test $ac_cv_func_readlink = no; then HAVE_READLINK=0 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlink signature is correct" >&5 $as_echo_n "checking whether readlink signature is correct... " >&6; } if ${gl_cv_decl_readlink_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Cause compilation failure if original declaration has wrong type. */ ssize_t readlink (const char *, char *, size_t); int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_decl_readlink_works=yes else gl_cv_decl_readlink_works=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_readlink_works" >&5 $as_echo "$gl_cv_decl_readlink_works" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlink handles trailing slash correctly" >&5 $as_echo_n "checking whether readlink handles trailing slash correctly... " >&6; } if ${gl_cv_func_readlink_works+:} false; then : $as_echo_n "(cached) " >&6 else # We have readlink, so assume ln -s works. ln -s conftest.no-such conftest.link ln -s conftest.link conftest.lnk2 if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_readlink_works="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_readlink_works="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char buf[20]; return readlink ("conftest.lnk2/", buf, sizeof buf) != -1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_readlink_works=yes else gl_cv_func_readlink_works=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 -f conftest.link conftest.lnk2 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_readlink_works" >&5 $as_echo "$gl_cv_func_readlink_works" >&6; } case "$gl_cv_func_readlink_works" in *yes) if test "$gl_cv_decl_readlink_works" != yes; then REPLACE_READLINK=1 fi ;; *) $as_echo "#define READLINK_TRAILING_SLASH_BUG 1" >>confdefs.h REPLACE_READLINK=1 ;; esac fi if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then gl_LIBOBJS="$gl_LIBOBJS readlink.$ac_objext" : fi GNULIB_READLINK=1 $as_echo "#define GNULIB_TEST_READLINK 1" >>confdefs.h # Check whether --with-included-regex was given. if test "${with_included_regex+set}" = set; then : withval=$with_included_regex; fi case $with_included_regex in #( yes|no) ac_use_included_regex=$with_included_regex ;; '') # If the system regex support is good enough that it passes the # following run test, then default to *not* using the included regex.c. # If cross compiling, assume the test would fail and use the included # regex.c. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working re_compile_pattern" >&5 $as_echo_n "checking for working re_compile_pattern... " >&6; } if ${gl_cv_func_re_compile_pattern_working+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_func_re_compile_pattern_working=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #if defined M_CHECK_ACTION || HAVE_DECL_ALARM # include # include #endif #if HAVE_MALLOC_H # include #endif #ifdef M_CHECK_ACTION /* Exit with distinguishable exit code. */ static void sigabrt_no_core (int sig) { raise (SIGTERM); } #endif int main () { int result = 0; static struct re_pattern_buffer regex; unsigned char folded_chars[UCHAR_MAX + 1]; int i; const char *s; struct re_registers regs; /* Some builds of glibc go into an infinite loop on this test. Use alarm to force death, and mallopt to avoid malloc recursion in diagnosing the corrupted heap. */ #if HAVE_DECL_ALARM signal (SIGALRM, SIG_DFL); alarm (2); #endif #ifdef M_CHECK_ACTION signal (SIGABRT, sigabrt_no_core); mallopt (M_CHECK_ACTION, 2); #endif if (setlocale (LC_ALL, "en_US.UTF-8")) { { /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html This test needs valgrind to catch the bug on Debian GNU/Linux 3.1 x86, but it might catch the bug better on other platforms and it shouldn't hurt to try the test here. */ static char const pat[] = "insert into"; static char const data[] = "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE | RE_ICASE); memset (®ex, 0, sizeof regex); s = re_compile_pattern (pat, sizeof pat - 1, ®ex); if (s) result |= 1; else if (re_search (®ex, data, sizeof data - 1, 0, sizeof data - 1, ®s) != -1) result |= 1; } { /* This test is from glibc bug 15078. The test case is from Andreas Schwab in . */ static char const pat[] = "[^x]x"; static char const data[] = /* */ "\xe1\x80\x80" "\xe1\x80\xbb" "\xe1\x80\xbd" "\xe1\x80\x94" "\xe1\x80\xba" "\xe1\x80\xaf" "\xe1\x80\x95" "\xe1\x80\xba" "x"; re_set_syntax (0); memset (®ex, 0, sizeof regex); s = re_compile_pattern (pat, sizeof pat - 1, ®ex); if (s) result |= 1; else { i = re_search (®ex, data, sizeof data - 1, 0, sizeof data - 1, 0); if (i != 0 && i != 21) result |= 1; } } if (! setlocale (LC_ALL, "C")) return 1; } /* This test is from glibc bug 3957, reported by Andrew Mackey. */ re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); memset (®ex, 0, sizeof regex); s = re_compile_pattern ("a[^x]b", 6, ®ex); if (s) result |= 2; /* This should fail, but succeeds for glibc-2.5. */ else if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) result |= 2; /* This regular expression is from Spencer ere test number 75 in grep-2.3. */ re_set_syntax (RE_SYNTAX_POSIX_EGREP); memset (®ex, 0, sizeof regex); for (i = 0; i <= UCHAR_MAX; i++) folded_chars[i] = i; regex.translate = folded_chars; s = re_compile_pattern ("a[[:]:]]b\n", 11, ®ex); /* This should fail with _Invalid character class name_ error. */ if (!s) result |= 4; /* Ensure that [b-a] is diagnosed as invalid, when using RE_NO_EMPTY_RANGES. */ re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES); memset (®ex, 0, sizeof regex); s = re_compile_pattern ("a[b-a]", 6, ®ex); if (s == 0) result |= 8; /* This should succeed, but does not for glibc-2.1.3. */ memset (®ex, 0, sizeof regex); s = re_compile_pattern ("{1", 2, ®ex); if (s) result |= 8; /* The following example is derived from a problem report against gawk from Jorge Stolfi . */ memset (®ex, 0, sizeof regex); s = re_compile_pattern ("[an\371]*n", 7, ®ex); if (s) result |= 8; /* This should match, but does not for glibc-2.2.1. */ else if (re_match (®ex, "an", 2, 0, ®s) != 2) result |= 8; memset (®ex, 0, sizeof regex); s = re_compile_pattern ("x", 1, ®ex); if (s) result |= 8; /* glibc-2.2.93 does not work with a negative RANGE argument. */ else if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) result |= 8; /* The version of regex.c in older versions of gnulib ignored RE_ICASE. Detect that problem too. */ re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); memset (®ex, 0, sizeof regex); s = re_compile_pattern ("x", 1, ®ex); if (s) result |= 16; else if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) result |= 16; /* Catch a bug reported by Vin Shelton in http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html */ re_set_syntax (RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES); memset (®ex, 0, sizeof regex); s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); if (s) result |= 32; /* REG_STARTEND was added to glibc on 2004-01-15. Reject older versions. */ if (! REG_STARTEND) result |= 64; #if 0 /* It would be nice to reject hosts whose regoff_t values are too narrow (including glibc on hosts with 64-bit ptrdiff_t and 32-bit int), but we should wait until glibc implements this feature. Otherwise, support for equivalence classes and multibyte collation symbols would always be broken except when compiling --without-included-regex. */ if (sizeof (regoff_t) < sizeof (ptrdiff_t) || sizeof (regoff_t) < sizeof (ssize_t)) result |= 64; #endif return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_re_compile_pattern_working=yes else gl_cv_func_re_compile_pattern_working=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_re_compile_pattern_working" >&5 $as_echo "$gl_cv_func_re_compile_pattern_working" >&6; } case $gl_cv_func_re_compile_pattern_working in #( yes) ac_use_included_regex=no;; #( no) ac_use_included_regex=yes;; esac ;; *) as_fn_error $? "Invalid value for --with-included-regex: $with_included_regex" "$LINENO" 5 ;; esac if test $ac_use_included_regex = yes; then $as_echo "#define _REGEX_INCLUDE_LIMITS_H 1" >>confdefs.h $as_echo "#define _REGEX_LARGE_OFFSETS 1" >>confdefs.h $as_echo "#define re_syntax_options rpl_re_syntax_options" >>confdefs.h $as_echo "#define re_set_syntax rpl_re_set_syntax" >>confdefs.h $as_echo "#define re_compile_pattern rpl_re_compile_pattern" >>confdefs.h $as_echo "#define re_compile_fastmap rpl_re_compile_fastmap" >>confdefs.h $as_echo "#define re_search rpl_re_search" >>confdefs.h $as_echo "#define re_search_2 rpl_re_search_2" >>confdefs.h $as_echo "#define re_match rpl_re_match" >>confdefs.h $as_echo "#define re_match_2 rpl_re_match_2" >>confdefs.h $as_echo "#define re_set_registers rpl_re_set_registers" >>confdefs.h $as_echo "#define re_comp rpl_re_comp" >>confdefs.h $as_echo "#define re_exec rpl_re_exec" >>confdefs.h $as_echo "#define regcomp rpl_regcomp" >>confdefs.h $as_echo "#define regexec rpl_regexec" >>confdefs.h $as_echo "#define regerror rpl_regerror" >>confdefs.h $as_echo "#define regfree rpl_regfree" >>confdefs.h fi if test $ac_use_included_regex = yes; then gl_LIBOBJS="$gl_LIBOBJS regex.$ac_objext" for ac_header in libintl.h do : ac_fn_c_check_header_mongrel "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default" if test "x$ac_cv_header_libintl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBINTL_H 1 _ACEOF fi done ac_fn_c_check_decl "$LINENO" "isblank" "ac_cv_have_decl_isblank" "#include " if test "x$ac_cv_have_decl_isblank" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_ISBLANK $ac_have_decl _ACEOF fi if test "$ac_cv_header_winsock2_h" = yes; then REPLACE_SELECT=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether select supports a 0 argument" >&5 $as_echo_n "checking whether select supports a 0 argument... " >&6; } if ${gl_cv_func_select_supports0+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess no on Interix. interix*) gl_cv_func_select_supports0="guessing no";; # Guess yes otherwise. *) gl_cv_func_select_supports0="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_SYS_SELECT_H #include #endif int main () { struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 5; return select (0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout) < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_select_supports0=yes else gl_cv_func_select_supports0=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_select_supports0" >&5 $as_echo "$gl_cv_func_select_supports0" >&6; } case "$gl_cv_func_select_supports0" in *yes) ;; *) REPLACE_SELECT=1 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether select detects invalid fds" >&5 $as_echo_n "checking whether select detects invalid fds... " >&6; } if ${gl_cv_func_select_detects_ebadf+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_select_detects_ebadf="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_select_detects_ebadf="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_SYS_SELECT_H # include #endif #include #include int main () { fd_set set; dup2(0, 16); FD_ZERO(&set); FD_SET(16, &set); close(16); struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 5; return select (17, &set, NULL, NULL, &timeout) != -1 || errno != EBADF; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_select_detects_ebadf=yes else gl_cv_func_select_detects_ebadf=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_select_detects_ebadf" >&5 $as_echo "$gl_cv_func_select_detects_ebadf" >&6; } case $gl_cv_func_select_detects_ebadf in *yes) ;; *) REPLACE_SELECT=1 ;; esac fi LIB_SELECT="$LIBSOCKET" if test $REPLACE_SELECT = 1; then case "$host_os" in mingw*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define WIN32_LEAN_AND_MEAN #include int main () { MsgWaitForMultipleObjects (0, NULL, 0, 0, 0); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : else LIB_SELECT="$LIB_SELECT -luser32" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ;; esac fi if test $REPLACE_SELECT = 1; then gl_LIBOBJS="$gl_LIBOBJS select.$ac_objext" fi GNULIB_SELECT=1 $as_echo "#define GNULIB_TEST_SELECT 1" >>confdefs.h if test $ac_cv_func_setenv = no; then HAVE_SETENV=0 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setenv validates arguments" >&5 $as_echo_n "checking whether setenv validates arguments... " >&6; } if ${gl_cv_func_setenv_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_setenv_works="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_setenv_works="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { int result = 0; { if (setenv ("", "", 0) != -1) result |= 1; else if (errno != EINVAL) result |= 2; } { if (setenv ("a", "=", 1) != 0) result |= 4; else if (strcmp (getenv ("a"), "=") != 0) result |= 8; } return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_setenv_works=yes else gl_cv_func_setenv_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_setenv_works" >&5 $as_echo "$gl_cv_func_setenv_works" >&6; } case "$gl_cv_func_setenv_works" in *yes) ;; *) REPLACE_SETENV=1 ;; esac fi if test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1; then gl_LIBOBJS="$gl_LIBOBJS setenv.$ac_objext" fi GNULIB_SETENV=1 $as_echo "#define GNULIB_TEST_SETENV 1" >>confdefs.h if test $gl_cv_have_include_next = yes; then gl_cv_next_signal_h='<'signal.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_signal_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'signal.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_signal_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_signal_h gl_cv_next_signal_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_signal_h" >&5 $as_echo "$gl_cv_next_signal_h" >&6; } fi NEXT_SIGNAL_H=$gl_cv_next_signal_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'signal.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_signal_h fi NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H=$gl_next_as_first_directive # AIX declares sig_atomic_t to already include volatile, and C89 compilers # then choke on 'volatile sig_atomic_t'. C99 requires that it compile. ac_fn_c_check_type "$LINENO" "volatile sig_atomic_t" "ac_cv_type_volatile_sig_atomic_t" " #include " if test "x$ac_cv_type_volatile_sig_atomic_t" = xyes; then : else HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0 fi ac_fn_c_check_type "$LINENO" "sighandler_t" "ac_cv_type_sighandler_t" " #include " if test "x$ac_cv_type_sighandler_t" = xyes; then : else HAVE_SIGHANDLER_T=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for signbit macro" >&5 $as_echo_n "checking for signbit macro... " >&6; } if ${gl_cv_func_signbit+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_signbit="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_signbit="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* If signbit is defined as a function, don't use it, since calling it for 'float' or 'long double' arguments would involve conversions. If signbit is not declared at all but exists as a library function, don't use it, since the prototype may not match. If signbit is not declared at all but exists as a compiler built-in, don't use it, since it's preferable to use __builtin_signbit* (no warnings, no conversions). */ #ifndef signbit # error "signbit should be a macro" #endif #include /* Global variables. Needed because GCC 4 constant-folds __builtin_signbitl (literal) but cannot constant-fold __builtin_signbitl (variable). */ float vf; double vd; long double vl; int main () { /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. So we use -p0f and -p0d instead. */ float p0f = 0.0f; float m0f = -p0f; double p0d = 0.0; double m0d = -p0d; /* On HP-UX 10.20, negating 0.0L does not yield -0.0L. So we use another constant expression instead. But that expression does not work on other platforms, such as when cross-compiling to PowerPC on Mac OS X 10.5. */ long double p0l = 0.0L; #if defined __hpux || defined __sgi long double m0l = -LDBL_MIN * LDBL_MIN; #else long double m0l = -p0l; #endif int result = 0; if (signbit (vf)) /* link check */ vf++; { float plus_inf = 1.0f / p0f; float minus_inf = -1.0f / p0f; if (!(!signbit (255.0f) && signbit (-255.0f) && !signbit (p0f) && (memcmp (&m0f, &p0f, sizeof (float)) == 0 || signbit (m0f)) && !signbit (plus_inf) && signbit (minus_inf))) result |= 1; } if (signbit (vd)) /* link check */ vd++; { double plus_inf = 1.0 / p0d; double minus_inf = -1.0 / p0d; if (!(!signbit (255.0) && signbit (-255.0) && !signbit (p0d) && (memcmp (&m0d, &p0d, sizeof (double)) == 0 || signbit (m0d)) && !signbit (plus_inf) && signbit (minus_inf))) result |= 2; } if (signbit (vl)) /* link check */ vl++; { long double plus_inf = 1.0L / p0l; long double minus_inf = -1.0L / p0l; if (signbit (255.0L)) result |= 4; if (!signbit (-255.0L)) result |= 4; if (signbit (p0l)) result |= 8; if (!(memcmp (&m0l, &p0l, sizeof (long double)) == 0 || signbit (m0l))) result |= 16; if (signbit (plus_inf)) result |= 32; if (!signbit (minus_inf)) result |= 64; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_signbit=yes else gl_cv_func_signbit=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_signbit" >&5 $as_echo "$gl_cv_func_signbit" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for signbit compiler built-ins" >&5 $as_echo_n "checking for signbit compiler built-ins... " >&6; } if ${gl_cv_func_signbit_gcc+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_signbit_gcc="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_signbit_gcc="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if __GNUC__ >= 4 # define signbit(x) \ (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ __builtin_signbitf (x)) #else # error "signbit should be three compiler built-ins" #endif #include /* Global variables. Needed because GCC 4 constant-folds __builtin_signbitl (literal) but cannot constant-fold __builtin_signbitl (variable). */ float vf; double vd; long double vl; int main () { /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. So we use -p0f and -p0d instead. */ float p0f = 0.0f; float m0f = -p0f; double p0d = 0.0; double m0d = -p0d; /* On HP-UX 10.20, negating 0.0L does not yield -0.0L. So we use another constant expression instead. But that expression does not work on other platforms, such as when cross-compiling to PowerPC on Mac OS X 10.5. */ long double p0l = 0.0L; #if defined __hpux || defined __sgi long double m0l = -LDBL_MIN * LDBL_MIN; #else long double m0l = -p0l; #endif int result = 0; if (signbit (vf)) /* link check */ vf++; { float plus_inf = 1.0f / p0f; float minus_inf = -1.0f / p0f; if (!(!signbit (255.0f) && signbit (-255.0f) && !signbit (p0f) && (memcmp (&m0f, &p0f, sizeof (float)) == 0 || signbit (m0f)) && !signbit (plus_inf) && signbit (minus_inf))) result |= 1; } if (signbit (vd)) /* link check */ vd++; { double plus_inf = 1.0 / p0d; double minus_inf = -1.0 / p0d; if (!(!signbit (255.0) && signbit (-255.0) && !signbit (p0d) && (memcmp (&m0d, &p0d, sizeof (double)) == 0 || signbit (m0d)) && !signbit (plus_inf) && signbit (minus_inf))) result |= 2; } if (signbit (vl)) /* link check */ vl++; { long double plus_inf = 1.0L / p0l; long double minus_inf = -1.0L / p0l; if (signbit (255.0L)) result |= 4; if (!signbit (-255.0L)) result |= 4; if (signbit (p0l)) result |= 8; if (!(memcmp (&m0l, &p0l, sizeof (long double)) == 0 || signbit (m0l))) result |= 16; if (signbit (plus_inf)) result |= 32; if (!signbit (minus_inf)) result |= 64; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_signbit_gcc=yes else gl_cv_func_signbit_gcc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_signbit_gcc" >&5 $as_echo "$gl_cv_func_signbit_gcc" >&6; } case "$gl_cv_func_signbit_gcc" in *yes) REPLACE_SIGNBIT_USING_GCC=1 ;; *) case "$gl_cv_func_signbit" in *yes) ;; *) REPLACE_SIGNBIT=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the sign bit in a 'float'" >&5 $as_echo_n "checking where to find the sign bit in a 'float'... " >&6; } if ${gl_cv_cc_float_signbit+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_cc_float_signbit="unknown" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #define NWORDS \ ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { float value; unsigned int word[NWORDS]; } memory_float; static memory_float plus = { 1.0f }; static memory_float minus = { -1.0f }; int main () { size_t j, k, i; unsigned int m; FILE *fp = fopen ("conftest.out", "w"); if (fp == NULL) return 1; /* Find the different bit. */ k = 0; m = 0; for (j = 0; j < NWORDS; j++) { unsigned int x = plus.word[j] ^ minus.word[j]; if ((x & (x - 1)) || (x && m)) { /* More than one bit difference. */ fprintf (fp, "unknown"); return 2; } if (x) { k = j; m = x; } } if (m == 0) { /* No difference. */ fprintf (fp, "unknown"); return 3; } /* Now m = plus.word[k] ^ ~minus.word[k]. */ if (plus.word[k] & ~minus.word[k]) { /* Oh? The sign bit is set in the positive and cleared in the negative numbers? */ fprintf (fp, "unknown"); return 4; } for (i = 0; ; i++) if ((m >> i) & 1) break; fprintf (fp, "word %d bit %d", (int) k, (int) i); if (fclose (fp) != 0) return 5; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_cc_float_signbit=`cat conftest.out` else gl_cv_cc_float_signbit="unknown" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_float_signbit" >&5 $as_echo "$gl_cv_cc_float_signbit" >&6; } case "$gl_cv_cc_float_signbit" in word*bit*) word=`echo "$gl_cv_cc_float_signbit" | sed -e 's/word //' -e 's/ bit.*//'` bit=`echo "$gl_cv_cc_float_signbit" | sed -e 's/word.*bit //'` cat >>confdefs.h <<_ACEOF #define FLT_SIGNBIT_WORD $word _ACEOF cat >>confdefs.h <<_ACEOF #define FLT_SIGNBIT_BIT $bit _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the sign bit in a 'double'" >&5 $as_echo_n "checking where to find the sign bit in a 'double'... " >&6; } if ${gl_cv_cc_double_signbit+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_cc_double_signbit="unknown" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #define NWORDS \ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { double value; unsigned int word[NWORDS]; } memory_float; static memory_float plus = { 1.0 }; static memory_float minus = { -1.0 }; int main () { size_t j, k, i; unsigned int m; FILE *fp = fopen ("conftest.out", "w"); if (fp == NULL) return 1; /* Find the different bit. */ k = 0; m = 0; for (j = 0; j < NWORDS; j++) { unsigned int x = plus.word[j] ^ minus.word[j]; if ((x & (x - 1)) || (x && m)) { /* More than one bit difference. */ fprintf (fp, "unknown"); return 2; } if (x) { k = j; m = x; } } if (m == 0) { /* No difference. */ fprintf (fp, "unknown"); return 3; } /* Now m = plus.word[k] ^ ~minus.word[k]. */ if (plus.word[k] & ~minus.word[k]) { /* Oh? The sign bit is set in the positive and cleared in the negative numbers? */ fprintf (fp, "unknown"); return 4; } for (i = 0; ; i++) if ((m >> i) & 1) break; fprintf (fp, "word %d bit %d", (int) k, (int) i); if (fclose (fp) != 0) return 5; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_cc_double_signbit=`cat conftest.out` else gl_cv_cc_double_signbit="unknown" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_double_signbit" >&5 $as_echo "$gl_cv_cc_double_signbit" >&6; } case "$gl_cv_cc_double_signbit" in word*bit*) word=`echo "$gl_cv_cc_double_signbit" | sed -e 's/word //' -e 's/ bit.*//'` bit=`echo "$gl_cv_cc_double_signbit" | sed -e 's/word.*bit //'` cat >>confdefs.h <<_ACEOF #define DBL_SIGNBIT_WORD $word _ACEOF cat >>confdefs.h <<_ACEOF #define DBL_SIGNBIT_BIT $bit _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the sign bit in a 'long double'" >&5 $as_echo_n "checking where to find the sign bit in a 'long double'... " >&6; } if ${gl_cv_cc_long_double_signbit+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_cc_long_double_signbit="unknown" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #define NWORDS \ ((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { long double value; unsigned int word[NWORDS]; } memory_float; static memory_float plus = { 1.0L }; static memory_float minus = { -1.0L }; int main () { size_t j, k, i; unsigned int m; FILE *fp = fopen ("conftest.out", "w"); if (fp == NULL) return 1; /* Find the different bit. */ k = 0; m = 0; for (j = 0; j < NWORDS; j++) { unsigned int x = plus.word[j] ^ minus.word[j]; if ((x & (x - 1)) || (x && m)) { /* More than one bit difference. */ fprintf (fp, "unknown"); return 2; } if (x) { k = j; m = x; } } if (m == 0) { /* No difference. */ fprintf (fp, "unknown"); return 3; } /* Now m = plus.word[k] ^ ~minus.word[k]. */ if (plus.word[k] & ~minus.word[k]) { /* Oh? The sign bit is set in the positive and cleared in the negative numbers? */ fprintf (fp, "unknown"); return 4; } for (i = 0; ; i++) if ((m >> i) & 1) break; fprintf (fp, "word %d bit %d", (int) k, (int) i); if (fclose (fp) != 0) return 5; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_cc_long_double_signbit=`cat conftest.out` else gl_cv_cc_long_double_signbit="unknown" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_long_double_signbit" >&5 $as_echo "$gl_cv_cc_long_double_signbit" >&6; } case "$gl_cv_cc_long_double_signbit" in word*bit*) word=`echo "$gl_cv_cc_long_double_signbit" | sed -e 's/word //' -e 's/ bit.*//'` bit=`echo "$gl_cv_cc_long_double_signbit" | sed -e 's/word.*bit //'` cat >>confdefs.h <<_ACEOF #define LDBL_SIGNBIT_WORD $word _ACEOF cat >>confdefs.h <<_ACEOF #define LDBL_SIGNBIT_BIT $bit _ACEOF ;; esac if test "$gl_cv_cc_float_signbit" = unknown; then ac_fn_c_check_decl "$LINENO" "copysignf" "ac_cv_have_decl_copysignf" "#include " if test "x$ac_cv_have_decl_copysignf" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_COPYSIGNF $ac_have_decl _ACEOF if test "$ac_cv_have_decl_copysignf" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether copysignf can be used without linking with libm" >&5 $as_echo_n "checking whether copysignf can be used without linking with libm... " >&6; } if ${gl_cv_func_copysignf_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include float x, y; int main () { return copysignf (x, y) < 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_copysignf_no_libm=yes else gl_cv_func_copysignf_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_copysignf_no_libm" >&5 $as_echo "$gl_cv_func_copysignf_no_libm" >&6; } if test $gl_cv_func_copysignf_no_libm = yes; then $as_echo "#define HAVE_COPYSIGNF_IN_LIBC 1" >>confdefs.h fi fi fi if test "$gl_cv_cc_double_signbit" = unknown; then ac_fn_c_check_decl "$LINENO" "copysign" "ac_cv_have_decl_copysign" "#include " if test "x$ac_cv_have_decl_copysign" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_COPYSIGN $ac_have_decl _ACEOF if test "$ac_cv_have_decl_copysign" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether copysign can be used without linking with libm" >&5 $as_echo_n "checking whether copysign can be used without linking with libm... " >&6; } if ${gl_cv_func_copysign_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include double x, y; int main () { return copysign (x, y) < 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_copysign_no_libm=yes else gl_cv_func_copysign_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_copysign_no_libm" >&5 $as_echo "$gl_cv_func_copysign_no_libm" >&6; } if test $gl_cv_func_copysign_no_libm = yes; then $as_echo "#define HAVE_COPYSIGN_IN_LIBC 1" >>confdefs.h fi fi fi if test "$gl_cv_cc_long_double_signbit" = unknown; then ac_fn_c_check_decl "$LINENO" "copysignl" "ac_cv_have_decl_copysignl" "#include " if test "x$ac_cv_have_decl_copysignl" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_COPYSIGNL $ac_have_decl _ACEOF if test "$ac_cv_have_decl_copysignl" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether copysignl can be used without linking with libm" >&5 $as_echo_n "checking whether copysignl can be used without linking with libm... " >&6; } if ${gl_cv_func_copysignl_no_libm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include long double x, y; int main () { return copysignl (x, y) < 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gl_cv_func_copysignl_no_libm=yes else gl_cv_func_copysignl_no_libm=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_copysignl_no_libm" >&5 $as_echo "$gl_cv_func_copysignl_no_libm" >&6; } if test $gl_cv_func_copysignl_no_libm = yes; then $as_echo "#define HAVE_COPYSIGNL_IN_LIBC 1" >>confdefs.h fi fi fi ;; esac ;; esac if test $REPLACE_SIGNBIT = 1; then gl_LIBOBJS="$gl_LIBOBJS signbitf.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS signbitd.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS signbitl.$ac_objext" fi GNULIB_SIGNBIT=1 $as_echo "#define GNULIB_TEST_SIGNBIT 1" >>confdefs.h for ac_header in stdint.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default" if test "x$ac_cv_header_stdint_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDINT_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SIZE_MAX" >&5 $as_echo_n "checking for SIZE_MAX... " >&6; } if ${gl_cv_size_max+:} false; then : $as_echo_n "(cached) " >&6 else gl_cv_size_max= cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_STDINT_H #include #endif #ifdef SIZE_MAX Found it #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Found it" >/dev/null 2>&1; then : gl_cv_size_max=yes fi rm -f conftest* if test -z "$gl_cv_size_max"; then if ac_fn_c_compute_int "$LINENO" "sizeof (size_t) * CHAR_BIT - 1" "size_t_bits_minus_1" "#include #include "; then : else size_t_bits_minus_1= fi if ac_fn_c_compute_int "$LINENO" "sizeof (size_t) <= sizeof (unsigned int)" "fits_in_uint" "#include "; then : else fits_in_uint= fi if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then if test $fits_in_uint = 1; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include extern size_t foo; extern unsigned long foo; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : fits_in_uint=0 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $fits_in_uint = 1; then gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)" else gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)" fi else gl_cv_size_max='((size_t)~(size_t)0)' fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_size_max" >&5 $as_echo "$gl_cv_size_max" >&6; } if test "$gl_cv_size_max" != yes; then cat >>confdefs.h <<_ACEOF #define SIZE_MAX $gl_cv_size_max _ACEOF fi ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" " /* is not needed according to POSIX, but the in i386-unknown-freebsd4.10 and powerpc-apple-darwin5.5 required it. */ #include #if HAVE_SYS_SOCKET_H # include #elif HAVE_WS2TCPIP_H # include #endif " if test "x$ac_cv_type_socklen_t" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t equivalent" >&5 $as_echo_n "checking for socklen_t equivalent... " >&6; } if ${gl_cv_socklen_t_equiv+:} false; then : $as_echo_n "(cached) " >&6 else # Systems have either "struct sockaddr *" or # "void *" as the second argument to getpeername gl_cv_socklen_t_equiv= for arg2 in "struct sockaddr" void; do for t in int size_t "unsigned int" "long int" "unsigned long int"; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int getpeername (int, $arg2 *, $t *); int main () { $t len; getpeername (0, 0, &len); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_socklen_t_equiv="$t" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$gl_cv_socklen_t_equiv" != "" && break done test "$gl_cv_socklen_t_equiv" != "" && break done fi if test "$gl_cv_socklen_t_equiv" = ""; then as_fn_error $? "Cannot find a type to use in place of socklen_t" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_socklen_t_equiv" >&5 $as_echo "$gl_cv_socklen_t_equiv" >&6; } cat >>confdefs.h <<_ACEOF #define socklen_t $gl_cv_socklen_t_equiv _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ssize_t" >&5 $as_echo_n "checking for ssize_t... " >&6; } if ${gt_cv_ssize_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int x = sizeof (ssize_t *) + sizeof (ssize_t); return !x; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gt_cv_ssize_t=yes else gt_cv_ssize_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_ssize_t" >&5 $as_echo "$gt_cv_ssize_t" >&6; } if test $gt_cv_ssize_t = no; then $as_echo "#define ssize_t int" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on directories" >&5 $as_echo_n "checking whether stat handles trailing slashes on directories... " >&6; } if ${gl_cv_func_stat_dir_slash+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case $host_os in mingw*) gl_cv_func_stat_dir_slash="guessing no";; *) gl_cv_func_stat_dir_slash="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct stat st; return stat (".", &st) != stat ("./", &st); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_stat_dir_slash=yes else gl_cv_func_stat_dir_slash=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_dir_slash" >&5 $as_echo "$gl_cv_func_stat_dir_slash" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on files" >&5 $as_echo_n "checking whether stat handles trailing slashes on files... " >&6; } if ${gl_cv_func_stat_file_slash+:} false; then : $as_echo_n "(cached) " >&6 else touch conftest.tmp # Assume that if we have lstat, we can also check symlinks. if test $ac_cv_func_lstat = yes; then ln -s conftest.tmp conftest.lnk fi if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_stat_file_slash="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int result = 0; struct stat st; if (!stat ("conftest.tmp/", &st)) result |= 1; #if HAVE_LSTAT if (!stat ("conftest.lnk/", &st)) result |= 2; #endif return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_stat_file_slash=yes else gl_cv_func_stat_file_slash=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 -f conftest.tmp conftest.lnk fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_file_slash" >&5 $as_echo "$gl_cv_func_stat_file_slash" >&6; } case $gl_cv_func_stat_dir_slash in *no) REPLACE_STAT=1 $as_echo "#define REPLACE_FUNC_STAT_DIR 1" >>confdefs.h ;; esac case $gl_cv_func_stat_file_slash in *no) REPLACE_STAT=1 $as_echo "#define REPLACE_FUNC_STAT_FILE 1" >>confdefs.h ;; esac if test $REPLACE_STAT = 1; then gl_LIBOBJS="$gl_LIBOBJS stat.$ac_objext" : fi GNULIB_STAT=1 $as_echo "#define GNULIB_TEST_STAT 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working stdalign.h" >&5 $as_echo_n "checking for working stdalign.h... " >&6; } if ${gl_cv_header_working_stdalign_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Test that alignof yields a result consistent with offsetof. This catches GCC bug 52023 . */ #ifdef __cplusplus template struct alignof_helper { char a; t b; }; # define ao(type) offsetof (alignof_helper, b) #else # define ao(type) offsetof (struct { char a; type b; }, b) #endif char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1]; char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1]; char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1]; /* Test _Alignas only on platforms where gnulib can help. */ #if \ ((defined __cplusplus && 201103 <= __cplusplus) \ || (defined __APPLE__ && defined __MACH__ \ ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \ : __GNUC__) \ || __HP_cc || __HP_aCC || __IBMC__ || __IBMCPP__ \ || __ICC || 0x5110 <= __SUNPRO_C \ || 1300 <= _MSC_VER) struct alignas_test { char c; char alignas (8) alignas_8; }; char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 ? 1 : -1]; #endif int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_working_stdalign_h=yes else gl_cv_header_working_stdalign_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdalign_h" >&5 $as_echo "$gl_cv_header_working_stdalign_h" >&6; } if test $gl_cv_header_working_stdalign_h = yes; then STDALIGN_H='' else STDALIGN_H='stdalign.h' fi if test -n "$STDALIGN_H"; then GL_GENERATE_STDALIGN_H_TRUE= GL_GENERATE_STDALIGN_H_FALSE='#' else GL_GENERATE_STDALIGN_H_TRUE='#' GL_GENERATE_STDALIGN_H_FALSE= fi # Define two additional variables used in the Makefile substitution. if test "$ac_cv_header_stdbool_h" = yes; then STDBOOL_H='' else STDBOOL_H='stdbool.h' fi if test -n "$STDBOOL_H"; then GL_GENERATE_STDBOOL_H_TRUE= GL_GENERATE_STDBOOL_H_FALSE='#' else GL_GENERATE_STDBOOL_H_TRUE='#' GL_GENERATE_STDBOOL_H_FALSE= fi if test "$ac_cv_type__Bool" = yes; then HAVE__BOOL=1 else HAVE__BOOL=0 fi STDDEF_H= ac_fn_c_check_type "$LINENO" "max_align_t" "ac_cv_type_max_align_t" "#include " if test "x$ac_cv_type_max_align_t" = xyes; then : else HAVE_MAX_ALIGN_T=0; STDDEF_H=stddef.h fi if test $gt_cv_c_wchar_t = no; then HAVE_WCHAR_T=0 STDDEF_H=stddef.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NULL can be used in arbitrary expressions" >&5 $as_echo_n "checking whether NULL can be used in arbitrary expressions... " >&6; } if ${gl_cv_decl_null_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int test[2 * (sizeof NULL == sizeof (void *)) -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_decl_null_works=yes else gl_cv_decl_null_works=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_null_works" >&5 $as_echo "$gl_cv_decl_null_works" >&6; } if test $gl_cv_decl_null_works = no; then REPLACE_NULL=1 STDDEF_H=stddef.h fi if test -n "$STDDEF_H"; then GL_GENERATE_STDDEF_H_TRUE= GL_GENERATE_STDDEF_H_FALSE='#' else GL_GENERATE_STDDEF_H_TRUE='#' GL_GENERATE_STDDEF_H_FALSE= fi if test -n "$STDDEF_H"; then if test $gl_cv_have_include_next = yes; then gl_cv_next_stddef_h='<'stddef.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_stddef_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'stddef.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_stddef_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_stddef_h gl_cv_next_stddef_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5 $as_echo "$gl_cv_next_stddef_h" >&6; } fi NEXT_STDDEF_H=$gl_cv_next_stddef_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'stddef.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_stddef_h fi NEXT_AS_FIRST_DIRECTIVE_STDDEF_H=$gl_next_as_first_directive fi if test $gl_cv_have_include_next = yes; then gl_cv_next_stdio_h='<'stdio.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_stdio_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'stdio.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_stdio_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_stdio_h gl_cv_next_stdio_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdio_h" >&5 $as_echo "$gl_cv_next_stdio_h" >&6; } fi NEXT_STDIO_H=$gl_cv_next_stdio_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'stdio.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_stdio_h fi NEXT_AS_FIRST_DIRECTIVE_STDIO_H=$gl_next_as_first_directive { $as_echo "$as_me:${as_lineno-$LINENO}: checking which flavor of printf attribute matches inttypes macros" >&5 $as_echo_n "checking which flavor of printf attribute matches inttypes macros... " >&6; } if ${gl_cv_func_printf_attribute_flavor+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define __STDC_FORMAT_MACROS 1 #include #include /* For non-mingw systems, compilation will trivially succeed. For mingw, compilation will succeed for older mingw (system printf, "I64d") and fail for newer mingw (gnu printf, "lld"). */ #if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) && \ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) extern char PRIdMAX_probe[sizeof PRIdMAX == sizeof "I64d" ? 1 : -1]; #endif int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_func_printf_attribute_flavor=system else gl_cv_func_printf_attribute_flavor=gnu fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_attribute_flavor" >&5 $as_echo "$gl_cv_func_printf_attribute_flavor" >&6; } if test "$gl_cv_func_printf_attribute_flavor" = gnu; then $as_echo "#define GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU 1" >>confdefs.h fi GNULIB_FSCANF=1 cat >>confdefs.h <<_ACEOF #define GNULIB_FSCANF 1 _ACEOF GNULIB_SCANF=1 cat >>confdefs.h <<_ACEOF #define GNULIB_SCANF 1 _ACEOF GNULIB_FGETC=1 GNULIB_GETC=1 GNULIB_GETCHAR=1 GNULIB_FGETS=1 GNULIB_FREAD=1 GNULIB_FPRINTF=1 GNULIB_PRINTF=1 GNULIB_VFPRINTF=1 GNULIB_VPRINTF=1 GNULIB_FPUTC=1 GNULIB_PUTC=1 GNULIB_PUTCHAR=1 GNULIB_FPUTS=1 GNULIB_PUTS=1 GNULIB_FWRITE=1 if test $gl_cv_have_include_next = yes; then gl_cv_next_stdlib_h='<'stdlib.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_stdlib_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'stdlib.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_stdlib_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_stdlib_h gl_cv_next_stdlib_h='"'$gl_header'"' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdlib_h" >&5 $as_echo "$gl_cv_next_stdlib_h" >&6; } fi NEXT_STDLIB_H=$gl_cv_next_stdlib_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'stdlib.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_stdlib_h fi NEXT_AS_FIRST_DIRECTIVE_STDLIB_H=$gl_next_as_first_directive for ac_func in strcasecmp do : ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" if test "x$ac_cv_func_strcasecmp" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRCASECMP 1 _ACEOF fi done if test $ac_cv_func_strcasecmp = no; then HAVE_STRCASECMP=0 fi for ac_func in strncasecmp do : ac_fn_c_check_func "$LINENO" "strncasecmp" "ac_cv_func_strncasecmp" if test "x$ac_cv_func_strncasecmp" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRNCASECMP 1 _ACEOF fi done if test $ac_cv_func_strncasecmp = yes; then HAVE_STRNCASECMP=1 else HAVE_STRNCASECMP=0 fi ac_fn_c_check_decl "$LINENO" "strncasecmp" "ac_cv_have_decl_strncasecmp" "$ac_includes_default" if test "x$ac_cv_have_decl_strncasecmp" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRNCASECMP $ac_have_decl _ACEOF if test $ac_cv_have_decl_strncasecmp = no; then HAVE_DECL_STRNCASECMP=0 fi if test $HAVE_STRCASECMP = 0; then gl_LIBOBJS="$gl_LIBOBJS strcasecmp.$ac_objext" : fi if test $HAVE_STRNCASECMP = 0; then gl_LIBOBJS="$gl_LIBOBJS strncasecmp.$ac_objext" : fi if test $ac_cv_func_strdup = yes; then if test $gl_cv_func_malloc_posix != yes; then REPLACE_STRDUP=1 fi fi if test $ac_cv_have_decl_strdup = no; then HAVE_DECL_STRDUP=0 fi if test $ac_cv_func_strdup = no || test $REPLACE_STRDUP = 1; then gl_LIBOBJS="$gl_LIBOBJS strdup.$ac_objext" : fi GNULIB_STRDUP=1 $as_echo "#define GNULIB_TEST_STRDUP 1" >>confdefs.h if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strerror function" >&5 $as_echo_n "checking for working strerror function... " >&6; } if ${gl_cv_func_working_strerror+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_working_strerror="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_working_strerror="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { if (!*strerror (-2)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_working_strerror=yes else gl_cv_func_working_strerror=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_strerror" >&5 $as_echo "$gl_cv_func_working_strerror" >&6; } case "$gl_cv_func_working_strerror" in *yes) ;; *) REPLACE_STRERROR=1 ;; esac else REPLACE_STRERROR=1 fi if test $REPLACE_STRERROR = 1; then gl_LIBOBJS="$gl_LIBOBJS strerror.$ac_objext" fi cat >>confdefs.h <<_ACEOF #define GNULIB_STRERROR 1 _ACEOF GNULIB_STRERROR=1 $as_echo "#define GNULIB_TEST_STRERROR 1" >>confdefs.h if test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1; then gl_LIBOBJS="$gl_LIBOBJS strerror-override.$ac_objext" if test $ac_cv_header_sys_socket_h != yes; then for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF fi done fi if test "$ac_cv_header_winsock2_h" = yes; then HAVE_WINSOCK2_H=1 UNISTD_H_HAVE_WINSOCK2_H=1 SYS_IOCTL_H_HAVE_WINSOCK2_H=1 else HAVE_WINSOCK2_H=0 fi fi # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE. $as_echo "#define my_strftime nstrftime" >>confdefs.h if test $ac_cv_func_strptime != yes; then HAVE_STRPTIME=0 fi if test $HAVE_STRPTIME = 0; then gl_LIBOBJS="$gl_LIBOBJS strptime.$ac_objext" : fi GNULIB_STRPTIME=1 $as_echo "#define GNULIB_TEST_STRPTIME 1" >>confdefs.h if test $REPLACE_STRSTR = 0; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strstr works in linear time" >&5 $as_echo_n "checking whether strstr works in linear time... " >&6; } if ${gl_cv_func_strstr_linear+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __GNU_LIBRARY__ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ && !(defined __i386__ || defined __x86_64__) \ && !defined __UCLIBC__ Lucky user #endif #endif #ifdef __CYGWIN__ #include #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7) Lucky user #endif #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Lucky user" >/dev/null 2>&1; then : gl_cv_func_strstr_linear="guessing yes" else gl_cv_func_strstr_linear="guessing no" fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for signal */ #include /* for strstr */ #include /* for malloc */ #include /* for alarm */ static void quit (int sig) { exit (sig + 128); } int main () { int result = 0; size_t m = 1000000; char *haystack = (char *) malloc (2 * m + 2); char *needle = (char *) malloc (m + 2); /* Failure to compile this test due to missing alarm is okay, since all such platforms (mingw) also have quadratic strstr. */ signal (SIGALRM, quit); alarm (5); /* Check for quadratic performance. */ if (haystack && needle) { memset (haystack, 'A', 2 * m); haystack[2 * m] = 'B'; haystack[2 * m + 1] = 0; memset (needle, 'A', m); needle[m] = 'B'; needle[m + 1] = 0; if (!strstr (haystack, needle)) result |= 1; } return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_strstr_linear=yes else gl_cv_func_strstr_linear=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strstr_linear" >&5 $as_echo "$gl_cv_func_strstr_linear" >&6; } case "$gl_cv_func_strstr_linear" in *yes) ;; *) REPLACE_STRSTR=1 ;; esac fi if test $REPLACE_STRSTR = 1; then gl_LIBOBJS="$gl_LIBOBJS strstr.$ac_objext" fi if test "$gl_cv_func_memchr_works" != yes; then REPLACE_STRSTR=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strstr works" >&5 $as_echo_n "checking whether strstr works... " >&6; } if ${gl_cv_func_strstr_works_always+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNU_LIBRARY__ #include #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ || defined __UCLIBC__ Lucky user #endif #elif defined __CYGWIN__ #include #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7) Lucky user #endif #else Lucky user #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "Lucky user" >/dev/null 2>&1; then : gl_cv_func_strstr_works_always="guessing yes" else gl_cv_func_strstr_works_always="guessing no" fi rm -f conftest* else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for strstr */ #define P "_EF_BF_BD" #define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P #define NEEDLE P P P P P int main () { return !!strstr (HAYSTACK, NEEDLE); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_strstr_works_always=yes else gl_cv_func_strstr_works_always=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strstr_works_always" >&5 $as_echo "$gl_cv_func_strstr_works_always" >&6; } case "$gl_cv_func_strstr_works_always" in *yes) ;; *) REPLACE_STRSTR=1 ;; esac fi if test $REPLACE_STRSTR = 1; then gl_LIBOBJS="$gl_LIBOBJS strstr.$ac_objext" fi GNULIB_STRSTR=1 $as_echo "#define GNULIB_TEST_STRSTR 1" >>confdefs.h for ac_func in strtok_r do : ac_fn_c_check_func "$LINENO" "strtok_r" "ac_cv_func_strtok_r" if test "x$ac_cv_func_strtok_r" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRTOK_R 1 _ACEOF fi done if test $ac_cv_func_strtok_r = yes; then HAVE_STRTOK_R=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strtok_r works" >&5 $as_echo_n "checking whether strtok_r works... " >&6; } if ${gl_cv_func_strtok_r_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess no on glibc systems. *-gnu*) gl_cv_func_strtok_r_works="guessing no";; *) gl_cv_func_strtok_r_works="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __OPTIMIZE__ # define __OPTIMIZE__ 1 #endif #undef __OPTIMIZE_SIZE__ #undef __NO_INLINE__ #include #include int main () { static const char dummy[] = "\177\01a"; char delimiters[] = "xxxxxxxx"; char *save_ptr = (char *) dummy; strtok_r (delimiters, "x", &save_ptr); strtok_r (NULL, "x", &save_ptr); return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_strtok_r_works=yes else gl_cv_func_strtok_r_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strtok_r_works" >&5 $as_echo "$gl_cv_func_strtok_r_works" >&6; } case "$gl_cv_func_strtok_r_works" in *no) UNDEFINE_STRTOK_R=1 ;; esac else HAVE_STRTOK_R=0 fi if test $ac_cv_have_decl_strtok_r = no; then HAVE_DECL_STRTOK_R=0 fi if test $HAVE_STRTOK_R = 0 || test $REPLACE_STRTOK_R = 1; then gl_LIBOBJS="$gl_LIBOBJS strtok_r.$ac_objext" : fi GNULIB_STRTOK_R=1 $as_echo "#define GNULIB_TEST_STRTOK_R 1" >>confdefs.h if test "$ac_cv_type_unsigned_long_long_int" = yes; then for ac_func in strtoull do : ac_fn_c_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull" if test "x$ac_cv_func_strtoull" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRTOULL 1 _ACEOF fi done if test $ac_cv_func_strtoull = no; then HAVE_STRTOULL=0 fi fi if test $HAVE_STRTOULL = 0; then gl_LIBOBJS="$gl_LIBOBJS strtoull.$ac_objext" : fi GNULIB_STRTOULL=1 $as_echo "#define GNULIB_TEST_STRTOULL 1" >>confdefs.h if test "$ac_cv_have_decl_strtoumax" = yes; then if test "$ac_cv_func_strtoumax" != yes; then # HP-UX 11.11 has "#define strtoimax(...) ..." but no function. REPLACE_STRTOUMAX=1 fi else HAVE_DECL_STRTOUMAX=0 fi if test $HAVE_DECL_STRTOUMAX = 0 || test $REPLACE_STRTOUMAX = 1; then gl_LIBOBJS="$gl_LIBOBJS strtoumax.$ac_objext" ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default" if test "x$ac_cv_have_decl_strtoull" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRTOULL $ac_have_decl _ACEOF fi GNULIB_STRTOUMAX=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is self-contained" >&5 $as_echo_n "checking whether is self-contained... " >&6; } if ${gl_cv_header_sys_select_h_selfcontained+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct timeval b; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_header_sys_select_h_selfcontained=yes else gl_cv_header_sys_select_h_selfcontained=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $gl_cv_header_sys_select_h_selfcontained = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int memset; int bzero; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #undef memset #define memset nonexistent_memset extern #ifdef __cplusplus "C" #endif void *memset (void *, int, unsigned long); #undef bzero #define bzero nonexistent_bzero extern #ifdef __cplusplus "C" #endif void bzero (void *, unsigned long); fd_set fds; FD_ZERO (&fds); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : else gl_cv_header_sys_select_h_selfcontained=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_sys_select_h_selfcontained" >&5 $as_echo "$gl_cv_header_sys_select_h_selfcontained" >&6; } if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_select_h='<'sys/select.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_sys_select_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_sys_select_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'sys/select.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_sys_select_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_sys_select_h gl_cv_next_sys_select_h='"'$gl_header'"' else gl_cv_next_sys_select_h='<'sys/select.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_select_h" >&5 $as_echo "$gl_cv_next_sys_select_h" >&6; } fi NEXT_SYS_SELECT_H=$gl_cv_next_sys_select_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'sys/select.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_sys_select_h fi NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H=$gl_next_as_first_directive if test $ac_cv_header_sys_select_h = yes; then HAVE_SYS_SELECT_H=1 else HAVE_SYS_SELECT_H=0 fi if test $ac_cv_header_sys_socket_h != yes; then for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF fi done fi if test "$ac_cv_header_winsock2_h" = yes; then HAVE_WINSOCK2_H=1 UNISTD_H_HAVE_WINSOCK2_H=1 SYS_IOCTL_H_HAVE_WINSOCK2_H=1 else HAVE_WINSOCK2_H=0 fi if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_stat_h='<'sys/stat.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_sys_stat_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_sys_stat_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'sys/stat.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_sys_stat_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_sys_stat_h gl_cv_next_sys_stat_h='"'$gl_header'"' else gl_cv_next_sys_stat_h='<'sys/stat.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_stat_h" >&5 $as_echo "$gl_cv_next_sys_stat_h" >&6; } fi NEXT_SYS_STAT_H=$gl_cv_next_sys_stat_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'sys/stat.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_sys_stat_h fi NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H=$gl_next_as_first_directive if test $WINDOWS_64_BIT_ST_SIZE = 1; then $as_echo "#define _GL_WINDOWS_64_BIT_ST_SIZE 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "nlink_t" "ac_cv_type_nlink_t" "#include #include " if test "x$ac_cv_type_nlink_t" = xyes; then : else $as_echo "#define nlink_t int" >>confdefs.h fi if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_uio_h='<'sys/uio.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_sys_uio_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_sys_uio_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'sys/uio.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_sys_uio_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_sys_uio_h gl_cv_next_sys_uio_h='"'$gl_header'"' else gl_cv_next_sys_uio_h='<'sys/uio.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_uio_h" >&5 $as_echo "$gl_cv_next_sys_uio_h" >&6; } fi NEXT_SYS_UIO_H=$gl_cv_next_sys_uio_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'sys/uio.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_sys_uio_h fi NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H=$gl_next_as_first_directive if test $ac_cv_header_sys_uio_h = yes; then HAVE_SYS_UIO_H=1 else HAVE_SYS_UIO_H=0 fi ac_fn_c_check_decl "$LINENO" "localtime_r" "ac_cv_have_decl_localtime_r" "#include " if test "x$ac_cv_have_decl_localtime_r" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_LOCALTIME_R $ac_have_decl _ACEOF if test $ac_cv_have_decl_localtime_r = no; then HAVE_DECL_LOCALTIME_R=0 fi if test $ac_cv_func_localtime_r = yes; then HAVE_LOCALTIME_R=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether localtime_r is compatible with its POSIX signature" >&5 $as_echo_n "checking whether localtime_r is compatible with its POSIX signature... " >&6; } if ${gl_cv_time_r_posix+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { /* We don't need to append 'restrict's to the argument types, even though the POSIX signature has the 'restrict's, since C99 says they can't affect type compatibility. */ struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r; if (ptr) return 0; /* Check the return type is a pointer. On HP-UX 10 it is 'int'. */ *localtime_r (0, 0); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_time_r_posix=yes else gl_cv_time_r_posix=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_time_r_posix" >&5 $as_echo "$gl_cv_time_r_posix" >&6; } if test $gl_cv_time_r_posix = yes; then REPLACE_LOCALTIME_R=0 else REPLACE_LOCALTIME_R=1 fi else HAVE_LOCALTIME_R=0 fi if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then gl_LIBOBJS="$gl_LIBOBJS time_r.$ac_objext" : fi GNULIB_TIME_R=1 $as_echo "#define GNULIB_TEST_TIME_R 1" >>confdefs.h : if test $gl_cv_have_include_next = yes; then gl_cv_next_unistd_h='<'unistd.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_unistd_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_unistd_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'unistd.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_unistd_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_unistd_h gl_cv_next_unistd_h='"'$gl_header'"' else gl_cv_next_unistd_h='<'unistd.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_unistd_h" >&5 $as_echo "$gl_cv_next_unistd_h" >&6; } fi NEXT_UNISTD_H=$gl_cv_next_unistd_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'unistd.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_unistd_h fi NEXT_AS_FIRST_DIRECTIVE_UNISTD_H=$gl_next_as_first_directive if test $ac_cv_header_unistd_h = yes; then HAVE_UNISTD_H=1 else HAVE_UNISTD_H=0 fi if { test "$HAVE_LIBUNISTRING" != yes \ || { test $LIBUNISTRING_VERSION_MAJOR -lt 0 \ || { test $LIBUNISTRING_VERSION_MAJOR -eq 0 \ && { test $LIBUNISTRING_VERSION_MINOR -lt 9 \ || { test $LIBUNISTRING_VERSION_MINOR -eq 9 \ && test $LIBUNISTRING_VERSION_SUBMINOR -lt 4 } } } } }; then LIBUNISTRING_UNISTR_H='unistr.h' else LIBUNISTRING_UNISTR_H= fi cat >>confdefs.h <<_ACEOF #define GNULIB_UNISTR_U8_MBTOUCR 1 _ACEOF if { test "$HAVE_LIBUNISTRING" != yes \ || { test $LIBUNISTRING_VERSION_MAJOR -lt 0 \ || { test $LIBUNISTRING_VERSION_MAJOR -eq 0 \ && { test $LIBUNISTRING_VERSION_MINOR -lt 9 \ || { test $LIBUNISTRING_VERSION_MINOR -eq 9 \ && test $LIBUNISTRING_VERSION_SUBMINOR -lt 0 } } } } }; then LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_TRUE= LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_FALSE='#' else LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_TRUE='#' LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_FALSE= fi cat >>confdefs.h <<_ACEOF #define GNULIB_UNISTR_U8_UCTOMB 1 _ACEOF if { test "$HAVE_LIBUNISTRING" != yes \ || { test $LIBUNISTRING_VERSION_MAJOR -lt 0 \ || { test $LIBUNISTRING_VERSION_MAJOR -eq 0 \ && { test $LIBUNISTRING_VERSION_MINOR -lt 9 \ || { test $LIBUNISTRING_VERSION_MINOR -eq 9 \ && test $LIBUNISTRING_VERSION_SUBMINOR -lt 0 } } } } }; then LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_TRUE= LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_FALSE='#' else LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_TRUE='#' LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_FALSE= fi if { test "$HAVE_LIBUNISTRING" != yes \ || { test $LIBUNISTRING_VERSION_MAJOR -lt 0 \ || { test $LIBUNISTRING_VERSION_MAJOR -eq 0 \ && { test $LIBUNISTRING_VERSION_MINOR -lt 9 \ || { test $LIBUNISTRING_VERSION_MINOR -eq 9 \ && test $LIBUNISTRING_VERSION_SUBMINOR -lt 4 } } } } }; then LIBUNISTRING_UNITYPES_H='unitypes.h' else LIBUNISTRING_UNITYPES_H= fi if { test "$HAVE_LIBUNISTRING" != yes \ || { test $LIBUNISTRING_VERSION_MAJOR -lt 0 \ || { test $LIBUNISTRING_VERSION_MAJOR -eq 0 \ && { test $LIBUNISTRING_VERSION_MINOR -lt 9 \ || { test $LIBUNISTRING_VERSION_MINOR -eq 9 \ && test $LIBUNISTRING_VERSION_SUBMINOR -lt 4 } } } } }; then LIBUNISTRING_UNIWIDTH_H='uniwidth.h' else LIBUNISTRING_UNIWIDTH_H= fi if { test "$HAVE_LIBUNISTRING" != yes \ || { test $LIBUNISTRING_VERSION_MAJOR -lt 0 \ || { test $LIBUNISTRING_VERSION_MAJOR -eq 0 \ && { test $LIBUNISTRING_VERSION_MINOR -lt 9 \ || { test $LIBUNISTRING_VERSION_MINOR -eq 9 \ && test $LIBUNISTRING_VERSION_SUBMINOR -lt 5 } } } } }; then LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE= LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_FALSE='#' else LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE='#' LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_FALSE= fi if test $ac_cv_have_decl_unsetenv = no; then HAVE_DECL_UNSETENV=0 fi for ac_func in unsetenv do : ac_fn_c_check_func "$LINENO" "unsetenv" "ac_cv_func_unsetenv" if test "x$ac_cv_func_unsetenv" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UNSETENV 1 _ACEOF fi done if test $ac_cv_func_unsetenv = no; then HAVE_UNSETENV=0 else HAVE_UNSETENV=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsetenv() return type" >&5 $as_echo_n "checking for unsetenv() return type... " >&6; } if ${gt_cv_func_unsetenv_ret+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef _BSD #define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 */ #include extern #ifdef __cplusplus "C" #endif int unsetenv (const char *name); int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gt_cv_func_unsetenv_ret='int' else gt_cv_func_unsetenv_ret='void' fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_unsetenv_ret" >&5 $as_echo "$gt_cv_func_unsetenv_ret" >&6; } if test $gt_cv_func_unsetenv_ret = 'void'; then $as_echo "#define VOID_UNSETENV 1" >>confdefs.h REPLACE_UNSETENV=1 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unsetenv obeys POSIX" >&5 $as_echo_n "checking whether unsetenv obeys POSIX... " >&6; } if ${gl_cv_func_unsetenv_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_unsetenv_works="guessing no" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include extern char **environ; int main () { char entry1[] = "a=1"; char entry2[] = "b=2"; char *env[] = { entry1, entry2, NULL }; if (putenv ((char *) "a=1")) return 1; if (putenv (entry2)) return 2; entry2[0] = 'a'; unsetenv ("a"); if (getenv ("a")) return 3; if (!unsetenv ("") || errno != EINVAL) return 4; entry2[0] = 'b'; environ = env; if (!getenv ("a")) return 5; entry2[0] = 'a'; unsetenv ("a"); if (getenv ("a")) return 6; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_unsetenv_works=yes else gl_cv_func_unsetenv_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_unsetenv_works" >&5 $as_echo "$gl_cv_func_unsetenv_works" >&6; } case "$gl_cv_func_unsetenv_works" in *yes) ;; *) REPLACE_UNSETENV=1 ;; esac fi if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then gl_LIBOBJS="$gl_LIBOBJS unsetenv.$ac_objext" fi GNULIB_UNSETENV=1 $as_echo "#define GNULIB_TEST_UNSETENV 1" >>confdefs.h if test $ac_cv_func_vasnprintf = no; then gl_LIBOBJS="$gl_LIBOBJS vasnprintf.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS printf-args.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS printf-parse.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS asnprintf.$ac_objext" if test $ac_cv_func_vasnprintf = yes; then $as_echo "#define REPLACE_VASNPRINTF 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" if test "x$ac_cv_type_ptrdiff_t" = xyes; then : else $as_echo "#define ptrdiff_t long" >>confdefs.h fi fi gl_cv_func_vsnprintf_usable=no for ac_func in vsnprintf do : ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf" if test "x$ac_cv_func_vsnprintf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VSNPRINTF 1 _ACEOF fi done if test $ac_cv_func_vsnprintf = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf respects a size of 1" >&5 $as_echo_n "checking whether snprintf respects a size of 1... " >&6; } if ${gl_cv_func_snprintf_size1+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_func_snprintf_size1="guessing yes" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_SNPRINTF # define my_snprintf snprintf #else # include static int my_snprintf (char *buf, int size, const char *format, ...) { va_list args; int ret; va_start (args, format); ret = vsnprintf (buf, size, format, args); va_end (args); return ret; } #endif int main() { static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; my_snprintf (buf, 1, "%d", 12345); return buf[1] != 'E'; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_snprintf_size1=yes else gl_cv_func_snprintf_size1=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_snprintf_size1" >&5 $as_echo "$gl_cv_func_snprintf_size1" >&6; } case "$gl_cv_func_snprintf_size1" in *yes) case "$gl_cv_func_snprintf_retval_c99" in *yes) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether printf supports POSIX/XSI format strings with positions" >&5 $as_echo_n "checking whether printf supports POSIX/XSI format strings with positions... " >&6; } if ${gl_cv_func_printf_positions+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) gl_cv_func_printf_positions="guessing no";; beos*) gl_cv_func_printf_positions="guessing no";; mingw* | pw*) gl_cv_func_printf_positions="guessing no";; *) gl_cv_func_printf_positions="guessing yes";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* The string "%2$d %1$d", with dollar characters protected from the shell's dollar expansion (possibly an autoconf bug). */ static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; static char buf[100]; int main () { sprintf (buf, format, 33, 55); return (strcmp (buf, "55 33") != 0); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_printf_positions=yes else gl_cv_func_printf_positions=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_positions" >&5 $as_echo "$gl_cv_func_printf_positions" >&6; } case "$gl_cv_func_printf_positions" in *yes) gl_cv_func_vsnprintf_usable=yes ;; esac ;; esac ;; esac fi if test $gl_cv_func_vsnprintf_usable = no; then gl_LIBOBJS="$gl_LIBOBJS vsnprintf.$ac_objext" if test $ac_cv_func_vsnprintf = yes; then REPLACE_VSNPRINTF=1 fi : fi if test $ac_cv_have_decl_vsnprintf = no; then HAVE_DECL_VSNPRINTF=0 fi GNULIB_VSNPRINTF=1 $as_echo "#define GNULIB_TEST_VSNPRINTF 1" >>confdefs.h gl_cv_func_vsnprintf_posix=no for ac_func in vsnprintf do : ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf" if test "x$ac_cv_func_vsnprintf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VSNPRINTF 1 _ACEOF fi done if test $ac_cv_func_vsnprintf = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf truncates the result as in C99" >&5 $as_echo_n "checking whether snprintf truncates the result as in C99... " >&6; } if ${gl_cv_func_snprintf_truncation_c99+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";; freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on Mac OS X >= 10.3. darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on OpenBSD >= 3.9. openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) gl_cv_func_snprintf_truncation_c99="guessing no";; openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on Solaris >= 2.6. solaris2.[0-5] | solaris2.[0-5].*) gl_cv_func_snprintf_truncation_c99="guessing no";; solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on AIX >= 4. aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on HP-UX >= 11. hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on IRIX >= 6.5. irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on OSF/1 >= 5. osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on NetBSD >= 3. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) gl_cv_func_snprintf_truncation_c99="guessing no";; netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess yes on BeOS. beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_snprintf_truncation_c99="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_SNPRINTF # define my_snprintf snprintf #else # include static int my_snprintf (char *buf, int size, const char *format, ...) { va_list args; int ret; va_start (args, format); ret = vsnprintf (buf, size, format, args); va_end (args); return ret; } #endif static char buf[100]; int main () { strcpy (buf, "ABCDEF"); my_snprintf (buf, 3, "%d %d", 4567, 89); if (memcmp (buf, "45\0DEF", 6) != 0) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_snprintf_truncation_c99=yes else gl_cv_func_snprintf_truncation_c99=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_snprintf_truncation_c99" >&5 $as_echo "$gl_cv_func_snprintf_truncation_c99" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf fully supports the 'n' directive" >&5 $as_echo_n "checking whether snprintf fully supports the 'n' directive... " >&6; } if ${gl_cv_func_snprintf_directive_n+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";; freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on Mac OS X >= 10.3. darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on Solaris >= 2.6. solaris2.[0-5] | solaris2.[0-5].*) gl_cv_func_snprintf_directive_n="guessing no";; solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on AIX >= 4. aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; aix*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on IRIX >= 6.5. irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on OSF/1 >= 5. osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; osf*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on NetBSD >= 3. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) gl_cv_func_snprintf_directive_n="guessing no";; netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on BeOS. beos*) gl_cv_func_snprintf_directive_n="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_snprintf_directive_n="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if HAVE_SNPRINTF # define my_snprintf snprintf #else # include static int my_snprintf (char *buf, int size, const char *format, ...) { va_list args; int ret; va_start (args, format); ret = vsnprintf (buf, size, format, args); va_end (args); return ret; } #endif static char fmtstring[10]; static char buf[100]; int main () { int count = -1; /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) support %n in format strings in read-only memory but not in writable memory. */ strcpy (fmtstring, "%d %n"); my_snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55); if (count != 6) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_snprintf_directive_n=yes else gl_cv_func_snprintf_directive_n=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_snprintf_directive_n" >&5 $as_echo "$gl_cv_func_snprintf_directive_n" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf respects a size of 1" >&5 $as_echo_n "checking whether snprintf respects a size of 1... " >&6; } if ${gl_cv_func_snprintf_size1+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : gl_cv_func_snprintf_size1="guessing yes" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if HAVE_SNPRINTF # define my_snprintf snprintf #else # include static int my_snprintf (char *buf, int size, const char *format, ...) { va_list args; int ret; va_start (args, format); ret = vsnprintf (buf, size, format, args); va_end (args); return ret; } #endif int main() { static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; my_snprintf (buf, 1, "%d", 12345); return buf[1] != 'E'; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_snprintf_size1=yes else gl_cv_func_snprintf_size1=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_snprintf_size1" >&5 $as_echo "$gl_cv_func_snprintf_size1" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether vsnprintf respects a zero size as in C99" >&5 $as_echo_n "checking whether vsnprintf respects a zero size as in C99... " >&6; } if ${gl_cv_func_vsnprintf_zerosize_c99+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc systems. *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on FreeBSD >= 5. freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on Mac OS X >= 10.3. darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on Cygwin. cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on Solaris >= 2.6. solaris2.[0-5] | solaris2.[0-5].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on AIX >= 4. aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on IRIX >= 6.5. irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on NetBSD >= 3. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on BeOS. beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # Guess yes on mingw. mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include static int my_snprintf (char *buf, int size, const char *format, ...) { va_list args; int ret; va_start (args, format); ret = vsnprintf (buf, size, format, args); va_end (args); return ret; } int main() { static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; my_snprintf (buf, 0, "%d", 12345); return buf[0] != 'D'; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_vsnprintf_zerosize_c99=yes else gl_cv_func_vsnprintf_zerosize_c99=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_vsnprintf_zerosize_c99" >&5 $as_echo "$gl_cv_func_vsnprintf_zerosize_c99" >&6; } case "$gl_cv_func_printf_sizes_c99" in *yes) case "$gl_cv_func_printf_long_double" in *yes) case "$gl_cv_func_printf_infinite" in *yes) case "$gl_cv_func_printf_infinite_long_double" in *yes) case "$gl_cv_func_printf_directive_a" in *yes) case "$gl_cv_func_printf_directive_f" in *yes) case "$gl_cv_func_printf_directive_n" in *yes) case "$gl_cv_func_printf_directive_ls" in *yes) case "$gl_cv_func_printf_positions" in *yes) case "$gl_cv_func_printf_flag_grouping" in *yes) case "$gl_cv_func_printf_flag_leftadjust" in *yes) case "$gl_cv_func_printf_flag_zero" in *yes) case "$gl_cv_func_printf_precision" in *yes) case "$gl_cv_func_printf_enomem" in *yes) case "$gl_cv_func_snprintf_truncation_c99" in *yes) case "$gl_cv_func_snprintf_retval_c99" in *yes) case "$gl_cv_func_snprintf_directive_n" in *yes) case "$gl_cv_func_snprintf_size1" in *yes) case "$gl_cv_func_vsnprintf_zerosize_c99" in *yes) # vsnprintf exists and is # already POSIX compliant. gl_cv_func_vsnprintf_posix=yes ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac ;; esac fi if test $gl_cv_func_vsnprintf_posix = no; then case "$gl_cv_func_printf_infinite" in *yes) ;; *) $as_echo "#define NEED_PRINTF_INFINITE_DOUBLE 1" >>confdefs.h ;; esac case "$gl_cv_func_printf_long_double" in *yes) case "$gl_cv_func_printf_infinite_long_double" in *yes) ;; *) $as_echo "#define NEED_PRINTF_INFINITE_LONG_DOUBLE 1" >>confdefs.h ;; esac ;; esac case "$gl_cv_func_printf_directive_a" in *yes) ;; *) $as_echo "#define NEED_PRINTF_DIRECTIVE_A 1" >>confdefs.h for ac_func in nl_langinfo do : ac_fn_c_check_func "$LINENO" "nl_langinfo" "ac_cv_func_nl_langinfo" if test "x$ac_cv_func_nl_langinfo" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NL_LANGINFO 1 _ACEOF fi done ;; esac case "$gl_cv_func_printf_directive_f" in *yes) ;; *) $as_echo "#define NEED_PRINTF_DIRECTIVE_F 1" >>confdefs.h ;; esac case "$gl_cv_func_printf_directive_ls" in *yes) ;; *) $as_echo "#define NEED_PRINTF_DIRECTIVE_LS 1" >>confdefs.h ;; esac case "$gl_cv_func_printf_flag_grouping" in *yes) ;; *) $as_echo "#define NEED_PRINTF_FLAG_GROUPING 1" >>confdefs.h ;; esac case "$gl_cv_func_printf_flag_leftadjust" in *yes) ;; *) $as_echo "#define NEED_PRINTF_FLAG_LEFTADJUST 1" >>confdefs.h ;; esac case "$gl_cv_func_printf_flag_zero" in *yes) ;; *) $as_echo "#define NEED_PRINTF_FLAG_ZERO 1" >>confdefs.h ;; esac case "$gl_cv_func_printf_precision" in *yes) ;; *) $as_echo "#define NEED_PRINTF_UNBOUNDED_PRECISION 1" >>confdefs.h $as_echo "#define NEED_PRINTF_DOUBLE 1" >>confdefs.h $as_echo "#define NEED_PRINTF_LONG_DOUBLE 1" >>confdefs.h ;; esac case "$gl_cv_func_printf_enomem" in *yes) ;; *) $as_echo "#define NEED_PRINTF_ENOMEM 1" >>confdefs.h $as_echo "#define NEED_PRINTF_DOUBLE 1" >>confdefs.h $as_echo "#define NEED_PRINTF_LONG_DOUBLE 1" >>confdefs.h ;; esac gl_LIBOBJS="$gl_LIBOBJS vasnprintf.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS printf-args.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS printf-parse.$ac_objext" gl_LIBOBJS="$gl_LIBOBJS asnprintf.$ac_objext" if test $ac_cv_func_vasnprintf = yes; then $as_echo "#define REPLACE_VASNPRINTF 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" if test "x$ac_cv_type_ptrdiff_t" = xyes; then : else $as_echo "#define ptrdiff_t long" >>confdefs.h fi gl_LIBOBJS="$gl_LIBOBJS vsnprintf.$ac_objext" if test $ac_cv_func_vsnprintf = yes; then REPLACE_VSNPRINTF=1 fi : fi if test $gl_cv_have_include_next = yes; then gl_cv_next_wchar_h='<'wchar.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_wchar_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_wchar_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'wchar.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_wchar_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_wchar_h gl_cv_next_wchar_h='"'$gl_header'"' else gl_cv_next_wchar_h='<'wchar.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_wchar_h" >&5 $as_echo "$gl_cv_next_wchar_h" >&6; } fi NEXT_WCHAR_H=$gl_cv_next_wchar_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'wchar.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_wchar_h fi NEXT_AS_FIRST_DIRECTIVE_WCHAR_H=$gl_next_as_first_directive if test $ac_cv_header_wchar_h = yes; then HAVE_WCHAR_H=1 else HAVE_WCHAR_H=0 fi if test $gt_cv_c_wint_t = yes; then HAVE_WINT_T=1 else HAVE_WINT_T=0 fi if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles incomplete characters" >&5 $as_echo_n "checking whether mbrtowc handles incomplete characters... " >&6; } if ${gl_cv_func_mbrtowc_incomplete_state+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on AIX and OSF/1. aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; esac if test $LOCALE_JA != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) { const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) if (mbsinit (&state)) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_incomplete_state=yes else gl_cv_func_mbrtowc_incomplete_state=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_incomplete_state" >&5 $as_echo "$gl_cv_func_mbrtowc_incomplete_state" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works as well as mbtowc" >&5 $as_echo_n "checking whether mbrtowc works as well as mbtowc... " >&6; } if ${gl_cv_func_mbrtowc_sanitycheck+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on Solaris 8. solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;; esac if test $LOCALE_ZH_CN != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { /* This fails on Solaris 8: mbrtowc returns 2, and sets wc to 0x00F0. mbtowc returns 4 (correct) and sets wc to 0x5EDC. */ if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) { char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ mbstate_t state; wchar_t wc; memset (&state, '\0', sizeof (mbstate_t)); if (mbrtowc (&wc, input + 3, 6, &state) != 4 && mbtowc (&wc, input + 3, 6) == 4) return 1; } return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_mbrtowc_sanitycheck=yes else gl_cv_func_mbrtowc_sanitycheck=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_sanitycheck" >&5 $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } REPLACE_MBSTATE_T=0 case "$gl_cv_func_mbrtowc_incomplete_state" in *yes) ;; *) REPLACE_MBSTATE_T=1 ;; esac case "$gl_cv_func_mbrtowc_sanitycheck" in *yes) ;; *) REPLACE_MBSTATE_T=1 ;; esac else REPLACE_MBSTATE_T=1 fi if test $ac_cv_func_wcrtomb = no; then HAVE_WCRTOMB=0 ac_fn_c_check_decl "$LINENO" "wcrtomb" "ac_cv_have_decl_wcrtomb" " /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include " if test "x$ac_cv_have_decl_wcrtomb" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_WCRTOMB $ac_have_decl _ACEOF if test $ac_cv_have_decl_wcrtomb = yes; then REPLACE_WCRTOMB=1 fi else if test $REPLACE_MBSTATE_T = 1; then REPLACE_WCRTOMB=1 else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether wcrtomb return value is correct" >&5 $as_echo_n "checking whether wcrtomb return value is correct... " >&6; } if ${gl_cv_func_wcrtomb_retval+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_os" in # Guess no on AIX 4, OSF/1 and Solaris. aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_wcrtomb_retval="guessing yes" ;; esac if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include int main () { int result = 0; if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) { if (wcrtomb (NULL, 0, NULL) != 1) result |= 1; } if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) { if (wcrtomb (NULL, 0, NULL) != 1) result |= 2; } if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) { if (wcrtomb (NULL, 0, NULL) != 1) result |= 4; } if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) { if (wcrtomb (NULL, 0, NULL) != 1) result |= 8; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_wcrtomb_retval=yes else gl_cv_func_wcrtomb_retval=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_wcrtomb_retval" >&5 $as_echo "$gl_cv_func_wcrtomb_retval" >&6; } case "$gl_cv_func_wcrtomb_retval" in *yes) ;; *) REPLACE_WCRTOMB=1 ;; esac fi fi if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then gl_LIBOBJS="$gl_LIBOBJS wcrtomb.$ac_objext" : fi GNULIB_WCRTOMB=1 $as_echo "#define GNULIB_TEST_WCRTOMB 1" >>confdefs.h if test $ac_cv_func_iswcntrl = yes; then HAVE_ISWCNTRL=1 else HAVE_ISWCNTRL=0 fi if test $gt_cv_c_wint_t = yes; then HAVE_WINT_T=1 else HAVE_WINT_T=0 fi if test $gl_cv_have_include_next = yes; then gl_cv_next_wctype_h='<'wctype.h'>' else { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 $as_echo_n "checking absolute name of ... " >&6; } if ${gl_cv_next_wctype_h+:} false; then : $as_echo_n "(cached) " >&6 else if test $ac_cv_header_wctype_h = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF case "$host_os" in aix*) gl_absname_cpp="$ac_cpp -C" ;; *) gl_absname_cpp="$ac_cpp" ;; esac case "$host_os" in mingw*) gl_dirsep_regex='[/\\]' ;; *) gl_dirsep_regex='\/' ;; esac gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' gl_header_literal_regex=`echo 'wctype.h' \ | sed -e "$gl_make_literal_regex_sed"` gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q }' gl_cv_absolute_wctype_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | sed -n "$gl_absolute_header_sed"` gl_header=$gl_cv_absolute_wctype_h gl_cv_next_wctype_h='"'$gl_header'"' else gl_cv_next_wctype_h='<'wctype.h'>' fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_wctype_h" >&5 $as_echo "$gl_cv_next_wctype_h" >&6; } fi NEXT_WCTYPE_H=$gl_cv_next_wctype_h if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'wctype.h'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' gl_next_as_first_directive=$gl_cv_next_wctype_h fi NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H=$gl_next_as_first_directive if test $ac_cv_header_wctype_h = yes; then if test $ac_cv_func_iswcntrl = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether iswcntrl works" >&5 $as_echo_n "checking whether iswcntrl works... " >&6; } if ${gl_cv_func_iswcntrl_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if __GNU_LIBRARY__ == 1 Linux libc5 i18n is broken. #endif int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_func_iswcntrl_works="guessing yes" else gl_cv_func_iswcntrl_works="guessing no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include #include int main () { return iswprint ('x') == 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_iswcntrl_works=yes else gl_cv_func_iswcntrl_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_iswcntrl_works" >&5 $as_echo "$gl_cv_func_iswcntrl_works" >&6; } fi HAVE_WCTYPE_H=1 else HAVE_WCTYPE_H=0 fi case "$gl_cv_func_iswcntrl_works" in *yes) REPLACE_ISWCNTRL=0 ;; *) REPLACE_ISWCNTRL=1 ;; esac if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then : fi if test $REPLACE_ISWCNTRL = 1; then REPLACE_TOWLOWER=1 else for ac_func in towlower do : ac_fn_c_check_func "$LINENO" "towlower" "ac_cv_func_towlower" if test "x$ac_cv_func_towlower" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TOWLOWER 1 _ACEOF fi done if test $ac_cv_func_towlower = yes; then REPLACE_TOWLOWER=0 else ac_fn_c_check_decl "$LINENO" "towlower" "ac_cv_have_decl_towlower" "/* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include #if HAVE_WCTYPE_H # include #endif " if test "x$ac_cv_have_decl_towlower" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_TOWLOWER $ac_have_decl _ACEOF if test $ac_cv_have_decl_towlower = yes; then REPLACE_TOWLOWER=1 else REPLACE_TOWLOWER=0 fi fi fi if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then : fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wctype_t" >&5 $as_echo_n "checking for wctype_t... " >&6; } if ${gl_cv_type_wctype_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include #if HAVE_WCTYPE_H # include #endif wctype_t a; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_type_wctype_t=yes else gl_cv_type_wctype_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_wctype_t" >&5 $as_echo "$gl_cv_type_wctype_t" >&6; } if test $gl_cv_type_wctype_t = no; then HAVE_WCTYPE_T=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wctrans_t" >&5 $as_echo_n "checking for wctrans_t... " >&6; } if ${gl_cv_type_wctrans_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include #include wctrans_t a; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_type_wctrans_t=yes else gl_cv_type_wctrans_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_wctrans_t" >&5 $as_echo "$gl_cv_type_wctrans_t" >&6; } if test $gl_cv_type_wctrans_t = no; then HAVE_WCTRANS_T=0 fi ac_fn_c_check_decl "$LINENO" "wcwidth" "ac_cv_have_decl_wcwidth" " /* AIX 3.2.5 declares wcwidth in . */ #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include " if test "x$ac_cv_have_decl_wcwidth" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_WCWIDTH $ac_have_decl _ACEOF if test $ac_cv_have_decl_wcwidth != yes; then HAVE_DECL_WCWIDTH=0 fi if test $ac_cv_func_wcwidth = yes; then HAVE_WCWIDTH=1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether wcwidth works reasonably in UTF-8 locales" >&5 $as_echo_n "checking whether wcwidth works reasonably in UTF-8 locales... " >&6; } if ${gl_cv_func_wcwidth_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : case "$host_os" in # Guess yes on glibc and AIX 7 systems. *-gnu* | aix[7-9]*) gl_cv_func_wcwidth_works="guessing yes";; *) gl_cv_func_wcwidth_works="guessing no";; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* AIX 3.2.5 declares wcwidth in . */ #include /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be included before . */ #include #include #include #include #if !HAVE_DECL_WCWIDTH extern # ifdef __cplusplus "C" # endif int wcwidth (int); #endif int main () { int result = 0; if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL || setlocale (LC_ALL, "en_US.UTF-8") != NULL) { if (wcwidth (0x0301) > 0) result |= 1; if (wcwidth (0x05B0) > 0) result |= 2; if (wcwidth (0x200B) > 0) result |= 4; if (wcwidth (0x2022) != 1) result |= 8; } return result; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_wcwidth_works=yes else gl_cv_func_wcwidth_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_wcwidth_works" >&5 $as_echo "$gl_cv_func_wcwidth_works" >&6; } case "$gl_cv_func_wcwidth_works" in *yes) ;; *no) REPLACE_WCWIDTH=1 ;; esac else HAVE_WCWIDTH=0 fi if test $HAVE_WCWIDTH = 0 || test $REPLACE_WCWIDTH = 1; then gl_LIBOBJS="$gl_LIBOBJS wcwidth.$ac_objext" fi GNULIB_WCWIDTH=1 $as_echo "#define GNULIB_TEST_WCWIDTH 1" >>confdefs.h : for ac_header in stdint.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default" if test "x$ac_cv_header_stdint_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDINT_H 1 _ACEOF fi done : # End of code from modules gltests_libdeps= gltests_ltlibdeps= gl_source_base='tests' gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS gl_module_indicator_condition=$gltests_WITNESS if test x$ac_cv_func_wcwidth != xyes || test x$REPLACE_WCWIDTH = x1; then gl_LIBOBJS="$gl_LIBOBJS wcwidth.$ac_objext" $as_echo "#define REPLACE_WCWIDTH 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 $as_echo_n "checking for library containing socket... " >&6; } if ${ac_cv_search_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socket (); int main () { return socket (); ; return 0; } _ACEOF for ac_lib in '' socket; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_socket=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_socket+:} false; then : break fi done if ${ac_cv_search_socket+:} false; then : else ac_cv_search_socket=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 $as_echo "$ac_cv_search_socket" >&6; } ac_res=$ac_cv_search_socket if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } if ${ac_cv_search_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF for ac_lib in '' nsl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostbyname=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_gethostbyname+:} false; then : break fi done if ${ac_cv_search_gethostbyname+:} false; then : else ac_cv_search_gethostbyname=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 $as_echo "$ac_cv_search_gethostbyname" >&6; } ac_res=$ac_cv_search_gethostbyname if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 $as_echo_n "checking for library containing dlopen... " >&6; } if ${ac_cv_search_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF for ac_lib in '' dl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_dlopen=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_dlopen+:} false; then : break fi done if ${ac_cv_search_dlopen+:} false; then : else ac_cv_search_dlopen=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 $as_echo "$ac_cv_search_dlopen" >&6; } ac_res=$ac_cv_search_dlopen if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_DLOPEN 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing res_9_search" >&5 $as_echo_n "checking for library containing res_9_search... " >&6; } if ${ac_cv_search_res_9_search+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char res_9_search (); int main () { return res_9_search (); ; return 0; } _ACEOF for ac_lib in '' resolv; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_res_9_search=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_res_9_search+:} false; then : break fi done if ${ac_cv_search_res_9_search+:} false; then : else ac_cv_search_res_9_search=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_res_9_search" >&5 $as_echo "$ac_cv_search_res_9_search" >&6; } ac_res=$ac_cv_search_res_9_search if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_RES_9_SEARCH 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing res_search" >&5 $as_echo_n "checking for library containing res_search... " >&6; } if ${ac_cv_search_res_search+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char res_search (); int main () { return res_search (); ; return 0; } _ACEOF for ac_lib in '' resolv bind; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_res_search=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_res_search+:} false; then : break fi done if ${ac_cv_search_res_search+:} false; then : else ac_cv_search_res_search=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_res_search" >&5 $as_echo "$ac_cv_search_res_search" >&6; } ac_res=$ac_cv_search_res_search if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_RES_SEARCH 1" >>confdefs.h fi ac_fn_c_check_decl "$LINENO" "res_search" "ac_cv_have_decl_res_search" " #include #include #include #include #include " if test "x$ac_cv_have_decl_res_search" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_RES_SEARCH $ac_have_decl _ACEOF # Check whether --with-libresolv was given. if test "${with_libresolv+set}" = set; then : withval=$with_libresolv; with_libresolv=$withval else with_libresolv=yes fi if test x$with_libresolv = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing hstrerror" >&5 $as_echo_n "checking for library containing hstrerror... " >&6; } if ${ac_cv_search_hstrerror+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char hstrerror (); int main () { return hstrerror (); ; return 0; } _ACEOF for ac_lib in '' resolv; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_hstrerror=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_hstrerror+:} false; then : break fi done if ${ac_cv_search_hstrerror+:} false; then : else ac_cv_search_hstrerror=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_hstrerror" >&5 $as_echo "$ac_cv_search_hstrerror" >&6; } ac_res=$ac_cv_search_hstrerror if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi for ac_header in curses.h term.h ncurses/curses.h ncurses/term.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Get a library with terminal caps if needed; prefer one with tigetstr. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tigetstr" >&5 $as_echo_n "checking for library containing tigetstr... " >&6; } if ${ac_cv_search_tigetstr+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char tigetstr (); int main () { return tigetstr (); ; return 0; } _ACEOF for ac_lib in '' tinfo curses ncurses; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_tigetstr=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_tigetstr+:} false; then : break fi done if ${ac_cv_search_tigetstr+:} false; then : else ac_cv_search_tigetstr=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tigetstr" >&5 $as_echo "$ac_cv_search_tigetstr" >&6; } ac_res=$ac_cv_search_tigetstr if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_TIGETSTR 1" >>confdefs.h for ac_func in tgetstr do : ac_fn_c_check_func "$LINENO" "tgetstr" "ac_cv_func_tgetstr" if test "x$ac_cv_func_tgetstr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TGETSTR 1 _ACEOF fi done else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetstr" >&5 $as_echo_n "checking for library containing tgetstr... " >&6; } if ${ac_cv_search_tgetstr+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char tgetstr (); int main () { return tgetstr (); ; return 0; } _ACEOF for ac_lib in '' termcap; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_tgetstr=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_tgetstr+:} false; then : break fi done if ${ac_cv_search_tgetstr+:} false; then : else ac_cv_search_tgetstr=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetstr" >&5 $as_echo "$ac_cv_search_tgetstr" >&6; } ac_res=$ac_cv_search_tgetstr if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_TGETSTR 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: No terminfo" >&5 $as_echo "$as_me: WARNING: No terminfo" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline" >&5 $as_echo_n "checking for readline... " >&6; } case "$with_included_readline" in yes) lftp_cv_precompiled_readline=no;; no) lftp_cv_precompiled_readline=yes;; *) if ${lftp_cv_precompiled_readline+:} false; then : $as_echo_n "(cached) " >&6 else old_LIBS="$LIBS" LIBS="-lreadline $READLINE_SUPPLIB $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ extern int (*rl_getc_function)(); int main () { rl_getc_function=0; rl_completion_matches(0,0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : lftp_cv_precompiled_readline=yes else lftp_cv_precompiled_readline=no fi rm -f conftest.err conftest.i conftest.$ac_ext else lftp_cv_precompiled_readline=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$old_LIBS" fi ;; esac if test $lftp_cv_precompiled_readline = yes; then READLINE_DIR='' { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } READLINE='-lreadline' READLINE_DEPEND='' COMPILE_READLINE=no else READLINE_DIR=readline-4.3 if ! test -d $READLINE_DIR; then as_fn_error $? "need installed readline-devel package" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - will compile" >&5 $as_echo "no - will compile" >&6; } ac_config_links="$ac_config_links include/readline:$READLINE_DIR" READLINE='$(top_builddir)/$(READLINE_DIR)/libreadline.a' READLINE_DEPEND='$(top_builddir)/$(READLINE_DIR)/libreadline.a' COMPILE_READLINE=yes fi # Check whether --with-gnutls was given. if test "${with_gnutls+set}" = set; then : withval=$with_gnutls; with_gnutls=$withval else with_gnutls=yes fi # Check whether --with-openssl was given. if test "${with_openssl+set}" = set; then : withval=$with_openssl; with_openssl=$withval else with_openssl=no fi case "$with_openssl" in yes) with_gnutls=no;; ""|no) : ;; *) openssl_loc=$with_openssl with_openssl=yes with_gnutls=no;; esac if test x$with_gnutls = xyes; then if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBGNUTLS" >&5 $as_echo_n "checking for LIBGNUTLS... " >&6; } if test -n "$LIBGNUTLS_CFLAGS"; then pkg_cv_LIBGNUTLS_CFLAGS="$LIBGNUTLS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls >= 1.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls >= 1.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBGNUTLS_CFLAGS=`$PKG_CONFIG --cflags "gnutls >= 1.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBGNUTLS_LIBS"; then pkg_cv_LIBGNUTLS_LIBS="$LIBGNUTLS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls >= 1.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls >= 1.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBGNUTLS_LIBS=`$PKG_CONFIG --libs "gnutls >= 1.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBGNUTLS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnutls >= 1.0.0" 2>&1` else LIBGNUTLS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnutls >= 1.0.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBGNUTLS_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (gnutls >= 1.0.0) were not met: $LIBGNUTLS_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBGNUTLS_CFLAGS and LIBGNUTLS_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables LIBGNUTLS_CFLAGS and LIBGNUTLS_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else LIBGNUTLS_CFLAGS=$pkg_cv_LIBGNUTLS_CFLAGS LIBGNUTLS_LIBS=$pkg_cv_LIBGNUTLS_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define USE_GNUTLS 1" >>confdefs.h gnutls_version_code=`$PKG_CONFIG --modversion gnutls | $AWK -F. '{ printf "0x%02X%02X%02X\n",$1,$2,$3 }'` cat >>confdefs.h <<_ACEOF #define LFTP_LIBGNUTLS_VERSION_CODE $gnutls_version_code _ACEOF fi fi if test x$with_openssl = xyes -a x"$LIBGNUTLS_LIBS" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl library" >&5 $as_echo_n "checking for openssl library... " >&6; } if ${lftp_cv_openssl+:} false; then : $as_echo_n "(cached) " >&6 else found_loc=none; lftp_cv_openssl=none; for loc in $openssl_loc default /usr/local/ssl; do old_LIBS="$LIBS" old_LDFLAGS="$LDFLAGS" old_CPPFLAGS="$CPPFLAGS" LIBS="$LIBS -lssl -lcrypto" if test $loc != default; then LDFLAGS="$LDFLAGS -L$loc/lib" CPPFLAGS="$CPPFLAGS -I$loc/include" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { static SSL_CTX *ctx; SSL_new(ctx); RAND_status() ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : found_loc="$loc" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$old_LIBS" LDFLAGS="$old_LDFLAGS" CPPFLAGS="$old_CPPFLAGS" if test $found_loc != "none"; then lftp_cv_openssl="OPENSSL_LIBS=\"-lssl -lcrypto\"" if test $found_loc != default; then lftp_cv_openssl="$lftp_cv_openssl OPENSSL_LDFLAGS=\"-L$found_loc/lib -R$found_loc/lib\"" lftp_cv_openssl="$lftp_cv_openssl OPENSSL_CPPFLAGS=-I$found_loc/include" fi break; fi done fi if test "$lftp_cv_openssl" != none; then eval $lftp_cv_openssl $as_echo "#define USE_OPENSSL 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_openssl" >&5 $as_echo "$lftp_cv_openssl" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none found" >&5 $as_echo "none found" >&6; } fi fi # Check whether --with-zlib was given. if test "${with_zlib+set}" = set; then : withval=$with_zlib; zlib_loc="$withval" fi for loc in $zlib_loc default; do old_LDFLAGS="$LDFLAGS" old_CPPFLAGS="$CPPFLAGS" case $loc in yes|no|default|"") ;; *) LDFLAGS="$LDFLAGS -L$loc/lib" CPPFLAGS="$CPPFLAGS -I$loc/include";; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflate in -lz" >&5 $as_echo_n "checking for deflate in -lz... " >&6; } if ${ac_cv_lib_z_deflate+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char deflate (); int main () { return deflate (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_z_deflate=yes else ac_cv_lib_z_deflate=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflate" >&5 $as_echo "$ac_cv_lib_z_deflate" >&6; } if test "x$ac_cv_lib_z_deflate" = xyes; then : LDFLAGS="$old_LDFLAGS" CPPFLAGS="$old_CPPFLAGS" ZLIB=-lz case $loc in yes|no|default|"") ;; *) ZLIB_LDFLAGS="-L$loc/lib" ZLIB_CPPFLAGS="-I$loc/include";; esac $as_echo "#define HAVE_ZLIB 1" >>confdefs.h break fi LDFLAGS="$old_LDFLAGS" CPPFLAGS="$old_CPPFLAGS" done if test "x$ZLIB" = x; then as_fn_error $? "cannot find -lz library, install zlib-devel package" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML_ParserCreateNS in -lexpat" >&5 $as_echo_n "checking for XML_ParserCreateNS in -lexpat... " >&6; } if ${ac_cv_lib_expat_XML_ParserCreateNS+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lexpat $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char XML_ParserCreateNS (); int main () { return XML_ParserCreateNS (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_expat_XML_ParserCreateNS=yes else ac_cv_lib_expat_XML_ParserCreateNS=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_expat_XML_ParserCreateNS" >&5 $as_echo "$ac_cv_lib_expat_XML_ParserCreateNS" >&6; } if test "x$ac_cv_lib_expat_XML_ParserCreateNS" = xyes; then : EXPAT_LIBS=-lexpat $as_echo "#define HAVE_LIBEXPAT 1" >>confdefs.h fi # Check whether user wants DNSSEC local validation support # Check whether --with-dnssec-local-validation was given. if test "${with_dnssec_local_validation+set}" = set; then : withval=$with_dnssec_local_validation; want_dnssec=$withval else want_dnssec=no fi if test "x$want_dnssec" = "xyes"; then for ac_header in validator/validator.h do : ac_fn_c_check_header_mongrel "$LINENO" "validator/validator.h" "ac_cv_header_validator_validator_h" "$ac_includes_default" if test "x$ac_cv_header_validator_validator_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VALIDATOR_VALIDATOR_H 1 _ACEOF fi done if test "$ac_cv_header_validator_validator_h" != yes; then as_fn_error $? "Can't find validator.h (from dnssec-tools)" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing SHA1_Init" >&5 $as_echo_n "checking for library containing SHA1_Init... " >&6; } if ${ac_cv_search_SHA1_Init+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char SHA1_Init (); int main () { return SHA1_Init (); ; return 0; } _ACEOF for ac_lib in '' crypto ssl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_SHA1_Init=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_SHA1_Init+:} false; then : break fi done if ${ac_cv_search_SHA1_Init+:} false; then : else ac_cv_search_SHA1_Init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_SHA1_Init" >&5 $as_echo "$ac_cv_search_SHA1_Init" >&6; } ac_res=$ac_cv_search_SHA1_Init if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for query_send in -lsres" >&5 $as_echo_n "checking for query_send in -lsres... " >&6; } if ${ac_cv_lib_sres_query_send+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsres $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char query_send (); int main () { return query_send (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_sres_query_send=yes else ac_cv_lib_sres_query_send=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sres_query_send" >&5 $as_echo "$ac_cv_lib_sres_query_send" >&6; } if test "x$ac_cv_lib_sres_query_send" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSRES 1 _ACEOF LIBS="-lsres $LIBS" fi if test "$ac_cv_lib_sres_query_send" != yes; then as_fn_error $? "Can't find libsres (from dnssec-tools)" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for p_val_status in -lval" >&5 $as_echo_n "checking for p_val_status in -lval... " >&6; } if ${ac_cv_lib_val_p_val_status+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lval $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char p_val_status (); int main () { return p_val_status (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_val_p_val_status=yes else ac_cv_lib_val_p_val_status=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_val_p_val_status" >&5 $as_echo "$ac_cv_lib_val_p_val_status" >&6; } if test "x$ac_cv_lib_val_p_val_status" = xyes; then : LIBS="$LIBS -lval" fi if test "x$ac_cv_lib_val_p_val_status" = "xno"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_rwlock_init in -lpthread" >&5 $as_echo_n "checking for pthread_rwlock_init in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_rwlock_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_rwlock_init (); int main () { return pthread_rwlock_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_rwlock_init=yes else ac_cv_lib_pthread_pthread_rwlock_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_rwlock_init" >&5 $as_echo "$ac_cv_lib_pthread_pthread_rwlock_init" >&6; } if test "x$ac_cv_lib_pthread_pthread_rwlock_init" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="-lpthread $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for p_val_status in -lval-threads" >&5 $as_echo_n "checking for p_val_status in -lval-threads... " >&6; } if ${ac_cv_lib_val_threads_p_val_status+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lval-threads $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char p_val_status (); int main () { return p_val_status (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_val_threads_p_val_status=yes else ac_cv_lib_val_threads_p_val_status=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_val_threads_p_val_status" >&5 $as_echo "$ac_cv_lib_val_threads_p_val_status" >&6; } if test "x$ac_cv_lib_val_threads_p_val_status" = xyes; then : LIBS="$LIBS -lval-threads -lpthread" LIBVAL_SUFFIX="-threads" else as_fn_error $? "Can't find libval or libval-threads (from dnssec-tools)" "$LINENO" 5 fi fi if test "x$ac_cv_lib_val_p_val_status" = "xyes" -o "x$ac_cv_lib_val_threads_p_val_status" = "xyes"; then $as_echo "#define DNSSEC_LOCAL_VALIDATION 1" >>confdefs.h fi fi case "$host" in *-*-linux*) no_dev_ptmx=1; no_dev_ptc=1;; *-*-sco3.2v4*) no_dev_ptmx=1;; *-*-sco3.2v5*) no_dev_ptmx=1;; esac if test -z "$no_dev_ptmx" ; then as_ac_File=`$as_echo "ac_cv_file_"/dev/ptmx"" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for \"/dev/ptmx\"" >&5 $as_echo_n "checking for \"/dev/ptmx\"... " >&6; } if eval \${$as_ac_File+:} false; then : $as_echo_n "(cached) " >&6 else test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r ""/dev/ptmx""; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : $as_echo "#define HAVE_DEV_PTMX 1" >>confdefs.h fi fi if test -z "$no_dev_ptc" ; then as_ac_File=`$as_echo "ac_cv_file_"/dev/ptc"" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for \"/dev/ptc\"" >&5 $as_echo_n "checking for \"/dev/ptc\"... " >&6; } if eval \${$as_ac_File+:} false; then : $as_echo_n "(cached) " >&6 else test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r ""/dev/ptc""; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : $as_echo "#define HAVE_DEV_PTS_AND_PTC 1" >>confdefs.h fi fi for ac_header in util.h sys/stropts.h pty.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing openpty" >&5 $as_echo_n "checking for library containing openpty... " >&6; } if ${ac_cv_search_openpty+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char openpty (); int main () { return openpty (); ; return 0; } _ACEOF for ac_lib in '' util; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_openpty=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_openpty+:} false; then : break fi done if ${ac_cv_search_openpty+:} false; then : else ac_cv_search_openpty=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_openpty" >&5 $as_echo "$ac_cv_search_openpty" >&6; } ac_res=$ac_cv_search_openpty if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_OPENPTY 1" >>confdefs.h fi for ac_func in _getpty do : ac_fn_c_check_func "$LINENO" "_getpty" "ac_cv_func__getpty" if test "x$ac_cv_func__getpty" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__GETPTY 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether posix_fallocate() works" >&5 $as_echo_n "checking whether posix_fallocate() works... " >&6; } if ${i_cv_posix_fallocate_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : if ${i_cv_posix_fallocate_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { posix_fallocate(0, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : i_cv_posix_fallocate_works=yes else i_cv_posix_fallocate_works=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 600 #include #include #include #include #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7) possibly broken posix_fallocate #endif int main() { int fd = creat("conftest.temp", 0600); int ret; if (fd == -1) { perror("creat()"); return 2; } ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0; unlink("conftest.temp"); return ret; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : i_cv_posix_fallocate_works=yes else i_cv_posix_fallocate_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $i_cv_posix_fallocate_works" >&5 $as_echo "$i_cv_posix_fallocate_works" >&6; } if test x$i_cv_posix_fallocate_works = xyes; then $as_echo "#define HAVE_POSIX_FALLOCATE 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for posix_fadvise" >&5 $as_echo_n "checking for posix_fadvise... " >&6; } if ${ac_cv_posix_fadvise+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 600 #include #include #include #include int main () { int res = posix_fadvise ((int)0, (off_t)0, (off_t)0, POSIX_FADV_NORMAL); int a = POSIX_FADV_SEQUENTIAL; int b = POSIX_FADV_NOREUSE; int c = POSIX_FADV_RANDOM; int d = POSIX_FADV_WILLNEED; int e = POSIX_FADV_DONTNEED; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_posix_fadvise=yes else ac_cv_posix_fadvise=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_posix_fadvise" >&5 $as_echo "$ac_cv_posix_fadvise" >&6; } if test x$ac_cv_posix_fadvise = xyes; then $as_echo "#define HAVE_POSIX_FADVISE 1" >>confdefs.h fi # Check whether --with-libidn was given. if test "${with_libidn+set}" = set; then : withval=$with_libidn; libidn=$withval else libidn=yes fi if test "$libidn" != "no"; then if test "$libidn" != "yes"; then LDFLAGS="${LDFLAGS} -L$libidn/lib" CPPFLAGS="${CPPFLAGS} -I$libidn/include" fi ac_fn_c_check_header_mongrel "$LINENO" "idna.h" "ac_cv_header_idna_h" "$ac_includes_default" if test "x$ac_cv_header_idna_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stringprep_check_version in -lidn" >&5 $as_echo_n "checking for stringprep_check_version in -lidn... " >&6; } if ${ac_cv_lib_idn_stringprep_check_version+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lidn $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char stringprep_check_version (); int main () { return stringprep_check_version (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_idn_stringprep_check_version=yes else ac_cv_lib_idn_stringprep_check_version=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_idn_stringprep_check_version" >&5 $as_echo "$ac_cv_lib_idn_stringprep_check_version" >&6; } if test "x$ac_cv_lib_idn_stringprep_check_version" = xyes; then : libidn=yes LIBS="${LIBS} -lidn" else libidn=no fi else libidn=no fi fi if test "$libidn" != "no" ; then $as_echo "#define LIBIDN 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libidn not found" >&5 $as_echo "$as_me: WARNING: Libidn not found" >&2;} fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Libidn should be used" >&5 $as_echo_n "checking if Libidn should be used... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libidn" >&5 $as_echo "$libidn" >&6; } ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } if eval \${$as_ac_Header+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$as_ac_Header=yes" else eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$as_ac_Header { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_opendir=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_opendir+:} false; then : break fi done if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 $as_echo "$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi for ac_header in libintl.h fcntl.h sys/time.h errno.h stdlib.h varargs.h dirent.h\ termios.h termio.h sys/select.h sys/stropts.h string.h memory.h\ strings.h sys/ioctl.h dlfcn.h arpa/inet.h arpa/nameser.h netinet/in.h netinet/tcp.h\ netinet/in_systm.h netinet/ip.h termcap.h sys/statfs.h ifaddrs.h\ resolv.h langinfo.h endian.h locale.h expat.h linux/magic.h socks.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " #include #ifdef HAVE_ARPA_NAMESER_H # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETINET_IN_SYSTM_H # include #endif " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in vsnprintf snprintf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking if trio library is needed" >&5 $as_echo_n "checking if trio library is needed... " >&6; } if ${ac_cv_need_trio+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_need_trio=no; if test x$ac_cv_func_vsnprintf != xyes -o x$ac_cv_func_snprintf != xyes; then ac_cv_need_trio="yes (because there is no system snprintf/vsnprintf functions)" else if test "$cross_compiling" = yes; then : ac_cv_need_trio="no (assumed)" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main() { unsigned long long x=0,x1; long long y=0,y1; char buf[128]; x=~x; sscanf("0","%llu",&x); if(x!=0) return 1; y=~y; sscanf("0","%lld",&y); if(y!=0) return 1; x=~x; sprintf(buf,"%lld %llu",y,x); sscanf (buf,"%lld %llu",&y1,&x1); if(x!=x1 || y!=y1) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_need_trio="yes (because %lld fails)" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_need_trio" >&5 $as_echo "$ac_cv_need_trio" >&6; } case $ac_cv_need_trio in yes*) ac_cv_need_trio=yes $as_echo "#define TRIO_REPLACE_STDIO 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking if math library is needed" >&5 $as_echo_n "checking if math library is needed... " >&6; } if ${lftp_cv_libm_needed+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include double a,b; int main () { return int(exp(a)+log(b)+pow(a,b)); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lftp_cv_libm_needed=no else lftp_cv_libm_needed=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_libm_needed" >&5 $as_echo "$lftp_cv_libm_needed" >&6; } if test x$lftp_cv_libm_needed = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing exp" >&5 $as_echo_n "checking for library containing exp... " >&6; } if ${ac_cv_search_exp+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char exp (); int main () { return exp (); ; return 0; } _ACEOF for ac_lib in '' m; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_exp=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_exp+:} false; then : break fi done if ${ac_cv_search_exp+:} false; then : else ac_cv_search_exp=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_exp" >&5 $as_echo "$ac_cv_search_exp" >&6; } ac_res=$ac_cv_search_exp if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi ;; *) ac_cv_need_trio=no ;; esac if test "$ac_cv_need_trio" = yes; then NEED_TRIO_TRUE= NEED_TRIO_FALSE='#' else NEED_TRIO_TRUE='#' NEED_TRIO_FALSE= fi # See if we have h_errno (the test is here so we can use -lresolv if necessary). { $as_echo "$as_me:${as_lineno-$LINENO}: checking for h_errno" >&5 $as_echo_n "checking for h_errno... " >&6; } if ${inetutils_cv_var_h_errno+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef h_errno extern int h_errno; #endif int iu_x = h_errno; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : inetutils_cv_var_h_errno=yes else inetutils_cv_var_h_errno=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $inetutils_cv_var_h_errno" >&5 $as_echo "$inetutils_cv_var_h_errno" >&6; } if test "$inetutils_cv_var_h_errno" = yes; then $as_echo "#define HAVE_H_ERRNO 1" >>confdefs.h ac_fn_c_check_decl "$LINENO" "h_errno" "ac_cv_have_decl_h_errno" "#include " if test "x$ac_cv_have_decl_h_errno" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_H_ERRNO $ac_have_decl _ACEOF fi # See if the system has hstrerror, and replace it if not ac_fn_c_check_func "$LINENO" "hstrerror" "ac_cv_func_hstrerror" if test "x$ac_cv_func_hstrerror" = xyes; then : else gl_LIBOBJS="$gl_LIBOBJS hstrerror.$ac_objext" fi if test "$ac_cv_func_hstrerror" = yes; then ac_fn_c_check_decl "$LINENO" "hstrerror" "ac_cv_have_decl_hstrerror" "#include " if test "x$ac_cv_have_decl_hstrerror" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_HSTRERROR $ac_have_decl _ACEOF else # No hstrerror, so see if the H_ERRLIST variable can be used by ours ac_fn_c_check_func "$LINENO" "h_errlist" "ac_cv_func_h_errlist" if test "x$ac_cv_func_h_errlist" = xyes; then : ac_fn_c_check_decl "$LINENO" "h_errlist" "ac_cv_have_decl_h_errlist" "#include " if test "x$ac_cv_have_decl_h_errlist" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_H_ERRLIST $ac_have_decl _ACEOF fi fi if test "$ac_cv_func_hstrerror" = yes -o "$ac_cv_func_h_errlist" = yes; then # If there's a system hstrerror, or we can reasonably replace it, say so. # We still provide some definition, regardless, but this allows people to use # a reasonable alternative if the situation allows, rather than using a # degenerate version that only says `Host lookup error N'. $as_echo "#define HAVE_HSTRERROR 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" if test "x$ac_cv_type_off_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define off_t long int _ACEOF fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi if test x$ac_cv_header_endian_h = xno; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac fi ac_fn_c_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_sockaddr_sa_len" "#include #include " if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_SOCKADDR_SA_LEN 1 _ACEOF fi ac_fn_c_check_member "$LINENO" "struct sockaddr_in6" "sin6_scope_id" "ac_cv_member_struct_sockaddr_in6_sin6_scope_id" "#include #include #include " if test "x$ac_cv_member_struct_sockaddr_in6_sin6_scope_id" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1 _ACEOF fi ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include #include <$ac_cv_struct_tm> " if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM_TM_ZONE 1 _ACEOF fi if test "$ac_cv_member_struct_tm_tm_zone" = yes; then $as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h else ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include " if test "x$ac_cv_have_decl_tzname" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_TZNAME $ac_have_decl _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5 $as_echo_n "checking for tzname... " >&6; } if ${ac_cv_var_tzname+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if !HAVE_DECL_TZNAME extern char *tzname[]; #endif int main () { return tzname[0][0]; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_var_tzname=yes else ac_cv_var_tzname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5 $as_echo "$ac_cv_var_tzname" >&6; } if test $ac_cv_var_tzname = yes; then $as_echo "#define HAVE_TZNAME 1" >>confdefs.h fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct tm tm; int *p = &tm.tm_sec; return !p; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_tm=time.h else ac_cv_struct_tm=sys/time.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 $as_echo "$ac_cv_struct_tm" >&6; } if test $ac_cv_struct_tm = sys/time.h; then $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether utime accepts a null argument" >&5 $as_echo_n "checking whether utime accepts a null argument... " >&6; } if ${ac_cv_func_utime_null+:} false; then : $as_echo_n "(cached) " >&6 else rm -f conftest.data; >conftest.data # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong. if test "$cross_compiling" = yes; then : ac_cv_func_utime_null='guessing yes' else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #ifdef HAVE_UTIME_H # include #endif int main () { struct stat s, t; return ! (stat ("conftest.data", &s) == 0 && utime ("conftest.data", 0) == 0 && stat ("conftest.data", &t) == 0 && t.st_mtime >= s.st_mtime && t.st_mtime - s.st_mtime < 120); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_utime_null=yes else ac_cv_func_utime_null=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_utime_null" >&5 $as_echo "$ac_cv_func_utime_null" >&6; } if test "x$ac_cv_func_utime_null" != xno; then ac_cv_func_utime_null=yes $as_echo "#define HAVE_UTIME_NULL 1" >>confdefs.h fi rm -f conftest.data { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpgrp requires zero arguments" >&5 $as_echo_n "checking whether getpgrp requires zero arguments... " >&6; } if ${ac_cv_func_getpgrp_void+:} false; then : $as_echo_n "(cached) " >&6 else # Use it with a single arg. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { getpgrp (0); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_func_getpgrp_void=no else ac_cv_func_getpgrp_void=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpgrp_void" >&5 $as_echo "$ac_cv_func_getpgrp_void" >&6; } if test $ac_cv_func_getpgrp_void = yes; then $as_echo "#define GETPGRP_VOID 1" >>confdefs.h fi for ac_func in vprintf do : ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" if test "x$ac_cv_func_vprintf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VPRINTF 1 _ACEOF ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" if test "x$ac_cv_func__doprnt" = xyes; then : $as_echo "#define HAVE_DOPRNT 1" >>confdefs.h fi fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5 $as_echo_n "checking whether stat file-mode macros are broken... " >&6; } if ${ac_cv_header_stat_broken+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if defined S_ISBLK && defined S_IFDIR extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1]; #endif #if defined S_ISBLK && defined S_IFCHR extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1]; #endif #if defined S_ISLNK && defined S_IFREG extern char c3[S_ISLNK (S_IFREG) ? -1 : 1]; #endif #if defined S_ISSOCK && defined S_IFREG extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1]; #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stat_broken=no else ac_cv_header_stat_broken=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5 $as_echo "$ac_cv_header_stat_broken" >&6; } if test $ac_cv_header_stat_broken = yes; then $as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sscanf works on const strings" >&5 $as_echo_n "checking whether sscanf works on const strings... " >&6; } if ${lftp_cv_func_sscanf_const_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lftp_cv_func_sscanf_const_works=yes; else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main() { int a,b; return !(sscanf("123x","%d%n",&a,&b)>0); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : lftp_cv_func_sscanf_const_works=yes; else lftp_cv_func_sscanf_const_works=no; fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_func_sscanf_const_works" >&5 $as_echo "$lftp_cv_func_sscanf_const_works" >&6; } if test $lftp_cv_func_sscanf_const_works = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: sscanf does not work on const strings" >&5 $as_echo "$as_me: WARNING: sscanf does not work on const strings" >&2;} fi for ac_func in statfs\ killpg setpgid tcgetattr vsnprintf snprintf sscanf \ gethostbyname2 getipnodebyname getaddrinfo getnameinfo setsid random\ inet_aton setlocale dn_expand socketpair do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an implementation of va_copy()" >&5 $as_echo_n "checking for an implementation of va_copy()... " >&6; } if ${lftp_cv_va_copy+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lftp_cv_va_copy=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include void f (int i, ...) { va_list args1, args2; va_start (args1, i); va_copy (args2, args1); if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) exit (1); va_end (args1); va_end (args2); } int main() { f (0, 42); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : lftp_cv_va_copy=yes else lftp_cv_va_copy=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_va_copy" >&5 $as_echo "$lftp_cv_va_copy" >&6; } if test x$lftp_cv_va_copy != xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an implementation of __va_copy()" >&5 $as_echo_n "checking for an implementation of __va_copy()... " >&6; } if ${lftp_cv___va_copy+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lftp_cv___va_copy=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include void f (int i, ...) { va_list args1, args2; va_start (args1, i); __va_copy (args2, args1); if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) exit (1); va_end (args1); va_end (args2); } int main() { f (0, 42); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : lftp_cv___va_copy=yes else lftp_cv___va_copy=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv___va_copy" >&5 $as_echo "$lftp_cv___va_copy" >&6; } fi if test "x$lftp_cv_va_copy" = "xyes"; then va_copy_func=va_copy elif test "x$lftp_cv___va_copy" = "xyes"; then va_copy_func=__va_copy fi if test -n "$va_copy_func"; then cat >>confdefs.h <<_ACEOF #define VA_COPY $va_copy_func _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether va_lists can be copied by value" >&5 $as_echo_n "checking whether va_lists can be copied by value... " >&6; } if ${lftp_cv_va_val_copy+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lftp_cv_va_val_copy=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include void f (int i, ...) { va_list args1, args2; va_start (args1, i); memmove(&args2, &args1, sizeof(args1)); if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) exit (1); va_end (args1); va_end (args2); } int main() { f (0, 42); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : lftp_cv_va_val_copy=yes else lftp_cv_va_val_copy=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_va_val_copy" >&5 $as_echo "$lftp_cv_va_val_copy" >&6; } if test x$lftp_cv_va_val_copy = xyes; then $as_echo "#define VA_VAL_COPY 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether va_lists can be copied by pointer" >&5 $as_echo_n "checking whether va_lists can be copied by pointer... " >&6; } if ${lftp_cv_va_ptr_copy+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lftp_cv_va_ptr_copy=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include void f (int i, ...) { va_list args1, args2; va_start (args1, i); *args2 = *args1; if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) exit (1); va_end (args1); va_end (args2); } int main() { f (0, 42); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : lftp_cv_va_ptr_copy=yes else lftp_cv_va_ptr_copy=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_va_ptr_copy" >&5 $as_echo "$lftp_cv_va_ptr_copy" >&6; } if test x$lftp_cv_va_ptr_copy = xyes; then $as_echo "#define VA_PTR_COPY 1" >>confdefs.h fi fi fi if test x$lftp_cv_va_val_copy != xyes -a x$lftp_cv_va_ptr_copy != xyes -a \ x$lftp_cv_va_copy != xyes -a x$lftp_cv___va_copy != xyes; then as_fn_error $? "Can't find a way to va_copy." "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for environ variable" >&5 $as_echo_n "checking for environ variable... " >&6; } if ${lftp_cv_environ+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include extern char **environ; int main () { return environ==(char**)0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lftp_cv_environ=yes else lftp_cv_environ=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lftp_cv_environ" >&5 $as_echo "$lftp_cv_environ" >&6; } if test x$lftp_cv_environ = xyes; then $as_echo "#define HAVE_ENVIRON 1" >>confdefs.h fi ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_vsnprintf" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_VSNPRINTF $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_snprintf" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SNPRINTF $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "unsetenv" "ac_cv_have_decl_unsetenv" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_unsetenv" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_UNSETENV $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "random" "ac_cv_have_decl_random" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_random" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_RANDOM $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "inet_aton" "ac_cv_have_decl_inet_aton" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_inet_aton" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_INET_ATON $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "strptime" "ac_cv_have_decl_strptime" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_strptime" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRPTIME $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "strtok_r" "ac_cv_have_decl_strtok_r" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_strtok_r" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRTOK_R $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "dn_expand" "ac_cv_have_decl_dn_expand" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_dn_expand" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_DN_EXPAND $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "memmem" "ac_cv_have_decl_memmem" " #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif " if test "x$ac_cv_have_decl_memmem" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_MEMMEM $ac_have_decl _ACEOF if test "$prefix" = /usr -a "$sysconfdir" = '${prefix}/etc'; then sysconfdir=/etc fi ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files src/Makefile" ac_config_files="$ac_config_files lib/Makefile" ac_config_files="$ac_config_files doc/Makefile" ac_config_files="$ac_config_files po/Makefile.in" ac_config_files="$ac_config_files m4/Makefile" ac_config_files="$ac_config_files trio/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_ICONV_H_TRUE}" && test -z "${GL_GENERATE_ICONV_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_ICONV_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_MODULES_TRUE}" && test -z "${WITH_MODULES_FALSE}"; then as_fn_error $? "conditional \"WITH_MODULES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_COND_LIBTOOL_TRUE}" && test -z "${GL_COND_LIBTOOL_FALSE}"; then as_fn_error $? "conditional \"GL_COND_LIBTOOL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_ALLOCA_H_TRUE}" && test -z "${GL_GENERATE_ALLOCA_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_ALLOCA_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_ERRNO_H_TRUE}" && test -z "${GL_GENERATE_ERRNO_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_ERRNO_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_FLOAT_H_TRUE}" && test -z "${GL_GENERATE_FLOAT_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_FLOAT_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_FNMATCH_H_TRUE}" && test -z "${GL_GENERATE_FNMATCH_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_FNMATCH_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_GLOB_H_TRUE}" && test -z "${GL_GENERATE_GLOB_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_GLOB_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_ICONV_H_TRUE}" && test -z "${GL_GENERATE_ICONV_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_ICONV_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_ICONV_H_TRUE}" && test -z "${GL_GENERATE_ICONV_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_ICONV_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_STDINT_H_TRUE}" && test -z "${GL_GENERATE_STDINT_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_STDINT_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_STDDEF_H_TRUE}" && test -z "${GL_GENERATE_STDDEF_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_STDDEF_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_NETINET_IN_H_TRUE}" && test -z "${GL_GENERATE_NETINET_IN_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_NETINET_IN_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_STDBOOL_H_TRUE}" && test -z "${GL_GENERATE_STDBOOL_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_STDBOOL_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_STDALIGN_H_TRUE}" && test -z "${GL_GENERATE_STDALIGN_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_STDALIGN_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_STDBOOL_H_TRUE}" && test -z "${GL_GENERATE_STDBOOL_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_STDBOOL_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${GL_GENERATE_STDDEF_H_TRUE}" && test -z "${GL_GENERATE_STDDEF_H_FALSE}"; then as_fn_error $? "conditional \"GL_GENERATE_STDDEF_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_TRUE}" && test -z "${LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR_FALSE}"; then as_fn_error $? "conditional \"LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUCR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_TRUE}" && test -z "${LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB_FALSE}"; then as_fn_error $? "conditional \"LIBUNISTRING_COMPILE_UNISTR_U8_UCTOMB\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_TRUE}" && test -z "${LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH_FALSE}"; then as_fn_error $? "conditional \"LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi gl_libobjs= gl_ltlibobjs= if test -n "$gl_LIBOBJS"; then # Remove the extension. sed_drop_objext='s/\.o$//;s/\.obj$//' for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do gl_libobjs="$gl_libobjs $i.$ac_objext" gl_ltlibobjs="$gl_ltlibobjs $i.lo" done fi gl_LIBOBJS=$gl_libobjs gl_LTLIBOBJS=$gl_ltlibobjs gltests_libobjs= gltests_ltlibobjs= if test -n "$gltests_LIBOBJS"; then # Remove the extension. sed_drop_objext='s/\.o$//;s/\.obj$//' for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do gltests_libobjs="$gltests_libobjs $i.$ac_objext" gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" done fi gltests_LIBOBJS=$gltests_libobjs gltests_LTLIBOBJS=$gltests_ltlibobjs if test -z "${NEED_TRIO_TRUE}" && test -z "${NEED_TRIO_FALSE}"; then as_fn_error $? "conditional \"NEED_TRIO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by lftp $as_me 4.6.3a, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_links="$ac_config_links" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration links: $config_links Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ lftp config.status 4.6.3a configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # Capture the value of obsolete ALL_LINGUAS because we need it to compute # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it # from automake < 1.5. eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' # Capture the value of LINGUAS because we need it to compute CATALOGS. LINGUAS="${LINGUAS-%UNSET%}" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`' file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ lt_cv_nm_interface \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib \ compiler_lib_search_dirs \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ LD_CXX \ reload_flag_CXX \ compiler_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_static_CXX \ lt_cv_prog_compiler_c_o_CXX \ export_dynamic_flag_spec_CXX \ whole_archive_flag_spec_CXX \ compiler_needs_object_CXX \ with_gnu_ld_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_separator_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX \ file_list_spec_CXX \ compiler_lib_search_dirs_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec \ reload_cmds_CXX \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ export_symbols_cmds_CXX \ prelink_cmds_CXX \ postlink_cmds_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "lib/config.h") CONFIG_HEADERS="$CONFIG_HEADERS lib/config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "include/readline") CONFIG_LINKS="$CONFIG_LINKS include/readline:$READLINE_DIR" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; "m4/Makefile") CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;; "trio/Makefile") CONFIG_FILES="$CONFIG_FILES trio/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_LINKS+set}" = set || CONFIG_LINKS=$config_links test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :L $CONFIG_LINKS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :L) # # CONFIG_LINK # if test "$ac_source" = "$ac_file" && test "$srcdir" = '.'; then : else # Prefer the file from the source tree if names are identical. if test "$ac_source" = "$ac_file" || test ! -r "$ac_source"; then ac_source=$srcdir/$ac_source fi { $as_echo "$as_me:${as_lineno-$LINENO}: linking $ac_source to $ac_file" >&5 $as_echo "$as_me: linking $ac_source to $ac_file" >&6;} if test ! -r "$ac_source"; then as_fn_error $? "$ac_source: file not found" "$LINENO" 5 fi rm -f "$ac_file" # Try a relative symlink, then a hard link, then a copy. case $ac_source in [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;; *) ac_rel_source=$ac_top_build_prefix$ac_source ;; esac ln -s "$ac_rel_source" "$ac_file" 2>/dev/null || ln "$ac_source" "$ac_file" 2>/dev/null || cp -p "$ac_source" "$ac_file" || as_fn_error $? "cannot link or copy $ac_source to $ac_file" "$LINENO" 5 fi ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "po-directories":C) for ac_file in $CONFIG_FILES; do # Support "outfile[:infile[:infile...]]" case "$ac_file" in *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; esac # PO directories have a Makefile.in generated from Makefile.in.in. case "$ac_file" in */Makefile.in) # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; /*) top_srcdir="$ac_given_srcdir" ;; *) top_srcdir="$ac_dots$ac_given_srcdir" ;; esac # Treat a directory as a PO directory if and only if it has a # POTFILES.in file. This allows packages to have multiple PO # directories under different names or in different locations. if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then rm -f "$ac_dir/POTFILES" test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" gt_tab=`printf '\t'` cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" POMAKEFILEDEPS="POTFILES.in" # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend # on $ac_dir but don't depend on user-specified configuration # parameters. if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then # The LINGUAS file contains the set of available languages. if test -n "$OBSOLETE_ALL_LINGUAS"; then test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" fi ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` # Hide the ALL_LINGUAS assignment from automake < 1.5. eval 'ALL_LINGUAS''=$ALL_LINGUAS_' POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" else # The set of available languages was given in configure.in. # Hide the ALL_LINGUAS assignment from automake < 1.5. eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' fi # Compute POFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) # Compute UPDATEPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) # Compute DUMMYPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) # Compute GMOFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) case "$ac_given_srcdir" in .) srcdirpre= ;; *) srcdirpre='$(srcdir)/' ;; esac POFILES= UPDATEPOFILES= DUMMYPOFILES= GMOFILES= for lang in $ALL_LINGUAS; do POFILES="$POFILES $srcdirpre$lang.po" UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" DUMMYPOFILES="$DUMMYPOFILES $lang.nop" GMOFILES="$GMOFILES $srcdirpre$lang.gmo" done # CATALOGS depends on both $ac_dir and the user's LINGUAS # environment variable. INST_LINGUAS= if test -n "$ALL_LINGUAS"; then for presentlang in $ALL_LINGUAS; do useit=no if test "%UNSET%" != "$LINGUAS"; then desiredlanguages="$LINGUAS" else desiredlanguages="$ALL_LINGUAS" fi for desiredlang in $desiredlanguages; do # Use the presentlang catalog if desiredlang is # a. equal to presentlang, or # b. a variant of presentlang (because in this case, # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in "$presentlang"*) useit=yes;; esac done if test $useit = yes; then INST_LINGUAS="$INST_LINGUAS $presentlang" fi done fi CATALOGS= if test -n "$INST_LINGUAS"; then for lang in $INST_LINGUAS; do CATALOGS="$CATALOGS $lang.gmo" done fi test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do if test -f "$f"; then case "$f" in *.orig | *.bak | *~) ;; *) cat "$f" >> "$ac_dir/Makefile" ;; esac fi done fi ;; esac done ;; "libtool":C) # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags='CXX ' # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm into a list of symbols to manually relocate. global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name lister interface. nm_interface=$lt_lt_cv_nm_interface # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and where our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects postdep_objects=$lt_postdep_objects predeps=$lt_predeps postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. LD=$lt_LD_CXX # How to create reloadable object files. reload_flag=$lt_reload_flag_CXX reload_cmds=$lt_reload_cmds_CXX # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_CXX # A language specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU compiler? with_gcc=$GCC_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_CXX # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_CXX # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_CXX # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_CXX # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_CXX # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_CXX # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds_CXX # Specify filename containing input files. file_list_spec=$lt_file_list_spec_CXX # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects_CXX postdep_objects=$lt_postdep_objects_CXX predeps=$lt_predeps_CXX postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi lftp-4.6.3a/configure.ac0000644000015000007670000004351112540277141012050 00000000000000dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.60]) AC_INIT([lftp], [4.6.3a], [lftp-bugs@lftp.yar.ru]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_LIBOBJ_DIR([lib]) AC_CONFIG_SRCDIR([src/ftpclass.cc]) AM_CONFIG_HEADER([lib/config.h]) AM_INIT_AUTOMAKE dnl This doesn't *require* GNU extensions; it merely enables them if dnl they're there. AC_GNU_SOURCE test -z "$CXX" && DEFAULT_CXX=yes test -z "$CFLAGS" && DEFAULT_CFLAGS=yes test -z "$CXXFLAGS" && DEFAULT_CXXFLAGS=yes test -z "$LDFLAGS" && DEFAULT_LDFLAGS=yes dnl Checks for programs. AC_PROG_CC gl_EARLY AC_PROG_CXX AC_PROG_YACC if test x$ac_cv_lib_fl_yywrap = xno; then AC_DEFINE(NEED_YYWRAP, 1, [need yywrap]) dnl ? fi dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds dnl (more than 10% execution time) to ./configure, with no benefit for dnl most users. Using it to look for bugs requires: dnl GNULIB_POSIXCHECK=1 autoreconf -f dnl ./configure dnl make dnl make -C src clean dnl make CFLAGS=-DGNULIB_POSIXCHECK=1 m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set]) m4_if(m4_sysval, [0], [], [dnl gl_ASSERT_NO_GNULIB_POSIXCHECK]) AC_SYS_LARGEFILE AC_ARG_WITH(debug, AS_HELP_STRING([--with-debug], [enable debug info]), [ with_debug=$withval; ], [ with_debug=no; ]) AC_ARG_WITH(profiling, AS_HELP_STRING([--with-profiling], [enable profiling]), [ with_profiling=$withval; ], [ with_profiling=no; ]) AC_ARG_ENABLE([packager-mode], AS_HELP_STRING([--enable-packager-mode], [Change configuration behavior to ease packaging]), [if test x"${enableval}" = xyes then DEFAULT_CXX=no DEFAULT_CFLAGS=no DEFAULT_CXXFLAGS=no DEFAULT_LDFLAGS=no fi]) if test x$with_debug = xno; then if test x$DEFAULT_CFLAGS = xyes; then CFLAGS="`echo $CFLAGS | sed 's/-g//'`" if test -z "$CFLAGS"; then CFLAGS=-O fi fi if test x$DEFAULT_CXXFLAGS = xyes; then CXXFLAGS="`echo $CXXFLAGS | sed 's/-g//'`" if test -z "$CXXFLAGS"; then CXXFLAGS=-O fi fi # don't strip when profiling if test x$DEFAULT_LDFLAGS = xyes -a x$with_profiling != xyes; then case "`uname -s`" in Darwin) ;; *) LDFLAGS="$LDFLAGS -s";; esac fi fi if test x$with_debug = xyes; then dnl m4 will mangle brackets if test x$DEFAULT_CFLAGS = xyes; then CFLAGS="`echo $CFLAGS | sed 's/-O@<:@0-9@:>@\?//'`" fi if test x$DEFAULT_CXXFLAGS = xyes; then CXXFLAGS="`echo $CXXFLAGS | sed 's/-O@<:@0-9@:>@\?//'`" fi fi if test x$with_profiling = xyes; then CFLAGS="$CFLAGS -pg" CXXFLAGS="$CXXFLAGS -pg" # profiling requires debugging, too, but don't nuke -O # if test x$with_debug != xyes; then # CFLAGS="$CFLAGS -g" # CXXFLAGS="$CXXFLAGS -g" # fi fi if test x$GCC = xyes; then CFLAGS="$CFLAGS -Wall" fi if test x$GXX = xyes; then CXXFLAGS="$CXXFLAGS -Wall -Wwrite-strings -Woverloaded-virtual" # save some bytes LFTP_CHECK_CXX_FLAGS([-fno-exceptions -fno-rtti]) # check for -fno-implement-inline (doesn't work without -O in gcc 2.95.4; functions are never inlined) if test x$with_debug = xno; then LFTP_NOIMPLEMENTINLINE fi fi dnl Make sure C++ build environment is sane. LFTP_CXX_TEST CXX_DYNAMIC_INITIALIZERS LFTP_CXX_BOOL LFTP_CXX__BOOL LFTP_CXX_ANSI_SCOPE LFTP_CXX_STDC_LIMIT_MACROS AC_ISC_POSIX case "`uname -sr`" in # Linux-2.2.x and older don't support fcntl64. Linux\ 2.[012].*) enable_largefile=no;; esac dnl ** LFTP needs iconv, call the test explicitly (even if --disable-nls) AM_ICONV ALL_LINGUAS="de es fr it ja ko pl pt_BR ru uk zh_CN zh_TW zh_HK cs" AM_GNU_GETTEXT([external]) test "$MSGFMT" = "no" && MSGFMT ="$missing_dir/missing msgfmt" test "$GMSGFMT" = "no" && GMSGFMT ="$missing_dir/missing msgfmt" test "$XGETTEXT" = ":" && XGETTEXT="$missing_dir/missing xgettext" if test x$gt_cv_func_gettext_libintl = xyes; then case "$LIBS" in *-lintl*) ;; *) LIBS="$LIBS -lintl";; esac fi AC_ARG_WITH(pager, AS_HELP_STRING([--with-pager=/path], [use specified pager by default]), [ with_pager=$withval; ], [ with_pager="exec more"; ]) AC_DEFINE_UNQUOTED([DEFAULT_PAGER], "$with_pager", [Default pager command]) AC_ARG_WITH(socks, AS_HELP_STRING([--with-socks@<:@=/path@:>@], [build with SOCKSv4 library]), [ with_socks=$withval; ], [ with_socks=no; ]) AC_ARG_WITH(socks5, AS_HELP_STRING([--with-socks5@<:@=/path@:>@], [build with SOCKSv5 library]), [ with_socks5=$withval;], [ with_socks5=no; ]) AC_ARG_WITH(socksdante, AS_HELP_STRING([--with-socksdante@<:@=/path@:>@], [build with SOCKS-Dante library]), [ with_socksdante=$withval;], [ with_socksdante=no; ]) case "$with_socks" in yes|no|"") ;; *) socks_loc=$with_socks with_socks=yes;; esac case "$with_socks5" in yes|no|"") ;; *) socks_loc=$with_socks5 with_socks5=yes;; esac case "$with_socksdante" in yes|no|"") ;; *) socks_loc=$with_socksdante with_socksdante=yes;; esac if test x$socks_loc != x; then LDFLAGS="$LDFLAGS -L$socks_loc/lib" CPPFLAGS="$CPPFLAGS -I$socks_loc/include" fi if test x$with_socks = xyes; then AC_DEFINE(SOCKS4, 1, [define if you are building with SOCKS support]) AC_CHECK_LIB(socks, main, [SOCKSLIBS=-lsocks], [AC_MSG_ERROR([cannot find -lsocks library])]) fi if test x$with_socks5 = xyes; then AC_DEFINE(SOCKS5, 1, [define if you are building with SOCKSv5 support]) AC_CHECK_LIB(socks5, main, [SOCKSLIBS=-lsocks5], [AC_MSG_ERROR([cannot find -lsocks5 library])]) fi if test x$with_socksdante = xyes; then AC_DEFINE(SOCKS_DANTE, 1, [define if you are building with SOCKS-Dante support]) AC_CHECK_LIB(socks, main, [SOCKSLIBS=-lsocks], [AC_MSG_ERROR([cannot find -lsocks library])]) fi AC_SUBST(SOCKSLIBS) if test -n "$SOCKSLIBS"; then old_LIBS="$LIBS" LIBS="$LIBS $SOCKSLIBS" AC_CHECK_FUNCS([Rpoll]) if test "$ac_cv_func_Rpoll" != yes; then gl_cv_func_poll=no fi LIBS="$old_LIBS" fi AC_ARG_WITH(modules, AS_HELP_STRING([--with-modules], [build modular lftp (protocols become dll's)]), [ with_modules=$withval; ], [ with_modules=no; ]) AM_CONDITIONAL([WITH_MODULES], [test "$with_modules" = yes]) if test "$with_modules" = yes; then enable_static=no enable_shared=yes AC_DEFINE(WITH_MODULES, 1, [build modular lftp]) else enable_static=yes enable_shared=no fi #test -z "$enable_static" && enable_static=no LT_INIT([dlopen]) LIBTOOL="$LIBTOOL --silent" gl_INIT if test x$ac_cv_func_wcwidth != xyes || test x$REPLACE_WCWIDTH = x1; then gl_LIBOBJ([wcwidth]) AC_DEFINE([REPLACE_WCWIDTH], 1, [Define when using wcwidth replacement]) fi dnl Checks for libraries. dnl LFTP_CHECK_LIBM AC_SEARCH_LIBS([socket],[socket]) AC_SEARCH_LIBS([gethostbyname],[nsl]) AC_SEARCH_LIBS([dlopen],[dl],[AC_DEFINE(HAVE_DLOPEN, 1, [have dlopen])]) AC_SEARCH_LIBS([res_9_search],[resolv],[AC_DEFINE(HAVE_RES_9_SEARCH, 1, [have res_9_search])]) AC_SEARCH_LIBS([res_search],[resolv bind],[AC_DEFINE(HAVE_RES_SEARCH, 1, [have res_search])]) AC_CHECK_DECLS([res_search],,, [ #include #include #include #include #include ]) AC_ARG_WITH(libresolv, AS_HELP_STRING([--without-libresolv], [don't use libresolv]), [with_libresolv=$withval], [with_libresolv=yes]) if test x$with_libresolv = xyes; then AC_SEARCH_LIBS(hstrerror, resolv) fi lftp_TERMINFO READLINE_CHECK AC_ARG_WITH(gnutls, AS_HELP_STRING([--without-gnutls], [don't use GNUTLS library]), [with_gnutls=$withval], [with_gnutls=yes]) AC_ARG_WITH(openssl, AS_HELP_STRING([--with-openssl@<:@=/path@:>@], [use OpenSSL @<:@at /path@:>@]) AS_HELP_STRING([--without-openssl], [don't use OpenSSL (default)]), [with_openssl=$withval], [with_openssl=no]) case "$with_openssl" in yes) with_gnutls=no;; ""|no) : ;; *) openssl_loc=$with_openssl with_openssl=yes with_gnutls=no;; esac if test x$with_gnutls = xyes; then PKG_PROG_PKG_CONFIG PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 1.0.0], [ AC_DEFINE([USE_GNUTLS], 1, [Define to 1 when using GNU TLS library]) gnutls_version_code=`$PKG_CONFIG --modversion gnutls | $AWK -F. '{ printf "0x%02X%02X%02X\n",$1,$2,$3 }'` AC_DEFINE_UNQUOTED([LFTP_LIBGNUTLS_VERSION_CODE], $gnutls_version_code, [Define to libgnutls version, e.g. 0x010203 for 1.2.3]) ]) fi if test x$with_openssl = xyes -a x"$LIBGNUTLS_LIBS" = x; then LFTP_OPENSSL_CHECK fi AC_ARG_WITH(zlib, AS_HELP_STRING([--with-zlib=/path], [use zlib at /path]), [zlib_loc="$withval"]) for loc in $zlib_loc default; do old_LDFLAGS="$LDFLAGS" old_CPPFLAGS="$CPPFLAGS" case $loc in yes|no|default|"") ;; *) LDFLAGS="$LDFLAGS -L$loc/lib" CPPFLAGS="$CPPFLAGS -I$loc/include";; esac AC_CHECK_LIB(z, deflate, [ LDFLAGS="$old_LDFLAGS" CPPFLAGS="$old_CPPFLAGS" ZLIB=-lz case $loc in yes|no|default|"") ;; *) ZLIB_LDFLAGS="-L$loc/lib" ZLIB_CPPFLAGS="-I$loc/include";; esac AC_SUBST(ZLIB) AC_SUBST(ZLIB_LDFLAGS) AC_SUBST(ZLIB_CPPFLAGS) AC_DEFINE(HAVE_ZLIB, 1, [Define if you have zlib library]) break ]) LDFLAGS="$old_LDFLAGS" CPPFLAGS="$old_CPPFLAGS" done if test "x$ZLIB" = x; then AC_MSG_ERROR([cannot find -lz library, install zlib-devel package]) fi AC_CHECK_LIB(expat, XML_ParserCreateNS, [ EXPAT_LIBS=-lexpat AC_SUBST(EXPAT_LIBS) AC_DEFINE(HAVE_LIBEXPAT, 1, [Define if you have expat library]) ]) # Check whether user wants DNSSEC local validation support AC_ARG_WITH(dnssec-local-validation, [ --with-dnssec-local-validation Enable local DNSSEC validation using libval (default=no)], want_dnssec=$withval, want_dnssec=no) if test "x$want_dnssec" = "xyes"; then AC_CHECK_HEADERS(validator/validator.h) if test "$ac_cv_header_validator_validator_h" != yes; then AC_MSG_ERROR([Can't find validator.h (from dnssec-tools)]) fi AC_SEARCH_LIBS([SHA1_Init], [crypto ssl]) AC_CHECK_LIB(sres, query_send) if test "$ac_cv_lib_sres_query_send" != yes; then AC_MSG_ERROR([Can't find libsres (from dnssec-tools)]) fi AC_CHECK_LIB(val, p_val_status,[LIBS="$LIBS -lval"]) if test "x$ac_cv_lib_val_p_val_status" = "xno"; then AC_CHECK_LIB(pthread, pthread_rwlock_init) AC_CHECK_LIB(val-threads, p_val_status, [LIBS="$LIBS -lval-threads -lpthread" LIBVAL_SUFFIX="-threads"], AC_MSG_ERROR([Can't find libval or libval-threads (from dnssec-tools)])) fi if test "x$ac_cv_lib_val_p_val_status" = "xyes" -o "x$ac_cv_lib_val_threads_p_val_status" = "xyes"; then AC_DEFINE(DNSSEC_LOCAL_VALIDATION, 1, [Define if you want local DNSSEC validation support]) fi fi LFTP_PTY_CHECK LFTP_POSIX_FALLOCATE_CHECK LFTP_POSIX_FADVISE_CHECK LFTP_LIBIDN_CHECK dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_HEADER_TIME AC_CHECK_HEADERS(libintl.h fcntl.h sys/time.h errno.h stdlib.h varargs.h dirent.h\ termios.h termio.h sys/select.h sys/stropts.h string.h memory.h\ strings.h sys/ioctl.h dlfcn.h arpa/inet.h arpa/nameser.h netinet/in.h netinet/tcp.h\ netinet/in_systm.h netinet/ip.h termcap.h sys/statfs.h ifaddrs.h\ resolv.h langinfo.h endian.h locale.h expat.h linux/magic.h socks.h,,,[ #include #ifdef HAVE_ARPA_NAMESER_H # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_NETINET_IN_SYSTM_H # include #endif ]) LFTP_NEED_TRIO # See if we have h_errno (the test is here so we can use -lresolv if necessary). AC_CACHE_CHECK([for h_errno], inetutils_cv_var_h_errno, AC_TRY_COMPILE([#include ], [ #ifndef h_errno extern int h_errno; #endif int iu_x = h_errno; ], inetutils_cv_var_h_errno=yes, inetutils_cv_var_h_errno=no)) if test "$inetutils_cv_var_h_errno" = yes; then AC_DEFINE([HAVE_H_ERRNO], 1, [system has h_errno]) AC_CHECK_DECLS([h_errno],,, [#include ]) fi # See if the system has hstrerror, and replace it if not AC_CHECK_FUNC(hstrerror, , [gl_LIBOBJ(hstrerror)]) if test "$ac_cv_func_hstrerror" = yes; then AC_CHECK_DECLS([hstrerror],,, [#include ]) else # No hstrerror, so see if the H_ERRLIST variable can be used by ours AC_CHECK_FUNC([h_errlist], AC_CHECK_DECLS([h_errlist],,, [#include ])) fi if test "$ac_cv_func_hstrerror" = yes -o "$ac_cv_func_h_errlist" = yes; then # If there's a system hstrerror, or we can reasonably replace it, say so. # We still provide some definition, regardless, but this allows people to use # a reasonable alternative if the situation allows, rather than using a # degenerate version that only says `Host lookup error N'. AC_DEFINE(HAVE_HSTRERROR, 1, [System has usable hstrerror]) fi dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_PID_T AC_C_CONST AC_C_INLINE AC_TYPE_OFF_T AC_TYPE_SIZE_T if test x$ac_cv_header_endian_h = xno; then AC_C_BIGENDIAN fi AC_CHECK_MEMBERS([struct sockaddr.sa_len],,, [#include #include ]) AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id],,, [#include #include #include ]) AC_STRUCT_TIMEZONE AC_STRUCT_TM dnl Checks for library functions. AC_TYPE_SIGNAL AC_FUNC_UTIME_NULL AC_FUNC_GETPGRP AC_FUNC_VPRINTF AC_HEADER_STAT LFTP_FUNC_SSCANF_CONST AC_CHECK_FUNCS([statfs\ killpg setpgid tcgetattr vsnprintf snprintf sscanf \ gethostbyname2 getipnodebyname getaddrinfo getnameinfo setsid random\ inet_aton setlocale dn_expand socketpair]) lftp_VA_COPY LFTP_ENVIRON_CHECK AC_CHECK_DECLS([vsnprintf,snprintf,unsetenv,random,inet_aton,strptime,strtok_r,dn_expand,memmem],,,[ #include #include #include #include #include #if STDC_HEADERS || HAVE_STRING_H # include # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif #else # include #endif #ifdef HAVE_NETINET_IN_H # include #endif #ifdef HAVE_ARPA_INET_H # include #endif #ifdef HAVE_RESOLV_H # include #endif ]) if test "$prefix" = /usr -a "$sysconfdir" = '${prefix}/etc'; then sysconfdir=/etc fi AH_TOP([ #ifndef CONFIG_H #define CONFIG_H ]) AH_BOTTOM([ #if defined(__cplusplus) && defined(inline) # undef /**/ inline #endif #if !defined(HAVE_SETPGID) && !defined(SETPGRP_VOID) # define setpgid(pid, pgrp) setpgrp((pid),(pgrp)) #endif #ifdef __cplusplus # define CDECL extern "C" # define CDECL_BEGIN CDECL { # define CDECL_END } template static inline T replace_value(T &var,T new_value) { T tmp=var; var=new_value; return tmp; } #else # define CDECL # define CDECL_BEGIN # define CDECL_END #endif /* should be included before any real code. */ #include #include "gettext.h" #define _(msgid) gettext (msgid) #define N_(msgid) msgid #ifndef PARAMS # if defined __STDC__ || defined __cplusplus # define PARAMS(x) x # else # define PARAMS(x) () # endif #endif #define INET6 (defined(AF_INET6) \ && defined(HAVE_GETNAMEINFO) \ && defined(HAVE_GETADDRINFO)) #define USE_EXPAT (defined(HAVE_EXPAT_H) && defined(HAVE_LIBEXPAT)) #if defined(SOCKS4) || defined(SOCKS5) || defined(SOCKS_DANTE) # define SOCKS 1 #endif #ifdef SOCKS # if defined(HAVE_SOCKS_H) CDECL_BEGIN # include CDECL_END # undef /**/ getc /* fix a problem with redefined getc */ # else // !HAVE_SOCKS_H # if defined(SOCKS4) || defined(SOCKS_DANTE) # define connect Rconnect # define getsockname Rgetsockname # define bind Rbind # define accept Raccept # define listen Rlisten # define select Rselect # ifdef HAVE_RPOLL # define poll Rpoll # endif CDECL int SOCKSinit(const char *); # endif # ifdef SOCKS_DANTE # define rresvport Rrresvport # define bindresvport Rbindresvport # define gethostbyname Rgethostbyname # define gethostbyname2 Rgethostbyname2 # define sendto Rsendto # define recvfrom Rrecvfrom # define recvfrom Rrecvfrom # define write Rwrite # define writev Rwritev # define send Rsend # define sendmsg Rsendmsg # define read Rread # define readv Rreadv # define recv Rrecv # define recvmsg Rrecvmsg # endif # endif // !HAVE_SOCKS_H #endif // SOCKS #if defined __MSDOS__ || defined __CYGWIN32__ # define NATIVE_CRLF 1 #endif #define E_RETRY(e) ((e)==EAGAIN || (e)==EWOULDBLOCK || (e)==EINTR) #define E_LOCK_IGNORE(e) ((e)==EINVAL || (e)==ENOLCK) #ifndef HAVE_RANDOM #define srandom(x) srand((x)) #define random() ((long)(rand()/(RAND_MAX+1.0)*2147483648.0)) #endif /* Tell the compiler when a conditional or integer expression is almost always true or almost always false. */ #ifndef HAVE_BUILTIN_EXPECT # define __builtin_expect(expr, val) (expr) #endif #ifdef __GNUC__ # define PRINTF_LIKE(n,m) __attribute__((format(__printf__,n,m))) #else # define PRINTF_LIKE(n,m) # define __attribute__(x) #endif /* Attribute `sentinel' was valid as of gcc 3.5. */ #if defined(__GNUC__) && \ (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 5)) # define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) #else # define ATTRIBUTE_SENTINEL #endif #ifdef TRIO_REPLACE_STDIO /* replace all the functions */ # undef /**/ HAVE_PRINTF # undef /**/ HAVE_VPRINTF # undef /**/ HAVE_FPRINTF # undef /**/ HAVE_VFPRINTF # undef /**/ HAVE_SPRINTF # undef /**/ HAVE_VSPRINTF # undef /**/ HAVE_SNPRINTF # undef /**/ HAVE_VSNPRINTF # undef /**/ HAVE_SCANF # undef /**/ HAVE_VSCANF # undef /**/ HAVE_FSCANF # undef /**/ HAVE_VFSCANF # undef /**/ HAVE_SSCANF # undef /**/ HAVE_VSSCANF # include "trio.h" #endif #define USE_SSL (defined(USE_GNUTLS) || defined(USE_OPENSSL)) #endif /* CONFIG_H */ ]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([lib/Makefile]) AC_CONFIG_FILES([doc/Makefile]) AC_CONFIG_FILES([po/Makefile.in]) AC_CONFIG_FILES([m4/Makefile]) AC_CONFIG_FILES([trio/Makefile]) AC_OUTPUT lftp-4.6.3a/trio/0000755000015000007670000000000012540300656010611 500000000000000lftp-4.6.3a/trio/Makefile.am0000644000015000007670000000026412122054516012564 00000000000000noinst_LTLIBRARIES = libtrio.la libtrio_la_SOURCES = trio.c triodef.h trio.h trionan.c trionan.h triop.h triostr.c triostr.h INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/lib lftp-4.6.3a/trio/triostr.h0000644000015000007670000001742112122061105012402 00000000000000/************************************************************************* * * $Id: triostr.h,v 1.9 2002/05/20 12:03:38 breese Exp $ * * Copyright (C) 2001 Bjorn Reese and Daniel Stenberg. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************/ #ifndef TRIO_TRIOSTR_H #define TRIO_TRIOSTR_H #include #include #include #include #include "triodef.h" #include "triop.h" enum { TRIO_HASH_NONE = 0, TRIO_HASH_PLAIN, TRIO_HASH_TWOSIGNED }; #if !defined(TRIO_STRING_PUBLIC) # if !defined(TRIO_PUBLIC) # define TRIO_PUBLIC # endif # define TRIO_STRING_PUBLIC TRIO_PUBLIC #endif /************************************************************************* * String functions */ TRIO_STRING_PUBLIC int trio_append TRIO_PROTO((char *target, const char *source)); TRIO_STRING_PUBLIC int trio_append_max TRIO_PROTO((char *target, size_t max, const char *source)); TRIO_STRING_PUBLIC int trio_contains TRIO_PROTO((const char *string, const char *substring)); TRIO_STRING_PUBLIC int trio_copy TRIO_PROTO((char *target, const char *source)); TRIO_STRING_PUBLIC int trio_copy_max TRIO_PROTO((char *target, size_t max, const char *source)); TRIO_STRING_PUBLIC char *trio_create TRIO_PROTO((size_t size)); TRIO_STRING_PUBLIC void trio_destroy TRIO_PROTO((char *string)); TRIO_STRING_PUBLIC char *trio_duplicate TRIO_PROTO((const char *source)); TRIO_STRING_PUBLIC char *trio_duplicate_max TRIO_PROTO((const char *source, size_t max)); TRIO_STRING_PUBLIC int trio_equal TRIO_PROTO((const char *first, const char *second)); TRIO_STRING_PUBLIC int trio_equal_case TRIO_PROTO((const char *first, const char *second)); TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_PROTO((const char *first, size_t max, const char *second)); TRIO_STRING_PUBLIC int trio_equal_locale TRIO_PROTO((const char *first, const char *second)); TRIO_STRING_PUBLIC int trio_equal_max TRIO_PROTO((const char *first, size_t max, const char *second)); TRIO_STRING_PUBLIC TRIO_CONST char *trio_error TRIO_PROTO((int)); TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_PROTO((char *target, size_t max, const char *format, const struct tm *datetime)); TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_PROTO((const char *string, int type)); TRIO_STRING_PUBLIC char *trio_index TRIO_PROTO((const char *string, int character)); TRIO_STRING_PUBLIC char *trio_index_last TRIO_PROTO((const char *string, int character)); TRIO_STRING_PUBLIC size_t trio_length TRIO_PROTO((const char *string)); TRIO_STRING_PUBLIC int trio_lower TRIO_PROTO((char *target)); TRIO_STRING_PUBLIC int trio_match TRIO_PROTO((const char *string, const char *pattern)); TRIO_STRING_PUBLIC int trio_match_case TRIO_PROTO((const char *string, const char *pattern)); TRIO_STRING_PUBLIC size_t trio_span_function TRIO_PROTO((char *target, const char *source, int (*Function) TRIO_PROTO((int)))); TRIO_STRING_PUBLIC char *trio_substring TRIO_PROTO((const char *string, const char *substring)); TRIO_STRING_PUBLIC char *trio_substring_max TRIO_PROTO((const char *string, size_t max, const char *substring)); TRIO_STRING_PUBLIC double trio_to_double TRIO_PROTO((const char *source, char **endp)); TRIO_STRING_PUBLIC float trio_to_float TRIO_PROTO((const char *source, char **endp)); TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_PROTO((const char *source, char **endp)); TRIO_STRING_PUBLIC long trio_to_long TRIO_PROTO((const char *source, char **endp, int base)); TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_PROTO((const char *source, char **endp, int base)); TRIO_STRING_PUBLIC char *trio_tokenize TRIO_PROTO((char *string, const char *delimiters)); TRIO_STRING_PUBLIC int trio_upper TRIO_PROTO((char *target)); /************************************************************************* * Dynamic string functions */ /* * Opaque type for dynamic strings */ typedef struct _trio_string_t trio_string_t; TRIO_STRING_PUBLIC trio_string_t *trio_string_create TRIO_PROTO((int initial_size)); TRIO_STRING_PUBLIC void trio_string_destroy TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC char *trio_string_get TRIO_PROTO((trio_string_t *self, int offset)); TRIO_STRING_PUBLIC void trio_xstring_set TRIO_PROTO((trio_string_t *self, char *buffer)); TRIO_STRING_PUBLIC char *trio_string_extract TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_string_size TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC void trio_string_terminate TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_string_append TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_contains TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_copy TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC trio_string_t *trio_string_duplicate TRIO_PROTO((trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_equal TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *second)); TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, trio_string_t *other)); TRIO_STRING_PUBLIC size_t trio_string_format_date_max TRIO_PROTO((trio_string_t *self, size_t max, const char *format, const struct tm *datetime)); TRIO_STRING_PUBLIC char *trio_string_index TRIO_PROTO((trio_string_t *self, int character)); TRIO_STRING_PUBLIC char *trio_string_index_last TRIO_PROTO((trio_string_t *self, int character)); TRIO_STRING_PUBLIC int trio_string_length TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_string_lower TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_string_match TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_match_case TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC char *trio_string_substring TRIO_PROTO((trio_string_t *self, trio_string_t *other)); TRIO_STRING_PUBLIC int trio_string_upper TRIO_PROTO((trio_string_t *self)); TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_PROTO((trio_string_t *self, char character)); TRIO_STRING_PUBLIC int trio_xstring_append TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC trio_string_t *trio_xstring_duplicate TRIO_PROTO((const char *other)); TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_equal_case_max TRIO_PROTO((trio_string_t *self, size_t max, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_match TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_PROTO((trio_string_t *self, const char *other)); TRIO_STRING_PUBLIC char *trio_xstring_substring TRIO_PROTO((trio_string_t *self, const char *other)); #endif /* TRIO_TRIOSTR_H */ lftp-4.6.3a/trio/trio.h0000644000015000007670000001611612122061071011653 00000000000000/************************************************************************* * * $Id: trio.h,v 1.15 2002/06/23 11:58:06 breese Exp $ * * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************* * * http://ctrio.sourceforge.net/ * ************************************************************************/ #ifndef TRIO_TRIO_H #define TRIO_TRIO_H #include #include #if defined(TRIO_COMPILER_ANCIENT) # include #else # include #endif #if !defined(WITHOUT_TRIO) /* * Use autoconf defines if present. Packages using trio must define * HAVE_CONFIG_H as a compiler option themselves. */ #if defined(HAVE_CONFIG_H) # include #endif #include "triodef.h" #ifdef __cplusplus extern "C" { #endif /* * Error codes. * * Remember to add a textual description to trio_strerror. */ enum { TRIO_EOF = 1, TRIO_EINVAL = 2, TRIO_ETOOMANY = 3, TRIO_EDBLREF = 4, TRIO_EGAP = 5, TRIO_ENOMEM = 6, TRIO_ERANGE = 7, TRIO_ERRNO = 8, TRIO_ECUSTOM = 9 }; /* Error macros */ #define TRIO_ERROR_CODE(x) ((-(x)) & 0x00FF) #define TRIO_ERROR_POSITION(x) ((-(x)) >> 8) #define TRIO_ERROR_NAME(x) trio_strerror(x) typedef int (*trio_outstream_t) TRIO_PROTO((trio_pointer_t, int)); typedef int (*trio_instream_t) TRIO_PROTO((trio_pointer_t)); TRIO_CONST char *trio_strerror TRIO_PROTO((int)); /************************************************************************* * Print Functions */ int trio_printf TRIO_PROTO((TRIO_CONST char *format, ...)); int trio_vprintf TRIO_PROTO((TRIO_CONST char *format, va_list args)); int trio_printfv TRIO_PROTO((TRIO_CONST char *format, void **args)); int trio_fprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...)); int trio_vfprintf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args)); int trio_fprintfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args)); int trio_dprintf TRIO_PROTO((int fd, TRIO_CONST char *format, ...)); int trio_vdprintf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args)); int trio_dprintfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args)); int trio_cprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure, TRIO_CONST char *format, ...)); int trio_vcprintf TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure, TRIO_CONST char *format, va_list args)); int trio_cprintfv TRIO_PROTO((trio_outstream_t stream, trio_pointer_t closure, TRIO_CONST char *format, void **args)); int trio_sprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, ...)); int trio_vsprintf TRIO_PROTO((char *buffer, TRIO_CONST char *format, va_list args)); int trio_sprintfv TRIO_PROTO((char *buffer, TRIO_CONST char *format, void **args)); int trio_snprintf TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...)); int trio_vsnprintf TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format, va_list args)); int trio_snprintfv TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format, void **args)); int trio_snprintfcat TRIO_PROTO((char *buffer, size_t max, TRIO_CONST char *format, ...)); int trio_vsnprintfcat TRIO_PROTO((char *buffer, size_t bufferSize, TRIO_CONST char *format, va_list args)); char *trio_aprintf TRIO_PROTO((TRIO_CONST char *format, ...)); char *trio_vaprintf TRIO_PROTO((TRIO_CONST char *format, va_list args)); int trio_asprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, ...)); int trio_vasprintf TRIO_PROTO((char **ret, TRIO_CONST char *format, va_list args)); /************************************************************************* * Scan Functions */ int trio_scanf TRIO_PROTO((TRIO_CONST char *format, ...)); int trio_vscanf TRIO_PROTO((TRIO_CONST char *format, va_list args)); int trio_scanfv TRIO_PROTO((TRIO_CONST char *format, void **args)); int trio_fscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, ...)); int trio_vfscanf TRIO_PROTO((FILE *file, TRIO_CONST char *format, va_list args)); int trio_fscanfv TRIO_PROTO((FILE *file, TRIO_CONST char *format, void **args)); int trio_dscanf TRIO_PROTO((int fd, TRIO_CONST char *format, ...)); int trio_vdscanf TRIO_PROTO((int fd, TRIO_CONST char *format, va_list args)); int trio_dscanfv TRIO_PROTO((int fd, TRIO_CONST char *format, void **args)); int trio_cscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure, TRIO_CONST char *format, ...)); int trio_vcscanf TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure, TRIO_CONST char *format, va_list args)); int trio_cscanfv TRIO_PROTO((trio_instream_t stream, trio_pointer_t closure, TRIO_CONST char *format, void **args)); int trio_sscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, ...)); int trio_vsscanf TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, va_list args)); int trio_sscanfv TRIO_PROTO((TRIO_CONST char *buffer, TRIO_CONST char *format, void **args)); /************************************************************************* * Locale Functions */ void trio_locale_set_decimal_point TRIO_PROTO((char *decimalPoint)); void trio_locale_set_thousand_separator TRIO_PROTO((char *thousandSeparator)); void trio_locale_set_grouping TRIO_PROTO((char *grouping)); /************************************************************************* * Renaming */ #ifdef TRIO_REPLACE_STDIO /* Replace the functions */ #ifndef HAVE_PRINTF # define printf trio_printf #endif #ifndef HAVE_VPRINTF # define vprintf trio_vprintf #endif #ifndef HAVE_FPRINTF # define fprintf trio_fprintf #endif #ifndef HAVE_VFPRINTF # define vfprintf trio_vfprintf #endif #ifndef HAVE_SPRINTF # define sprintf trio_sprintf #endif #ifndef HAVE_VSPRINTF # define vsprintf trio_vsprintf #endif #ifndef HAVE_SNPRINTF # define snprintf trio_snprintf #endif #ifndef HAVE_VSNPRINTF # define vsnprintf trio_vsnprintf #endif #ifndef HAVE_SCANF # define scanf trio_scanf #endif #ifndef HAVE_VSCANF # define vscanf trio_vscanf #endif #ifndef HAVE_FSCANF # define fscanf trio_fscanf #endif #ifndef HAVE_VFSCANF # define vfscanf trio_vfscanf #endif #ifndef HAVE_SSCANF # define sscanf trio_sscanf #endif #ifndef HAVE_VSSCANF # define vsscanf trio_vsscanf #endif /* These aren't stdio functions, but we make them look similar */ #define dprintf trio_dprintf #define vdprintf trio_vdprintf #define aprintf trio_aprintf #define vaprintf trio_vaprintf #define asprintf trio_asprintf #define vasprintf trio_vasprintf #define dscanf trio_dscanf #define vdscanf trio_vdscanf #endif #ifdef __cplusplus } /* extern "C" */ #endif #endif /* WITHOUT_TRIO */ #endif /* TRIO_TRIO_H */ lftp-4.6.3a/trio/triodef.h0000644000015000007670000001257512122061065012342 00000000000000/************************************************************************* * * $Id: triodef.h,v 1.12 2002/06/01 09:22:57 breese Exp $ * * Copyright (C) 2001 Bjorn Reese * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************/ #ifndef TRIO_TRIODEF_H #define TRIO_TRIODEF_H /************************************************************************* * Platform and compiler support detection */ #if defined(__GNUC__) # define TRIO_COMPILER_GCC #elif defined(__SUNPRO_C) # define TRIO_COMPILER_SUNPRO #elif defined(__SUNPRO_CC) # define TRIO_COMPILER_SUNPRO # define __SUNPRO_C __SUNPRO_CC #elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__) # define TRIO_COMPILER_XLC #elif defined(_AIX) && !defined(__GNUC__) # define TRIO_COMPILER_XLC /* Workaround for old xlc */ #elif defined(__DECC) || defined(__DECCXX) # define TRIO_COMPILER_DECC #elif defined(__osf__) && defined(__LANGUAGE_C__) # define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */ #elif defined(_MSC_VER) # define TRIO_COMPILER_MSVC #elif defined(__BORLANDC__) # define TRIO_COMPILER_BCB #endif #if defined(unix) || defined(__unix) || defined(__unix__) # define TRIO_PLATFORM_UNIX #elif defined(TRIO_COMPILER_XLC) || defined(_AIX) # define TRIO_PLATFORM_UNIX #elif defined(TRIO_COMPILER_DECC) || defined(__osf__) # define TRIO_PLATFORM_UNIX #elif defined(__NetBSD__) # define TRIO_PLATFORM_UNIX #elif defined(__QNX__) # define TRIO_PLATFORM_UNIX # define TRIO_PLATFORM_QNX #elif defined(__CYGWIN__) # define TRIO_PLATFORM_UNIX #elif defined(AMIGA) && defined(TRIO_COMPILER_GCC) # define TRIO_PLATFORM_UNIX #elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32) # define TRIO_PLATFORM_WIN32 #elif defined(VMS) || defined(__VMS) # define TRIO_PLATFORM_VMS #elif defined(mpeix) || defined(__mpexl) # define TRIO_PLATFORM_MPEIX #endif #if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) # define TRIO_COMPILER_SUPPORTS_C89 # if defined(__STDC_VERSION__) # define TRIO_COMPILER_SUPPORTS_C90 # if (__STDC_VERSION__ >= 199409L) # define TRIO_COMPILER_SUPPORTS_C94 # endif # if (__STDC_VERSION__ >= 199901L) # define TRIO_COMPILER_SUPPORTS_C99 # endif # elif defined(TRIO_COMPILER_SUNPRO) # if (__SUNPRO_C >= 0x420) # define TRIO_COMPILER_SUPPORTS_C94 # endif # endif #endif #if defined(_XOPEN_SOURCE) # if defined(_XOPEN_SOURCE_EXTENDED) # define TRIO_COMPILER_SUPPORTS_UNIX95 # endif # if (_XOPEN_VERSION >= 500) # define TRIO_COMPILER_SUPPORTS_UNIX98 # endif # if (_XOPEN_VERSION >= 600) # define TRIO_COMPILER_SUPPORTS_UNIX01 # endif #endif /************************************************************************* * Generic defines */ #if !defined(TRIO_PUBLIC) # define TRIO_PUBLIC #endif #if !defined(TRIO_PRIVATE) # define TRIO_PRIVATE static #endif #if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus)) # define TRIO_COMPILER_ANCIENT #endif #if defined(TRIO_COMPILER_ANCIENT) # define TRIO_CONST # define TRIO_VOLATILE # define TRIO_SIGNED typedef double trio_long_double_t; typedef char * trio_pointer_t; # define TRIO_SUFFIX_LONG(x) x # define TRIO_PROTO(x) () # define TRIO_NOARGS # define TRIO_ARGS1(list,a1) list a1; # define TRIO_ARGS2(list,a1,a2) list a1; a2; # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; # define TRIO_VARGS2(list,a1,a2) list a1; a2 # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 # define TRIO_VA_DECL va_dcl # define TRIO_VA_START(x,y) va_start((x)) # define TRIO_VA_END(x) va_end(x) #else /* ANSI C */ # define TRIO_CONST const # define TRIO_VOLATILE volatile # define TRIO_SIGNED signed typedef long double trio_long_double_t; typedef void * trio_pointer_t; # define TRIO_SUFFIX_LONG(x) x ## L # define TRIO_PROTO(x) x # define TRIO_NOARGS void # define TRIO_ARGS1(list,a1) (a1) # define TRIO_ARGS2(list,a1,a2) (a1,a2) # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) # define TRIO_VARGS2 TRIO_ARGS2 # define TRIO_VARGS3 TRIO_ARGS3 # define TRIO_VARGS4 TRIO_ARGS4 # define TRIO_VARGS5 TRIO_ARGS5 # define TRIO_VA_DECL ... # define TRIO_VA_START(x,y) va_start((x),(y)) # define TRIO_VA_END(x) va_end(x) #endif #if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus) # define TRIO_INLINE inline #elif defined(TRIO_COMPILER_GCC) # define TRIO_INLINE __inline__ #elif defined(TRIO_COMPILER_MSVC) # define TRIO_INLINE _inline #elif defined(TRIO_COMPILER_BCB) # define TRIO_INLINE __inline #else # define TRIO_INLINE #endif #endif /* TRIO_TRIODEF_H */ lftp-4.6.3a/trio/trionan.h0000644000015000007670000000376512122061077012364 00000000000000/************************************************************************* * * $Id: trionan.h,v 1.7 2002/05/04 14:26:44 breese Exp $ * * Copyright (C) 2001 Bjorn Reese * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************/ #ifndef TRIO_NAN_H #define TRIO_NAN_H #include "triodef.h" #ifdef __cplusplus extern "C" { #endif enum { TRIO_FP_INFINITE, TRIO_FP_NAN, TRIO_FP_NORMAL, TRIO_FP_SUBNORMAL, TRIO_FP_ZERO }; /* * Return NaN (Not-a-Number). */ TRIO_PUBLIC double trio_nan TRIO_PROTO((void)); /* * Return positive infinity. */ TRIO_PUBLIC double trio_pinf TRIO_PROTO((void)); /* * Return negative infinity. */ TRIO_PUBLIC double trio_ninf TRIO_PROTO((void)); /* * Return negative zero. */ TRIO_PUBLIC double trio_nzero TRIO_PROTO((TRIO_NOARGS)); /* * If number is a NaN return non-zero, otherwise return zero. */ TRIO_PUBLIC int trio_isnan TRIO_PROTO((double number)); /* * If number is positive infinity return 1, if number is negative * infinity return -1, otherwise return 0. */ TRIO_PUBLIC int trio_isinf TRIO_PROTO((double number)); /* * If number is finite return non-zero, otherwise return zero. */ TRIO_PUBLIC int trio_isfinite TRIO_PROTO((double number)); TRIO_PUBLIC int trio_signbit TRIO_PROTO((double number)); TRIO_PUBLIC int trio_fpclassify TRIO_PROTO((double number)); TRIO_PUBLIC int trio_fpclassify_and_signbit TRIO_PROTO((double number, int *is_negative)); #ifdef __cplusplus } #endif #endif /* TRIO_NAN_H */ lftp-4.6.3a/trio/trionan.c0000644000015000007670000005351412122061075012352 00000000000000/************************************************************************* * * $Id: trionan.c,v 1.20 2002/06/30 10:20:30 breese Exp $ * * Copyright (C) 2001 Bjorn Reese * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************ * * Functions to handle special quantities in floating-point numbers * (that is, NaNs and infinity). They provide the capability to detect * and fabricate special quantities. * * Although written to be as portable as possible, it can never be * guaranteed to work on all platforms, as not all hardware supports * special quantities. * * The approach used here (approximately) is to: * * 1. Use C99 functionality when available. * 2. Use IEEE 754 bit-patterns if possible. * 3. Use platform-specific techniques. * ************************************************************************/ /* * TODO: * o Put all the magic into trio_fpclassify_and_signbit(), and use this from * trio_isnan() etc. */ /************************************************************************* * Include files */ #include "triodef.h" #include "trionan.h" #include #include #include #include #if defined(TRIO_PLATFORM_UNIX) # include #endif #if defined(TRIO_COMPILER_DECC) # include #endif #include #if defined(TRIO_DOCUMENTATION) # include "doc/doc_nan.h" #endif /** @addtogroup SpecialQuantities @{ */ /************************************************************************* * Definitions */ #define TRIO_TRUE (1 == 1) #define TRIO_FALSE (0 == 1) /* We must enable IEEE floating-point on Alpha */ #if defined(__alpha) && !defined(_IEEE_FP) # if defined(TRIO_COMPILER_DECC) # if defined(TRIO_PLATFORM_VMS) # error "Must be compiled with option /IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE" # else # if !defined(_CFE) # error "Must be compiled with option -ieee" # endif # endif # elif defined(TRIO_COMPILER_GCC) && (defined(__osf__) || defined(__linux__)) # error "Must be compiled with option -mieee" # endif #endif /* __alpha && ! _IEEE_FP */ /* * In ANSI/IEEE 754-1985 64-bits double format numbers have the * following properties (amoungst others) * * o FLT_RADIX == 2: binary encoding * o DBL_MAX_EXP == 1024: 11 bits exponent, where one bit is used * to indicate special numbers (e.g. NaN and Infinity), so the * maximum exponent is 10 bits wide (2^10 == 1024). * o DBL_MANT_DIG == 53: The mantissa is 52 bits wide, but because * numbers are normalized the initial binary 1 is represented * implicitly (the so-called "hidden bit"), which leaves us with * the ability to represent 53 bits wide mantissa. */ #if (FLT_RADIX == 2) && (DBL_MAX_EXP == 1024) && (DBL_MANT_DIG == 53) # define USE_IEEE_754 #endif /************************************************************************* * Constants */ static TRIO_CONST char rcsid[] = "@(#)$Id: trionan.c,v 1.20 2002/06/30 10:20:30 breese Exp $"; #if defined(USE_IEEE_754) /* * Endian-agnostic indexing macro. * * The value of internalEndianMagic, when converted into a 64-bit * integer, becomes 0x0706050403020100 (we could have used a 64-bit * integer value instead of a double, but not all platforms supports * that type). The value is automatically encoded with the correct * endianess by the compiler, which means that we can support any * kind of endianess. The individual bytes are then used as an index * for the IEEE 754 bit-patterns and masks. */ #define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)]) static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275; /* Mask for the exponent */ static TRIO_CONST unsigned char ieee_754_exponent_mask[] = { 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* Mask for the mantissa */ static TRIO_CONST unsigned char ieee_754_mantissa_mask[] = { 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; /* Mask for the sign bit */ static TRIO_CONST unsigned char ieee_754_sign_mask[] = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* Bit-pattern for negative zero */ static TRIO_CONST unsigned char ieee_754_negzero_array[] = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* Bit-pattern for infinity */ static TRIO_CONST unsigned char ieee_754_infinity_array[] = { 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* Bit-pattern for quiet NaN */ static TRIO_CONST unsigned char ieee_754_qnan_array[] = { 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /************************************************************************* * Functions */ /* * trio_make_double */ TRIO_PRIVATE double trio_make_double TRIO_ARGS1((values), TRIO_CONST unsigned char *values) { TRIO_VOLATILE double result; int i; for (i = 0; i < (int)sizeof(double); i++) { ((TRIO_VOLATILE unsigned char *)&result)[TRIO_DOUBLE_INDEX(i)] = values[i]; } return result; } /* * trio_is_special_quantity */ TRIO_PRIVATE int trio_is_special_quantity TRIO_ARGS2((number, has_mantissa), double number, int *has_mantissa) { unsigned int i; unsigned char current; int is_special_quantity = TRIO_TRUE; *has_mantissa = 0; for (i = 0; i < (unsigned int)sizeof(double); i++) { current = ((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)]; is_special_quantity &= ((current & ieee_754_exponent_mask[i]) == ieee_754_exponent_mask[i]); *has_mantissa |= (current & ieee_754_mantissa_mask[i]); } return is_special_quantity; } /* * trio_is_negative */ TRIO_PRIVATE int trio_is_negative TRIO_ARGS1((number), double number) { unsigned int i; int is_negative = TRIO_FALSE; for (i = 0; i < (unsigned int)sizeof(double); i++) { is_negative |= (((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)] & ieee_754_sign_mask[i]); } return is_negative; } #endif /* USE_IEEE_754 */ /** Generate negative zero. @return Floating-point representation of negative zero. */ TRIO_PUBLIC double trio_nzero(TRIO_NOARGS) { #if defined(USE_IEEE_754) return trio_make_double(ieee_754_negzero_array); #else TRIO_VOLATILE double zero = 0.0; return -zero; #endif } /** Generate positive infinity. @return Floating-point representation of positive infinity. */ TRIO_PUBLIC double trio_pinf(TRIO_NOARGS) { /* Cache the result */ static double result = 0.0; if (result == 0.0) { #if defined(INFINITY) && defined(__STDC_IEC_559__) result = (double)INFINITY; #elif defined(USE_IEEE_754) result = trio_make_double(ieee_754_infinity_array); #else /* * If HUGE_VAL is different from DBL_MAX, then HUGE_VAL is used * as infinity. Otherwise we have to resort to an overflow * operation to generate infinity. */ # if defined(TRIO_PLATFORM_UNIX) void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); # endif result = HUGE_VAL; if (HUGE_VAL == DBL_MAX) { /* Force overflow */ result += HUGE_VAL; } # if defined(TRIO_PLATFORM_UNIX) signal(SIGFPE, signal_handler); # endif #endif } return result; } /** Generate negative infinity. @return Floating-point value of negative infinity. */ TRIO_PUBLIC double trio_ninf(TRIO_NOARGS) { static double result = 0.0; if (result == 0.0) { /* * Negative infinity is calculated by negating positive infinity, * which can be done because it is legal to do calculations on * infinity (for example, 1 / infinity == 0). */ result = -trio_pinf(); } return result; } /** Generate NaN. @return Floating-point representation of NaN. */ TRIO_PUBLIC double trio_nan(TRIO_NOARGS) { /* Cache the result */ static double result = 0.0; if (result == 0.0) { #if defined(TRIO_COMPILER_SUPPORTS_C99) result = nan(""); #elif defined(NAN) && defined(__STDC_IEC_559__) result = (double)NAN; #elif defined(USE_IEEE_754) result = trio_make_double(ieee_754_qnan_array); #else /* * There are several ways to generate NaN. The one used here is * to divide infinity by infinity. I would have preferred to add * negative infinity to positive infinity, but that yields wrong * result (infinity) on FreeBSD. * * This may fail if the hardware does not support NaN, or if * the Invalid Operation floating-point exception is unmasked. */ # if defined(TRIO_PLATFORM_UNIX) void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); # endif result = trio_pinf() / trio_pinf(); # if defined(TRIO_PLATFORM_UNIX) signal(SIGFPE, signal_handler); # endif #endif } return result; } /** Check for NaN. @param number An arbitrary floating-point number. @return Boolean value indicating whether or not the number is a NaN. */ TRIO_PUBLIC int trio_isnan TRIO_ARGS1((number), double number) { #if (defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isnan)) \ || defined(TRIO_COMPILER_SUPPORTS_UNIX95) /* * C99 defines isnan() as a macro. UNIX95 defines isnan() as a * function. This function was already present in XPG4, but this * is a bit tricky to detect with compiler defines, so we choose * the conservative approach and only use it for UNIX95. */ return isnan(number); #elif defined(TRIO_COMPILER_MSVC) /* * MSVC has an _isnan() function */ return _isnan(number); #elif defined(USE_IEEE_754) /* * Examine IEEE 754 bit-pattern. A NaN must have a special exponent * pattern, and a non-empty mantissa. */ int has_mantissa; int is_special_quantity; is_special_quantity = trio_is_special_quantity(number, &has_mantissa); return (is_special_quantity && has_mantissa); #else /* * Fallback solution */ int status; double integral, fraction; # if defined(TRIO_PLATFORM_UNIX) void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); # endif status = (/* * NaN is the only number which does not compare to itself */ ((TRIO_VOLATILE double)number != (TRIO_VOLATILE double)number) || /* * Fallback solution if NaN compares to NaN */ ((number != 0.0) && (fraction = modf(number, &integral), integral == fraction))); # if defined(TRIO_PLATFORM_UNIX) signal(SIGFPE, signal_handler); # endif return status; #endif } /** Check for infinity. @param number An arbitrary floating-point number. @return 1 if positive infinity, -1 if negative infinity, 0 otherwise. */ TRIO_PUBLIC int trio_isinf TRIO_ARGS1((number), double number) { #if defined(TRIO_COMPILER_DECC) /* * DECC has an isinf() macro, but it works differently than that * of C99, so we use the fp_class() function instead. */ return ((fp_class(number) == FP_POS_INF) ? 1 : ((fp_class(number) == FP_NEG_INF) ? -1 : 0)); #elif defined(isinf) /* * C99 defines isinf() as a macro. */ return isinf(number) ? ((number > 0.0) ? 1 ; -1) : 0; #elif defined(TRIO_COMPILER_MSVC) /* * MSVC has an _fpclass() function that can be used to detect infinity. */ return ((_fpclass(number) == _FPCLASS_PINF) ? 1 : ((_fpclass(number) == _FPCLASS_NINF) ? -1 : 0)); #elif defined(USE_IEEE_754) /* * Examine IEEE 754 bit-pattern. Infinity must have a special exponent * pattern, and an empty mantissa. */ int has_mantissa; int is_special_quantity; is_special_quantity = trio_is_special_quantity(number, &has_mantissa); return (is_special_quantity && !has_mantissa) ? ((number < 0.0) ? -1 : 1) : 0; #else /* * Fallback solution. */ int status; # if defined(TRIO_PLATFORM_UNIX) void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN); # endif double infinity = trio_pinf(); status = ((number == infinity) ? 1 : ((number == -infinity) ? -1 : 0)); # if defined(TRIO_PLATFORM_UNIX) signal(SIGFPE, signal_handler); # endif return status; #endif } /** Check for finity. @param number An arbitrary floating-point number. @return Boolean value indicating whether or not the number is a finite. */ TRIO_PUBLIC int trio_isfinite TRIO_ARGS1((number), double number) { #if defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isfinite) /* * C99 defines isfinite() as a macro. */ return isfinite(number); #elif defined(TRIO_COMPILER_MSVC) /* * MSVC uses _finite(). */ return _finite(number); #elif defined(USE_IEEE_754) /* * Examine IEEE 754 bit-pattern. For finity we do not care about the * mantissa. */ int dummy; return (! trio_is_special_quantity(number, &dummy)); #else /* * Fallback solution. */ return ((trio_isinf(number) == 0) && (trio_isnan(number) == 0)); #endif } /* * The sign of NaN is always false */ TRIO_PUBLIC int trio_fpclassify_and_signbit TRIO_ARGS2((number, is_negative), double number, int *is_negative) { #if defined(fpclassify) && defined(signbit) /* * C99 defines fpclassify() and signbit() as a macros */ *is_negative = signbit(number); switch (fpclassify(number)) { case FP_NAN: return TRIO_FP_NAN; case FP_INFINITE: return TRIO_FP_INFINITE; case FP_SUBNORMAL: return TRIO_FP_SUBNORMAL; case FP_ZERO: return TRIO_FP_ZERO; default: return TRIO_FP_NORMAL; } #elif defined(TRIO_COMPILER_DECC) /* * DECC has an fp_class() function. */ switch (fp_class(number)) { case FP_QNAN: case FP_SNAN: *is_negative = TRIO_FALSE; /* NaN has no sign */ return TRIO_FP_NAN; case FP_POS_INF: *is_negative = TRIO_FALSE; return TRIO_FP_INFINITE; case FP_NEG_INF: *is_negative = TRIO_TRUE; return TRIO_FP_INFINITE; case FP_POS_DENORM: *is_negative = TRIO_FALSE; return TRIO_FP_SUBNORMAL; case FP_NEG_DENORM: *is_negative = TRIO_TRUE; return TRIO_FP_SUBNORMAL; case FP_POS_ZERO: *is_negative = TRIO_FALSE; return TRIO_FP_ZERO; case FP_NEG_ZERO: *is_negative = TRIO_TRUE; return TRIO_FP_ZERO; case FP_POS_NORM: *is_negative = TRIO_FALSE; return TRIO_FP_NORMAL; case FP_NEG_NORM: *is_negative = TRIO_TRUE; return TRIO_FP_NORMAL; default: /* Just in case... */ *is_negative = (number < 0.0); return TRIO_FP_NORMAL; } #elif defined(TRIO_COMPILER_MSVC) /* * MSVC has an _fpclass() function. */ switch (_fpclass(number)) { case _FPCLASS_QNAN: case _FPCLASS_SNAN: *is_negative = TRIO_FALSE; return TRIO_FP_NAN; case _FPCLASS_PINF: *is_negative = TRIO_FALSE; return TRIO_FP_INFINITE; case _FPCLASS_NINF: *is_negative = TRIO_TRUE; return TRIO_FP_INFINITE; case _FPCLASS_PD: *is_negative = TRIO_FALSE; return TRIO_FP_SUBNORMAL; case _FPCLASS_ND: *is_negative = TRIO_TRUE; return TRIO_FP_SUBNORMAL; case _FPCLASS_PZ: *is_negative = TRIO_FALSE; return TRIO_FP_ZERO; case _FPCLASS_NZ: *is_negative = TRIO_TRUE; return TRIO_FP_ZERO; case _FPCLASS_PN: *is_negative = TRIO_FALSE; return TRIO_FP_NORMAL; case _FPCLASS_NN: *is_negative = TRIO_TRUE; return TRIO_FP_NORMAL; default: /* Just in case... */ *is_negative = (number < 0.0); return TRIO_FP_NORMAL; } #elif defined(FP_PLUS_NORM) || defined(__hpux) /* * HP-UX 9.x and 10.x have an fpclassify() function, that is different * from the C99 fpclassify() macro supported on HP-UX 11.x. */ switch (fpclassify(number)) { case FP_QNAN: case FP_SNAN: *is_negative = TRIO_FALSE; return TRIO_FP_NAN; case FP_PLUS_INF: *is_negative = TRIO_FALSE; return TRIO_FP_INFINITE; case FP_MINUS_INF: *is_negative = TRIO_TRUE; return TRIO_FP_INFINITE; case FP_PLUS_DENORM: *is_negative = TRIO_FALSE; return TRIO_FP_SUBNORMAL; case FP_MINUS_DENORM: *is_negative = TRIO_TRUE; return TRIO_FP_SUBNORMAL; case FP_PLUS_ZERO: *is_negative = TRIO_FALSE; return TRIO_FP_ZERO; case FP_MINUS_ZERO: *is_negative = TRIO_TRUE; return TRIO_FP_ZERO; case FP_PLUS_NORM: *is_negative = TRIO_FALSE; return TRIO_FP_NORMAL; case FP_MINUS_NORM: *is_negative = TRIO_TRUE; return TRIO_FP_NORMAL; default: assert(0); } #else /* * Fallback solution. */ int rc; if (number == 0.0) { /* * In IEEE 754 the sign of zero is ignored in comparisons, so we * have to handle this as a special case by examining the sign bit * directly. */ #if defined(USE_IEEE_754) *is_negative = trio_is_negative(number); #else *is_negative = TRIO_FALSE; /* FIXME */ #endif return TRIO_FP_ZERO; } if (trio_isnan(number)) { *is_negative = TRIO_FALSE; return TRIO_FP_NAN; } if ((rc = trio_isinf(number))) { *is_negative = (rc == -1); return TRIO_FP_INFINITE; } if ((number > 0.0) && (number < DBL_MIN)) { *is_negative = TRIO_FALSE; return TRIO_FP_SUBNORMAL; } if ((number < 0.0) && (number > -DBL_MIN)) { *is_negative = TRIO_TRUE; return TRIO_FP_SUBNORMAL; } *is_negative = (number < 0.0); return TRIO_FP_NORMAL; #endif } /** Examine the sign of a number. @param number An arbitrary floating-point number. @return Boolean value indicating whether or not the number has the sign bit set (i.e. is negative). */ TRIO_PUBLIC int trio_signbit TRIO_ARGS1((number), double number) { int is_negative; (void)trio_fpclassify_and_signbit(number, &is_negative); return is_negative; } /** Examine the class of a number. @param number An arbitrary floating-point number. @return Enumerable value indicating the class of @p number */ TRIO_PUBLIC int trio_fpclassify TRIO_ARGS1((number), double number) { int dummy; return trio_fpclassify_and_signbit(number, &dummy); } /** @} SpecialQuantities */ /************************************************************************* * For test purposes. * * Add the following compiler option to include this test code. * * Unix : -DSTANDALONE * VMS : /DEFINE=(STANDALONE) */ #if defined(STANDALONE) # include static TRIO_CONST char * getClassification TRIO_ARGS1((type) int type) { switch (type) { case TRIO_FP_INFINITE: return "FP_INFINITE"; case TRIO_FP_NAN: return "FP_NAN"; case TRIO_FP_NORMAL: return "FP_NORMAL"; case TRIO_FP_SUBNORMAL: return "FP_SUBNORMAL"; case TRIO_FP_ZERO: return "FP_ZERO"; default: return "FP_UNKNOWN"; } } static void print_class TRIO_ARGS2((prefix, number) TRIO_CONST char *prefix, double number) { printf("%-6s: %s %-15s %g\n", prefix, trio_signbit(number) ? "-" : "+", getClassification(trio_fpclassify(number)), number); } int main(TRIO_NOARGS) { double my_nan; double my_pinf; double my_ninf; # if defined(TRIO_PLATFORM_UNIX) void (*signal_handler) TRIO_PROTO((int)); # endif my_nan = trio_nan(); my_pinf = trio_pinf(); my_ninf = trio_ninf(); print_class("Nan", my_nan); print_class("PInf", my_pinf); print_class("NInf", my_ninf); print_class("PZero", 0.0); print_class("NZero", -0.0); print_class("PNorm", 1.0); print_class("NNorm", -1.0); print_class("PSub", 1.01e-307 - 1.00e-307); print_class("NSub", 1.00e-307 - 1.01e-307); printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", my_nan, ((unsigned char *)&my_nan)[0], ((unsigned char *)&my_nan)[1], ((unsigned char *)&my_nan)[2], ((unsigned char *)&my_nan)[3], ((unsigned char *)&my_nan)[4], ((unsigned char *)&my_nan)[5], ((unsigned char *)&my_nan)[6], ((unsigned char *)&my_nan)[7], trio_isnan(my_nan), trio_isinf(my_nan)); printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", my_pinf, ((unsigned char *)&my_pinf)[0], ((unsigned char *)&my_pinf)[1], ((unsigned char *)&my_pinf)[2], ((unsigned char *)&my_pinf)[3], ((unsigned char *)&my_pinf)[4], ((unsigned char *)&my_pinf)[5], ((unsigned char *)&my_pinf)[6], ((unsigned char *)&my_pinf)[7], trio_isnan(my_pinf), trio_isinf(my_pinf)); printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", my_ninf, ((unsigned char *)&my_ninf)[0], ((unsigned char *)&my_ninf)[1], ((unsigned char *)&my_ninf)[2], ((unsigned char *)&my_ninf)[3], ((unsigned char *)&my_ninf)[4], ((unsigned char *)&my_ninf)[5], ((unsigned char *)&my_ninf)[6], ((unsigned char *)&my_ninf)[7], trio_isnan(my_ninf), trio_isinf(my_ninf)); # if defined(TRIO_PLATFORM_UNIX) signal_handler = signal(SIGFPE, SIG_IGN); # endif my_pinf = DBL_MAX + DBL_MAX; my_ninf = -my_pinf; my_nan = my_pinf / my_pinf; # if defined(TRIO_PLATFORM_UNIX) signal(SIGFPE, signal_handler); # endif printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", my_nan, ((unsigned char *)&my_nan)[0], ((unsigned char *)&my_nan)[1], ((unsigned char *)&my_nan)[2], ((unsigned char *)&my_nan)[3], ((unsigned char *)&my_nan)[4], ((unsigned char *)&my_nan)[5], ((unsigned char *)&my_nan)[6], ((unsigned char *)&my_nan)[7], trio_isnan(my_nan), trio_isinf(my_nan)); printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", my_pinf, ((unsigned char *)&my_pinf)[0], ((unsigned char *)&my_pinf)[1], ((unsigned char *)&my_pinf)[2], ((unsigned char *)&my_pinf)[3], ((unsigned char *)&my_pinf)[4], ((unsigned char *)&my_pinf)[5], ((unsigned char *)&my_pinf)[6], ((unsigned char *)&my_pinf)[7], trio_isnan(my_pinf), trio_isinf(my_pinf)); printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n", my_ninf, ((unsigned char *)&my_ninf)[0], ((unsigned char *)&my_ninf)[1], ((unsigned char *)&my_ninf)[2], ((unsigned char *)&my_ninf)[3], ((unsigned char *)&my_ninf)[4], ((unsigned char *)&my_ninf)[5], ((unsigned char *)&my_ninf)[6], ((unsigned char *)&my_ninf)[7], trio_isnan(my_ninf), trio_isinf(my_ninf)); return 0; } #endif lftp-4.6.3a/trio/trio.c0000644000015000007670000046453112122061057011662 00000000000000/************************************************************************* * * $Id: trio.c,v 1.61 2002/06/23 11:58:06 breese Exp $ * * Copyright (C) 1998 Bjorn Reese and Daniel Stenberg. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************* * * A note to trio contributors: * * Avoid heap allocation at all costs to ensure that the trio functions * are async-safe. The exceptions are the printf/fprintf functions, which * uses fputc, and the asprintf functions and the modifier, which * by design are required to allocate form the heap. * ************************************************************************/ /* * TODO: * - Scan is probably too permissive about its modifiers. * - C escapes in %#[] ? * - Multibyte characters (done for format parsing, except scan groups) * - Complex numbers? (C99 _Complex) * - Boolean values? (C99 _Bool) * - C99 NaN(n-char-sequence) missing * - Should we support the GNU %a alloc modifier? GNU has an ugly hack * for %a, because C99 used %a for other purposes. If specified as * %as or %a[ it is interpreted as the alloc modifier, otherwise as * the C99 hex-float. This means that you cannot scan %as as a hex-float * immediately followed by an 's'. * - Scanning of collating symbols. */ /************************************************************************* * Trio include files */ #include "triodef.h" #include "trio.h" #include "triop.h" #include "trionan.h" #if !defined(TRIO_MINIMAL) # include "triostr.h" #endif /************************************************************************** * * Definitions * *************************************************************************/ #if defined(__STDC_ISO_10646__) || defined(MB_LEN_MAX) || defined(USE_MULTIBYTE) || TRIO_WIDECHAR # define TRIO_COMPILER_SUPPORTS_MULTIBYTE # if !defined(MB_LEN_MAX) # define MB_LEN_MAX 6 # endif #endif /************************************************************************* * Generic definitions */ #if !(defined(DEBUG) || defined(NDEBUG)) # define NDEBUG #endif #include #include #if !defined(TRIO_COMPILER_SUPPORTS_C99) # define isblank(x) (((x)==32) || ((x)==9)) #endif #include #include #include #if defined(TRIO_COMPILER_ANCIENT) # include #else # include #endif #include #include #ifndef NULL # define NULL 0 #endif #define NIL ((char)0) #ifndef FALSE # define FALSE (1 == 0) # define TRUE (! FALSE) #endif #define BOOLEAN_T int /* mincore() can be used for debugging purposes */ #define VALID(x) (NULL != (x)) #if TRIO_ERRORS /* * Encode the error code and the position. This is decoded * with TRIO_ERROR_CODE and TRIO_ERROR_POSITION. */ # define TRIO_ERROR_RETURN(x,y) (- ((x) + ((y) << 8))) #else # define TRIO_ERROR_RETURN(x,y) (-1) #endif /************************************************************************* * Platform specific definitions */ #if defined(TRIO_PLATFORM_UNIX) # include # include # include # define USE_LOCALE #endif /* TRIO_PLATFORM_UNIX */ #if defined(TRIO_PLATFORM_VMS) # include #endif #if defined(TRIO_PLATFORM_WIN32) # include # define read _read # define write _write #endif /* TRIO_PLATFORM_WIN32 */ #define TRIO_MSVC_VERSION_5 1100 #if TRIO_WIDECHAR # if defined(TRIO_COMPILER_SUPPORTS_ISO94) # include # include typedef wchar_t trio_wchar_t; typedef wint_t trio_wint_t; # else typedef char trio_wchar_t; typedef int trio_wint_t; # define WCONST(x) L ## x # define WEOF EOF # define iswalnum(x) isalnum(x) # define iswalpha(x) isalpha(x) # define iswblank(x) isblank(x) # define iswcntrl(x) iscntrl(x) # define iswdigit(x) isdigit(x) # define iswgraph(x) isgraph(x) # define iswlower(x) islower(x) # define iswprint(x) isprint(x) # define iswpunct(x) ispunct(x) # define iswspace(x) isspace(x) # define iswupper(x) isupper(x) # define iswxdigit(x) isxdigit(x) # endif #endif /************************************************************************* * Compiler dependent definitions */ /* Support for long long */ #ifndef __cplusplus # if !defined(USE_LONGLONG) # if defined(TRIO_COMPILER_GCC) && !defined(__STRICT_ANSI__) # define USE_LONGLONG # elif defined(TRIO_COMPILER_SUNPRO) # define USE_LONGLONG # elif defined(_LONG_LONG) || defined(_LONGLONG) # define USE_LONGLONG # endif # endif #endif /* The extra long numbers */ #if defined(USE_LONGLONG) typedef signed long long int trio_longlong_t; typedef unsigned long long int trio_ulonglong_t; #elif defined(TRIO_COMPILER_MSVC) # if (_MSC_VER >= TRIO_MSVC_VERSION_5) typedef signed __int64 trio_longlong_t; typedef unsigned __int64 trio_ulonglong_t; # else typedef signed long int trio_longlong_t; typedef unsigned long int trio_ulonglong_t; # endif #else typedef TRIO_SIGNED long int trio_longlong_t; typedef unsigned long int trio_ulonglong_t; #endif /* Maximal and fixed integer types */ #if defined(TRIO_COMPILER_SUPPORTS_C99) # include typedef intmax_t trio_intmax_t; typedef uintmax_t trio_uintmax_t; typedef int8_t trio_int8_t; typedef int16_t trio_int16_t; typedef int32_t trio_int32_t; typedef int64_t trio_int64_t; #elif defined(TRIO_COMPILER_SUPPORTS_UNIX98) # include typedef intmax_t trio_intmax_t; typedef uintmax_t trio_uintmax_t; typedef int8_t trio_int8_t; typedef int16_t trio_int16_t; typedef int32_t trio_int32_t; typedef int64_t trio_int64_t; #elif defined(TRIO_COMPILER_MSVC) && (_MSC_VER >= TRIO_MSVC_VERSION_5) typedef trio_longlong_t trio_intmax_t; typedef trio_ulonglong_t trio_uintmax_t; typedef __int8 trio_int8_t; typedef __int16 trio_int16_t; typedef __int32 trio_int32_t; typedef __int64 trio_int64_t; #else typedef trio_longlong_t trio_intmax_t; typedef trio_ulonglong_t trio_uintmax_t; # if defined(TRIO_INT8_T) typedef TRIO_INT8_T trio_int8_t; # else typedef TRIO_SIGNED char trio_int8_t; # endif # if defined(TRIO_INT16_T) typedef TRIO_INT16_T trio_int16_t; # else typedef TRIO_SIGNED short trio_int16_t; # endif # if defined(TRIO_INT32_T) typedef TRIO_INT32_T trio_int32_t; # else typedef TRIO_SIGNED int trio_int32_t; # endif # if defined(TRIO_INT64_T) typedef TRIO_INT64_T trio_int64_t; # else typedef trio_longlong_t trio_int64_t; # endif #endif #if !(defined(TRIO_COMPILER_SUPPORTS_C99) \ || defined(TRIO_COMPILER_SUPPORTS_UNIX01)) # define floorl(x) floor((double)(x)) # define fmodl(x,y) fmod((double)(x),(double)(y)) # define powl(x,y) pow((double)(x),(double)(y)) #endif #define TRIO_FABS(x) (((x) < 0.0) ? -(x) : (x)) /************************************************************************* * Internal Definitions */ #ifndef DECIMAL_DIG # define DECIMAL_DIG DBL_DIG #endif /* Long double sizes */ #ifdef LDBL_DIG # define MAX_MANTISSA_DIGITS LDBL_DIG # define MAX_EXPONENT_DIGITS 4 # define MAX_DOUBLE_DIGITS LDBL_MAX_10_EXP #else # define MAX_MANTISSA_DIGITS DECIMAL_DIG # define MAX_EXPONENT_DIGITS 3 # define MAX_DOUBLE_DIGITS DBL_MAX_10_EXP #endif #if defined(TRIO_COMPILER_ANCIENT) || !defined(LDBL_DIG) # undef LDBL_DIG # undef LDBL_MANT_DIG # undef LDBL_EPSILON # define LDBL_DIG DBL_DIG # define LDBL_MANT_DIG DBL_MANT_DIG # define LDBL_EPSILON DBL_EPSILON #endif /* The maximal number of digits is for base 2 */ #define MAX_CHARS_IN(x) (sizeof(x) * CHAR_BIT) /* The width of a pointer. The number of bits in a hex digit is 4 */ #define POINTER_WIDTH ((sizeof("0x") - 1) + sizeof(trio_pointer_t) * CHAR_BIT / 4) /* Infinite and Not-A-Number for floating-point */ #define INFINITE_LOWER "inf" #define INFINITE_UPPER "INF" #define LONG_INFINITE_LOWER "infinite" #define LONG_INFINITE_UPPER "INFINITE" #define NAN_LOWER "nan" #define NAN_UPPER "NAN" /* Various constants */ enum { TYPE_PRINT = 1, TYPE_SCAN = 2, /* Flags. Use maximum 32 */ FLAGS_NEW = 0, FLAGS_STICKY = 1, FLAGS_SPACE = 2 * FLAGS_STICKY, FLAGS_SHOWSIGN = 2 * FLAGS_SPACE, FLAGS_LEFTADJUST = 2 * FLAGS_SHOWSIGN, FLAGS_ALTERNATIVE = 2 * FLAGS_LEFTADJUST, FLAGS_SHORT = 2 * FLAGS_ALTERNATIVE, FLAGS_SHORTSHORT = 2 * FLAGS_SHORT, FLAGS_LONG = 2 * FLAGS_SHORTSHORT, FLAGS_QUAD = 2 * FLAGS_LONG, FLAGS_LONGDOUBLE = 2 * FLAGS_QUAD, FLAGS_SIZE_T = 2 * FLAGS_LONGDOUBLE, FLAGS_PTRDIFF_T = 2 * FLAGS_SIZE_T, FLAGS_INTMAX_T = 2 * FLAGS_PTRDIFF_T, FLAGS_NILPADDING = 2 * FLAGS_INTMAX_T, FLAGS_UNSIGNED = 2 * FLAGS_NILPADDING, FLAGS_UPPER = 2 * FLAGS_UNSIGNED, FLAGS_WIDTH = 2 * FLAGS_UPPER, FLAGS_WIDTH_PARAMETER = 2 * FLAGS_WIDTH, FLAGS_PRECISION = 2 * FLAGS_WIDTH_PARAMETER, FLAGS_PRECISION_PARAMETER = 2 * FLAGS_PRECISION, FLAGS_BASE = 2 * FLAGS_PRECISION_PARAMETER, FLAGS_BASE_PARAMETER = 2 * FLAGS_BASE, FLAGS_FLOAT_E = 2 * FLAGS_BASE_PARAMETER, FLAGS_FLOAT_G = 2 * FLAGS_FLOAT_E, FLAGS_QUOTE = 2 * FLAGS_FLOAT_G, FLAGS_WIDECHAR = 2 * FLAGS_QUOTE, FLAGS_ALLOC = 2 * FLAGS_WIDECHAR, FLAGS_IGNORE = 2 * FLAGS_ALLOC, FLAGS_IGNORE_PARAMETER = 2 * FLAGS_IGNORE, FLAGS_VARSIZE_PARAMETER = 2 * FLAGS_IGNORE_PARAMETER, FLAGS_FIXED_SIZE = 2 * FLAGS_VARSIZE_PARAMETER, /* Reused flags */ FLAGS_EXCLUDE = FLAGS_SHORT, FLAGS_USER_DEFINED = FLAGS_IGNORE, FLAGS_ROUNDING = FLAGS_INTMAX_T, /* Compounded flags */ FLAGS_ALL_VARSIZES = FLAGS_LONG | FLAGS_QUAD | FLAGS_INTMAX_T | FLAGS_PTRDIFF_T | FLAGS_SIZE_T, FLAGS_ALL_SIZES = FLAGS_ALL_VARSIZES | FLAGS_SHORTSHORT | FLAGS_SHORT, NO_POSITION = -1, NO_WIDTH = 0, NO_PRECISION = -1, NO_SIZE = -1, /* Do not change these */ NO_BASE = -1, MIN_BASE = 2, MAX_BASE = 36, BASE_BINARY = 2, BASE_OCTAL = 8, BASE_DECIMAL = 10, BASE_HEX = 16, /* Maximal number of allowed parameters */ MAX_PARAMETERS = 64, /* Maximal number of characters in class */ MAX_CHARACTER_CLASS = UCHAR_MAX + 1, /* Maximal string lengths for user-defined specifiers */ MAX_USER_NAME = 64, MAX_USER_DATA = 256, /* Maximal length of locale separator strings */ MAX_LOCALE_SEPARATOR_LENGTH = MB_LEN_MAX, /* Maximal number of integers in grouping */ MAX_LOCALE_GROUPS = 64, /* Initial size of asprintf buffer */ DYNAMIC_START_SIZE = 32 }; #define NO_GROUPING ((int)CHAR_MAX) /* Fundamental formatting parameter types */ #define FORMAT_UNKNOWN 0 #define FORMAT_INT 1 #define FORMAT_DOUBLE 2 #define FORMAT_CHAR 3 #define FORMAT_STRING 4 #define FORMAT_POINTER 5 #define FORMAT_COUNT 6 #define FORMAT_PARAMETER 7 #define FORMAT_GROUP 8 #if TRIO_GNU # define FORMAT_ERRNO 9 #endif #if TRIO_EXTENSION # define FORMAT_USER_DEFINED 10 #endif /* Character constants */ #define CHAR_IDENTIFIER '%' #define CHAR_BACKSLASH '\\' #define CHAR_QUOTE '\"' #define CHAR_ADJUST ' ' /* Character class expressions */ #define CLASS_ALNUM "[:alnum:]" #define CLASS_ALPHA "[:alpha:]" #define CLASS_BLANK "[:blank:]" #define CLASS_CNTRL "[:cntrl:]" #define CLASS_DIGIT "[:digit:]" #define CLASS_GRAPH "[:graph:]" #define CLASS_LOWER "[:lower:]" #define CLASS_PRINT "[:print:]" #define CLASS_PUNCT "[:punct:]" #define CLASS_SPACE "[:space:]" #define CLASS_UPPER "[:upper:]" #define CLASS_XDIGIT "[:xdigit:]" /* * SPECIFIERS: * * * a Hex-float * A Hex-float * c Character * C Widechar character (wint_t) * d Decimal * e Float * E Float * F Float * F Float * g Float * G Float * i Integer * m Error message * n Count * o Octal * p Pointer * s String * S Widechar string (wchar_t *) * u Unsigned * x Hex * X Hex * [] Group * <> User-defined * * Reserved: * * D Binary Coded Decimal %D(length,precision) (OS/390) */ #define SPECIFIER_CHAR 'c' #define SPECIFIER_STRING 's' #define SPECIFIER_DECIMAL 'd' #define SPECIFIER_INTEGER 'i' #define SPECIFIER_UNSIGNED 'u' #define SPECIFIER_OCTAL 'o' #define SPECIFIER_HEX 'x' #define SPECIFIER_HEX_UPPER 'X' #define SPECIFIER_FLOAT_E 'e' #define SPECIFIER_FLOAT_E_UPPER 'E' #define SPECIFIER_FLOAT_F 'f' #define SPECIFIER_FLOAT_F_UPPER 'F' #define SPECIFIER_FLOAT_G 'g' #define SPECIFIER_FLOAT_G_UPPER 'G' #define SPECIFIER_POINTER 'p' #define SPECIFIER_GROUP '[' #define SPECIFIER_UNGROUP ']' #define SPECIFIER_COUNT 'n' #if TRIO_UNIX98 # define SPECIFIER_CHAR_UPPER 'C' # define SPECIFIER_STRING_UPPER 'S' #endif #if TRIO_C99 # define SPECIFIER_HEXFLOAT 'a' # define SPECIFIER_HEXFLOAT_UPPER 'A' #endif #if TRIO_GNU # define SPECIFIER_ERRNO 'm' #endif #if TRIO_EXTENSION # define SPECIFIER_BINARY 'b' # define SPECIFIER_BINARY_UPPER 'B' # define SPECIFIER_USER_DEFINED_BEGIN '<' # define SPECIFIER_USER_DEFINED_END '>' # define SPECIFIER_USER_DEFINED_SEPARATOR ':' #endif /* * QUALIFIERS: * * * Numbers = d,i,o,u,x,X * Float = a,A,e,E,f,F,g,G * String = s * Char = c * * * 9$ Position * Use the 9th parameter. 9 can be any number between 1 and * the maximal argument * * 9 Width * Set width to 9. 9 can be any number, but must not be postfixed * by '$' * * h Short * Numbers: * (unsigned) short int * * hh Short short * Numbers: * (unsigned) char * * l Long * Numbers: * (unsigned) long int * String: * as the S specifier * Char: * as the C specifier * * ll Long Long * Numbers: * (unsigned) long long int * * L Long Double * Float * long double * * # Alternative * Float: * Decimal-point is always present * String: * non-printable characters are handled as \number * * Spacing * * + Sign * * - Alignment * * . Precision * * * Parameter * print: use parameter * scan: no parameter (ignore) * * q Quad * * Z size_t * * w Widechar * * ' Thousands/quote * Numbers: * Integer part grouped in thousands * Binary numbers: * Number grouped in nibbles (4 bits) * String: * Quoted string * * j intmax_t * t prtdiff_t * z size_t * * ! Sticky * @ Parameter (for both print and scan) * * I n-bit Integer * Numbers: * The following options exists * I8 = 8-bit integer * I16 = 16-bit integer * I32 = 32-bit integer * I64 = 64-bit integer */ #define QUALIFIER_POSITION '$' #define QUALIFIER_SHORT 'h' #define QUALIFIER_LONG 'l' #define QUALIFIER_LONG_UPPER 'L' #define QUALIFIER_ALTERNATIVE '#' #define QUALIFIER_SPACE ' ' #define QUALIFIER_PLUS '+' #define QUALIFIER_MINUS '-' #define QUALIFIER_DOT '.' #define QUALIFIER_STAR '*' #define QUALIFIER_CIRCUMFLEX '^' /* For scanlists */ #if TRIO_C99 # define QUALIFIER_SIZE_T 'z' # define QUALIFIER_PTRDIFF_T 't' # define QUALIFIER_INTMAX_T 'j' #endif #if TRIO_BSD || TRIO_GNU # define QUALIFIER_QUAD 'q' #endif #if TRIO_GNU # define QUALIFIER_SIZE_T_UPPER 'Z' #endif #if TRIO_MISC # define QUALIFIER_WIDECHAR 'w' #endif #if TRIO_MICROSOFT # define QUALIFIER_FIXED_SIZE 'I' #endif #if TRIO_EXTENSION # define QUALIFIER_QUOTE '\'' # define QUALIFIER_STICKY '!' # define QUALIFIER_VARSIZE '&' /* This should remain undocumented */ # define QUALIFIER_PARAM '@' /* Experimental */ # define QUALIFIER_COLON ':' /* For scanlists */ # define QUALIFIER_EQUAL '=' /* For scanlists */ # define QUALIFIER_ROUNDING_UPPER 'R' #endif /************************************************************************* * * Internal Structures * *************************************************************************/ /* Parameters */ typedef struct { /* An indication of which entry in the data union is used */ int type; /* The flags */ unsigned long flags; /* The width qualifier */ int width; /* The precision qualifier */ int precision; /* The base qualifier */ int base; /* The size for the variable size qualifier */ int varsize; /* The marker of the end of the specifier */ int indexAfterSpecifier; /* The data from the argument list */ union { char *string; #if TRIO_WIDECHAR trio_wchar_t *wstring; #endif trio_pointer_t pointer; union { trio_intmax_t as_signed; trio_uintmax_t as_unsigned; } number; double doubleNumber; double *doublePointer; trio_long_double_t longdoubleNumber; trio_long_double_t *longdoublePointer; int errorNumber; } data; /* For the user-defined specifier */ char user_name[MAX_USER_NAME]; char user_data[MAX_USER_DATA]; } trio_parameter_t; /* Container for customized functions */ typedef struct { union { trio_outstream_t out; trio_instream_t in; } stream; trio_pointer_t closure; } trio_custom_t; /* General trio "class" */ typedef struct _trio_class_t { /* * The function to write characters to a stream. */ void (*OutStream) TRIO_PROTO((struct _trio_class_t *, int)); /* * The function to read characters from a stream. */ void (*InStream) TRIO_PROTO((struct _trio_class_t *, int *)); /* * The current location in the stream. */ trio_pointer_t location; /* * The character currently being processed. */ int current; /* * The number of characters that would have been written/read * if there had been sufficient space. */ int processed; /* * The number of characters that are actually written/read. * Processed and committed will only differ for the *nprintf * and *nscanf functions. */ int committed; /* * The upper limit of characters that may be written/read. */ int max; /* * The last output error that was detected. */ int error; } trio_class_t; /* References (for user-defined callbacks) */ typedef struct _trio_reference_t { trio_class_t *data; trio_parameter_t *parameter; } trio_reference_t; /* Registered entries (for user-defined callbacks) */ typedef struct _trio_userdef_t { struct _trio_userdef_t *next; trio_callback_t callback; char *name; } trio_userdef_t; /************************************************************************* * * Internal Variables * *************************************************************************/ static TRIO_CONST char rcsid[] = "@(#)$Id: trio.c,v 1.61 2002/06/23 11:58:06 breese Exp $"; /* * Need this to workaround a parser bug in HP C/iX compiler that fails * to resolves macro definitions that includes type 'long double', * e.g: va_arg(arg_ptr, long double) */ #if defined(TRIO_PLATFORM_MPEIX) static TRIO_CONST trio_long_double_t ___dummy_long_double = 0; #endif static TRIO_CONST char internalNullString[] = "(nil)"; #if defined(USE_LOCALE) static struct lconv *internalLocaleValues = NULL; #endif /* * UNIX98 says "in a locale where the radix character is not defined, * the radix character defaults to a period (.)" */ static int internalDecimalPointLength = 1; static int internalThousandSeparatorLength = 1; static char internalDecimalPoint = '.'; static char internalDecimalPointString[MAX_LOCALE_SEPARATOR_LENGTH + 1] = "."; static char internalThousandSeparator[MAX_LOCALE_SEPARATOR_LENGTH + 1] = ","; static char internalGrouping[MAX_LOCALE_GROUPS] = { (char)NO_GROUPING }; static TRIO_CONST char internalDigitsLower[] = "0123456789abcdefghijklmnopqrstuvwxyz"; static TRIO_CONST char internalDigitsUpper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static BOOLEAN_T internalDigitsUnconverted = TRUE; static int internalDigitArray[128]; #if TRIO_EXTENSION static BOOLEAN_T internalCollationUnconverted = TRUE; static char internalCollationArray[MAX_CHARACTER_CLASS][MAX_CHARACTER_CLASS]; #endif #if TRIO_EXTENSION static TRIO_VOLATILE trio_callback_t internalEnterCriticalRegion = NULL; static TRIO_VOLATILE trio_callback_t internalLeaveCriticalRegion = NULL; static trio_userdef_t *internalUserDef = NULL; #endif /************************************************************************* * * Internal Functions * ************************************************************************/ #if defined(TRIO_MINIMAL) # define TRIO_STRING_PUBLIC static # include "triostr.c" #endif /* defined(TRIO_MINIMAL) */ /************************************************************************* * TrioIsQualifier * * Description: * Remember to add all new qualifiers to this function. * QUALIFIER_POSITION must not be added. */ TRIO_PRIVATE BOOLEAN_T TrioIsQualifier TRIO_ARGS1((character), TRIO_CONST char character) { /* QUALIFIER_POSITION is not included */ switch (character) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case QUALIFIER_PLUS: case QUALIFIER_MINUS: case QUALIFIER_SPACE: case QUALIFIER_DOT: case QUALIFIER_STAR: case QUALIFIER_ALTERNATIVE: case QUALIFIER_SHORT: case QUALIFIER_LONG: case QUALIFIER_LONG_UPPER: case QUALIFIER_CIRCUMFLEX: #if defined(QUALIFIER_SIZE_T) case QUALIFIER_SIZE_T: #endif #if defined(QUALIFIER_PTRDIFF_T) case QUALIFIER_PTRDIFF_T: #endif #if defined(QUALIFIER_INTMAX_T) case QUALIFIER_INTMAX_T: #endif #if defined(QUALIFIER_QUAD) case QUALIFIER_QUAD: #endif #if defined(QUALIFIER_SIZE_T_UPPER) case QUALIFIER_SIZE_T_UPPER: #endif #if defined(QUALIFIER_WIDECHAR) case QUALIFIER_WIDECHAR: #endif #if defined(QUALIFIER_QUOTE) case QUALIFIER_QUOTE: #endif #if defined(QUALIFIER_STICKY) case QUALIFIER_STICKY: #endif #if defined(QUALIFIER_VARSIZE) case QUALIFIER_VARSIZE: #endif #if defined(QUALIFIER_PARAM) case QUALIFIER_PARAM: #endif #if defined(QUALIFIER_FIXED_SIZE) case QUALIFIER_FIXED_SIZE: #endif #if defined(QUALIFIER_ROUNDING_UPPER) case QUALIFIER_ROUNDING_UPPER: #endif return TRUE; default: return FALSE; } } /************************************************************************* * TrioSetLocale */ #if defined(USE_LOCALE) TRIO_PRIVATE void TrioSetLocale(TRIO_NOARGS) { internalLocaleValues = (struct lconv *)localeconv(); if (internalLocaleValues) { if ((internalLocaleValues->decimal_point) && (internalLocaleValues->decimal_point[0] != NIL)) { internalDecimalPointLength = trio_length(internalLocaleValues->decimal_point); if (internalDecimalPointLength == 1) { internalDecimalPoint = internalLocaleValues->decimal_point[0]; } else { internalDecimalPoint = NIL; trio_copy_max(internalDecimalPointString, sizeof(internalDecimalPointString), internalLocaleValues->decimal_point); } } if ((internalLocaleValues->thousands_sep) && (internalLocaleValues->thousands_sep[0] != NIL)) { trio_copy_max(internalThousandSeparator, sizeof(internalThousandSeparator), internalLocaleValues->thousands_sep); internalThousandSeparatorLength = trio_length(internalThousandSeparator); } if ((internalLocaleValues->grouping) && (internalLocaleValues->grouping[0] != NIL)) { trio_copy_max(internalGrouping, sizeof(internalGrouping), internalLocaleValues->grouping); } } } #endif /* defined(USE_LOCALE) */ TRIO_PRIVATE int TrioCalcThousandSeparatorLength TRIO_ARGS1((digits), int digits) { #if TRIO_EXTENSION int count = 0; int step = NO_GROUPING; char *groupingPointer = internalGrouping; while (digits > 0) { if (*groupingPointer == CHAR_MAX) { /* Disable grouping */ break; /* while */ } else if (*groupingPointer == 0) { /* Repeat last group */ if (step == NO_GROUPING) { /* Error in locale */ break; /* while */ } } else { step = *groupingPointer++; } if (digits > step) count += internalThousandSeparatorLength; digits -= step; } return count; #else return 0; #endif } TRIO_PRIVATE BOOLEAN_T TrioFollowedBySeparator TRIO_ARGS1((position), int position) { #if TRIO_EXTENSION int step = 0; char *groupingPointer = internalGrouping; position--; if (position == 0) return FALSE; while (position > 0) { if (*groupingPointer == CHAR_MAX) { /* Disable grouping */ break; /* while */ } else if (*groupingPointer != 0) { step = *groupingPointer++; } if (step == 0) break; position -= step; } return (position == 0); #else return FALSE; #endif } /************************************************************************* * TrioGetPosition * * Get the %n$ position. */ TRIO_PRIVATE int TrioGetPosition TRIO_ARGS2((format, indexPointer), TRIO_CONST char *format, int *indexPointer) { #if TRIO_UNIX98 char *tmpformat; int number = 0; int index = *indexPointer; number = (int)trio_to_long(&format[index], &tmpformat, BASE_DECIMAL); index = (int)(tmpformat - format); if ((number != 0) && (QUALIFIER_POSITION == format[index++])) { *indexPointer = index; /* * number is decreased by 1, because n$ starts from 1, whereas * the array it is indexing starts from 0. */ return number - 1; } #endif return NO_POSITION; } #if TRIO_EXTENSION /************************************************************************* * TrioFindNamespace * * Find registered user-defined specifier. * The prev argument is used for optimization only. */ TRIO_PRIVATE trio_userdef_t * TrioFindNamespace TRIO_ARGS2((name, prev), TRIO_CONST char *name, trio_userdef_t **prev) { trio_userdef_t *def; if (internalEnterCriticalRegion) (void)internalEnterCriticalRegion(NULL); for (def = internalUserDef; def; def = def->next) { /* Case-sensitive string comparison */ if (trio_equal_case(def->name, name)) break; if (prev) *prev = def; } if (internalLeaveCriticalRegion) (void)internalLeaveCriticalRegion(NULL); return def; } #endif /************************************************************************* * TrioPower * * Description: * Calculate pow(base, exponent), where number and exponent are integers. */ TRIO_PRIVATE trio_long_double_t TrioPower TRIO_ARGS2((number, exponent), int number, int exponent) { trio_long_double_t result; if (number == 10) { switch (exponent) { /* Speed up calculation of common cases */ case 0: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E-1); break; case 1: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+0); break; case 2: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+1); break; case 3: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+2); break; case 4: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+3); break; case 5: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+4); break; case 6: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+5); break; case 7: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+6); break; case 8: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+7); break; case 9: result = (trio_long_double_t)number * TRIO_SUFFIX_LONG(1E+8); break; default: result = powl((trio_long_double_t)number, (trio_long_double_t)exponent); break; } } else { return powl((trio_long_double_t)number, (trio_long_double_t)exponent); } return result; } /************************************************************************* * TrioLogarithm */ TRIO_PRIVATE double TrioLogarithm TRIO_ARGS2((number, base), double number, int base) { double result; if (number <= 0.0) { /* xlC crashes on log(0) */ result = (number == 0.0) ? trio_ninf() : trio_nan(); } else { if (base == 10) { result = log10(number); } else { result = log10(number) / log10((double)base); } } return result; } /************************************************************************* * TrioLogarithmBase */ TRIO_PRIVATE double TrioLogarithmBase TRIO_ARGS1((base), int base) { switch (base) { case BASE_BINARY : return 1.0; case BASE_OCTAL : return 3.0; case BASE_DECIMAL: return 3.321928094887362345; case BASE_HEX : return 4.0; default : return TrioLogarithm((double)base, 2); } } /************************************************************************* * TrioParse * * Description: * Parse the format string */ TRIO_PRIVATE int TrioParse TRIO_ARGS5((type, format, parameters, arglist, argarray), int type, TRIO_CONST char *format, trio_parameter_t *parameters, va_list arglist, trio_pointer_t *argarray) { /* Count the number of times a parameter is referenced */ unsigned short usedEntries[MAX_PARAMETERS]; /* Parameter counters */ int parameterPosition; int currentParam; int maxParam = -1; /* Utility variables */ unsigned long flags; int width; int precision; int varsize; int base; int index; /* Index into formatting string */ int dots; /* Count number of dots in modifier part */ BOOLEAN_T positional; /* Does the specifier have a positional? */ BOOLEAN_T gotSticky = FALSE; /* Are there any sticky modifiers at all? */ /* * indices specifies the order in which the parameters must be * read from the va_args (this is necessary to handle positionals) */ int indices[MAX_PARAMETERS]; int pos = 0; /* Various variables */ char ch; #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) int charlen; #endif int save_errno; int i = -1; int num; char *tmpformat; /* * The 'parameters' array is not initialized, but we need to * know which entries we have used. */ memset(usedEntries, 0, sizeof(usedEntries)); save_errno = errno; index = 0; parameterPosition = 0; #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) mblen(NULL, 0); #endif while (format[index]) { #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) if (! isascii(format[index])) { /* * Multibyte characters cannot be legal specifiers or * modifiers, so we skip over them. */ charlen = mblen(&format[index], MB_LEN_MAX); index += (charlen > 0) ? charlen : 1; continue; /* while */ } #endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ if (CHAR_IDENTIFIER == format[index++]) { if (CHAR_IDENTIFIER == format[index]) { index++; continue; /* while */ } flags = FLAGS_NEW; dots = 0; currentParam = TrioGetPosition(format, &index); positional = (NO_POSITION != currentParam); if (!positional) { /* We have no positional, get the next counter */ currentParam = parameterPosition; } if(currentParam >= MAX_PARAMETERS) { /* Bail out completely to make the error more obvious */ return TRIO_ERROR_RETURN(TRIO_ETOOMANY, index); } if (currentParam > maxParam) maxParam = currentParam; /* Default values */ width = NO_WIDTH; precision = NO_PRECISION; base = NO_BASE; varsize = NO_SIZE; while (TrioIsQualifier(format[index])) { ch = format[index++]; switch (ch) { case QUALIFIER_SPACE: flags |= FLAGS_SPACE; break; case QUALIFIER_PLUS: flags |= FLAGS_SHOWSIGN; break; case QUALIFIER_MINUS: flags |= FLAGS_LEFTADJUST; flags &= ~FLAGS_NILPADDING; break; case QUALIFIER_ALTERNATIVE: flags |= FLAGS_ALTERNATIVE; break; case QUALIFIER_DOT: if (dots == 0) /* Precision */ { dots++; /* Skip if no precision */ if (QUALIFIER_DOT == format[index]) break; /* After the first dot we have the precision */ flags |= FLAGS_PRECISION; if ((QUALIFIER_STAR == format[index]) #if defined(QUALIFIER_PARAM) || (QUALIFIER_PARAM == format[index]) #endif ) { index++; flags |= FLAGS_PRECISION_PARAMETER; precision = TrioGetPosition(format, &index); if (precision == NO_POSITION) { parameterPosition++; if (positional) precision = parameterPosition; else { precision = currentParam; currentParam = precision + 1; } } else { if (! positional) currentParam = precision + 1; if (width > maxParam) maxParam = precision; } if (currentParam > maxParam) maxParam = currentParam; } else { precision = trio_to_long(&format[index], &tmpformat, BASE_DECIMAL); index = (int)(tmpformat - format); } } else if (dots == 1) /* Base */ { dots++; /* After the second dot we have the base */ flags |= FLAGS_BASE; if ((QUALIFIER_STAR == format[index]) #if defined(QUALIFIER_PARAM) || (QUALIFIER_PARAM == format[index]) #endif ) { index++; flags |= FLAGS_BASE_PARAMETER; base = TrioGetPosition(format, &index); if (base == NO_POSITION) { parameterPosition++; if (positional) base = parameterPosition; else { base = currentParam; currentParam = base + 1; } } else { if (! positional) currentParam = base + 1; if (base > maxParam) maxParam = base; } if (currentParam > maxParam) maxParam = currentParam; } else { base = trio_to_long(&format[index], &tmpformat, BASE_DECIMAL); if (base > MAX_BASE) return TRIO_ERROR_RETURN(TRIO_EINVAL, index); index = (int)(tmpformat - format); } } else { return TRIO_ERROR_RETURN(TRIO_EINVAL, index); } break; /* QUALIFIER_DOT */ #if defined(QUALIFIER_PARAM) case QUALIFIER_PARAM: type = TYPE_PRINT; /* FALLTHROUGH */ #endif case QUALIFIER_STAR: /* This has different meanings for print and scan */ if (TYPE_PRINT == type) { /* Read with from parameter */ flags |= (FLAGS_WIDTH | FLAGS_WIDTH_PARAMETER); width = TrioGetPosition(format, &index); if (width == NO_POSITION) { parameterPosition++; if (positional) width = parameterPosition; else { width = currentParam; currentParam = width + 1; } } else { if (! positional) currentParam = width + 1; if (width > maxParam) maxParam = width; } if (currentParam > maxParam) maxParam = currentParam; } else { /* Scan, but do not store result */ flags |= FLAGS_IGNORE; } break; /* QUALIFIER_STAR */ case '0': if (! (flags & FLAGS_LEFTADJUST)) flags |= FLAGS_NILPADDING; /* FALLTHROUGH */ case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': flags |= FLAGS_WIDTH; /* &format[index - 1] is used to "rewind" the read * character from format */ width = trio_to_long(&format[index - 1], &tmpformat, BASE_DECIMAL); index = (int)(tmpformat - format); break; case QUALIFIER_SHORT: if (flags & FLAGS_SHORTSHORT) return TRIO_ERROR_RETURN(TRIO_EINVAL, index); else if (flags & FLAGS_SHORT) flags |= FLAGS_SHORTSHORT; else flags |= FLAGS_SHORT; break; case QUALIFIER_LONG: if (flags & FLAGS_QUAD) return TRIO_ERROR_RETURN(TRIO_EINVAL, index); else if (flags & FLAGS_LONG) flags |= FLAGS_QUAD; else flags |= FLAGS_LONG; break; case QUALIFIER_LONG_UPPER: flags |= FLAGS_LONGDOUBLE; break; #if defined(QUALIFIER_SIZE_T) case QUALIFIER_SIZE_T: flags |= FLAGS_SIZE_T; /* Modify flags for later truncation of number */ if (sizeof(size_t) == sizeof(trio_ulonglong_t)) flags |= FLAGS_QUAD; else if (sizeof(size_t) == sizeof(long)) flags |= FLAGS_LONG; break; #endif #if defined(QUALIFIER_PTRDIFF_T) case QUALIFIER_PTRDIFF_T: flags |= FLAGS_PTRDIFF_T; if (sizeof(ptrdiff_t) == sizeof(trio_ulonglong_t)) flags |= FLAGS_QUAD; else if (sizeof(ptrdiff_t) == sizeof(long)) flags |= FLAGS_LONG; break; #endif #if defined(QUALIFIER_INTMAX_T) case QUALIFIER_INTMAX_T: flags |= FLAGS_INTMAX_T; if (sizeof(trio_intmax_t) == sizeof(trio_ulonglong_t)) flags |= FLAGS_QUAD; else if (sizeof(trio_intmax_t) == sizeof(long)) flags |= FLAGS_LONG; break; #endif #if defined(QUALIFIER_QUAD) case QUALIFIER_QUAD: flags |= FLAGS_QUAD; break; #endif #if defined(QUALIFIER_FIXED_SIZE) case QUALIFIER_FIXED_SIZE: if (flags & FLAGS_FIXED_SIZE) return TRIO_ERROR_RETURN(TRIO_EINVAL, index); if (flags & (FLAGS_ALL_SIZES | FLAGS_LONGDOUBLE | FLAGS_WIDECHAR | FLAGS_VARSIZE_PARAMETER)) return TRIO_ERROR_RETURN(TRIO_EINVAL, index); if ((format[index] == '6') && (format[index + 1] == '4')) { varsize = sizeof(trio_int64_t); index += 2; } else if ((format[index] == '3') && (format[index + 1] == '2')) { varsize = sizeof(trio_int32_t); index += 2; } else if ((format[index] == '1') && (format[index + 1] == '6')) { varsize = sizeof(trio_int16_t); index += 2; } else if (format[index] == '8') { varsize = sizeof(trio_int8_t); index++; } else return TRIO_ERROR_RETURN(TRIO_EINVAL, index); flags |= FLAGS_FIXED_SIZE; break; #endif #if defined(QUALIFIER_WIDECHAR) case QUALIFIER_WIDECHAR: flags |= FLAGS_WIDECHAR; break; #endif #if defined(QUALIFIER_SIZE_T_UPPER) case QUALIFIER_SIZE_T_UPPER: break; #endif #if defined(QUALIFIER_QUOTE) case QUALIFIER_QUOTE: flags |= FLAGS_QUOTE; break; #endif #if defined(QUALIFIER_STICKY) case QUALIFIER_STICKY: flags |= FLAGS_STICKY; gotSticky = TRUE; break; #endif #if defined(QUALIFIER_VARSIZE) case QUALIFIER_VARSIZE: flags |= FLAGS_VARSIZE_PARAMETER; parameterPosition++; if (positional) varsize = parameterPosition; else { varsize = currentParam; currentParam = varsize + 1; } if (currentParam > maxParam) maxParam = currentParam; break; #endif #if defined(QUALIFIER_ROUNDING_UPPER) case QUALIFIER_ROUNDING_UPPER: flags |= FLAGS_ROUNDING; break; #endif default: /* Bail out completely to make the error more obvious */ return TRIO_ERROR_RETURN(TRIO_EINVAL, index); } } /* while qualifier */ /* * Parameters only need the type and value. The value is * read later. */ if (flags & FLAGS_WIDTH_PARAMETER) { usedEntries[width] += 1; parameters[pos].type = FORMAT_PARAMETER; parameters[pos].flags = 0; indices[width] = pos; width = pos++; } if (flags & FLAGS_PRECISION_PARAMETER) { usedEntries[precision] += 1; parameters[pos].type = FORMAT_PARAMETER; parameters[pos].flags = 0; indices[precision] = pos; precision = pos++; } if (flags & FLAGS_BASE_PARAMETER) { usedEntries[base] += 1; parameters[pos].type = FORMAT_PARAMETER; parameters[pos].flags = 0; indices[base] = pos; base = pos++; } if (flags & FLAGS_VARSIZE_PARAMETER) { usedEntries[varsize] += 1; parameters[pos].type = FORMAT_PARAMETER; parameters[pos].flags = 0; indices[varsize] = pos; varsize = pos++; } indices[currentParam] = pos; switch (format[index++]) { #if defined(SPECIFIER_CHAR_UPPER) case SPECIFIER_CHAR_UPPER: flags |= FLAGS_WIDECHAR; /* FALLTHROUGH */ #endif case SPECIFIER_CHAR: if (flags & FLAGS_LONG) flags |= FLAGS_WIDECHAR; else if (flags & FLAGS_SHORT) flags &= ~FLAGS_WIDECHAR; parameters[pos].type = FORMAT_CHAR; break; #if defined(SPECIFIER_STRING_UPPER) case SPECIFIER_STRING_UPPER: flags |= FLAGS_WIDECHAR; /* FALLTHROUGH */ #endif case SPECIFIER_STRING: if (flags & FLAGS_LONG) flags |= FLAGS_WIDECHAR; else if (flags & FLAGS_SHORT) flags &= ~FLAGS_WIDECHAR; parameters[pos].type = FORMAT_STRING; break; case SPECIFIER_GROUP: if (TYPE_SCAN == type) { int depth = 1; parameters[pos].type = FORMAT_GROUP; if (format[index] == QUALIFIER_CIRCUMFLEX) index++; if (format[index] == SPECIFIER_UNGROUP) index++; if (format[index] == QUALIFIER_MINUS) index++; /* Skip nested brackets */ while (format[index] != NIL) { if (format[index] == SPECIFIER_GROUP) { depth++; } else if (format[index] == SPECIFIER_UNGROUP) { if (--depth <= 0) { index++; break; } } index++; } } break; case SPECIFIER_INTEGER: parameters[pos].type = FORMAT_INT; break; case SPECIFIER_UNSIGNED: flags |= FLAGS_UNSIGNED; parameters[pos].type = FORMAT_INT; break; case SPECIFIER_DECIMAL: /* Disable base modifier */ flags &= ~FLAGS_BASE_PARAMETER; base = BASE_DECIMAL; parameters[pos].type = FORMAT_INT; break; case SPECIFIER_OCTAL: flags &= ~FLAGS_BASE_PARAMETER; base = BASE_OCTAL; parameters[pos].type = FORMAT_INT; break; #if defined(SPECIFIER_BINARY) case SPECIFIER_BINARY_UPPER: flags |= FLAGS_UPPER; /* FALLTHROUGH */ case SPECIFIER_BINARY: flags |= FLAGS_NILPADDING; flags &= ~FLAGS_BASE_PARAMETER; base = BASE_BINARY; parameters[pos].type = FORMAT_INT; break; #endif case SPECIFIER_HEX_UPPER: flags |= FLAGS_UPPER; /* FALLTHROUGH */ case SPECIFIER_HEX: flags |= FLAGS_UNSIGNED; flags &= ~FLAGS_BASE_PARAMETER; base = BASE_HEX; parameters[pos].type = FORMAT_INT; break; case SPECIFIER_FLOAT_E_UPPER: flags |= FLAGS_UPPER; /* FALLTHROUGH */ case SPECIFIER_FLOAT_E: flags |= FLAGS_FLOAT_E; parameters[pos].type = FORMAT_DOUBLE; break; case SPECIFIER_FLOAT_G_UPPER: flags |= FLAGS_UPPER; /* FALLTHROUGH */ case SPECIFIER_FLOAT_G: flags |= FLAGS_FLOAT_G; parameters[pos].type = FORMAT_DOUBLE; break; case SPECIFIER_FLOAT_F_UPPER: flags |= FLAGS_UPPER; /* FALLTHROUGH */ case SPECIFIER_FLOAT_F: parameters[pos].type = FORMAT_DOUBLE; break; case SPECIFIER_POINTER: if (sizeof(trio_pointer_t) == sizeof(trio_ulonglong_t)) flags |= FLAGS_QUAD; else if (sizeof(trio_pointer_t) == sizeof(long)) flags |= FLAGS_LONG; parameters[pos].type = FORMAT_POINTER; break; case SPECIFIER_COUNT: parameters[pos].type = FORMAT_COUNT; break; #if defined(SPECIFIER_HEXFLOAT) # if defined(SPECIFIER_HEXFLOAT_UPPER) case SPECIFIER_HEXFLOAT_UPPER: flags |= FLAGS_UPPER; /* FALLTHROUGH */ # endif case SPECIFIER_HEXFLOAT: base = BASE_HEX; parameters[pos].type = FORMAT_DOUBLE; break; #endif #if defined(FORMAT_ERRNO) case SPECIFIER_ERRNO: parameters[pos].type = FORMAT_ERRNO; break; #endif #if defined(SPECIFIER_USER_DEFINED_BEGIN) case SPECIFIER_USER_DEFINED_BEGIN: { unsigned int max; int without_namespace = TRUE; parameters[pos].type = FORMAT_USER_DEFINED; parameters[pos].user_name[0] = NIL; tmpformat = (char *)&format[index]; while ((ch = format[index])) { index++; if (ch == SPECIFIER_USER_DEFINED_END) { if (without_namespace) { /* We must get the handle first */ parameters[pos].type = FORMAT_PARAMETER; parameters[pos].indexAfterSpecifier = index; parameters[pos].flags = FLAGS_USER_DEFINED; /* Adjust parameters for insertion of new one */ pos++; usedEntries[currentParam] += 1; parameters[pos].type = FORMAT_USER_DEFINED; currentParam++; indices[currentParam] = pos; if (currentParam > maxParam) maxParam = currentParam; } /* Copy the user data */ max = (unsigned int)(&format[index] - tmpformat); if (max > MAX_USER_DATA) max = MAX_USER_DATA; trio_copy_max(parameters[pos].user_data, max, tmpformat); break; /* while */ } if (ch == SPECIFIER_USER_DEFINED_SEPARATOR) { without_namespace = FALSE; /* Copy the namespace for later looking-up */ max = (int)(&format[index] - tmpformat); if (max > MAX_USER_NAME) max = MAX_USER_NAME; trio_copy_max(parameters[pos].user_name, max, tmpformat); tmpformat = (char *)&format[index]; } } if (ch != SPECIFIER_USER_DEFINED_END) return TRIO_ERROR_RETURN(TRIO_EINVAL, index); } break; #endif /* defined(SPECIFIER_USER_DEFINED_BEGIN) */ default: /* Bail out completely to make the error more obvious */ return TRIO_ERROR_RETURN(TRIO_EINVAL, index); } /* Count the number of times this entry has been used */ usedEntries[currentParam] += 1; /* Find last sticky parameters */ if (gotSticky && !(flags & FLAGS_STICKY)) { for (i = pos - 1; i >= 0; i--) { if (parameters[i].type == FORMAT_PARAMETER) continue; if ((parameters[i].flags & FLAGS_STICKY) && (parameters[i].type == parameters[pos].type)) { /* Do not overwrite current qualifiers */ flags |= (parameters[i].flags & (unsigned long)~FLAGS_STICKY); if (width == NO_WIDTH) width = parameters[i].width; if (precision == NO_PRECISION) precision = parameters[i].precision; if (base == NO_BASE) base = parameters[i].base; break; } } } parameters[pos].indexAfterSpecifier = index; parameters[pos].flags = flags; parameters[pos].width = width; parameters[pos].precision = precision; parameters[pos].base = (base == NO_BASE) ? BASE_DECIMAL : base; parameters[pos].varsize = varsize; pos++; if (! positional) parameterPosition++; } /* if identifier */ } /* while format characters left */ for (num = 0; num <= maxParam; num++) { if (usedEntries[num] != 1) { if (usedEntries[num] == 0) /* gap detected */ return TRIO_ERROR_RETURN(TRIO_EGAP, num); else /* double references detected */ return TRIO_ERROR_RETURN(TRIO_EDBLREF, num); } i = indices[num]; /* * FORMAT_PARAMETERS are only present if they must be read, * so it makes no sense to check the ignore flag (besides, * the flags variable is not set for that particular type) */ if ((parameters[i].type != FORMAT_PARAMETER) && (parameters[i].flags & FLAGS_IGNORE)) continue; /* for all arguments */ /* * The stack arguments are read according to ANSI C89 * default argument promotions: * * char = int * short = int * unsigned char = unsigned int * unsigned short = unsigned int * float = double * * In addition to the ANSI C89 these types are read (the * default argument promotions of C99 has not been * considered yet) * * long long * long double * size_t * ptrdiff_t * intmax_t */ switch (parameters[i].type) { case FORMAT_GROUP: case FORMAT_STRING: #if TRIO_WIDECHAR if (flags & FLAGS_WIDECHAR) { parameters[i].data.wstring = (argarray == NULL) ? va_arg(arglist, trio_wchar_t *) : (trio_wchar_t *)(argarray[num]); } else #endif { parameters[i].data.string = (argarray == NULL) ? va_arg(arglist, char *) : (char *)(argarray[num]); } break; #if defined(FORMAT_USER_DEFINED) case FORMAT_USER_DEFINED: #endif case FORMAT_POINTER: case FORMAT_COUNT: case FORMAT_UNKNOWN: parameters[i].data.pointer = (argarray == NULL) ? va_arg(arglist, trio_pointer_t ) : argarray[num]; break; case FORMAT_CHAR: case FORMAT_INT: if (TYPE_SCAN == type) { if (argarray == NULL) parameters[i].data.pointer = (trio_pointer_t)va_arg(arglist, trio_pointer_t); else { if (parameters[i].type == FORMAT_CHAR) parameters[i].data.pointer = (trio_pointer_t)((char *)argarray[num]); else if (parameters[i].flags & FLAGS_SHORT) parameters[i].data.pointer = (trio_pointer_t)((short *)argarray[num]); else parameters[i].data.pointer = (trio_pointer_t)((int *)argarray[num]); } } else { #if defined(QUALIFIER_VARSIZE) || defined(QUALIFIER_FIXED_SIZE) if (parameters[i].flags & (FLAGS_VARSIZE_PARAMETER | FLAGS_FIXED_SIZE)) { if (parameters[i].flags & FLAGS_VARSIZE_PARAMETER) { /* * Variable sizes are mapped onto the fixed sizes, in * accordance with integer promotion. * * Please note that this may not be portable, as we * only guess the size, not the layout of the numbers. * For example, if int is little-endian, and long is * big-endian, then this will fail. */ varsize = (int)parameters[parameters[i].varsize].data.number.as_unsigned; } else { /* Used for the I modifiers */ varsize = parameters[i].varsize; } parameters[i].flags &= ~FLAGS_ALL_VARSIZES; if (varsize <= (int)sizeof(int)) ; else if (varsize <= (int)sizeof(long)) parameters[i].flags |= FLAGS_LONG; #if defined(QUALIFIER_INTMAX_T) else if (varsize <= (int)sizeof(trio_longlong_t)) parameters[i].flags |= FLAGS_QUAD; else parameters[i].flags |= FLAGS_INTMAX_T; #else else parameters[i].flags |= FLAGS_QUAD; #endif } #endif /* defined(QUALIFIER_VARSIZE) */ #if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) if (parameters[i].flags & FLAGS_SIZE_T) parameters[i].data.number.as_unsigned = (argarray == NULL) ? (trio_uintmax_t)va_arg(arglist, size_t) : (trio_uintmax_t)(*((size_t *)argarray[num])); else #endif #if defined(QUALIFIER_PTRDIFF_T) if (parameters[i].flags & FLAGS_PTRDIFF_T) parameters[i].data.number.as_unsigned = (argarray == NULL) ? (trio_uintmax_t)va_arg(arglist, ptrdiff_t) : (trio_uintmax_t)(*((ptrdiff_t *)argarray[num])); else #endif #if defined(QUALIFIER_INTMAX_T) if (parameters[i].flags & FLAGS_INTMAX_T) parameters[i].data.number.as_unsigned = (argarray == NULL) ? (trio_uintmax_t)va_arg(arglist, trio_intmax_t) : (trio_uintmax_t)(*((trio_intmax_t *)argarray[num])); else #endif if (parameters[i].flags & FLAGS_QUAD) parameters[i].data.number.as_unsigned = (argarray == NULL) ? (trio_uintmax_t)va_arg(arglist, trio_ulonglong_t) : (trio_uintmax_t)(*((trio_ulonglong_t *)argarray[num])); else if (parameters[i].flags & FLAGS_LONG) parameters[i].data.number.as_unsigned = (argarray == NULL) ? (trio_uintmax_t)va_arg(arglist, long) : (trio_uintmax_t)(*((long *)argarray[num])); else { if (argarray == NULL) parameters[i].data.number.as_unsigned = (trio_uintmax_t)va_arg(arglist, int); else { if (parameters[i].type == FORMAT_CHAR) parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((char *)argarray[num])); else if (parameters[i].flags & FLAGS_SHORT) parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((short *)argarray[num])); else parameters[i].data.number.as_unsigned = (trio_uintmax_t)(*((int *)argarray[num])); } } } break; case FORMAT_PARAMETER: /* * The parameter for the user-defined specifier is a pointer, * whereas the rest (width, precision, base) uses an integer. */ if (parameters[i].flags & FLAGS_USER_DEFINED) parameters[i].data.pointer = (argarray == NULL) ? va_arg(arglist, trio_pointer_t ) : argarray[num]; else parameters[i].data.number.as_unsigned = (argarray == NULL) ? (trio_uintmax_t)va_arg(arglist, int) : (trio_uintmax_t)(*((int *)argarray[num])); break; case FORMAT_DOUBLE: if (TYPE_SCAN == type) { if (parameters[i].flags & FLAGS_LONGDOUBLE) parameters[i].data.longdoublePointer = (argarray == NULL) ? va_arg(arglist, trio_long_double_t *) : (trio_long_double_t *)argarray[num]; else { if (parameters[i].flags & FLAGS_LONG) parameters[i].data.doublePointer = (argarray == NULL) ? va_arg(arglist, double *) : (double *)argarray[num]; else parameters[i].data.doublePointer = (argarray == NULL) ? (double *)va_arg(arglist, float *) : (double *)((float *)argarray[num]); } } else { if (parameters[i].flags & FLAGS_LONGDOUBLE) parameters[i].data.longdoubleNumber = (argarray == NULL) ? va_arg(arglist, trio_long_double_t) : (trio_long_double_t)(*((trio_long_double_t *)argarray[num])); else { if (argarray == NULL) parameters[i].data.longdoubleNumber = (trio_long_double_t)va_arg(arglist, double); else { if (parameters[i].flags & FLAGS_SHORT) parameters[i].data.longdoubleNumber = (trio_long_double_t)(*((float *)argarray[num])); else parameters[i].data.longdoubleNumber = (trio_long_double_t)(*((double *)argarray[num])); } } } break; #if defined(FORMAT_ERRNO) case FORMAT_ERRNO: parameters[i].data.errorNumber = save_errno; break; #endif default: break; } } /* for all specifiers */ return num; } /************************************************************************* * * FORMATTING * ************************************************************************/ /************************************************************************* * TrioWriteNumber * * Description: * Output a number. * The complexity of this function is a result of the complexity * of the dependencies of the flags. */ TRIO_PRIVATE void TrioWriteNumber TRIO_ARGS6((self, number, flags, width, precision, base), trio_class_t *self, trio_uintmax_t number, unsigned long flags, int width, int precision, int base) { BOOLEAN_T isNegative; char buffer[MAX_CHARS_IN(trio_uintmax_t) * (1 + MAX_LOCALE_SEPARATOR_LENGTH) + 1]; char *bufferend; char *pointer; TRIO_CONST char *digits; int i; int length; char *p; int count; assert(VALID(self)); assert(VALID(self->OutStream)); assert(((base >= MIN_BASE) && (base <= MAX_BASE)) || (base == NO_BASE)); digits = (flags & FLAGS_UPPER) ? internalDigitsUpper : internalDigitsLower; if (base == NO_BASE) base = BASE_DECIMAL; isNegative = (flags & FLAGS_UNSIGNED) ? FALSE : ((trio_intmax_t)number < 0); if (isNegative) number = -((trio_intmax_t)number); if (flags & FLAGS_QUAD) number &= (trio_ulonglong_t)-1; else if (flags & FLAGS_LONG) number &= (unsigned long)-1; else number &= (unsigned int)-1; /* Build number */ pointer = bufferend = &buffer[sizeof(buffer) - 1]; *pointer-- = NIL; for (i = 1; i < (int)sizeof(buffer); i++) { *pointer-- = digits[number % base]; number /= base; if (number == 0) break; if ((flags & FLAGS_QUOTE) && TrioFollowedBySeparator(i + 1)) { /* * We are building the number from the least significant * to the most significant digit, so we have to copy the * thousand separator backwards */ length = internalThousandSeparatorLength; if (((int)(pointer - buffer) - length) > 0) { p = &internalThousandSeparator[length - 1]; while (length-- > 0) *pointer-- = *p--; } } } /* Adjust width */ width -= (bufferend - pointer) - 1; /* Adjust precision */ if (NO_PRECISION != precision) { precision -= (bufferend - pointer) - 1; if (precision < 0) precision = 0; flags |= FLAGS_NILPADDING; } /* Adjust width further */ if (isNegative || (flags & FLAGS_SHOWSIGN) || (flags & FLAGS_SPACE)) width--; if (flags & FLAGS_ALTERNATIVE) { switch (base) { case BASE_BINARY: case BASE_HEX: width -= 2; break; case BASE_OCTAL: width--; break; default: break; } } /* Output prefixes spaces if needed */ if (! ((flags & FLAGS_LEFTADJUST) || ((flags & FLAGS_NILPADDING) && (precision == NO_PRECISION)))) { count = (precision == NO_PRECISION) ? 0 : precision; while (width-- > count) self->OutStream(self, CHAR_ADJUST); } /* width has been adjusted for signs and alternatives */ if (isNegative) self->OutStream(self, '-'); else if (flags & FLAGS_SHOWSIGN) self->OutStream(self, '+'); else if (flags & FLAGS_SPACE) self->OutStream(self, ' '); if (flags & FLAGS_ALTERNATIVE) { switch (base) { case BASE_BINARY: self->OutStream(self, '0'); self->OutStream(self, (flags & FLAGS_UPPER) ? 'B' : 'b'); break; case BASE_OCTAL: self->OutStream(self, '0'); break; case BASE_HEX: self->OutStream(self, '0'); self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); break; default: break; } /* switch base */ } /* Output prefixed zero padding if needed */ if (flags & FLAGS_NILPADDING) { if (precision == NO_PRECISION) precision = width; while (precision-- > 0) { self->OutStream(self, '0'); width--; } } /* Output the number itself */ while (*(++pointer)) { self->OutStream(self, *pointer); } /* Output trailing spaces if needed */ if (flags & FLAGS_LEFTADJUST) { while (width-- > 0) self->OutStream(self, CHAR_ADJUST); } } /************************************************************************* * TrioWriteStringCharacter * * Description: * Output a single character of a string */ TRIO_PRIVATE void TrioWriteStringCharacter TRIO_ARGS3((self, ch, flags), trio_class_t *self, int ch, unsigned long flags) { if (flags & FLAGS_ALTERNATIVE) { if (! isprint(ch)) { /* * Non-printable characters are converted to C escapes or * \number, if no C escape exists. */ self->OutStream(self, CHAR_BACKSLASH); switch (ch) { case '\007': self->OutStream(self, 'a'); break; case '\b': self->OutStream(self, 'b'); break; case '\f': self->OutStream(self, 'f'); break; case '\n': self->OutStream(self, 'n'); break; case '\r': self->OutStream(self, 'r'); break; case '\t': self->OutStream(self, 't'); break; case '\v': self->OutStream(self, 'v'); break; case '\\': self->OutStream(self, '\\'); break; default: self->OutStream(self, 'x'); TrioWriteNumber(self, (trio_uintmax_t)ch, FLAGS_UNSIGNED | FLAGS_NILPADDING, 2, 2, BASE_HEX); break; } } else if (ch == CHAR_BACKSLASH) { self->OutStream(self, CHAR_BACKSLASH); self->OutStream(self, CHAR_BACKSLASH); } else { self->OutStream(self, ch); } } else { self->OutStream(self, ch); } } /************************************************************************* * TrioWriteString * * Description: * Output a string */ TRIO_PRIVATE void TrioWriteString TRIO_ARGS5((self, string, flags, width, precision), trio_class_t *self, TRIO_CONST char *string, unsigned long flags, int width, int precision) { int length; int ch; assert(VALID(self)); assert(VALID(self->OutStream)); if (string == NULL) { string = internalNullString; length = sizeof(internalNullString) - 1; /* Disable quoting for the null pointer */ flags &= (~FLAGS_QUOTE); width = 0; } else { length = trio_length(string); } if ((NO_PRECISION != precision) && (precision < length)) { length = precision; } width -= length; if (flags & FLAGS_QUOTE) self->OutStream(self, CHAR_QUOTE); if (! (flags & FLAGS_LEFTADJUST)) { while (width-- > 0) self->OutStream(self, CHAR_ADJUST); } while (length-- > 0) { /* The ctype parameters must be an unsigned char (or EOF) */ ch = (int)((unsigned char)(*string++)); TrioWriteStringCharacter(self, ch, flags); } if (flags & FLAGS_LEFTADJUST) { while (width-- > 0) self->OutStream(self, CHAR_ADJUST); } if (flags & FLAGS_QUOTE) self->OutStream(self, CHAR_QUOTE); } /************************************************************************* * TrioWriteWideStringCharacter * * Description: * Output a wide string as a multi-byte sequence */ #if TRIO_WIDECHAR TRIO_PRIVATE int TrioWriteWideStringCharacter TRIO_ARGS4((self, wch, flags, width), trio_class_t *self, trio_wchar_t wch, unsigned long flags, int width) { int size; int i; int ch; char *string; char buffer[MB_LEN_MAX + 1]; if (width == NO_WIDTH) width = sizeof(buffer); size = wctomb(buffer, wch); if ((size <= 0) || (size > width) || (buffer[0] == NIL)) return 0; string = buffer; i = size; while ((width >= i) && (width-- > 0) && (i-- > 0)) { /* The ctype parameters must be an unsigned char (or EOF) */ ch = (int)((unsigned char)(*string++)); TrioWriteStringCharacter(self, ch, flags); } return size; } #endif /* TRIO_WIDECHAR */ /************************************************************************* * TrioWriteWideString * * Description: * Output a wide character string as a multi-byte string */ #if TRIO_WIDECHAR TRIO_PRIVATE void TrioWriteWideString TRIO_ARGS5((self, wstring, flags, width, precision), trio_class_t *self, TRIO_CONST trio_wchar_t *wstring, unsigned long flags, int width, int precision) { int length; int size; assert(VALID(self)); assert(VALID(self->OutStream)); #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) mblen(NULL, 0); #endif if (wstring == NULL) { TrioWriteString(self, NULL, flags, width, precision); return; } if (NO_PRECISION == precision) { length = INT_MAX; } else { length = precision; width -= length; } if (flags & FLAGS_QUOTE) self->OutStream(self, CHAR_QUOTE); if (! (flags & FLAGS_LEFTADJUST)) { while (width-- > 0) self->OutStream(self, CHAR_ADJUST); } while (length > 0) { size = TrioWriteWideStringCharacter(self, *wstring++, flags, length); if (size == 0) break; /* while */ length -= size; } if (flags & FLAGS_LEFTADJUST) { while (width-- > 0) self->OutStream(self, CHAR_ADJUST); } if (flags & FLAGS_QUOTE) self->OutStream(self, CHAR_QUOTE); } #endif /* TRIO_WIDECHAR */ /************************************************************************* * TrioWriteDouble * * http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_211.htm * * "5.2.4.2.2 paragraph #4 * * The accuracy [...] is implementation defined, as is the accuracy * of the conversion between floating-point internal representations * and string representations performed by the libray routine in * " */ /* FIXME: handle all instances of constant long-double number (L) * and *l() math functions. */ TRIO_PRIVATE void TrioWriteDouble TRIO_ARGS6((self, number, flags, width, precision, base), trio_class_t *self, trio_long_double_t number, unsigned long flags, int width, int precision, int base) { trio_long_double_t integerNumber; trio_long_double_t fractionNumber; trio_long_double_t workNumber; int integerDigits; int fractionDigits; int exponentDigits; int baseDigits; int integerThreshold; int fractionThreshold; int expectedWidth; int exponent = 0; unsigned int uExponent = 0; int exponentBase; trio_long_double_t dblBase; trio_long_double_t dblIntegerBase; trio_long_double_t dblFractionBase; trio_long_double_t integerAdjust; trio_long_double_t fractionAdjust; BOOLEAN_T isNegative; BOOLEAN_T isExponentNegative = FALSE; BOOLEAN_T requireTwoDigitExponent; BOOLEAN_T isHex; TRIO_CONST char *digits; char *groupingPointer; int i; int index; BOOLEAN_T hasOnlyZeroes; int zeroes = 0; register int trailingZeroes; BOOLEAN_T keepTrailingZeroes; BOOLEAN_T keepDecimalPoint; trio_long_double_t epsilon; assert(VALID(self)); assert(VALID(self->OutStream)); assert(((base >= MIN_BASE) && (base <= MAX_BASE)) || (base == NO_BASE)); /* Determine sign and look for special quantities */ switch (trio_fpclassify_and_signbit(number, &isNegative)) { case TRIO_FP_NAN: TrioWriteString(self, (flags & FLAGS_UPPER) ? NAN_UPPER : NAN_LOWER, flags, width, precision); return; case TRIO_FP_INFINITE: if (isNegative) { /* Negative infinity */ TrioWriteString(self, (flags & FLAGS_UPPER) ? "-" INFINITE_UPPER : "-" INFINITE_LOWER, flags, width, precision); return; } else { /* Positive infinity */ TrioWriteString(self, (flags & FLAGS_UPPER) ? INFINITE_UPPER : INFINITE_LOWER, flags, width, precision); return; } default: /* Finitude */ break; } /* Normal numbers */ if (flags & FLAGS_LONGDOUBLE) { baseDigits = (base == 10) ? LDBL_DIG : (int)floor(LDBL_MANT_DIG / TrioLogarithmBase(base)); epsilon = LDBL_EPSILON; } else if (flags & FLAGS_SHORT) { baseDigits = (base == BASE_DECIMAL) ? FLT_DIG : (int)floor(FLT_MANT_DIG / TrioLogarithmBase(base)); epsilon = FLT_EPSILON; } else { baseDigits = (base == BASE_DECIMAL) ? DBL_DIG : (int)floor(DBL_MANT_DIG / TrioLogarithmBase(base)); epsilon = DBL_EPSILON; } digits = (flags & FLAGS_UPPER) ? internalDigitsUpper : internalDigitsLower; isHex = (base == BASE_HEX); if (base == NO_BASE) base = BASE_DECIMAL; dblBase = (trio_long_double_t)base; keepTrailingZeroes = !( (flags & FLAGS_ROUNDING) || ( (flags & FLAGS_FLOAT_G) && !(flags & FLAGS_ALTERNATIVE) ) ); if (flags & FLAGS_ROUNDING) precision = baseDigits; if (precision == NO_PRECISION) precision = FLT_DIG; if (isNegative) number = -number; if (isHex) flags |= FLAGS_FLOAT_E; if (flags & FLAGS_FLOAT_G) { if (precision == 0) precision = 1; if ((number < 1.0E-4) || (number > powl(base, (trio_long_double_t)precision))) { /* Use scientific notation */ flags |= FLAGS_FLOAT_E; } else if (number < 1.0) { /* * Use normal notation. If the integer part of the number is * zero, then adjust the precision to include leading fractional * zeros. */ workNumber = TrioLogarithm(number, base); workNumber = TRIO_FABS(workNumber); if (workNumber - floorl(workNumber) < 0.001) workNumber--; zeroes = (int)floorl(workNumber); } } if (flags & FLAGS_FLOAT_E) { /* Scale the number */ workNumber = TrioLogarithm(number, base); if (trio_isinf(workNumber) == -1) { exponent = 0; /* Undo setting */ if (flags & FLAGS_FLOAT_G) flags &= ~FLAGS_FLOAT_E; } else { exponent = (int)floorl(workNumber); number /= powl(dblBase, (trio_long_double_t)exponent); isExponentNegative = (exponent < 0); uExponent = (isExponentNegative) ? -exponent : exponent; /* No thousand separators */ flags &= ~FLAGS_QUOTE; } } integerNumber = floorl(number); fractionNumber = number - integerNumber; /* * Truncated number. * * Precision is number of significant digits for FLOAT_G * and number of fractional digits for others. */ integerDigits = (integerNumber > epsilon) ? 1 + (int)TrioLogarithm(integerNumber, base) : 1; fractionDigits = ((flags & FLAGS_FLOAT_G) && (zeroes == 0)) ? precision - integerDigits : zeroes + precision; dblFractionBase = TrioPower(base, fractionDigits); workNumber = number + 0.5 / dblFractionBase; if (floorl(number) != floorl(workNumber)) { if (flags & FLAGS_FLOAT_E) { /* Adjust if number was rounded up one digit (ie. 0.99 to 1.00) */ exponent++; isExponentNegative = (exponent < 0); uExponent = (isExponentNegative) ? -exponent : exponent; workNumber = (number + 0.5 / dblFractionBase) / dblBase; integerNumber = floorl(workNumber); fractionNumber = workNumber - integerNumber; } else { /* Adjust if number was rounded up one digit (ie. 99 to 100) */ integerNumber = floorl(number + 0.5); fractionNumber = 0.0; integerDigits = (integerNumber > epsilon) ? 1 + (int)TrioLogarithm(integerNumber, base) : 1; } } /* Estimate accuracy */ integerAdjust = fractionAdjust = 0.5; if (flags & FLAGS_ROUNDING) { if (integerDigits > baseDigits) { integerThreshold = baseDigits; fractionDigits = 0; dblFractionBase = 1.0; fractionThreshold = 0; precision = 0; /* Disable decimal-point */ integerAdjust = TrioPower(base, integerDigits - integerThreshold - 1); fractionAdjust = 0.0; } else { integerThreshold = integerDigits; fractionThreshold = fractionDigits - integerThreshold; fractionAdjust = 1.0; } } else { integerThreshold = INT_MAX; fractionThreshold = INT_MAX; } /* * Calculate expected width. * sign + integer part + thousands separators + decimal point * + fraction + exponent */ fractionAdjust /= dblFractionBase; hasOnlyZeroes = (floorl((fractionNumber + fractionAdjust) * dblFractionBase) < epsilon); keepDecimalPoint = ( (flags & FLAGS_ALTERNATIVE) || !((precision == 0) || (!keepTrailingZeroes && hasOnlyZeroes)) ); if (flags & FLAGS_FLOAT_E) { exponentDigits = (uExponent == 0) ? 1 : (int)ceil(TrioLogarithm((double)(uExponent + 1), base)); } else exponentDigits = 0; requireTwoDigitExponent = ((base == BASE_DECIMAL) && (exponentDigits == 1)); expectedWidth = integerDigits + fractionDigits + (keepDecimalPoint ? internalDecimalPointLength : 0) + ((flags & FLAGS_QUOTE) ? TrioCalcThousandSeparatorLength(integerDigits) : 0); if (isNegative || (flags & FLAGS_SHOWSIGN)) expectedWidth += sizeof("-") - 1; if (exponentDigits > 0) expectedWidth += exponentDigits + ((requireTwoDigitExponent ? sizeof("E+0") : sizeof("E+")) - 1); if (isHex) expectedWidth += sizeof("0X") - 1; /* Output prefixing */ if (flags & FLAGS_NILPADDING) { /* Leading zeros must be after sign */ if (isNegative) self->OutStream(self, '-'); else if (flags & FLAGS_SHOWSIGN) self->OutStream(self, '+'); if (isHex) { self->OutStream(self, '0'); self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); } if (!(flags & FLAGS_LEFTADJUST)) { for (i = expectedWidth; i < width; i++) { self->OutStream(self, '0'); } } } else { /* Leading spaces must be before sign */ if (!(flags & FLAGS_LEFTADJUST)) { for (i = expectedWidth; i < width; i++) { self->OutStream(self, CHAR_ADJUST); } } if (isNegative) self->OutStream(self, '-'); else if (flags & FLAGS_SHOWSIGN) self->OutStream(self, '+'); if (isHex) { self->OutStream(self, '0'); self->OutStream(self, (flags & FLAGS_UPPER) ? 'X' : 'x'); } } /* Output the integer part and thousand separators */ dblIntegerBase = 1.0 / TrioPower(base, integerDigits - 1); for (i = 0; i < integerDigits; i++) { workNumber = floorl(((integerNumber + integerAdjust) * dblIntegerBase)); if (i > integerThreshold) { /* Beyond accuracy */ self->OutStream(self, digits[0]); } else { self->OutStream(self, digits[(int)fmodl(workNumber, dblBase)]); } dblIntegerBase *= dblBase; if (((flags & (FLAGS_FLOAT_E | FLAGS_QUOTE)) == FLAGS_QUOTE) && TrioFollowedBySeparator(integerDigits - i)) { for (groupingPointer = internalThousandSeparator; *groupingPointer != NIL; groupingPointer++) { self->OutStream(self, *groupingPointer); } } } /* Insert decimal point and build the fraction part */ trailingZeroes = 0; if (keepDecimalPoint) { if (internalDecimalPoint) { self->OutStream(self, internalDecimalPoint); } else { for (i = 0; i < internalDecimalPointLength; i++) { self->OutStream(self, internalDecimalPointString[i]); } } } for (i = 0; i < fractionDigits; i++) { if ((integerDigits > integerThreshold) || (i > fractionThreshold)) { /* Beyond accuracy */ trailingZeroes++; } else { fractionNumber *= dblBase; fractionAdjust *= dblBase; workNumber = floorl(fractionNumber + fractionAdjust); fractionNumber -= workNumber; index = (int)fmodl(workNumber, dblBase); if (index == 0) { trailingZeroes++; } else { while (trailingZeroes > 0) { /* Not trailing zeroes after all */ self->OutStream(self, digits[0]); trailingZeroes--; } self->OutStream(self, digits[index]); } } } if (keepTrailingZeroes) { while (trailingZeroes > 0) { self->OutStream(self, digits[0]); trailingZeroes--; } } /* Output exponent */ if (exponentDigits > 0) { self->OutStream(self, isHex ? ((flags & FLAGS_UPPER) ? 'P' : 'p') : ((flags & FLAGS_UPPER) ? 'E' : 'e')); self->OutStream(self, (isExponentNegative) ? '-' : '+'); /* The exponent must contain at least two digits */ if (requireTwoDigitExponent) self->OutStream(self, '0'); exponentBase = (int)TrioPower(base, exponentDigits - 1); for (i = 0; i < exponentDigits; i++) { self->OutStream(self, digits[(uExponent / exponentBase) % base]); exponentBase /= base; } } /* Output trailing spaces */ if (flags & FLAGS_LEFTADJUST) { for (i = expectedWidth; i < width; i++) { self->OutStream(self, CHAR_ADJUST); } } } /************************************************************************* * TrioFormatProcess * * Description: * This is the main engine for formatting output */ TRIO_PRIVATE int TrioFormatProcess TRIO_ARGS3((data, format, parameters), trio_class_t *data, TRIO_CONST char *format, trio_parameter_t *parameters) { #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) int charlen; #endif int i; TRIO_CONST char *string; trio_pointer_t pointer; unsigned long flags; int width; int precision; int base; int index; index = 0; i = 0; #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) mblen(NULL, 0); #endif while (format[index]) { #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) if (! isascii(format[index])) { charlen = mblen(&format[index], MB_LEN_MAX); while (charlen-- > 0) { data->OutStream(data, format[index++]); } continue; /* while */ } #endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ if (CHAR_IDENTIFIER == format[index]) { if (CHAR_IDENTIFIER == format[index + 1]) { data->OutStream(data, CHAR_IDENTIFIER); index += 2; } else { /* Skip the parameter entries */ while (parameters[i].type == FORMAT_PARAMETER) i++; flags = parameters[i].flags; /* Find width */ width = parameters[i].width; if (flags & FLAGS_WIDTH_PARAMETER) { /* Get width from parameter list */ width = (int)parameters[width].data.number.as_signed; } /* Find precision */ if (flags & FLAGS_PRECISION) { precision = parameters[i].precision; if (flags & FLAGS_PRECISION_PARAMETER) { /* Get precision from parameter list */ precision = (int)parameters[precision].data.number.as_signed; } } else { precision = NO_PRECISION; } /* Find base */ base = parameters[i].base; if (flags & FLAGS_BASE_PARAMETER) { /* Get base from parameter list */ base = (int)parameters[base].data.number.as_signed; } switch (parameters[i].type) { case FORMAT_CHAR: if (flags & FLAGS_QUOTE) data->OutStream(data, CHAR_QUOTE); if (! (flags & FLAGS_LEFTADJUST)) { while (--width > 0) data->OutStream(data, CHAR_ADJUST); } #if TRIO_WIDECHAR if (flags & FLAGS_WIDECHAR) { TrioWriteWideStringCharacter(data, (trio_wchar_t)parameters[i].data.number.as_signed, flags, NO_WIDTH); } else #endif { TrioWriteStringCharacter(data, (int)parameters[i].data.number.as_signed, flags); } if (flags & FLAGS_LEFTADJUST) { while(--width > 0) data->OutStream(data, CHAR_ADJUST); } if (flags & FLAGS_QUOTE) data->OutStream(data, CHAR_QUOTE); break; /* FORMAT_CHAR */ case FORMAT_INT: TrioWriteNumber(data, parameters[i].data.number.as_unsigned, flags, width, precision, base); break; /* FORMAT_INT */ case FORMAT_DOUBLE: TrioWriteDouble(data, parameters[i].data.longdoubleNumber, flags, width, precision, base); break; /* FORMAT_DOUBLE */ case FORMAT_STRING: #if TRIO_WIDECHAR if (flags & FLAGS_WIDECHAR) { TrioWriteWideString(data, parameters[i].data.wstring, flags, width, precision); } else #endif { TrioWriteString(data, parameters[i].data.string, flags, width, precision); } break; /* FORMAT_STRING */ case FORMAT_POINTER: { trio_reference_t reference; reference.data = data; reference.parameter = ¶meters[i]; trio_print_pointer(&reference, parameters[i].data.pointer); } break; /* FORMAT_POINTER */ case FORMAT_COUNT: pointer = parameters[i].data.pointer; if (NULL != pointer) { /* * C99 paragraph 7.19.6.1.8 says "the number of * characters written to the output stream so far by * this call", which is data->committed */ #if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) if (flags & FLAGS_SIZE_T) *(size_t *)pointer = (size_t)data->committed; else #endif #if defined(QUALIFIER_PTRDIFF_T) if (flags & FLAGS_PTRDIFF_T) *(ptrdiff_t *)pointer = (ptrdiff_t)data->committed; else #endif #if defined(QUALIFIER_INTMAX_T) if (flags & FLAGS_INTMAX_T) *(trio_intmax_t *)pointer = (trio_intmax_t)data->committed; else #endif if (flags & FLAGS_QUAD) { *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)data->committed; } else if (flags & FLAGS_LONG) { *(long int *)pointer = (long int)data->committed; } else if (flags & FLAGS_SHORT) { *(short int *)pointer = (short int)data->committed; } else { *(int *)pointer = (int)data->committed; } } break; /* FORMAT_COUNT */ case FORMAT_PARAMETER: break; /* FORMAT_PARAMETER */ #if defined(FORMAT_ERRNO) case FORMAT_ERRNO: string = trio_error(parameters[i].data.errorNumber); if (string) { TrioWriteString(data, string, flags, width, precision); } else { data->OutStream(data, '#'); TrioWriteNumber(data, (trio_uintmax_t)parameters[i].data.errorNumber, flags, width, precision, BASE_DECIMAL); } break; /* FORMAT_ERRNO */ #endif /* defined(FORMAT_ERRNO) */ #if defined(FORMAT_USER_DEFINED) case FORMAT_USER_DEFINED: { trio_reference_t reference; trio_userdef_t *def = NULL; if (parameters[i].user_name[0] == NIL) { /* Use handle */ if ((i > 0) || (parameters[i - 1].type == FORMAT_PARAMETER)) def = (trio_userdef_t *)parameters[i - 1].data.pointer; } else { /* Look up namespace */ def = TrioFindNamespace(parameters[i].user_name, NULL); } if (def) { reference.data = data; reference.parameter = ¶meters[i]; def->callback(&reference); } } break; #endif /* defined(FORMAT_USER_DEFINED) */ default: break; } /* switch parameter type */ /* Prepare for next */ index = parameters[i].indexAfterSpecifier; i++; } } else /* not identifier */ { data->OutStream(data, format[index++]); } } return data->processed; } /************************************************************************* * TrioFormatRef */ TRIO_PRIVATE int TrioFormatRef TRIO_ARGS4((reference, format, arglist, argarray), trio_reference_t *reference, TRIO_CONST char *format, va_list arglist, trio_pointer_t *argarray) { int status; trio_parameter_t parameters[MAX_PARAMETERS]; status = TrioParse(TYPE_PRINT, format, parameters, arglist, argarray); if (status < 0) return status; status = TrioFormatProcess(reference->data, format, parameters); if (reference->data->error != 0) { status = reference->data->error; } return status; } /************************************************************************* * TrioFormat */ TRIO_PRIVATE int TrioFormat TRIO_ARGS6((destination, destinationSize, OutStream, format, arglist, argarray), trio_pointer_t destination, size_t destinationSize, void (*OutStream) TRIO_PROTO((trio_class_t *, int)), TRIO_CONST char *format, va_list arglist, trio_pointer_t *argarray) { int status; trio_class_t data; trio_parameter_t parameters[MAX_PARAMETERS]; assert(VALID(OutStream)); assert(VALID(format)); memset(&data, 0, sizeof(data)); data.OutStream = OutStream; data.location = destination; data.max = destinationSize; data.error = 0; #if defined(USE_LOCALE) if (NULL == internalLocaleValues) { TrioSetLocale(); } #endif status = TrioParse(TYPE_PRINT, format, parameters, arglist, argarray); if (status < 0) return status; status = TrioFormatProcess(&data, format, parameters); if (data.error != 0) { status = data.error; } return status; } /************************************************************************* * TrioOutStreamFile */ TRIO_PRIVATE void TrioOutStreamFile TRIO_ARGS2((self, output), trio_class_t *self, int output) { FILE *file; assert(VALID(self)); file = (FILE *)self->location; assert(VALID(file)); self->processed++; if (fputc(output, file) == EOF) { self->error = TRIO_ERROR_RETURN(TRIO_EOF, 0); } else { self->committed++; } } /************************************************************************* * TrioOutStreamFileDescriptor */ TRIO_PRIVATE void TrioOutStreamFileDescriptor TRIO_ARGS2((self, output), trio_class_t *self, int output) { int fd; char ch; assert(VALID(self)); fd = *((int *)self->location); ch = (char)output; self->processed++; if (write(fd, &ch, sizeof(char)) == -1) { self->error = TRIO_ERROR_RETURN(TRIO_ERRNO, 0); } else { self->committed++; } } /************************************************************************* * TrioOutStreamCustom */ TRIO_PRIVATE void TrioOutStreamCustom TRIO_ARGS2((self, output), trio_class_t *self, int output) { int status; trio_custom_t *data; assert(VALID(self)); assert(VALID(self->location)); data = (trio_custom_t *)self->location; if (data->stream.out) { status = (data->stream.out)(data->closure, output); if (status >= 0) { self->committed++; } else { if (self->error == 0) { self->error = TRIO_ERROR_RETURN(TRIO_ECUSTOM, -status); } } } self->processed++; } /************************************************************************* * TrioOutStreamString */ TRIO_PRIVATE void TrioOutStreamString TRIO_ARGS2((self, output), trio_class_t *self, int output) { char **buffer; assert(VALID(self)); assert(VALID(self->location)); buffer = (char **)self->location; **buffer = (char)output; (*buffer)++; self->processed++; self->committed++; } /************************************************************************* * TrioOutStreamStringMax */ TRIO_PRIVATE void TrioOutStreamStringMax TRIO_ARGS2((self, output), trio_class_t *self, int output) { char **buffer; assert(VALID(self)); buffer = (char **)self->location; assert(VALID(buffer)); if (self->processed < self->max) { **buffer = (char)output; (*buffer)++; self->committed++; } self->processed++; } /************************************************************************* * TrioOutStreamStringDynamic */ TRIO_PRIVATE void TrioOutStreamStringDynamic TRIO_ARGS2((self, output), trio_class_t *self, int output) { assert(VALID(self)); assert(VALID(self->location)); if (self->error == 0) { trio_xstring_append_char((trio_string_t *)self->location, (char)output); self->committed++; } /* The processed variable must always be increased */ self->processed++; } /************************************************************************* * * Formatted printing functions * ************************************************************************/ #if defined(TRIO_DOCUMENTATION) # include "doc/doc_printf.h" #endif /** @addtogroup Printf @{ */ #if defined(TRIO_COMPILER_MSVC) # pragma warning(push) # pragma warning(disable : 4700) #endif /************************************************************************* * printf */ /** Print to standard output stream. @param format Formatting string. @param ... Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_printf TRIO_VARGS2((format, va_alist), TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(format)); TRIO_VA_START(args, format); status = TrioFormat(stdout, 0, TrioOutStreamFile, format, args, NULL); TRIO_VA_END(args); return status; } /** Print to standard output stream. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_vprintf TRIO_ARGS2((format, args), TRIO_CONST char *format, va_list args) { assert(VALID(format)); return TrioFormat(stdout, 0, TrioOutStreamFile, format, args, NULL); } /** Print to standard output stream. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_printfv TRIO_ARGS2((format, args), TRIO_CONST char *format, trio_pointer_t * args) { /* * Many compiles will warn about dummy being uninitialized. This * warning is a "false positive"; the dummy variable is not used, * so it does not have be initialized. * * Unfortunately there is no portable way to avoid this warning. * The only correct way to initialize a va_list is to use va_start, * but that requires variadic arguments (ellipsis) in the function * signature, and the printfv does not have this. * * Do not attempt to fix this by setting dummy equal to zero, because * that will fail on platforms/compilers where va_list is implemented * as a struct (which is quite common on 64 bit platforms). */ va_list dummy; assert(VALID(format)); return TrioFormat(stdout, 0, TrioOutStreamFile, format, dummy, args); } /************************************************************************* * fprintf */ /** Print to file. @param file File pointer. @param format Formatting string. @param ... Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_fprintf TRIO_VARGS3((file, format, va_alist), FILE *file, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(file)); assert(VALID(format)); TRIO_VA_START(args, format); status = TrioFormat(file, 0, TrioOutStreamFile, format, args, NULL); TRIO_VA_END(args); return status; } /** Print to file. @param file File pointer. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_vfprintf TRIO_ARGS3((file, format, args), FILE *file, TRIO_CONST char *format, va_list args) { assert(VALID(file)); assert(VALID(format)); return TrioFormat(file, 0, TrioOutStreamFile, format, args, NULL); } /** Print to file. @param file File pointer. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_fprintfv TRIO_ARGS3((file, format, args), FILE *file, TRIO_CONST char *format, trio_pointer_t * args) { va_list dummy; assert(VALID(file)); assert(VALID(format)); return TrioFormat(file, 0, TrioOutStreamFile, format, dummy, args); } /************************************************************************* * dprintf */ /** Print to file descriptor. @param fd File descriptor. @param format Formatting string. @param ... Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_dprintf TRIO_VARGS3((fd, format, va_alist), int fd, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(format)); TRIO_VA_START(args, format); status = TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, args, NULL); TRIO_VA_END(args); return status; } /** Print to file descriptor. @param fd File descriptor. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_vdprintf TRIO_ARGS3((fd, format, args), int fd, TRIO_CONST char *format, va_list args) { assert(VALID(format)); return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, args, NULL); } /** Print to file descriptor. @param fd File descriptor. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_dprintfv TRIO_ARGS3((fd, format, args), int fd, TRIO_CONST char *format, trio_pointer_t *args) { va_list dummy; assert(VALID(format)); return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, dummy, args); } /************************************************************************* * cprintf */ TRIO_PUBLIC int trio_cprintf TRIO_VARGS4((stream, closure, format, va_alist), trio_outstream_t stream, trio_pointer_t closure, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; trio_custom_t data; assert(VALID(stream)); assert(VALID(format)); TRIO_VA_START(args, format); data.stream.out = stream; data.closure = closure; status = TrioFormat(&data, 0, TrioOutStreamCustom, format, args, NULL); TRIO_VA_END(args); return status; } TRIO_PUBLIC int trio_vcprintf TRIO_ARGS4((stream, closure, format, args), trio_outstream_t stream, trio_pointer_t closure, TRIO_CONST char *format, va_list args) { trio_custom_t data; assert(VALID(stream)); assert(VALID(format)); data.stream.out = stream; data.closure = closure; return TrioFormat(&data, 0, TrioOutStreamCustom, format, args, NULL); } TRIO_PUBLIC int trio_cprintfv TRIO_ARGS4((stream, closure, format, args), trio_outstream_t stream, trio_pointer_t closure, TRIO_CONST char *format, void **args) { va_list dummy; trio_custom_t data; assert(VALID(stream)); assert(VALID(format)); data.stream.out = stream; data.closure = closure; return TrioFormat(&data, 0, TrioOutStreamCustom, format, dummy, args); } /************************************************************************* * sprintf */ /** Print to string. @param buffer Output string. @param format Formatting string. @param ... Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_sprintf TRIO_VARGS3((buffer, format, va_alist), char *buffer, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(buffer)); assert(VALID(format)); TRIO_VA_START(args, format); status = TrioFormat(&buffer, 0, TrioOutStreamString, format, args, NULL); *buffer = NIL; /* Terminate with NIL character */ TRIO_VA_END(args); return status; } /** Print to string. @param buffer Output string. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_vsprintf TRIO_ARGS3((buffer, format, args), char *buffer, TRIO_CONST char *format, va_list args) { int status; assert(VALID(buffer)); assert(VALID(format)); status = TrioFormat(&buffer, 0, TrioOutStreamString, format, args, NULL); *buffer = NIL; return status; } /** Print to string. @param buffer Output string. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_sprintfv TRIO_ARGS3((buffer, format, args), char *buffer, TRIO_CONST char *format, trio_pointer_t *args) { int status; va_list dummy; assert(VALID(buffer)); assert(VALID(format)); status = TrioFormat(&buffer, 0, TrioOutStreamString, format, dummy, args); *buffer = NIL; return status; } /************************************************************************* * snprintf */ /** Print at most @p max characters to string. @param buffer Output string. @param max Maximum number of characters to print. @param format Formatting string. @param ... Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_snprintf TRIO_VARGS4((buffer, max, format, va_alist), char *buffer, size_t max, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(buffer)); assert(VALID(format)); TRIO_VA_START(args, format); status = TrioFormat(&buffer, max > 0 ? max - 1 : 0, TrioOutStreamStringMax, format, args, NULL); if (max > 0) *buffer = NIL; TRIO_VA_END(args); return status; } /** Print at most @p max characters to string. @param buffer Output string. @param max Maximum number of characters to print. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_vsnprintf TRIO_ARGS4((buffer, max, format, args), char *buffer, size_t max, TRIO_CONST char *format, va_list args) { int status; assert(VALID(buffer)); assert(VALID(format)); status = TrioFormat(&buffer, max > 0 ? max - 1 : 0, TrioOutStreamStringMax, format, args, NULL); if (max > 0) *buffer = NIL; return status; } /** Print at most @p max characters to string. @param buffer Output string. @param max Maximum number of characters to print. @param format Formatting string. @param args Arguments. @return Number of printed characters. */ TRIO_PUBLIC int trio_snprintfv TRIO_ARGS4((buffer, max, format, args), char *buffer, size_t max, TRIO_CONST char *format, trio_pointer_t *args) { int status; va_list dummy; assert(VALID(buffer)); assert(VALID(format)); status = TrioFormat(&buffer, max > 0 ? max - 1 : 0, TrioOutStreamStringMax, format, dummy, args); if (max > 0) *buffer = NIL; return status; } /************************************************************************* * snprintfcat * Appends the new string to the buffer string overwriting the '\0' * character at the end of buffer. */ TRIO_PUBLIC int trio_snprintfcat TRIO_VARGS4((buffer, max, format, va_alist), char *buffer, size_t max, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; size_t buf_len; TRIO_VA_START(args, format); assert(VALID(buffer)); assert(VALID(format)); buf_len = trio_length(buffer); buffer = &buffer[buf_len]; status = TrioFormat(&buffer, max - 1 - buf_len, TrioOutStreamStringMax, format, args, NULL); TRIO_VA_END(args); *buffer = NIL; return status; } TRIO_PUBLIC int trio_vsnprintfcat TRIO_ARGS4((buffer, max, format, args), char *buffer, size_t max, TRIO_CONST char *format, va_list args) { int status; size_t buf_len; assert(VALID(buffer)); assert(VALID(format)); buf_len = trio_length(buffer); buffer = &buffer[buf_len]; status = TrioFormat(&buffer, max - 1 - buf_len, TrioOutStreamStringMax, format, args, NULL); *buffer = NIL; return status; } /************************************************************************* * trio_aprintf */ /* Deprecated */ TRIO_PUBLIC char * trio_aprintf TRIO_VARGS2((format, va_alist), TRIO_CONST char *format, TRIO_VA_DECL) { va_list args; trio_string_t *info; char *result = NULL; assert(VALID(format)); info = trio_xstring_duplicate(""); if (info) { TRIO_VA_START(args, format); (void)TrioFormat(info, 0, TrioOutStreamStringDynamic, format, args, NULL); TRIO_VA_END(args); trio_string_terminate(info); result = trio_string_extract(info); trio_string_destroy(info); } return result; } /* Deprecated */ TRIO_PUBLIC char * trio_vaprintf TRIO_ARGS2((format, args), TRIO_CONST char *format, va_list args) { trio_string_t *info; char *result = NULL; assert(VALID(format)); info = trio_xstring_duplicate(""); if (info) { (void)TrioFormat(info, 0, TrioOutStreamStringDynamic, format, args, NULL); trio_string_terminate(info); result = trio_string_extract(info); trio_string_destroy(info); } return result; } TRIO_PUBLIC int trio_asprintf TRIO_VARGS3((result, format, va_alist), char **result, TRIO_CONST char *format, TRIO_VA_DECL) { va_list args; int status; trio_string_t *info; assert(VALID(format)); *result = NULL; info = trio_xstring_duplicate(""); if (info == NULL) { status = TRIO_ERROR_RETURN(TRIO_ENOMEM, 0); } else { TRIO_VA_START(args, format); status = TrioFormat(info, 0, TrioOutStreamStringDynamic, format, args, NULL); TRIO_VA_END(args); if (status >= 0) { trio_string_terminate(info); *result = trio_string_extract(info); } trio_string_destroy(info); } return status; } TRIO_PUBLIC int trio_vasprintf TRIO_ARGS3((result, format, args), char **result, TRIO_CONST char *format, va_list args) { int status; trio_string_t *info; assert(VALID(format)); *result = NULL; info = trio_xstring_duplicate(""); if (info == NULL) { status = TRIO_ERROR_RETURN(TRIO_ENOMEM, 0); } else { status = TrioFormat(info, 0, TrioOutStreamStringDynamic, format, args, NULL); if (status >= 0) { trio_string_terminate(info); *result = trio_string_extract(info); } trio_string_destroy(info); } return status; } #if defined(TRIO_COMPILER_MSVC) # pragma warning(pop) #endif /** @} End of Printf documentation module */ /************************************************************************* * * CALLBACK * ************************************************************************/ #if defined(TRIO_DOCUMENTATION) # include "doc/doc_register.h" #endif /** @addtogroup UserDefined @{ */ #if TRIO_EXTENSION /************************************************************************* * trio_register */ /** Register new user-defined specifier. @param callback @param name @return Handle. */ TRIO_PUBLIC trio_pointer_t trio_register TRIO_ARGS2((callback, name), trio_callback_t callback, TRIO_CONST char *name) { trio_userdef_t *def; trio_userdef_t *prev = NULL; if (callback == NULL) return NULL; if (name) { /* Handle built-in namespaces */ if (name[0] == ':') { if (trio_equal(name, ":enter")) { internalEnterCriticalRegion = callback; } else if (trio_equal(name, ":leave")) { internalLeaveCriticalRegion = callback; } return NULL; } /* Bail out if namespace is too long */ if (trio_length(name) >= MAX_USER_NAME) return NULL; /* Bail out if namespace already is registered */ def = TrioFindNamespace(name, &prev); if (def) return NULL; } def = (trio_userdef_t *)TRIO_MALLOC(sizeof(trio_userdef_t)); if (def) { if (internalEnterCriticalRegion) (void)internalEnterCriticalRegion(NULL); if (name) { /* Link into internal list */ if (prev == NULL) internalUserDef = def; else prev->next = def; } /* Initialize */ def->callback = callback; def->name = (name == NULL) ? NULL : trio_duplicate(name); def->next = NULL; if (internalLeaveCriticalRegion) (void)internalLeaveCriticalRegion(NULL); } return (trio_pointer_t)def; } /** Unregister an existing user-defined specifier. @param handle */ void trio_unregister TRIO_ARGS1((handle), trio_pointer_t handle) { trio_userdef_t *self = (trio_userdef_t *)handle; trio_userdef_t *def; trio_userdef_t *prev = NULL; assert(VALID(self)); if (self->name) { def = TrioFindNamespace(self->name, &prev); if (def) { if (internalEnterCriticalRegion) (void)internalEnterCriticalRegion(NULL); if (prev == NULL) internalUserDef = NULL; else prev->next = def->next; if (internalLeaveCriticalRegion) (void)internalLeaveCriticalRegion(NULL); } trio_destroy(self->name); } TRIO_FREE(self); } /************************************************************************* * trio_get_format [public] */ TRIO_CONST char * trio_get_format TRIO_ARGS1((ref), trio_pointer_t ref) { #if defined(FORMAT_USER_DEFINED) assert(((trio_reference_t *)ref)->parameter->type == FORMAT_USER_DEFINED); #endif return (((trio_reference_t *)ref)->parameter->user_data); } /************************************************************************* * trio_get_argument [public] */ trio_pointer_t trio_get_argument TRIO_ARGS1((ref), trio_pointer_t ref) { #if defined(FORMAT_USER_DEFINED) assert(((trio_reference_t *)ref)->parameter->type == FORMAT_USER_DEFINED); #endif return ((trio_reference_t *)ref)->parameter->data.pointer; } /************************************************************************* * trio_get_width / trio_set_width [public] */ int trio_get_width TRIO_ARGS1((ref), trio_pointer_t ref) { return ((trio_reference_t *)ref)->parameter->width; } void trio_set_width TRIO_ARGS2((ref, width), trio_pointer_t ref, int width) { ((trio_reference_t *)ref)->parameter->width = width; } /************************************************************************* * trio_get_precision / trio_set_precision [public] */ int trio_get_precision TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->precision); } void trio_set_precision TRIO_ARGS2((ref, precision), trio_pointer_t ref, int precision) { ((trio_reference_t *)ref)->parameter->precision = precision; } /************************************************************************* * trio_get_base / trio_set_base [public] */ int trio_get_base TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->base); } void trio_set_base TRIO_ARGS2((ref, base), trio_pointer_t ref, int base) { ((trio_reference_t *)ref)->parameter->base = base; } /************************************************************************* * trio_get_long / trio_set_long [public] */ int trio_get_long TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_LONG); } void trio_set_long TRIO_ARGS2((ref, is_long), trio_pointer_t ref, int is_long) { if (is_long) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_LONG; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_LONG; } /************************************************************************* * trio_get_longlong / trio_set_longlong [public] */ int trio_get_longlong TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_QUAD); } void trio_set_longlong TRIO_ARGS2((ref, is_longlong), trio_pointer_t ref, int is_longlong) { if (is_longlong) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_QUAD; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_QUAD; } /************************************************************************* * trio_get_longdouble / trio_set_longdouble [public] */ int trio_get_longdouble TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_LONGDOUBLE); } void trio_set_longdouble TRIO_ARGS2((ref, is_longdouble), trio_pointer_t ref, int is_longdouble) { if (is_longdouble) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_LONGDOUBLE; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_LONGDOUBLE; } /************************************************************************* * trio_get_short / trio_set_short [public] */ int trio_get_short TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SHORT); } void trio_set_short TRIO_ARGS2((ref, is_short), trio_pointer_t ref, int is_short) { if (is_short) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SHORT; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SHORT; } /************************************************************************* * trio_get_shortshort / trio_set_shortshort [public] */ int trio_get_shortshort TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SHORTSHORT); } void trio_set_shortshort TRIO_ARGS2((ref, is_shortshort), trio_pointer_t ref, int is_shortshort) { if (is_shortshort) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SHORTSHORT; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SHORTSHORT; } /************************************************************************* * trio_get_alternative / trio_set_alternative [public] */ int trio_get_alternative TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_ALTERNATIVE); } void trio_set_alternative TRIO_ARGS2((ref, is_alternative), trio_pointer_t ref, int is_alternative) { if (is_alternative) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_ALTERNATIVE; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_ALTERNATIVE; } /************************************************************************* * trio_get_alignment / trio_set_alignment [public] */ int trio_get_alignment TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_LEFTADJUST); } void trio_set_alignment TRIO_ARGS2((ref, is_leftaligned), trio_pointer_t ref, int is_leftaligned) { if (is_leftaligned) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_LEFTADJUST; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_LEFTADJUST; } /************************************************************************* * trio_get_spacing /trio_set_spacing [public] */ int trio_get_spacing TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SPACE); } void trio_set_spacing TRIO_ARGS2((ref, is_space), trio_pointer_t ref, int is_space) { if (is_space) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SPACE; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SPACE; } /************************************************************************* * trio_get_sign / trio_set_sign [public] */ int trio_get_sign TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SHOWSIGN); } void trio_set_sign TRIO_ARGS2((ref, is_sign), trio_pointer_t ref, int is_sign) { if (is_sign) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SHOWSIGN; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SHOWSIGN; } /************************************************************************* * trio_get_padding / trio_set_padding [public] */ int trio_get_padding TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_NILPADDING); } void trio_set_padding TRIO_ARGS2((ref, is_padding), trio_pointer_t ref, int is_padding) { if (is_padding) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_NILPADDING; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_NILPADDING; } /************************************************************************* * trio_get_quote / trio_set_quote [public] */ int trio_get_quote TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_QUOTE); } void trio_set_quote TRIO_ARGS2((ref, is_quote), trio_pointer_t ref, int is_quote) { if (is_quote) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_QUOTE; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_QUOTE; } /************************************************************************* * trio_get_upper / trio_set_upper [public] */ int trio_get_upper TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_UPPER); } void trio_set_upper TRIO_ARGS2((ref, is_upper), trio_pointer_t ref, int is_upper) { if (is_upper) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_UPPER; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_UPPER; } /************************************************************************* * trio_get_largest / trio_set_largest [public] */ #if TRIO_C99 int trio_get_largest TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_INTMAX_T); } void trio_set_largest TRIO_ARGS2((ref, is_largest), trio_pointer_t ref, int is_largest) { if (is_largest) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_INTMAX_T; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_INTMAX_T; } #endif /************************************************************************* * trio_get_ptrdiff / trio_set_ptrdiff [public] */ int trio_get_ptrdiff TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_PTRDIFF_T); } void trio_set_ptrdiff TRIO_ARGS2((ref, is_ptrdiff), trio_pointer_t ref, int is_ptrdiff) { if (is_ptrdiff) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_PTRDIFF_T; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_PTRDIFF_T; } /************************************************************************* * trio_get_size / trio_set_size [public] */ #if TRIO_C99 int trio_get_size TRIO_ARGS1((ref), trio_pointer_t ref) { return (((trio_reference_t *)ref)->parameter->flags & FLAGS_SIZE_T); } void trio_set_size TRIO_ARGS2((ref, is_size), trio_pointer_t ref, int is_size) { if (is_size) ((trio_reference_t *)ref)->parameter->flags |= FLAGS_SIZE_T; else ((trio_reference_t *)ref)->parameter->flags &= ~FLAGS_SIZE_T; } #endif /************************************************************************* * trio_print_int [public] */ void trio_print_int TRIO_ARGS2((ref, number), trio_pointer_t ref, int number) { trio_reference_t *self = (trio_reference_t *)ref; TrioWriteNumber(self->data, (trio_uintmax_t)number, self->parameter->flags, self->parameter->width, self->parameter->precision, self->parameter->base); } /************************************************************************* * trio_print_uint [public] */ void trio_print_uint TRIO_ARGS2((ref, number), trio_pointer_t ref, unsigned int number) { trio_reference_t *self = (trio_reference_t *)ref; TrioWriteNumber(self->data, (trio_uintmax_t)number, self->parameter->flags | FLAGS_UNSIGNED, self->parameter->width, self->parameter->precision, self->parameter->base); } /************************************************************************* * trio_print_double [public] */ void trio_print_double TRIO_ARGS2((ref, number), trio_pointer_t ref, double number) { trio_reference_t *self = (trio_reference_t *)ref; TrioWriteDouble(self->data, number, self->parameter->flags, self->parameter->width, self->parameter->precision, self->parameter->base); } /************************************************************************* * trio_print_string [public] */ void trio_print_string TRIO_ARGS2((ref, string), trio_pointer_t ref, char *string) { trio_reference_t *self = (trio_reference_t *)ref; TrioWriteString(self->data, string, self->parameter->flags, self->parameter->width, self->parameter->precision); } /************************************************************************* * trio_print_ref [public] */ int trio_print_ref TRIO_VARGS3((ref, format, va_alist), trio_pointer_t ref, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list arglist; assert(VALID(format)); TRIO_VA_START(arglist, format); status = TrioFormatRef((trio_reference_t *)ref, format, arglist, NULL); TRIO_VA_END(arglist); return status; } /************************************************************************* * trio_vprint_ref [public] */ int trio_vprint_ref TRIO_ARGS3((ref, format, arglist), trio_pointer_t ref, TRIO_CONST char *format, va_list arglist) { assert(VALID(format)); return TrioFormatRef((trio_reference_t *)ref, format, arglist, NULL); } /************************************************************************* * trio_printv_ref [public] */ int trio_printv_ref TRIO_ARGS3((ref, format, argarray), trio_pointer_t ref, TRIO_CONST char *format, trio_pointer_t *argarray) { va_list dummy; assert(VALID(format)); return TrioFormatRef((trio_reference_t *)ref, format, dummy, argarray); } #endif /* TRIO_EXTENSION */ /************************************************************************* * trio_print_pointer [public] */ void trio_print_pointer TRIO_ARGS2((ref, pointer), trio_pointer_t ref, trio_pointer_t pointer) { trio_reference_t *self = (trio_reference_t *)ref; unsigned long flags; trio_uintmax_t number; if (NULL == pointer) { TRIO_CONST char *string = internalNullString; while (*string) self->data->OutStream(self->data, *string++); } else { /* * The subtraction of the null pointer is a workaround * to avoid a compiler warning. The performance overhead * is negligible (and likely to be removed by an * optimizing compiler). The (char *) casting is done * to please ANSI C++. */ number = (trio_uintmax_t)((char *)pointer - (char *)0); /* Shrink to size of pointer */ number &= (trio_uintmax_t)-1; flags = self->parameter->flags; flags |= (FLAGS_UNSIGNED | FLAGS_ALTERNATIVE | FLAGS_NILPADDING); TrioWriteNumber(self->data, number, flags, POINTER_WIDTH, NO_PRECISION, BASE_HEX); } } /** @} End of UserDefined documentation module */ /************************************************************************* * * LOCALES * ************************************************************************/ /************************************************************************* * trio_locale_set_decimal_point * * Decimal point can only be one character. The input argument is a * string to enable multibyte characters. At most MB_LEN_MAX characters * will be used. */ TRIO_PUBLIC void trio_locale_set_decimal_point TRIO_ARGS1((decimalPoint), char *decimalPoint) { #if defined(USE_LOCALE) if (NULL == internalLocaleValues) { TrioSetLocale(); } #endif internalDecimalPointLength = trio_length(decimalPoint); if (internalDecimalPointLength == 1) { internalDecimalPoint = *decimalPoint; } else { internalDecimalPoint = NIL; trio_copy_max(internalDecimalPointString, sizeof(internalDecimalPointString), decimalPoint); } } /************************************************************************* * trio_locale_set_thousand_separator * * See trio_locale_set_decimal_point */ TRIO_PUBLIC void trio_locale_set_thousand_separator TRIO_ARGS1((thousandSeparator), char *thousandSeparator) { #if defined(USE_LOCALE) if (NULL == internalLocaleValues) { TrioSetLocale(); } #endif trio_copy_max(internalThousandSeparator, sizeof(internalThousandSeparator), thousandSeparator); internalThousandSeparatorLength = trio_length(internalThousandSeparator); } /************************************************************************* * trio_locale_set_grouping * * Array of bytes. Reversed order. * * CHAR_MAX : No further grouping * 0 : Repeat last group for the remaining digits (not necessary * as C strings are zero-terminated) * n : Set current group to n * * Same order as the grouping attribute in LC_NUMERIC. */ TRIO_PUBLIC void trio_locale_set_grouping TRIO_ARGS1((grouping), char *grouping) { #if defined(USE_LOCALE) if (NULL == internalLocaleValues) { TrioSetLocale(); } #endif trio_copy_max(internalGrouping, sizeof(internalGrouping), grouping); } /************************************************************************* * * SCANNING * ************************************************************************/ /************************************************************************* * TrioSkipWhitespaces */ TRIO_PRIVATE int TrioSkipWhitespaces TRIO_ARGS1((self), trio_class_t *self) { int ch; ch = self->current; while (isspace(ch)) { self->InStream(self, &ch); } return ch; } /************************************************************************* * TrioGetCollation */ #if TRIO_EXTENSION TRIO_PRIVATE void TrioGetCollation(TRIO_NOARGS) { int i; int j; int k; char first[2]; char second[2]; /* This is computational expensive */ first[1] = NIL; second[1] = NIL; for (i = 0; i < MAX_CHARACTER_CLASS; i++) { k = 0; first[0] = (char)i; for (j = 0; j < MAX_CHARACTER_CLASS; j++) { second[0] = (char)j; if (trio_equal_locale(first, second)) internalCollationArray[i][k++] = (char)j; } internalCollationArray[i][k] = NIL; } } #endif /************************************************************************* * TrioGetCharacterClass * * FIXME: * multibyte */ TRIO_PRIVATE int TrioGetCharacterClass TRIO_ARGS4((format, indexPointer, flagsPointer, characterclass), TRIO_CONST char *format, int *indexPointer, unsigned long *flagsPointer, int *characterclass) { int index = *indexPointer; int i; char ch; char range_begin; char range_end; *flagsPointer &= ~FLAGS_EXCLUDE; if (format[index] == QUALIFIER_CIRCUMFLEX) { *flagsPointer |= FLAGS_EXCLUDE; index++; } /* * If the ungroup character is at the beginning of the scanlist, * it will be part of the class, and a second ungroup character * must follow to end the group. */ if (format[index] == SPECIFIER_UNGROUP) { characterclass[(int)SPECIFIER_UNGROUP]++; index++; } /* * Minus is used to specify ranges. To include minus in the class, * it must be at the beginning of the list */ if (format[index] == QUALIFIER_MINUS) { characterclass[(int)QUALIFIER_MINUS]++; index++; } /* Collect characters */ for (ch = format[index]; (ch != SPECIFIER_UNGROUP) && (ch != NIL); ch = format[++index]) { switch (ch) { case QUALIFIER_MINUS: /* Scanlist ranges */ /* * Both C99 and UNIX98 describes ranges as implementation- * defined. * * We support the following behaviour (although this may * change as we become wiser) * - only increasing ranges, ie. [a-b] but not [b-a] * - transitive ranges, ie. [a-b-c] == [a-c] * - trailing minus, ie. [a-] is interpreted as an 'a' * and a '-' * - duplicates (although we can easily convert these * into errors) */ range_begin = format[index - 1]; range_end = format[++index]; if (range_end == SPECIFIER_UNGROUP) { /* Trailing minus is included */ characterclass[(int)ch]++; ch = range_end; break; /* for */ } if (range_end == NIL) return TRIO_ERROR_RETURN(TRIO_EINVAL, index); if (range_begin > range_end) return TRIO_ERROR_RETURN(TRIO_ERANGE, index); for (i = (int)range_begin; i <= (int)range_end; i++) characterclass[i]++; ch = range_end; break; #if TRIO_EXTENSION case SPECIFIER_GROUP: switch (format[index + 1]) { case QUALIFIER_DOT: /* Collating symbol */ /* * FIXME: This will be easier to implement when multibyte * characters have been implemented. Until now, we ignore * this feature. */ for (i = index + 2; ; i++) { if (format[i] == NIL) /* Error in syntax */ return -1; else if (format[i] == QUALIFIER_DOT) break; /* for */ } if (format[++i] != SPECIFIER_UNGROUP) return -1; index = i; break; case QUALIFIER_EQUAL: /* Equivalence class expressions */ { unsigned int j; unsigned int k; if (internalCollationUnconverted) { /* Lazy evaluation of collation array */ TrioGetCollation(); internalCollationUnconverted = FALSE; } for (i = index + 2; ; i++) { if (format[i] == NIL) /* Error in syntax */ return -1; else if (format[i] == QUALIFIER_EQUAL) break; /* for */ else { /* Mark any equivalent character */ k = (unsigned int)format[i]; for (j = 0; internalCollationArray[k][j] != NIL; j++) characterclass[(int)internalCollationArray[k][j]]++; } } if (format[++i] != SPECIFIER_UNGROUP) return -1; index = i; } break; case QUALIFIER_COLON: /* Character class expressions */ if (trio_equal_max(CLASS_ALNUM, sizeof(CLASS_ALNUM) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (isalnum(i)) characterclass[i]++; index += sizeof(CLASS_ALNUM) - 1; } else if (trio_equal_max(CLASS_ALPHA, sizeof(CLASS_ALPHA) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (isalpha(i)) characterclass[i]++; index += sizeof(CLASS_ALPHA) - 1; } else if (trio_equal_max(CLASS_CNTRL, sizeof(CLASS_CNTRL) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (iscntrl(i)) characterclass[i]++; index += sizeof(CLASS_CNTRL) - 1; } else if (trio_equal_max(CLASS_DIGIT, sizeof(CLASS_DIGIT) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (isdigit(i)) characterclass[i]++; index += sizeof(CLASS_DIGIT) - 1; } else if (trio_equal_max(CLASS_GRAPH, sizeof(CLASS_GRAPH) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (isgraph(i)) characterclass[i]++; index += sizeof(CLASS_GRAPH) - 1; } else if (trio_equal_max(CLASS_LOWER, sizeof(CLASS_LOWER) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (islower(i)) characterclass[i]++; index += sizeof(CLASS_LOWER) - 1; } else if (trio_equal_max(CLASS_PRINT, sizeof(CLASS_PRINT) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (isprint(i)) characterclass[i]++; index += sizeof(CLASS_PRINT) - 1; } else if (trio_equal_max(CLASS_PUNCT, sizeof(CLASS_PUNCT) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (ispunct(i)) characterclass[i]++; index += sizeof(CLASS_PUNCT) - 1; } else if (trio_equal_max(CLASS_SPACE, sizeof(CLASS_SPACE) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (isspace(i)) characterclass[i]++; index += sizeof(CLASS_SPACE) - 1; } else if (trio_equal_max(CLASS_UPPER, sizeof(CLASS_UPPER) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (isupper(i)) characterclass[i]++; index += sizeof(CLASS_UPPER) - 1; } else if (trio_equal_max(CLASS_XDIGIT, sizeof(CLASS_XDIGIT) - 1, &format[index])) { for (i = 0; i < MAX_CHARACTER_CLASS; i++) if (isxdigit(i)) characterclass[i]++; index += sizeof(CLASS_XDIGIT) - 1; } else { characterclass[(int)ch]++; } break; default: characterclass[(int)ch]++; break; } break; #endif /* TRIO_EXTENSION */ default: characterclass[(int)ch]++; break; } } return 0; } /************************************************************************* * TrioReadNumber * * We implement our own number conversion in preference of strtol and * strtoul, because we must handle 'long long' and thousand separators. */ TRIO_PRIVATE BOOLEAN_T TrioReadNumber TRIO_ARGS5((self, target, flags, width, base), trio_class_t *self, trio_uintmax_t *target, unsigned long flags, int width, int base) { trio_uintmax_t number = 0; int digit; int count; BOOLEAN_T isNegative = FALSE; BOOLEAN_T gotNumber = FALSE; int j; assert(VALID(self)); assert(VALID(self->InStream)); assert((base >= MIN_BASE && base <= MAX_BASE) || (base == NO_BASE)); if (internalDigitsUnconverted) { /* Lazy evaluation of digits array */ memset(internalDigitArray, -1, sizeof(internalDigitArray)); for (j = 0; j < (int)sizeof(internalDigitsLower) - 1; j++) { internalDigitArray[(int)internalDigitsLower[j]] = j; internalDigitArray[(int)internalDigitsUpper[j]] = j; } internalDigitsUnconverted = FALSE; } TrioSkipWhitespaces(self); if (!(flags & FLAGS_UNSIGNED)) { /* Leading sign */ if (self->current == '+') { self->InStream(self, NULL); } else if (self->current == '-') { self->InStream(self, NULL); isNegative = TRUE; } } count = self->processed; if (flags & FLAGS_ALTERNATIVE) { switch (base) { case NO_BASE: case BASE_OCTAL: case BASE_HEX: case BASE_BINARY: if (self->current == '0') { self->InStream(self, NULL); if (self->current) { if ((base == BASE_HEX) && (toupper(self->current) == 'X')) { self->InStream(self, NULL); } else if ((base == BASE_BINARY) && (toupper(self->current) == 'B')) { self->InStream(self, NULL); } } } else return FALSE; break; default: break; } } while (((width == NO_WIDTH) || (self->processed - count < width)) && (! ((self->current == EOF) || isspace(self->current)))) { if (isascii(self->current)) { digit = internalDigitArray[self->current]; /* Abort if digit is not allowed in the specified base */ if ((digit == -1) || (digit >= base)) break; } else if (flags & FLAGS_QUOTE) { /* Compare with thousands separator */ for (j = 0; internalThousandSeparator[j] && self->current; j++) { if (internalThousandSeparator[j] != self->current) break; self->InStream(self, NULL); } if (internalThousandSeparator[j]) break; /* Mismatch */ else continue; /* Match */ } else break; number *= base; number += digit; gotNumber = TRUE; /* we need at least one digit */ self->InStream(self, NULL); } /* Was anything read at all? */ if (!gotNumber) return FALSE; if (target) *target = (isNegative) ? -((trio_intmax_t)number) : number; return TRUE; } /************************************************************************* * TrioReadChar */ TRIO_PRIVATE int TrioReadChar TRIO_ARGS4((self, target, flags, width), trio_class_t *self, char *target, unsigned long flags, int width) { int i; char ch; trio_uintmax_t number; assert(VALID(self)); assert(VALID(self->InStream)); for (i = 0; (self->current != EOF) && (i < width); i++) { ch = (char)self->current; self->InStream(self, NULL); if ((flags & FLAGS_ALTERNATIVE) && (ch == CHAR_BACKSLASH)) { switch (self->current) { case '\\': ch = '\\'; break; case 'a': ch = '\007'; break; case 'b': ch = '\b'; break; case 'f': ch = '\f'; break; case 'n': ch = '\n'; break; case 'r': ch = '\r'; break; case 't': ch = '\t'; break; case 'v': ch = '\v'; break; default: if (isdigit(self->current)) { /* Read octal number */ if (!TrioReadNumber(self, &number, 0, 3, BASE_OCTAL)) return 0; ch = (char)number; } else if (toupper(self->current) == 'X') { /* Read hexadecimal number */ self->InStream(self, NULL); if (!TrioReadNumber(self, &number, 0, 2, BASE_HEX)) return 0; ch = (char)number; } else { ch = (char)self->current; } break; } } if (target) target[i] = ch; } return i + 1; } /************************************************************************* * TrioReadString */ TRIO_PRIVATE BOOLEAN_T TrioReadString TRIO_ARGS4((self, target, flags, width), trio_class_t *self, char *target, unsigned long flags, int width) { int i; assert(VALID(self)); assert(VALID(self->InStream)); TrioSkipWhitespaces(self); /* * Continue until end of string is reached, a whitespace is encountered, * or width is exceeded */ for (i = 0; ((width == NO_WIDTH) || (i < width)) && (! ((self->current == EOF) || isspace(self->current))); i++) { if (TrioReadChar(self, (target ? &target[i] : 0), flags, 1) == 0) break; /* for */ } if (target) target[i] = NIL; return TRUE; } /************************************************************************* * TrioReadWideChar */ #if TRIO_WIDECHAR TRIO_PRIVATE int TrioReadWideChar TRIO_ARGS4((self, target, flags, width), trio_class_t *self, trio_wchar_t *target, unsigned long flags, int width) { int i; int j; int size; int amount = 0; trio_wchar_t wch; char buffer[MB_LEN_MAX + 1]; assert(VALID(self)); assert(VALID(self->InStream)); for (i = 0; (self->current != EOF) && (i < width); i++) { if (isascii(self->current)) { if (TrioReadChar(self, buffer, flags, 1) == 0) return 0; buffer[1] = NIL; } else { /* * Collect a multibyte character, by enlarging buffer until * it contains a fully legal multibyte character, or the * buffer is full. */ j = 0; do { buffer[j++] = (char)self->current; buffer[j] = NIL; self->InStream(self, NULL); } while ((j < (int)sizeof(buffer)) && (mblen(buffer, (size_t)j) != j)); } if (target) { size = mbtowc(&wch, buffer, sizeof(buffer)); if (size > 0) target[i] = wch; } amount += size; self->InStream(self, NULL); } return amount; } #endif /* TRIO_WIDECHAR */ /************************************************************************* * TrioReadWideString */ #if TRIO_WIDECHAR TRIO_PRIVATE BOOLEAN_T TrioReadWideString TRIO_ARGS4((self, target, flags, width), trio_class_t *self, trio_wchar_t *target, unsigned long flags, int width) { int i; int size; assert(VALID(self)); assert(VALID(self->InStream)); TrioSkipWhitespaces(self); #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) mblen(NULL, 0); #endif /* * Continue until end of string is reached, a whitespace is encountered, * or width is exceeded */ for (i = 0; ((width == NO_WIDTH) || (i < width)) && (! ((self->current == EOF) || isspace(self->current))); ) { size = TrioReadWideChar(self, &target[i], flags, 1); if (size == 0) break; /* for */ i += size; } if (target) target[i] = WCONST('\0'); return TRUE; } #endif /* TRIO_WIDECHAR */ /************************************************************************* * TrioReadGroup * * FIXME: characterclass does not work with multibyte characters */ TRIO_PRIVATE BOOLEAN_T TrioReadGroup TRIO_ARGS5((self, target, characterclass, flags, width), trio_class_t *self, char *target, int *characterclass, unsigned long flags, int width) { int ch; int i; assert(VALID(self)); assert(VALID(self->InStream)); ch = self->current; for (i = 0; ((width == NO_WIDTH) || (i < width)) && (! ((ch == EOF) || (((flags & FLAGS_EXCLUDE) != 0) ^ (characterclass[ch] == 0)))); i++) { if (target) target[i] = (char)ch; self->InStream(self, &ch); } if (target) target[i] = NIL; return TRUE; } /************************************************************************* * TrioReadDouble * * FIXME: * add long double * handle base */ TRIO_PRIVATE BOOLEAN_T TrioReadDouble TRIO_ARGS4((self, target, flags, width), trio_class_t *self, trio_pointer_t target, unsigned long flags, int width) { int ch; char doubleString[512]; int index = 0; int start; int j; BOOLEAN_T isHex = FALSE; doubleString[0] = 0; if ((width == NO_WIDTH) || (width > (int)sizeof(doubleString) - 1)) width = sizeof(doubleString) - 1; TrioSkipWhitespaces(self); /* * Read entire double number from stream. trio_to_double requires * a string as input, but InStream can be anything, so we have to * collect all characters. */ ch = self->current; if ((ch == '+') || (ch == '-')) { doubleString[index++] = (char)ch; self->InStream(self, &ch); width--; } start = index; switch (ch) { case 'n': case 'N': /* Not-a-number */ if (index != 0) break; /* FALLTHROUGH */ case 'i': case 'I': /* Infinity */ while (isalpha(ch) && (index - start < width)) { doubleString[index++] = (char)ch; self->InStream(self, &ch); } doubleString[index] = NIL; /* Case insensitive string comparison */ if (trio_equal(&doubleString[start], INFINITE_UPPER) || trio_equal(&doubleString[start], LONG_INFINITE_UPPER)) { if (flags & FLAGS_LONGDOUBLE) { if ((start == 1) && (doubleString[0] == '-')) { *((trio_long_double_t *)target) = trio_ninf(); } else { *((trio_long_double_t *)target) = trio_pinf(); } } else { if ((start == 1) && (doubleString[0] == '-')) { *((double *)target) = trio_ninf(); } else { *((double *)target) = trio_pinf(); } } return TRUE; } if (trio_equal(doubleString, NAN_UPPER)) { /* NaN must not have a preceeding + nor - */ if (flags & FLAGS_LONGDOUBLE) { *((trio_long_double_t *)target) = trio_nan(); } else { *((double *)target) = trio_nan(); } return TRUE; } return FALSE; case '0': doubleString[index++] = (char)ch; self->InStream(self, &ch); if (toupper(ch) == 'X') { isHex = TRUE; doubleString[index++] = (char)ch; self->InStream(self, &ch); } break; default: break; } while ((ch != EOF) && (index - start < width)) { /* Integer part */ if (isHex ? isxdigit(ch) : isdigit(ch)) { doubleString[index++] = (char)ch; self->InStream(self, &ch); } else if (flags & FLAGS_QUOTE) { /* Compare with thousands separator */ for (j = 0; internalThousandSeparator[j] && self->current; j++) { if (internalThousandSeparator[j] != self->current) break; self->InStream(self, &ch); } if (internalThousandSeparator[j]) break; /* Mismatch */ else continue; /* Match */ } else break; /* while */ } if (ch == '.') { /* Decimal part */ doubleString[index++] = (char)ch; self->InStream(self, &ch); while ((isHex ? isxdigit(ch) : isdigit(ch)) && (index - start < width)) { doubleString[index++] = (char)ch; self->InStream(self, &ch); } if (isHex ? (toupper(ch) == 'P') : (toupper(ch) == 'E')) { /* Exponent */ doubleString[index++] = (char)ch; self->InStream(self, &ch); if ((ch == '+') || (ch == '-')) { doubleString[index++] = (char)ch; self->InStream(self, &ch); } while ((isHex ? isxdigit(ch) : isdigit(ch)) && (index - start < width)) { doubleString[index++] = (char)ch; self->InStream(self, &ch); } } } if ((index == start) || (*doubleString == NIL)) return FALSE; doubleString[index] = 0; if (flags & FLAGS_LONGDOUBLE) { *((trio_long_double_t *)target) = trio_to_long_double(doubleString, NULL); } else { *((double *)target) = trio_to_double(doubleString, NULL); } return TRUE; } /************************************************************************* * TrioReadPointer */ TRIO_PRIVATE BOOLEAN_T TrioReadPointer TRIO_ARGS3((self, target, flags), trio_class_t *self, trio_pointer_t *target, unsigned long flags) { trio_uintmax_t number; char buffer[sizeof(internalNullString)]; flags |= (FLAGS_UNSIGNED | FLAGS_ALTERNATIVE | FLAGS_NILPADDING); if (TrioReadNumber(self, &number, flags, POINTER_WIDTH, BASE_HEX)) { /* * The strange assignment of number is a workaround for a compiler * warning */ if (target) *target = (char *)0 + number; return TRUE; } else if (TrioReadString(self, (flags & FLAGS_IGNORE) ? NULL : buffer, 0, sizeof(internalNullString) - 1)) { if (trio_equal_case(buffer, internalNullString)) { if (target) *target = NULL; return TRUE; } } return FALSE; } /************************************************************************* * TrioScanProcess */ TRIO_PRIVATE int TrioScanProcess TRIO_ARGS3((data, format, parameters), trio_class_t *data, TRIO_CONST char *format, trio_parameter_t *parameters) { #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) int charlen; int cnt; #endif int assignment; int ch; int index; /* Index of format string */ int i; /* Index of current parameter */ unsigned long flags; int width; int base; trio_pointer_t pointer; assignment = 0; i = 0; index = 0; data->InStream(data, &ch); #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) mblen(NULL, 0); #endif while (format[index]) { #if defined(TRIO_COMPILER_SUPPORTS_MULTIBYTE) if (! isascii(format[index])) { charlen = mblen(&format[index], MB_LEN_MAX); /* Compare multibyte characters in format string */ for (cnt = 0; cnt < charlen - 1; cnt++) { if (ch != format[index + cnt]) { return TRIO_ERROR_RETURN(TRIO_EINVAL, index); } data->InStream(data, &ch); } continue; /* while */ } #endif /* TRIO_COMPILER_SUPPORTS_MULTIBYTE */ if ((EOF == ch) && (parameters[i].type != FORMAT_COUNT)) { return (assignment > 0) ? assignment : EOF; } if (CHAR_IDENTIFIER == format[index]) { if (CHAR_IDENTIFIER == format[index + 1]) { /* Two % in format matches one % in input stream */ if (CHAR_IDENTIFIER == ch) { data->InStream(data, &ch); index += 2; continue; /* while format chars left */ } else return TRIO_ERROR_RETURN(TRIO_EINVAL, index); } /* Skip the parameter entries */ while (parameters[i].type == FORMAT_PARAMETER) i++; flags = parameters[i].flags; /* Find width */ width = parameters[i].width; if (flags & FLAGS_WIDTH_PARAMETER) { /* Get width from parameter list */ width = (int)parameters[width].data.number.as_signed; } /* Find base */ base = parameters[i].base; if (flags & FLAGS_BASE_PARAMETER) { /* Get base from parameter list */ base = (int)parameters[base].data.number.as_signed; } switch (parameters[i].type) { case FORMAT_INT: { trio_uintmax_t number; if (0 == base) base = BASE_DECIMAL; if (!TrioReadNumber(data, &number, flags, width, base)) return assignment; if (!(flags & FLAGS_IGNORE)) { assignment++; pointer = parameters[i].data.pointer; #if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) if (flags & FLAGS_SIZE_T) *(size_t *)pointer = (size_t)number; else #endif #if defined(QUALIFIER_PTRDIFF_T) if (flags & FLAGS_PTRDIFF_T) *(ptrdiff_t *)pointer = (ptrdiff_t)number; else #endif #if defined(QUALIFIER_INTMAX_T) if (flags & FLAGS_INTMAX_T) *(trio_intmax_t *)pointer = (trio_intmax_t)number; else #endif if (flags & FLAGS_QUAD) *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)number; else if (flags & FLAGS_LONG) *(long int *)pointer = (long int)number; else if (flags & FLAGS_SHORT) *(short int *)pointer = (short int)number; else *(int *)pointer = (int)number; } } break; /* FORMAT_INT */ case FORMAT_STRING: #if TRIO_WIDECHAR if (flags & FLAGS_WIDECHAR) { if (!TrioReadWideString(data, (flags & FLAGS_IGNORE) ? NULL : parameters[i].data.wstring, flags, width)) return assignment; } else #endif { if (!TrioReadString(data, (flags & FLAGS_IGNORE) ? NULL : parameters[i].data.string, flags, width)) return assignment; } if (!(flags & FLAGS_IGNORE)) assignment++; break; /* FORMAT_STRING */ case FORMAT_DOUBLE: { trio_pointer_t pointer; if (flags & FLAGS_IGNORE) { pointer = NULL; } else { pointer = (flags & FLAGS_LONGDOUBLE) ? (trio_pointer_t)parameters[i].data.longdoublePointer : (trio_pointer_t)parameters[i].data.doublePointer; } if (!TrioReadDouble(data, pointer, flags, width)) { return assignment; } if (!(flags & FLAGS_IGNORE)) { assignment++; } break; /* FORMAT_DOUBLE */ } case FORMAT_GROUP: { int characterclass[MAX_CHARACTER_CLASS + 1]; int rc; /* Skip over modifiers */ while (format[index] != SPECIFIER_GROUP) { index++; } /* Skip over group specifier */ index++; memset(characterclass, 0, sizeof(characterclass)); rc = TrioGetCharacterClass(format, &index, &flags, characterclass); if (rc < 0) return rc; if (!TrioReadGroup(data, (flags & FLAGS_IGNORE) ? NULL : parameters[i].data.string, characterclass, flags, parameters[i].width)) return assignment; if (!(flags & FLAGS_IGNORE)) assignment++; } break; /* FORMAT_GROUP */ case FORMAT_COUNT: pointer = parameters[i].data.pointer; if (NULL != pointer) { int count = data->committed; if (ch != EOF) count--; /* a character is read, but is not consumed yet */ #if defined(QUALIFIER_SIZE_T) || defined(QUALIFIER_SIZE_T_UPPER) if (flags & FLAGS_SIZE_T) *(size_t *)pointer = (size_t)count; else #endif #if defined(QUALIFIER_PTRDIFF_T) if (flags & FLAGS_PTRDIFF_T) *(ptrdiff_t *)pointer = (ptrdiff_t)count; else #endif #if defined(QUALIFIER_INTMAX_T) if (flags & FLAGS_INTMAX_T) *(trio_intmax_t *)pointer = (trio_intmax_t)count; else #endif if (flags & FLAGS_QUAD) { *(trio_ulonglong_t *)pointer = (trio_ulonglong_t)count; } else if (flags & FLAGS_LONG) { *(long int *)pointer = (long int)count; } else if (flags & FLAGS_SHORT) { *(short int *)pointer = (short int)count; } else { *(int *)pointer = (int)count; } } break; /* FORMAT_COUNT */ case FORMAT_CHAR: #if TRIO_WIDECHAR if (flags & FLAGS_WIDECHAR) { if (TrioReadWideChar(data, (flags & FLAGS_IGNORE) ? NULL : parameters[i].data.wstring, flags, (width == NO_WIDTH) ? 1 : width) == 0) return assignment; } else #endif { if (TrioReadChar(data, (flags & FLAGS_IGNORE) ? NULL : parameters[i].data.string, flags, (width == NO_WIDTH) ? 1 : width) == 0) return assignment; } if (!(flags & FLAGS_IGNORE)) assignment++; break; /* FORMAT_CHAR */ case FORMAT_POINTER: if (!TrioReadPointer(data, (flags & FLAGS_IGNORE) ? NULL : (trio_pointer_t *)parameters[i].data.pointer, flags)) return assignment; if (!(flags & FLAGS_IGNORE)) assignment++; break; /* FORMAT_POINTER */ case FORMAT_PARAMETER: break; /* FORMAT_PARAMETER */ default: return TRIO_ERROR_RETURN(TRIO_EINVAL, index); } ch = data->current; index = parameters[i].indexAfterSpecifier; i++; } else /* Not an % identifier */ { if (isspace((int)format[index])) { /* Whitespaces may match any amount of whitespaces */ ch = TrioSkipWhitespaces(data); } else if (ch == format[index]) { data->InStream(data, &ch); } else return assignment; index++; } } return assignment; } /************************************************************************* * TrioScan */ TRIO_PRIVATE int TrioScan TRIO_ARGS6((source, sourceSize, InStream, format, arglist, argarray), trio_pointer_t source, size_t sourceSize, void (*InStream) TRIO_PROTO((trio_class_t *, int *)), TRIO_CONST char *format, va_list arglist, trio_pointer_t *argarray) { int status; trio_parameter_t parameters[MAX_PARAMETERS]; trio_class_t data; assert(VALID(InStream)); assert(VALID(format)); memset(&data, 0, sizeof(data)); data.InStream = InStream; data.location = (trio_pointer_t)source; data.max = sourceSize; data.error = 0; #if defined(USE_LOCALE) if (NULL == internalLocaleValues) { TrioSetLocale(); } #endif status = TrioParse(TYPE_SCAN, format, parameters, arglist, argarray); if (status < 0) return status; status = TrioScanProcess(&data, format, parameters); if (data.error != 0) { status = data.error; } return status; } /************************************************************************* * TrioInStreamFile */ TRIO_PRIVATE void TrioInStreamFile TRIO_ARGS2((self, intPointer), trio_class_t *self, int *intPointer) { FILE *file = (FILE *)self->location; assert(VALID(self)); assert(VALID(file)); self->current = fgetc(file); if (self->current == EOF) { self->error = (ferror(file)) ? TRIO_ERROR_RETURN(TRIO_ERRNO, 0) : TRIO_ERROR_RETURN(TRIO_EOF, 0); } else { self->processed++; self->committed++; } if (VALID(intPointer)) { *intPointer = self->current; } } /************************************************************************* * TrioInStreamFileDescriptor */ TRIO_PRIVATE void TrioInStreamFileDescriptor TRIO_ARGS2((self, intPointer), trio_class_t *self, int *intPointer) { int fd = *((int *)self->location); int size; unsigned char input; assert(VALID(self)); size = read(fd, &input, sizeof(char)); if (size == -1) { self->error = TRIO_ERROR_RETURN(TRIO_ERRNO, 0); self->current = EOF; } else { self->current = (size == 0) ? EOF : input; } if (self->current != EOF) { self->committed++; self->processed++; } if (VALID(intPointer)) { *intPointer = self->current; } } /************************************************************************* * TrioInStreamCustom */ TRIO_PRIVATE void TrioInStreamCustom TRIO_ARGS2((self, intPointer), trio_class_t *self, int *intPointer) { trio_custom_t *data; assert(VALID(self)); assert(VALID(self->location)); data = (trio_custom_t *)self->location; self->current = (data->stream.in == NULL) ? NIL : (data->stream.in)(data->closure); if (self->current == NIL) { self->current = EOF; } else { self->processed++; self->committed++; } if (VALID(intPointer)) { *intPointer = self->current; } } /************************************************************************* * TrioInStreamString */ TRIO_PRIVATE void TrioInStreamString TRIO_ARGS2((self, intPointer), trio_class_t *self, int *intPointer) { unsigned char **buffer; assert(VALID(self)); assert(VALID(self->location)); buffer = (unsigned char **)self->location; self->current = (*buffer)[0]; if (self->current == NIL) { self->current = EOF; } else { (*buffer)++; self->processed++; self->committed++; } if (VALID(intPointer)) { *intPointer = self->current; } } /************************************************************************* * * Formatted scanning functions * ************************************************************************/ #if defined(TRIO_DOCUMENTATION) # include "doc/doc_scanf.h" #endif /** @addtogroup Scanf @{ */ #if defined(TRIO_COMPILER_MSVC) # pragma warning(push) # pragma warning(disable : 4700) #endif /************************************************************************* * scanf */ /** Scan characters from standard input stream. @param format Formatting string. @param ... Arguments. @return Number of scanned characters. */ TRIO_PUBLIC int trio_scanf TRIO_VARGS2((format, va_alist), TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(format)); TRIO_VA_START(args, format); status = TrioScan((trio_pointer_t)stdin, 0, TrioInStreamFile, format, args, NULL); TRIO_VA_END(args); return status; } TRIO_PUBLIC int trio_vscanf TRIO_ARGS2((format, args), TRIO_CONST char *format, va_list args) { assert(VALID(format)); return TrioScan((trio_pointer_t)stdin, 0, TrioInStreamFile, format, args, NULL); } TRIO_PUBLIC int trio_scanfv TRIO_ARGS2((format, args), TRIO_CONST char *format, trio_pointer_t *args) { va_list dummy; assert(VALID(format)); return TrioScan((trio_pointer_t)stdin, 0, TrioInStreamFile, format, dummy, args); } /************************************************************************* * fscanf */ TRIO_PUBLIC int trio_fscanf TRIO_VARGS3((file, format, va_alist), FILE *file, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(file)); assert(VALID(format)); TRIO_VA_START(args, format); status = TrioScan((trio_pointer_t)file, 0, TrioInStreamFile, format, args, NULL); TRIO_VA_END(args); return status; } TRIO_PUBLIC int trio_vfscanf TRIO_ARGS3((file, format, args), FILE *file, TRIO_CONST char *format, va_list args) { assert(VALID(file)); assert(VALID(format)); return TrioScan((trio_pointer_t)file, 0, TrioInStreamFile, format, args, NULL); } TRIO_PUBLIC int trio_fscanfv TRIO_ARGS3((file, format, args), FILE *file, TRIO_CONST char *format, trio_pointer_t *args) { va_list dummy; assert(VALID(file)); assert(VALID(format)); return TrioScan((trio_pointer_t)file, 0, TrioInStreamFile, format, dummy, args); } /************************************************************************* * dscanf */ TRIO_PUBLIC int trio_dscanf TRIO_VARGS3((fd, format, va_alist), int fd, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(format)); TRIO_VA_START(args, format); status = TrioScan((trio_pointer_t)&fd, 0, TrioInStreamFileDescriptor, format, args, NULL); TRIO_VA_END(args); return status; } TRIO_PUBLIC int trio_vdscanf TRIO_ARGS3((fd, format, args), int fd, TRIO_CONST char *format, va_list args) { assert(VALID(format)); return TrioScan((trio_pointer_t)&fd, 0, TrioInStreamFileDescriptor, format, args, NULL); } TRIO_PUBLIC int trio_dscanfv TRIO_ARGS3((fd, format, args), int fd, TRIO_CONST char *format, trio_pointer_t *args) { va_list dummy; assert(VALID(format)); return TrioScan((trio_pointer_t)&fd, 0, TrioInStreamFileDescriptor, format, dummy, args); } /************************************************************************* * cscanf */ TRIO_PUBLIC int trio_cscanf TRIO_VARGS4((stream, closure, format, va_alist), trio_instream_t stream, trio_pointer_t closure, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; trio_custom_t data; assert(VALID(stream)); assert(VALID(format)); TRIO_VA_START(args, format); data.stream.in = stream; data.closure = closure; status = TrioScan(&data, 0, TrioInStreamCustom, format, args, NULL); TRIO_VA_END(args); return status; } TRIO_PUBLIC int trio_vcscanf TRIO_ARGS4((stream, closure, format, args), trio_instream_t stream, trio_pointer_t closure, TRIO_CONST char *format, va_list args) { trio_custom_t data; assert(VALID(stream)); assert(VALID(format)); data.stream.in = stream; data.closure = closure; return TrioScan(&data, 0, TrioInStreamCustom, format, args, NULL); } TRIO_PUBLIC int trio_cscanfv TRIO_ARGS4((stream, closure, format, args), trio_instream_t stream, trio_pointer_t closure, TRIO_CONST char *format, trio_pointer_t *args) { va_list dummy; trio_custom_t data; assert(VALID(stream)); assert(VALID(format)); data.stream.in = stream; data.closure = closure; return TrioScan(&data, 0, TrioInStreamCustom, format, dummy, args); } /************************************************************************* * sscanf */ TRIO_PUBLIC int trio_sscanf TRIO_VARGS3((buffer, format, va_alist), TRIO_CONST char *buffer, TRIO_CONST char *format, TRIO_VA_DECL) { int status; va_list args; assert(VALID(buffer)); assert(VALID(format)); TRIO_VA_START(args, format); status = TrioScan((trio_pointer_t)&buffer, 0, TrioInStreamString, format, args, NULL); TRIO_VA_END(args); return status; } TRIO_PUBLIC int trio_vsscanf TRIO_ARGS3((buffer, format, args), TRIO_CONST char *buffer, TRIO_CONST char *format, va_list args) { assert(VALID(buffer)); assert(VALID(format)); return TrioScan((trio_pointer_t)&buffer, 0, TrioInStreamString, format, args, NULL); } TRIO_PUBLIC int trio_sscanfv TRIO_ARGS3((buffer, format, args), TRIO_CONST char *buffer, TRIO_CONST char *format, trio_pointer_t *args) { va_list dummy; assert(VALID(buffer)); assert(VALID(format)); return TrioScan((trio_pointer_t)&buffer, 0, TrioInStreamString, format, dummy, args); } #if defined(TRIO_COMPILER_MSVC) # pragma warning(pop) #endif /** @} End of Scanf documentation module */ /************************************************************************* * trio_strerror */ TRIO_PUBLIC TRIO_CONST char * trio_strerror TRIO_ARGS1((errorcode), int errorcode) { /* Textual versions of the error codes */ switch (TRIO_ERROR_CODE(errorcode)) { case TRIO_EOF: return "End of file"; case TRIO_EINVAL: return "Invalid argument"; case TRIO_ETOOMANY: return "Too many arguments"; case TRIO_EDBLREF: return "Double reference"; case TRIO_EGAP: return "Reference gap"; case TRIO_ENOMEM: return "Out of memory"; case TRIO_ERANGE: return "Invalid range"; case TRIO_ECUSTOM: return "Custom error"; default: return "Unknown"; } } lftp-4.6.3a/trio/Makefile.in0000644000015000007670000017152312540277162012614 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = trio DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/build-aux/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/arpa_inet_h.m4 $(top_srcdir)/m4/bison.m4 \ $(top_srcdir)/m4/btowc.m4 $(top_srcdir)/m4/chown.m4 \ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/close.m4 \ $(top_srcdir)/m4/closedir.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/configmake.m4 \ $(top_srcdir)/m4/cxx-dynamic-initializers.m4 \ $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirent_h.m4 \ $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dup2.m4 \ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/exponentf.m4 \ $(top_srcdir)/m4/exponentl.m4 $(top_srcdir)/m4/extensions.m4 \ $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fcntl-o.m4 \ $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/float_h.m4 \ $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fpieee.m4 \ $(top_srcdir)/m4/frexp.m4 $(top_srcdir)/m4/frexpl.m4 \ $(top_srcdir)/m4/fstat.m4 $(top_srcdir)/m4/getdtablesize.m4 \ $(top_srcdir)/m4/getlogin_r.m4 $(top_srcdir)/m4/getopt.m4 \ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gettime.m4 \ $(top_srcdir)/m4/gettimeofday.m4 \ $(top_srcdir)/m4/gl-openssl.m4 $(top_srcdir)/m4/glibc21.m4 \ $(top_srcdir)/m4/glob.m4 $(top_srcdir)/m4/gnulib-common.m4 \ $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/human.m4 \ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/iconv_h.m4 \ $(top_srcdir)/m4/iconv_open.m4 \ $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/inet_pton.m4 \ $(top_srcdir)/m4/inline.m4 $(top_srcdir)/m4/intlmacosx.m4 \ $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/isnand.m4 \ $(top_srcdir)/m4/isnanf.m4 $(top_srcdir)/m4/isnanl.m4 \ $(top_srcdir)/m4/langinfo_h.m4 $(top_srcdir)/m4/largefile.m4 \ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/ldexpl.m4 \ $(top_srcdir)/m4/lftp.m4 $(top_srcdir)/m4/lib-ld.m4 \ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/libunistring-base.m4 \ $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \ $(top_srcdir)/m4/locale_h.m4 $(top_srcdir)/m4/localeconv.m4 \ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/malloc.m4 \ $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/math_h.m4 \ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/mbtowc.m4 \ $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memchr.m4 \ $(top_srcdir)/m4/memmem.m4 $(top_srcdir)/m4/mempcpy.m4 \ $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/modechange.m4 \ $(top_srcdir)/m4/msvc-inval.m4 \ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/needtrio.m4 $(top_srcdir)/m4/netinet_in_h.m4 \ $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \ $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/opendir.m4 \ $(top_srcdir)/m4/parse-datetime.m4 $(top_srcdir)/m4/passfd.m4 \ $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/po.m4 \ $(top_srcdir)/m4/poll.m4 $(top_srcdir)/m4/poll_h.m4 \ $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/pty.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/readdir.m4 $(top_srcdir)/m4/readline.m4 \ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/regex.m4 \ $(top_srcdir)/m4/select.m4 $(top_srcdir)/m4/setenv.m4 \ $(top_srcdir)/m4/sha1.m4 $(top_srcdir)/m4/signal_h.m4 \ $(top_srcdir)/m4/signbit.m4 $(top_srcdir)/m4/size_max.m4 \ $(top_srcdir)/m4/socketlib.m4 $(top_srcdir)/m4/sockets.m4 \ $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/sockpfaf.m4 \ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/ssl.m4 \ $(top_srcdir)/m4/st_dm_mode.m4 $(top_srcdir)/m4/stat.m4 \ $(top_srcdir)/m4/stdalign.m4 $(top_srcdir)/m4/stdbool.m4 \ $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \ $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio_h.m4 \ $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strcase.m4 \ $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/string_h.m4 \ $(top_srcdir)/m4/strings_h.m4 $(top_srcdir)/m4/strptime.m4 \ $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtok_r.m4 \ $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ $(top_srcdir)/m4/sys_select_h.m4 \ $(top_srcdir)/m4/sys_socket_h.m4 \ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ $(top_srcdir)/m4/sys_types_h.m4 $(top_srcdir)/m4/sys_uio_h.m4 \ $(top_srcdir)/m4/terminfo.m4 $(top_srcdir)/m4/threadlib.m4 \ $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \ $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/va_copy.m4 \ $(top_srcdir)/m4/vasnprintf.m4 \ $(top_srcdir)/m4/vsnprintf-posix.m4 \ $(top_srcdir)/m4/vsnprintf.m4 $(top_srcdir)/m4/wchar_h.m4 \ $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wcrtomb.m4 \ $(top_srcdir)/m4/wctype_h.m4 $(top_srcdir)/m4/wcwidth.m4 \ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrtol.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/lib/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtrio_la_LIBADD = am_libtrio_la_OBJECTS = trio.lo trionan.lo triostr.lo libtrio_la_OBJECTS = $(am_libtrio_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/lib depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtrio_la_SOURCES) DIST_SOURCES = $(libtrio_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) pkglibexecdir = @pkglibexecdir@ ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ ALLOCA_H = @ALLOCA_H@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ AR = @AR@ ARFLAGS = @ARFLAGS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@ BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@ BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@ BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@ BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ COMPILE_READLINE = @COMPILE_READLINE@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@ EMULTIHOP_VALUE = @EMULTIHOP_VALUE@ ENOLINK_HIDDEN = @ENOLINK_HIDDEN@ ENOLINK_VALUE = @ENOLINK_VALUE@ EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@ EOVERFLOW_VALUE = @EOVERFLOW_VALUE@ ERRNO_H = @ERRNO_H@ EXEEXT = @EXEEXT@ EXPAT_LIBS = @EXPAT_LIBS@ FGREP = @FGREP@ FLOAT_H = @FLOAT_H@ FNMATCH_H = @FNMATCH_H@ GETOPT_H = @GETOPT_H@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GLIBC21 = @GLIBC21@ GLOB_H = @GLOB_H@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNULIB_ACCEPT = @GNULIB_ACCEPT@ GNULIB_ACCEPT4 = @GNULIB_ACCEPT4@ GNULIB_ACOSF = @GNULIB_ACOSF@ GNULIB_ACOSL = @GNULIB_ACOSL@ GNULIB_ALPHASORT = @GNULIB_ALPHASORT@ GNULIB_ASINF = @GNULIB_ASINF@ GNULIB_ASINL = @GNULIB_ASINL@ GNULIB_ATAN2F = @GNULIB_ATAN2F@ GNULIB_ATANF = @GNULIB_ATANF@ GNULIB_ATANL = @GNULIB_ATANL@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ GNULIB_BTOWC = @GNULIB_BTOWC@ GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@ GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@ GNULIB_CBRT = @GNULIB_CBRT@ GNULIB_CBRTF = @GNULIB_CBRTF@ GNULIB_CBRTL = @GNULIB_CBRTL@ GNULIB_CEIL = @GNULIB_CEIL@ GNULIB_CEILF = @GNULIB_CEILF@ GNULIB_CEILL = @GNULIB_CEILL@ GNULIB_CHDIR = @GNULIB_CHDIR@ GNULIB_CHOWN = @GNULIB_CHOWN@ GNULIB_CLOSE = @GNULIB_CLOSE@ GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@ GNULIB_CONNECT = @GNULIB_CONNECT@ GNULIB_COPYSIGN = @GNULIB_COPYSIGN@ GNULIB_COPYSIGNF = @GNULIB_COPYSIGNF@ GNULIB_COPYSIGNL = @GNULIB_COPYSIGNL@ GNULIB_COSF = @GNULIB_COSF@ GNULIB_COSHF = @GNULIB_COSHF@ GNULIB_COSL = @GNULIB_COSL@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP = @GNULIB_DUP@ GNULIB_DUP2 = @GNULIB_DUP2@ GNULIB_DUP3 = @GNULIB_DUP3@ GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ GNULIB_EXP2 = @GNULIB_EXP2@ GNULIB_EXP2F = @GNULIB_EXP2F@ GNULIB_EXP2L = @GNULIB_EXP2L@ GNULIB_EXPF = @GNULIB_EXPF@ GNULIB_EXPL = @GNULIB_EXPL@ GNULIB_EXPM1 = @GNULIB_EXPM1@ GNULIB_EXPM1F = @GNULIB_EXPM1F@ GNULIB_EXPM1L = @GNULIB_EXPM1L@ GNULIB_FABSF = @GNULIB_FABSF@ GNULIB_FABSL = @GNULIB_FABSL@ GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ GNULIB_FCNTL = @GNULIB_FCNTL@ GNULIB_FDATASYNC = @GNULIB_FDATASYNC@ GNULIB_FDOPEN = @GNULIB_FDOPEN@ GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FFS = @GNULIB_FFS@ GNULIB_FFSL = @GNULIB_FFSL@ GNULIB_FFSLL = @GNULIB_FFSLL@ GNULIB_FGETC = @GNULIB_FGETC@ GNULIB_FGETS = @GNULIB_FGETS@ GNULIB_FLOOR = @GNULIB_FLOOR@ GNULIB_FLOORF = @GNULIB_FLOORF@ GNULIB_FLOORL = @GNULIB_FLOORL@ GNULIB_FMA = @GNULIB_FMA@ GNULIB_FMAF = @GNULIB_FMAF@ GNULIB_FMAL = @GNULIB_FMAL@ GNULIB_FMOD = @GNULIB_FMOD@ GNULIB_FMODF = @GNULIB_FMODF@ GNULIB_FMODL = @GNULIB_FMODL@ GNULIB_FOPEN = @GNULIB_FOPEN@ GNULIB_FPRINTF = @GNULIB_FPRINTF@ GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@ GNULIB_FPURGE = @GNULIB_FPURGE@ GNULIB_FPUTC = @GNULIB_FPUTC@ GNULIB_FPUTS = @GNULIB_FPUTS@ GNULIB_FREAD = @GNULIB_FREAD@ GNULIB_FREOPEN = @GNULIB_FREOPEN@ GNULIB_FREXP = @GNULIB_FREXP@ GNULIB_FREXPF = @GNULIB_FREXPF@ GNULIB_FREXPL = @GNULIB_FREXPL@ GNULIB_FSCANF = @GNULIB_FSCANF@ GNULIB_FSEEK = @GNULIB_FSEEK@ GNULIB_FSEEKO = @GNULIB_FSEEKO@ GNULIB_FSTAT = @GNULIB_FSTAT@ GNULIB_FSTATAT = @GNULIB_FSTATAT@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ GNULIB_FUTIMENS = @GNULIB_FUTIMENS@ GNULIB_FWRITE = @GNULIB_FWRITE@ GNULIB_GETC = @GNULIB_GETC@ GNULIB_GETCHAR = @GNULIB_GETCHAR@ GNULIB_GETCWD = @GNULIB_GETCWD@ GNULIB_GETDELIM = @GNULIB_GETDELIM@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ GNULIB_GETLINE = @GNULIB_GETLINE@ GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@ GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ GNULIB_GETPEERNAME = @GNULIB_GETPEERNAME@ GNULIB_GETSOCKNAME = @GNULIB_GETSOCKNAME@ GNULIB_GETSOCKOPT = @GNULIB_GETSOCKOPT@ GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@ GNULIB_GETTIMEOFDAY = @GNULIB_GETTIMEOFDAY@ GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@ GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@ GNULIB_GRANTPT = @GNULIB_GRANTPT@ GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@ GNULIB_HYPOT = @GNULIB_HYPOT@ GNULIB_HYPOTF = @GNULIB_HYPOTF@ GNULIB_HYPOTL = @GNULIB_HYPOTL@ GNULIB_ICONV = @GNULIB_ICONV@ GNULIB_ILOGB = @GNULIB_ILOGB@ GNULIB_ILOGBF = @GNULIB_ILOGBF@ GNULIB_ILOGBL = @GNULIB_ILOGBL@ GNULIB_IMAXABS = @GNULIB_IMAXABS@ GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ GNULIB_INET_NTOP = @GNULIB_INET_NTOP@ GNULIB_INET_PTON = @GNULIB_INET_PTON@ GNULIB_ISATTY = @GNULIB_ISATTY@ GNULIB_ISFINITE = @GNULIB_ISFINITE@ GNULIB_ISINF = @GNULIB_ISINF@ GNULIB_ISNAN = @GNULIB_ISNAN@ GNULIB_ISNAND = @GNULIB_ISNAND@ GNULIB_ISNANF = @GNULIB_ISNANF@ GNULIB_ISNANL = @GNULIB_ISNANL@ GNULIB_ISWBLANK = @GNULIB_ISWBLANK@ GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@ GNULIB_LCHMOD = @GNULIB_LCHMOD@ GNULIB_LCHOWN = @GNULIB_LCHOWN@ GNULIB_LDEXPF = @GNULIB_LDEXPF@ GNULIB_LDEXPL = @GNULIB_LDEXPL@ GNULIB_LINK = @GNULIB_LINK@ GNULIB_LINKAT = @GNULIB_LINKAT@ GNULIB_LISTEN = @GNULIB_LISTEN@ GNULIB_LOCALECONV = @GNULIB_LOCALECONV@ GNULIB_LOG = @GNULIB_LOG@ GNULIB_LOG10 = @GNULIB_LOG10@ GNULIB_LOG10F = @GNULIB_LOG10F@ GNULIB_LOG10L = @GNULIB_LOG10L@ GNULIB_LOG1P = @GNULIB_LOG1P@ GNULIB_LOG1PF = @GNULIB_LOG1PF@ GNULIB_LOG1PL = @GNULIB_LOG1PL@ GNULIB_LOG2 = @GNULIB_LOG2@ GNULIB_LOG2F = @GNULIB_LOG2F@ GNULIB_LOG2L = @GNULIB_LOG2L@ GNULIB_LOGB = @GNULIB_LOGB@ GNULIB_LOGBF = @GNULIB_LOGBF@ GNULIB_LOGBL = @GNULIB_LOGBL@ GNULIB_LOGF = @GNULIB_LOGF@ GNULIB_LOGL = @GNULIB_LOGL@ GNULIB_LSEEK = @GNULIB_LSEEK@ GNULIB_LSTAT = @GNULIB_LSTAT@ GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@ GNULIB_MBRLEN = @GNULIB_MBRLEN@ GNULIB_MBRTOWC = @GNULIB_MBRTOWC@ GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@ GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@ GNULIB_MBSCHR = @GNULIB_MBSCHR@ GNULIB_MBSCSPN = @GNULIB_MBSCSPN@ GNULIB_MBSINIT = @GNULIB_MBSINIT@ GNULIB_MBSLEN = @GNULIB_MBSLEN@ GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@ GNULIB_MBSNLEN = @GNULIB_MBSNLEN@ GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@ GNULIB_MBSPBRK = @GNULIB_MBSPBRK@ GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@ GNULIB_MBSRCHR = @GNULIB_MBSRCHR@ GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@ GNULIB_MBSSEP = @GNULIB_MBSSEP@ GNULIB_MBSSPN = @GNULIB_MBSSPN@ GNULIB_MBSSTR = @GNULIB_MBSSTR@ GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@ GNULIB_MBTOWC = @GNULIB_MBTOWC@ GNULIB_MEMCHR = @GNULIB_MEMCHR@ GNULIB_MEMMEM = @GNULIB_MEMMEM@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ GNULIB_MKFIFO = @GNULIB_MKFIFO@ GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ GNULIB_MKNOD = @GNULIB_MKNOD@ GNULIB_MKNODAT = @GNULIB_MKNODAT@ GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@ GNULIB_MKTIME = @GNULIB_MKTIME@ GNULIB_MODF = @GNULIB_MODF@ GNULIB_MODFF = @GNULIB_MODFF@ GNULIB_MODFL = @GNULIB_MODFL@ GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@ GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@ GNULIB_NONBLOCKING = @GNULIB_NONBLOCKING@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_OPENDIR = @GNULIB_OPENDIR@ GNULIB_PCLOSE = @GNULIB_PCLOSE@ GNULIB_PERROR = @GNULIB_PERROR@ GNULIB_PIPE = @GNULIB_PIPE@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POLL = @GNULIB_POLL@ GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@ GNULIB_POWF = @GNULIB_POWF@ GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PSELECT = @GNULIB_PSELECT@ GNULIB_PTHREAD_SIGMASK = @GNULIB_PTHREAD_SIGMASK@ GNULIB_PTSNAME = @GNULIB_PTSNAME@ GNULIB_PTSNAME_R = @GNULIB_PTSNAME_R@ GNULIB_PUTC = @GNULIB_PUTC@ GNULIB_PUTCHAR = @GNULIB_PUTCHAR@ GNULIB_PUTENV = @GNULIB_PUTENV@ GNULIB_PUTS = @GNULIB_PUTS@ GNULIB_PWRITE = @GNULIB_PWRITE@ GNULIB_QSORT_R = @GNULIB_QSORT_R@ GNULIB_RAISE = @GNULIB_RAISE@ GNULIB_RANDOM = @GNULIB_RANDOM@ GNULIB_RANDOM_R = @GNULIB_RANDOM_R@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READ = @GNULIB_READ@ GNULIB_READDIR = @GNULIB_READDIR@ GNULIB_READLINK = @GNULIB_READLINK@ GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ GNULIB_REALPATH = @GNULIB_REALPATH@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ GNULIB_REMAINDER = @GNULIB_REMAINDER@ GNULIB_REMAINDERF = @GNULIB_REMAINDERF@ GNULIB_REMAINDERL = @GNULIB_REMAINDERL@ GNULIB_REMOVE = @GNULIB_REMOVE@ GNULIB_RENAME = @GNULIB_RENAME@ GNULIB_RENAMEAT = @GNULIB_RENAMEAT@ GNULIB_REWINDDIR = @GNULIB_REWINDDIR@ GNULIB_RINT = @GNULIB_RINT@ GNULIB_RINTF = @GNULIB_RINTF@ GNULIB_RINTL = @GNULIB_RINTL@ GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ GNULIB_RPMATCH = @GNULIB_RPMATCH@ GNULIB_SCANDIR = @GNULIB_SCANDIR@ GNULIB_SCANF = @GNULIB_SCANF@ GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@ GNULIB_SELECT = @GNULIB_SELECT@ GNULIB_SEND = @GNULIB_SEND@ GNULIB_SENDTO = @GNULIB_SENDTO@ GNULIB_SETENV = @GNULIB_SETENV@ GNULIB_SETHOSTNAME = @GNULIB_SETHOSTNAME@ GNULIB_SETLOCALE = @GNULIB_SETLOCALE@ GNULIB_SETSOCKOPT = @GNULIB_SETSOCKOPT@ GNULIB_SHUTDOWN = @GNULIB_SHUTDOWN@ GNULIB_SIGACTION = @GNULIB_SIGACTION@ GNULIB_SIGNAL_H_SIGPIPE = @GNULIB_SIGNAL_H_SIGPIPE@ GNULIB_SIGNBIT = @GNULIB_SIGNBIT@ GNULIB_SIGPROCMASK = @GNULIB_SIGPROCMASK@ GNULIB_SINF = @GNULIB_SINF@ GNULIB_SINHF = @GNULIB_SINHF@ GNULIB_SINL = @GNULIB_SINL@ GNULIB_SLEEP = @GNULIB_SLEEP@ GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ GNULIB_SOCKET = @GNULIB_SOCKET@ GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ GNULIB_SQRTF = @GNULIB_SQRTF@ GNULIB_SQRTL = @GNULIB_SQRTL@ GNULIB_STAT = @GNULIB_STAT@ GNULIB_STDIO_H_NONBLOCKING = @GNULIB_STDIO_H_NONBLOCKING@ GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@ GNULIB_STPCPY = @GNULIB_STPCPY@ GNULIB_STPNCPY = @GNULIB_STPNCPY@ GNULIB_STRCASESTR = @GNULIB_STRCASESTR@ GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@ GNULIB_STRDUP = @GNULIB_STRDUP@ GNULIB_STRERROR = @GNULIB_STRERROR@ GNULIB_STRERROR_R = @GNULIB_STRERROR_R@ GNULIB_STRNCAT = @GNULIB_STRNCAT@ GNULIB_STRNDUP = @GNULIB_STRNDUP@ GNULIB_STRNLEN = @GNULIB_STRNLEN@ GNULIB_STRPBRK = @GNULIB_STRPBRK@ GNULIB_STRPTIME = @GNULIB_STRPTIME@ GNULIB_STRSEP = @GNULIB_STRSEP@ GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@ GNULIB_STRSTR = @GNULIB_STRSTR@ GNULIB_STRTOD = @GNULIB_STRTOD@ GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@ GNULIB_STRTOK_R = @GNULIB_STRTOK_R@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ GNULIB_SYMLINK = @GNULIB_SYMLINK@ GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@ GNULIB_TANF = @GNULIB_TANF@ GNULIB_TANHF = @GNULIB_TANHF@ GNULIB_TANL = @GNULIB_TANL@ GNULIB_TIMEGM = @GNULIB_TIMEGM@ GNULIB_TIME_R = @GNULIB_TIME_R@ GNULIB_TMPFILE = @GNULIB_TMPFILE@ GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@ GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ GNULIB_UNLINK = @GNULIB_UNLINK@ GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ GNULIB_USLEEP = @GNULIB_USLEEP@ GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ GNULIB_VFPRINTF = @GNULIB_VFPRINTF@ GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@ GNULIB_VFSCANF = @GNULIB_VFSCANF@ GNULIB_VPRINTF = @GNULIB_VPRINTF@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ GNULIB_VSCANF = @GNULIB_VSCANF@ GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ GNULIB_WCPCPY = @GNULIB_WCPCPY@ GNULIB_WCPNCPY = @GNULIB_WCPNCPY@ GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@ GNULIB_WCSCAT = @GNULIB_WCSCAT@ GNULIB_WCSCHR = @GNULIB_WCSCHR@ GNULIB_WCSCMP = @GNULIB_WCSCMP@ GNULIB_WCSCOLL = @GNULIB_WCSCOLL@ GNULIB_WCSCPY = @GNULIB_WCSCPY@ GNULIB_WCSCSPN = @GNULIB_WCSCSPN@ GNULIB_WCSDUP = @GNULIB_WCSDUP@ GNULIB_WCSLEN = @GNULIB_WCSLEN@ GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@ GNULIB_WCSNCAT = @GNULIB_WCSNCAT@ GNULIB_WCSNCMP = @GNULIB_WCSNCMP@ GNULIB_WCSNCPY = @GNULIB_WCSNCPY@ GNULIB_WCSNLEN = @GNULIB_WCSNLEN@ GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@ GNULIB_WCSPBRK = @GNULIB_WCSPBRK@ GNULIB_WCSRCHR = @GNULIB_WCSRCHR@ GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@ GNULIB_WCSSPN = @GNULIB_WCSSPN@ GNULIB_WCSSTR = @GNULIB_WCSSTR@ GNULIB_WCSTOK = @GNULIB_WCSTOK@ GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@ GNULIB_WCSXFRM = @GNULIB_WCSXFRM@ GNULIB_WCTOB = @GNULIB_WCTOB@ GNULIB_WCTOMB = @GNULIB_WCTOMB@ GNULIB_WCTRANS = @GNULIB_WCTRANS@ GNULIB_WCTYPE = @GNULIB_WCTYPE@ GNULIB_WCWIDTH = @GNULIB_WCWIDTH@ GNULIB_WMEMCHR = @GNULIB_WMEMCHR@ GNULIB_WMEMCMP = @GNULIB_WMEMCMP@ GNULIB_WMEMCPY = @GNULIB_WMEMCPY@ GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@ GNULIB_WMEMSET = @GNULIB_WMEMSET@ GNULIB_WRITE = @GNULIB_WRITE@ GNULIB__EXIT = @GNULIB__EXIT@ GREP = @GREP@ HAVE_ACCEPT4 = @HAVE_ACCEPT4@ HAVE_ACOSF = @HAVE_ACOSF@ HAVE_ACOSL = @HAVE_ACOSL@ HAVE_ALPHASORT = @HAVE_ALPHASORT@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ASINF = @HAVE_ASINF@ HAVE_ASINL = @HAVE_ASINL@ HAVE_ATAN2F = @HAVE_ATAN2F@ HAVE_ATANF = @HAVE_ATANF@ HAVE_ATANL = @HAVE_ATANL@ HAVE_ATOLL = @HAVE_ATOLL@ HAVE_BTOWC = @HAVE_BTOWC@ HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ HAVE_CBRT = @HAVE_CBRT@ HAVE_CBRTF = @HAVE_CBRTF@ HAVE_CBRTL = @HAVE_CBRTL@ HAVE_CHOWN = @HAVE_CHOWN@ HAVE_CLOSEDIR = @HAVE_CLOSEDIR@ HAVE_COPYSIGN = @HAVE_COPYSIGN@ HAVE_COPYSIGNL = @HAVE_COPYSIGNL@ HAVE_COSF = @HAVE_COSF@ HAVE_COSHF = @HAVE_COSHF@ HAVE_COSL = @HAVE_COSL@ HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@ HAVE_DECL_ASINL = @HAVE_DECL_ASINL@ HAVE_DECL_ATANL = @HAVE_DECL_ATANL@ HAVE_DECL_CBRTF = @HAVE_DECL_CBRTF@ HAVE_DECL_CBRTL = @HAVE_DECL_CBRTL@ HAVE_DECL_CEILF = @HAVE_DECL_CEILF@ HAVE_DECL_CEILL = @HAVE_DECL_CEILL@ HAVE_DECL_COPYSIGNF = @HAVE_DECL_COPYSIGNF@ HAVE_DECL_COSL = @HAVE_DECL_COSL@ HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@ HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@ HAVE_DECL_EXP2 = @HAVE_DECL_EXP2@ HAVE_DECL_EXP2F = @HAVE_DECL_EXP2F@ HAVE_DECL_EXP2L = @HAVE_DECL_EXP2L@ HAVE_DECL_EXPL = @HAVE_DECL_EXPL@ HAVE_DECL_EXPM1L = @HAVE_DECL_EXPM1L@ HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@ HAVE_DECL_FDATASYNC = @HAVE_DECL_FDATASYNC@ HAVE_DECL_FDOPENDIR = @HAVE_DECL_FDOPENDIR@ HAVE_DECL_FLOORF = @HAVE_DECL_FLOORF@ HAVE_DECL_FLOORL = @HAVE_DECL_FLOORL@ HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@ HAVE_DECL_FREXPL = @HAVE_DECL_FREXPL@ HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@ HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@ HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@ HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@ HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@ HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@ HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@ HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@ HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@ HAVE_DECL_IMAXABS = @HAVE_DECL_IMAXABS@ HAVE_DECL_IMAXDIV = @HAVE_DECL_IMAXDIV@ HAVE_DECL_INET_NTOP = @HAVE_DECL_INET_NTOP@ HAVE_DECL_INET_PTON = @HAVE_DECL_INET_PTON@ HAVE_DECL_LDEXPL = @HAVE_DECL_LDEXPL@ HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@ HAVE_DECL_LOG10L = @HAVE_DECL_LOG10L@ HAVE_DECL_LOG2 = @HAVE_DECL_LOG2@ HAVE_DECL_LOG2F = @HAVE_DECL_LOG2F@ HAVE_DECL_LOG2L = @HAVE_DECL_LOG2L@ HAVE_DECL_LOGB = @HAVE_DECL_LOGB@ HAVE_DECL_LOGL = @HAVE_DECL_LOGL@ HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@ HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@ HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@ HAVE_DECL_REMAINDER = @HAVE_DECL_REMAINDER@ HAVE_DECL_REMAINDERL = @HAVE_DECL_REMAINDERL@ HAVE_DECL_RINTF = @HAVE_DECL_RINTF@ HAVE_DECL_ROUND = @HAVE_DECL_ROUND@ HAVE_DECL_ROUNDF = @HAVE_DECL_ROUNDF@ HAVE_DECL_ROUNDL = @HAVE_DECL_ROUNDL@ HAVE_DECL_SETENV = @HAVE_DECL_SETENV@ HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@ HAVE_DECL_SINL = @HAVE_DECL_SINL@ 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@ HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@ HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@ HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@ HAVE_DECL_TANL = @HAVE_DECL_TANL@ HAVE_DECL_TRUNC = @HAVE_DECL_TRUNC@ HAVE_DECL_TRUNCF = @HAVE_DECL_TRUNCF@ HAVE_DECL_TRUNCL = @HAVE_DECL_TRUNCL@ HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@ HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@ HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@ HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@ HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@ HAVE_DIRENT_H = @HAVE_DIRENT_H@ HAVE_DPRINTF = @HAVE_DPRINTF@ HAVE_DUP2 = @HAVE_DUP2@ HAVE_DUP3 = @HAVE_DUP3@ HAVE_DUPLOCALE = @HAVE_DUPLOCALE@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ HAVE_EXPF = @HAVE_EXPF@ HAVE_EXPL = @HAVE_EXPL@ HAVE_EXPM1 = @HAVE_EXPM1@ HAVE_EXPM1F = @HAVE_EXPM1F@ HAVE_FABSF = @HAVE_FABSF@ HAVE_FABSL = @HAVE_FABSL@ HAVE_FACCESSAT = @HAVE_FACCESSAT@ HAVE_FCHDIR = @HAVE_FCHDIR@ HAVE_FCHMODAT = @HAVE_FCHMODAT@ HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ HAVE_FCNTL = @HAVE_FCNTL@ HAVE_FDATASYNC = @HAVE_FDATASYNC@ HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ HAVE_FEATURES_H = @HAVE_FEATURES_H@ HAVE_FFS = @HAVE_FFS@ HAVE_FFSL = @HAVE_FFSL@ HAVE_FFSLL = @HAVE_FFSLL@ HAVE_FMA = @HAVE_FMA@ HAVE_FMAF = @HAVE_FMAF@ HAVE_FMAL = @HAVE_FMAL@ HAVE_FMODF = @HAVE_FMODF@ HAVE_FMODL = @HAVE_FMODL@ HAVE_FREXPF = @HAVE_FREXPF@ HAVE_FSEEKO = @HAVE_FSEEKO@ HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ HAVE_FUTIMENS = @HAVE_FUTIMENS@ HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ HAVE_GETGROUPS = @HAVE_GETGROUPS@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ HAVE_GETLOGIN = @HAVE_GETLOGIN@ HAVE_GETOPT_H = @HAVE_GETOPT_H@ HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ HAVE_GETTIMEOFDAY = @HAVE_GETTIMEOFDAY@ HAVE_GRANTPT = @HAVE_GRANTPT@ HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@ HAVE_HYPOTF = @HAVE_HYPOTF@ HAVE_HYPOTL = @HAVE_HYPOTL@ HAVE_ILOGB = @HAVE_ILOGB@ HAVE_ILOGBF = @HAVE_ILOGBF@ HAVE_ILOGBL = @HAVE_ILOGBL@ HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ HAVE_ISNAND = @HAVE_ISNAND@ HAVE_ISNANF = @HAVE_ISNANF@ HAVE_ISNANL = @HAVE_ISNANL@ HAVE_ISWBLANK = @HAVE_ISWBLANK@ HAVE_ISWCNTRL = @HAVE_ISWCNTRL@ HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@ HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@ HAVE_LANGINFO_H = @HAVE_LANGINFO_H@ HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@ HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@ HAVE_LCHMOD = @HAVE_LCHMOD@ HAVE_LCHOWN = @HAVE_LCHOWN@ HAVE_LDEXPF = @HAVE_LDEXPF@ HAVE_LINK = @HAVE_LINK@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LOG10F = @HAVE_LOG10F@ HAVE_LOG10L = @HAVE_LOG10L@ HAVE_LOG1P = @HAVE_LOG1P@ HAVE_LOG1PF = @HAVE_LOG1PF@ HAVE_LOG1PL = @HAVE_LOG1PL@ HAVE_LOGBF = @HAVE_LOGBF@ HAVE_LOGBL = @HAVE_LOGBL@ HAVE_LOGF = @HAVE_LOGF@ HAVE_LOGL = @HAVE_LOGL@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ HAVE_MBSLEN = @HAVE_MBSLEN@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMCHR = @HAVE_MEMCHR@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ HAVE_MKFIFO = @HAVE_MKFIFO@ HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ HAVE_MKNOD = @HAVE_MKNOD@ HAVE_MKNODAT = @HAVE_MKNODAT@ HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@ HAVE_MKSTEMP = @HAVE_MKSTEMP@ HAVE_MKSTEMPS = @HAVE_MKSTEMPS@ HAVE_MODFF = @HAVE_MODFF@ HAVE_MODFL = @HAVE_MODFL@ HAVE_MSVC_INVALID_PARAMETER_HANDLER = @HAVE_MSVC_INVALID_PARAMETER_HANDLER@ HAVE_NANOSLEEP = @HAVE_NANOSLEEP@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@ HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OPENDIR = @HAVE_OPENDIR@ HAVE_OS_H = @HAVE_OS_H@ HAVE_PCLOSE = @HAVE_PCLOSE@ HAVE_PIPE = @HAVE_PIPE@ HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POLL = @HAVE_POLL@ HAVE_POLL_H = @HAVE_POLL_H@ HAVE_POPEN = @HAVE_POPEN@ HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ HAVE_POWF = @HAVE_POWF@ HAVE_PREAD = @HAVE_PREAD@ HAVE_PSELECT = @HAVE_PSELECT@ HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@ HAVE_PTSNAME = @HAVE_PTSNAME@ HAVE_PTSNAME_R = @HAVE_PTSNAME_R@ HAVE_PWRITE = @HAVE_PWRITE@ HAVE_RAISE = @HAVE_RAISE@ HAVE_RANDOM = @HAVE_RANDOM@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READDIR = @HAVE_READDIR@ HAVE_READLINK = @HAVE_READLINK@ HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALPATH = @HAVE_REALPATH@ HAVE_REMAINDER = @HAVE_REMAINDER@ HAVE_REMAINDERF = @HAVE_REMAINDERF@ HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_REWINDDIR = @HAVE_REWINDDIR@ HAVE_RINT = @HAVE_RINT@ HAVE_RINTL = @HAVE_RINTL@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = @HAVE_SAME_LONG_DOUBLE_AS_DOUBLE@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ HAVE_SCANDIR = @HAVE_SCANDIR@ HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@ HAVE_SETENV = @HAVE_SETENV@ HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@ HAVE_SIGACTION = @HAVE_SIGACTION@ HAVE_SIGHANDLER_T = @HAVE_SIGHANDLER_T@ HAVE_SIGINFO_T = @HAVE_SIGINFO_T@ HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@ HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@ HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@ HAVE_SIGSET_T = @HAVE_SIGSET_T@ HAVE_SINF = @HAVE_SINF@ HAVE_SINHF = @HAVE_SINHF@ HAVE_SINL = @HAVE_SINL@ HAVE_SLEEP = @HAVE_SLEEP@ HAVE_SQRTF = @HAVE_SQRTF@ 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@ HAVE_STRTOD = @HAVE_STRTOD@ HAVE_STRTOLL = @HAVE_STRTOLL@ HAVE_STRTOULL = @HAVE_STRTOULL@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = @HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ HAVE_SYMLINK = @HAVE_SYMLINK@ HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@ HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@ HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@ HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@ HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ HAVE_SYS_UIO_H = @HAVE_SYS_UIO_H@ HAVE_TANF = @HAVE_TANF@ HAVE_TANHF = @HAVE_TANHF@ HAVE_TANL = @HAVE_TANL@ HAVE_TIMEGM = @HAVE_TIMEGM@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNLOCKPT = @HAVE_UNLOCKPT@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ HAVE_USLEEP = @HAVE_USLEEP@ HAVE_UTIMENSAT = @HAVE_UTIMENSAT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ HAVE_VDPRINTF = @HAVE_VDPRINTF@ HAVE_WCHAR_H = @HAVE_WCHAR_H@ HAVE_WCHAR_T = @HAVE_WCHAR_T@ HAVE_WCPCPY = @HAVE_WCPCPY@ HAVE_WCPNCPY = @HAVE_WCPNCPY@ HAVE_WCRTOMB = @HAVE_WCRTOMB@ HAVE_WCSCASECMP = @HAVE_WCSCASECMP@ HAVE_WCSCAT = @HAVE_WCSCAT@ HAVE_WCSCHR = @HAVE_WCSCHR@ HAVE_WCSCMP = @HAVE_WCSCMP@ HAVE_WCSCOLL = @HAVE_WCSCOLL@ HAVE_WCSCPY = @HAVE_WCSCPY@ HAVE_WCSCSPN = @HAVE_WCSCSPN@ HAVE_WCSDUP = @HAVE_WCSDUP@ HAVE_WCSLEN = @HAVE_WCSLEN@ HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@ HAVE_WCSNCAT = @HAVE_WCSNCAT@ HAVE_WCSNCMP = @HAVE_WCSNCMP@ HAVE_WCSNCPY = @HAVE_WCSNCPY@ HAVE_WCSNLEN = @HAVE_WCSNLEN@ HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@ HAVE_WCSPBRK = @HAVE_WCSPBRK@ HAVE_WCSRCHR = @HAVE_WCSRCHR@ HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@ HAVE_WCSSPN = @HAVE_WCSSPN@ HAVE_WCSSTR = @HAVE_WCSSTR@ HAVE_WCSTOK = @HAVE_WCSTOK@ HAVE_WCSWIDTH = @HAVE_WCSWIDTH@ HAVE_WCSXFRM = @HAVE_WCSXFRM@ HAVE_WCTRANS_T = @HAVE_WCTRANS_T@ HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ HAVE_WCTYPE_T = @HAVE_WCTYPE_T@ HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ HAVE_WINT_T = @HAVE_WINT_T@ HAVE_WMEMCHR = @HAVE_WMEMCHR@ HAVE_WMEMCMP = @HAVE_WMEMCMP@ HAVE_WMEMCPY = @HAVE_WMEMCPY@ HAVE_WMEMMOVE = @HAVE_WMEMMOVE@ HAVE_WMEMSET = @HAVE_WMEMSET@ HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ HAVE_XLOCALE_H = @HAVE_XLOCALE_H@ HAVE__BOOL = @HAVE__BOOL@ HAVE__EXIT = @HAVE__EXIT@ ICONV_CONST = @ICONV_CONST@ ICONV_H = @ICONV_H@ INCLUDE_NEXT = @INCLUDE_NEXT@ INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ INET_PTON_LIB = @INET_PTON_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@ INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBMULTITHREAD = @LIBMULTITHREAD@ LIBOBJS = @LIBOBJS@ LIBPTH = @LIBPTH@ LIBPTH_PREFIX = @LIBPTH_PREFIX@ LIBS = @LIBS@ LIBSOCKET = @LIBSOCKET@ LIBTHREAD = @LIBTHREAD@ LIBTOOL = @LIBTOOL@ LIBUNISTRING_UNISTR_H = @LIBUNISTRING_UNISTR_H@ LIBUNISTRING_UNITYPES_H = @LIBUNISTRING_UNITYPES_H@ LIBUNISTRING_UNIWIDTH_H = @LIBUNISTRING_UNIWIDTH_H@ LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ LIB_CRYPTO = @LIB_CRYPTO@ LIB_POLL = @LIB_POLL@ LIB_SELECT = @LIB_SELECT@ LIPO = @LIPO@ LN_S = @LN_S@ LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@ LOCALE_FR = @LOCALE_FR@ LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@ LOCALE_JA = @LOCALE_JA@ LOCALE_ZH_CN = @LOCALE_ZH_CN@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ LTLIBOBJS = @LTLIBOBJS@ LTLIBPTH = @LTLIBPTH@ LTLIBTHREAD = @LTLIBTHREAD@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NETINET_IN_H = @NETINET_IN_H@ NEXT_ARPA_INET_H = @NEXT_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H = @NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@ NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@ NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@ NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@ NEXT_AS_FIRST_DIRECTIVE_POLL_H = @NEXT_AS_FIRST_DIRECTIVE_POLL_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ 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_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H@ NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@ NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@ NEXT_DIRENT_H = @NEXT_DIRENT_H@ NEXT_ERRNO_H = @NEXT_ERRNO_H@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_FLOAT_H = @NEXT_FLOAT_H@ NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_ICONV_H = @NEXT_ICONV_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ NEXT_LANGINFO_H = @NEXT_LANGINFO_H@ NEXT_LOCALE_H = @NEXT_LOCALE_H@ NEXT_MATH_H = @NEXT_MATH_H@ NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@ NEXT_POLL_H = @NEXT_POLL_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ 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_SELECT_H = @NEXT_SYS_SELECT_H@ NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@ NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@ NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@ NEXT_SYS_UIO_H = @NEXT_SYS_UIO_H@ NEXT_TIME_H = @NEXT_TIME_H@ NEXT_UNISTD_H = @NEXT_UNISTD_H@ NEXT_WCHAR_H = @NEXT_WCHAR_H@ NEXT_WCTYPE_H = @NEXT_WCTYPE_H@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPENSSL_CPPFLAGS = @OPENSSL_CPPFLAGS@ OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POSUB = @POSUB@ PRAGMA_COLUMNS = @PRAGMA_COLUMNS@ PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@ PRIPTR_PREFIX = @PRIPTR_PREFIX@ PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ RANLIB = @RANLIB@ READLINE = @READLINE@ READLINE_DEPEND = @READLINE_DEPEND@ READLINE_DIR = @READLINE_DIR@ REPLACE_BTOWC = @REPLACE_BTOWC@ REPLACE_CALLOC = @REPLACE_CALLOC@ REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ REPLACE_CBRTF = @REPLACE_CBRTF@ REPLACE_CBRTL = @REPLACE_CBRTL@ REPLACE_CEIL = @REPLACE_CEIL@ REPLACE_CEILF = @REPLACE_CEILF@ REPLACE_CEILL = @REPLACE_CEILL@ REPLACE_CHOWN = @REPLACE_CHOWN@ REPLACE_CLOSE = @REPLACE_CLOSE@ REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ REPLACE_DIRFD = @REPLACE_DIRFD@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ REPLACE_DUP = @REPLACE_DUP@ REPLACE_DUP2 = @REPLACE_DUP2@ REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@ REPLACE_EXP2 = @REPLACE_EXP2@ REPLACE_EXP2L = @REPLACE_EXP2L@ REPLACE_EXPM1 = @REPLACE_EXPM1@ REPLACE_EXPM1F = @REPLACE_EXPM1F@ REPLACE_FABSL = @REPLACE_FABSL@ REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ REPLACE_FCNTL = @REPLACE_FCNTL@ REPLACE_FDOPEN = @REPLACE_FDOPEN@ REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOOR = @REPLACE_FLOOR@ REPLACE_FLOORF = @REPLACE_FLOORF@ REPLACE_FLOORL = @REPLACE_FLOORL@ REPLACE_FMA = @REPLACE_FMA@ REPLACE_FMAF = @REPLACE_FMAF@ REPLACE_FMAL = @REPLACE_FMAL@ REPLACE_FMOD = @REPLACE_FMOD@ REPLACE_FMODF = @REPLACE_FMODF@ REPLACE_FMODL = @REPLACE_FMODL@ REPLACE_FOPEN = @REPLACE_FOPEN@ REPLACE_FPRINTF = @REPLACE_FPRINTF@ REPLACE_FPURGE = @REPLACE_FPURGE@ REPLACE_FREOPEN = @REPLACE_FREOPEN@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPF = @REPLACE_FREXPF@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ REPLACE_FSTAT = @REPLACE_FSTAT@ REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ REPLACE_FTRUNCATE = @REPLACE_FTRUNCATE@ REPLACE_FUTIMENS = @REPLACE_FUTIMENS@ REPLACE_GETCWD = @REPLACE_GETCWD@ REPLACE_GETDELIM = @REPLACE_GETDELIM@ REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@ REPLACE_GETDTABLESIZE = @REPLACE_GETDTABLESIZE@ REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ REPLACE_GETLINE = @REPLACE_GETLINE@ REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ REPLACE_GMTIME = @REPLACE_GMTIME@ REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@ REPLACE_HYPOT = @REPLACE_HYPOT@ REPLACE_HYPOTF = @REPLACE_HYPOTF@ REPLACE_HYPOTL = @REPLACE_HYPOTL@ REPLACE_ICONV = @REPLACE_ICONV@ REPLACE_ICONV_OPEN = @REPLACE_ICONV_OPEN@ REPLACE_ICONV_UTF = @REPLACE_ICONV_UTF@ REPLACE_ILOGB = @REPLACE_ILOGB@ REPLACE_ILOGBF = @REPLACE_ILOGBF@ REPLACE_INET_NTOP = @REPLACE_INET_NTOP@ REPLACE_INET_PTON = @REPLACE_INET_PTON@ REPLACE_ISATTY = @REPLACE_ISATTY@ REPLACE_ISFINITE = @REPLACE_ISFINITE@ REPLACE_ISINF = @REPLACE_ISINF@ REPLACE_ISNAN = @REPLACE_ISNAN@ REPLACE_ISWBLANK = @REPLACE_ISWBLANK@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_ITOLD = @REPLACE_ITOLD@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ REPLACE_LINK = @REPLACE_LINK@ REPLACE_LINKAT = @REPLACE_LINKAT@ REPLACE_LOCALECONV = @REPLACE_LOCALECONV@ REPLACE_LOCALTIME = @REPLACE_LOCALTIME@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LOG = @REPLACE_LOG@ REPLACE_LOG10 = @REPLACE_LOG10@ REPLACE_LOG10F = @REPLACE_LOG10F@ REPLACE_LOG10L = @REPLACE_LOG10L@ REPLACE_LOG1P = @REPLACE_LOG1P@ REPLACE_LOG1PF = @REPLACE_LOG1PF@ REPLACE_LOG1PL = @REPLACE_LOG1PL@ REPLACE_LOG2 = @REPLACE_LOG2@ REPLACE_LOG2F = @REPLACE_LOG2F@ REPLACE_LOG2L = @REPLACE_LOG2L@ REPLACE_LOGB = @REPLACE_LOGB@ REPLACE_LOGBF = @REPLACE_LOGBF@ REPLACE_LOGBL = @REPLACE_LOGBL@ REPLACE_LOGF = @REPLACE_LOGF@ REPLACE_LOGL = @REPLACE_LOGL@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ REPLACE_MALLOC = @REPLACE_MALLOC@ REPLACE_MBRLEN = @REPLACE_MBRLEN@ REPLACE_MBRTOWC = @REPLACE_MBRTOWC@ REPLACE_MBSINIT = @REPLACE_MBSINIT@ REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@ REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@ REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@ REPLACE_MBTOWC = @REPLACE_MBTOWC@ REPLACE_MEMCHR = @REPLACE_MEMCHR@ REPLACE_MEMMEM = @REPLACE_MEMMEM@ REPLACE_MKDIR = @REPLACE_MKDIR@ REPLACE_MKFIFO = @REPLACE_MKFIFO@ REPLACE_MKNOD = @REPLACE_MKNOD@ REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ REPLACE_MKTIME = @REPLACE_MKTIME@ REPLACE_MODF = @REPLACE_MODF@ REPLACE_MODFF = @REPLACE_MODFF@ REPLACE_MODFL = @REPLACE_MODFL@ REPLACE_NAN = @REPLACE_NAN@ REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ REPLACE_OPENAT = @REPLACE_OPENAT@ REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POLL = @REPLACE_POLL@ REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PSELECT = @REPLACE_PSELECT@ REPLACE_PTHREAD_SIGMASK = @REPLACE_PTHREAD_SIGMASK@ REPLACE_PTSNAME = @REPLACE_PTSNAME@ REPLACE_PTSNAME_R = @REPLACE_PTSNAME_R@ REPLACE_PUTENV = @REPLACE_PUTENV@ REPLACE_PWRITE = @REPLACE_PWRITE@ REPLACE_QSORT_R = @REPLACE_QSORT_R@ REPLACE_RAISE = @REPLACE_RAISE@ REPLACE_RANDOM_R = @REPLACE_RANDOM_R@ REPLACE_READ = @REPLACE_READ@ REPLACE_READLINK = @REPLACE_READLINK@ REPLACE_READLINKAT = @REPLACE_READLINKAT@ REPLACE_REALLOC = @REPLACE_REALLOC@ REPLACE_REALPATH = @REPLACE_REALPATH@ REPLACE_REMAINDER = @REPLACE_REMAINDER@ REPLACE_REMAINDERF = @REPLACE_REMAINDERF@ REPLACE_REMAINDERL = @REPLACE_REMAINDERL@ REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ REPLACE_SELECT = @REPLACE_SELECT@ REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SETLOCALE = @REPLACE_SETLOCALE@ REPLACE_SIGNBIT = @REPLACE_SIGNBIT@ REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@ REPLACE_SLEEP = @REPLACE_SLEEP@ REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ REPLACE_SPRINTF = @REPLACE_SPRINTF@ REPLACE_SQRTL = @REPLACE_SQRTL@ REPLACE_STAT = @REPLACE_STAT@ REPLACE_STDIO_READ_FUNCS = @REPLACE_STDIO_READ_FUNCS@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STPNCPY = @REPLACE_STPNCPY@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@ REPLACE_STRDUP = @REPLACE_STRDUP@ REPLACE_STRERROR = @REPLACE_STRERROR@ REPLACE_STRERROR_R = @REPLACE_STRERROR_R@ REPLACE_STRNCAT = @REPLACE_STRNCAT@ REPLACE_STRNDUP = @REPLACE_STRNDUP@ REPLACE_STRNLEN = @REPLACE_STRNLEN@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ REPLACE_STRTOIMAX = @REPLACE_STRTOIMAX@ REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ REPLACE_STRTOUMAX = @REPLACE_STRTOUMAX@ REPLACE_STRUCT_LCONV = @REPLACE_STRUCT_LCONV@ REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@ REPLACE_SYMLINK = @REPLACE_SYMLINK@ REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TMPFILE = @REPLACE_TMPFILE@ REPLACE_TOWLOWER = @REPLACE_TOWLOWER@ REPLACE_TRUNC = @REPLACE_TRUNC@ REPLACE_TRUNCF = @REPLACE_TRUNCF@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@ REPLACE_UNLINK = @REPLACE_UNLINK@ REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ REPLACE_UNSETENV = @REPLACE_UNSETENV@ REPLACE_USLEEP = @REPLACE_USLEEP@ REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ REPLACE_VDPRINTF = @REPLACE_VDPRINTF@ REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ REPLACE_VPRINTF = @REPLACE_VPRINTF@ REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@ REPLACE_VSPRINTF = @REPLACE_VSPRINTF@ REPLACE_WCRTOMB = @REPLACE_WCRTOMB@ REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@ REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@ REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@ REPLACE_WCTOB = @REPLACE_WCTOB@ REPLACE_WCTOMB = @REPLACE_WCTOMB@ REPLACE_WCWIDTH = @REPLACE_WCWIDTH@ REPLACE_WRITE = @REPLACE_WRITE@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@ SIZE_T_SUFFIX = @SIZE_T_SUFFIX@ SOCKSLIBS = @SOCKSLIBS@ STDALIGN_H = @STDALIGN_H@ STDBOOL_H = @STDBOOL_H@ STDDEF_H = @STDDEF_H@ STDINT_H = @STDINT_H@ STRIP = @STRIP@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@ UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@ UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@ UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@ WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@ WINT_T_SUFFIX = @WINT_T_SUFFIX@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ YACC = @YACC@ YFLAGS = @YFLAGS@ ZLIB = @ZLIB@ ZLIB_CPPFLAGS = @ZLIB_CPPFLAGS@ ZLIB_LDFLAGS = @ZLIB_LDFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ gl_LIBOBJS = @gl_LIBOBJS@ gl_LTLIBOBJS = @gl_LTLIBOBJS@ gltests_LIBOBJS = @gltests_LIBOBJS@ gltests_LTLIBOBJS = @gltests_LTLIBOBJS@ gltests_WITNESS = @gltests_WITNESS@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ lispdir = @lispdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libtrio.la libtrio_la_SOURCES = trio.c triodef.h trio.h trionan.c trionan.h triop.h triostr.c triostr.h INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/lib all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu trio/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu trio/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libtrio.la: $(libtrio_la_OBJECTS) $(libtrio_la_DEPENDENCIES) $(EXTRA_libtrio_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libtrio_la_OBJECTS) $(libtrio_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trionan.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/triostr.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: lftp-4.6.3a/trio/triostr.c0000644000015000007670000011714312122061103012375 00000000000000/************************************************************************* * * $Id: triostr.c,v 1.17 2002/05/20 12:03:38 breese Exp $ * * Copyright (C) 2001 Bjorn Reese and Daniel Stenberg. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************/ /************************************************************************* * Include files */ #include #include #include #include #include #include "triodef.h" #include "triostr.h" /************************************************************************* * Definitions */ #if !defined(TRIO_STRING_PUBLIC) # define TRIO_STRING_PUBLIC TRIO_PUBLIC #endif #if !defined(TRIO_STRING_PRIVATE) # define TRIO_STRING_PRIVATE TRIO_PRIVATE #endif #if !defined(NULL) # define NULL 0 #endif #if !defined(NIL) # define NIL ((char)0) #endif #if !defined(FALSE) # define FALSE (1 == 0) # define TRUE (! FALSE) #endif #if !defined(BOOLEAN_T) # define BOOLEAN_T int #endif #if defined(TRIO_COMPILER_SUPPORTS_C99) # define USE_STRTOD # define USE_STRTOF #elif defined(TRIO_COMPILER_MSVC) # define USE_STRTOD #endif #if defined(TRIO_PLATFORM_UNIX) # define USE_STRCASECMP # define USE_STRNCASECMP # define USE_STRERROR # if defined(TRIO_PLATFORM_QNX) # define strcasecmp(x,y) stricmp(x,y) # define strncasecmp(x,y,n) strnicmp(x,y,n) # endif #elif defined(TRIO_PLATFORM_WIN32) # define USE_STRCASECMP # define strcasecmp(x,y) strcmpi(x,y) #endif /************************************************************************* * Structures */ struct _trio_string_t { char *content; size_t length; size_t allocated; }; /************************************************************************* * Constants */ #if !defined(TRIO_MINIMAL) static TRIO_CONST char rcsid[] = "@(#)$Id: triostr.c,v 1.17 2002/05/20 12:03:38 breese Exp $"; #endif /************************************************************************* * Static String Functions */ #if defined(TRIO_DOCUMENTATION) # include "doc/doc_static.h" #endif /** @addtogroup StaticStrings @{ */ /** Create new string. @param size Size of new string. @return Pointer to string, or NULL if allocation failed. */ TRIO_STRING_PUBLIC char * trio_create TRIO_ARGS1((size), size_t size) { return (char *)TRIO_MALLOC(size); } /** Destroy string. @param string String to be freed. */ TRIO_STRING_PUBLIC void trio_destroy TRIO_ARGS1((string), char *string) { if (string) { TRIO_FREE(string); } } /** Count the number of characters in a string. @param string String to measure. @return Number of characters in @string. */ TRIO_STRING_PUBLIC size_t trio_length TRIO_ARGS1((string), TRIO_CONST char *string) { return strlen(string); } #if !defined(TRIO_MINIMAL) /** Append @p source at the end of @p target. @param target Target string. @param source Source string. @return Boolean value indicating success or failure. @pre @p target must point to a memory chunk with sufficient room to contain the @p target string and @p source string. @pre No boundary checking is performed, so insufficient memory will result in a buffer overrun. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC int trio_append TRIO_ARGS2((target, source), char *target, TRIO_CONST char *source) { assert(target); assert(source); return (strcat(target, source) != NULL); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Append at most @p max characters from @p source to @p target. @param target Target string. @param max Maximum number of characters to append. @param source Source string. @return Boolean value indicating success or failure. @pre @p target must point to a memory chuck with sufficient room to contain the @p target string and the @p source string (at most @p max characters). @pre No boundary checking is performed, so insufficient memory will result in a buffer overrun. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC int trio_append_max TRIO_ARGS3((target, max, source), char *target, size_t max, TRIO_CONST char *source) { size_t length; assert(target); assert(source); length = trio_length(target); if (max > length) { strncat(target, source, max - length - 1); } return TRUE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Determine if a string contains a substring. @param string String to be searched. @param substring String to be found. @return Boolean value indicating success or failure. */ TRIO_STRING_PUBLIC int trio_contains TRIO_ARGS2((string, substring), TRIO_CONST char *string, TRIO_CONST char *substring) { assert(string); assert(substring); return (0 != strstr(string, substring)); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Copy @p source to @p target. @param target Target string. @param source Source string. @return Boolean value indicating success or failure. @pre @p target must point to a memory chunk with sufficient room to contain the @p source string. @pre No boundary checking is performed, so insufficient memory will result in a buffer overrun. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC int trio_copy TRIO_ARGS2((target, source), char *target, TRIO_CONST char *source) { assert(target); assert(source); (void)strcpy(target, source); return TRUE; } #endif /* !defined(TRIO_MINIMAL) */ /** Copy at most @p max characters from @p source to @p target. @param target Target string. @param max Maximum number of characters to append. @param source Source string. @return Boolean value indicating success or failure. @pre @p target must point to a memory chunk with sufficient room to contain the @p source string (at most @p max characters). @pre No boundary checking is performed, so insufficient memory will result in a buffer overrun. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC int trio_copy_max TRIO_ARGS3((target, max, source), char *target, size_t max, TRIO_CONST char *source) { assert(target); assert(source); assert(max > 0); /* Includes != 0 */ (void)strncpy(target, source, max - 1); target[max - 1] = (char)0; return TRUE; } /* * TrioDuplicateMax */ TRIO_STRING_PRIVATE char * TrioDuplicateMax TRIO_ARGS2((source, size), TRIO_CONST char *source, size_t size) { char *target; assert(source); /* Make room for string plus a terminating zero */ size++; target = trio_create(size); if (target) { trio_copy_max(target, size, source); } return target; } /** Duplicate @p source. @param source Source string. @return A copy of the @p source string. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC char * trio_duplicate TRIO_ARGS1((source), TRIO_CONST char *source) { return TrioDuplicateMax(source, trio_length(source)); } #if !defined(TRIO_MINIMAL) /** Duplicate at most @p max characters of @p source. @param source Source string. @param max Maximum number of characters to duplicate. @return A copy of the @p source string. @post @p target will be zero terminated. */ TRIO_STRING_PUBLIC char * trio_duplicate_max TRIO_ARGS2((source, max), TRIO_CONST char *source, size_t max) { size_t length; assert(source); assert(max > 0); length = trio_length(source); if (length > max) { length = max; } return TrioDuplicateMax(source, length); } #endif /* !defined(TRIO_MINIMAL) */ /** Compare if two strings are equal. @param first First string. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Case-insensitive comparison. */ TRIO_STRING_PUBLIC int trio_equal TRIO_ARGS2((first, second), TRIO_CONST char *first, TRIO_CONST char *second) { assert(first); assert(second); if ((first != NULL) && (second != NULL)) { #if defined(USE_STRCASECMP) return (0 == strcasecmp(first, second)); #else while ((*first != NIL) && (*second != NIL)) { if (toupper(*first) != toupper(*second)) { break; } first++; second++; } return ((*first == NIL) && (*second == NIL)); #endif } return FALSE; } /** Compare if two strings are equal. @param first First string. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Case-sensitive comparison. */ TRIO_STRING_PUBLIC int trio_equal_case TRIO_ARGS2((first, second), TRIO_CONST char *first, TRIO_CONST char *second) { assert(first); assert(second); if ((first != NULL) && (second != NULL)) { return (0 == strcmp(first, second)); } return FALSE; } #if !defined(TRIO_MINIMAL) /** Compare if two strings up until the first @p max characters are equal. @param first First string. @param max Maximum number of characters to compare. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Case-sensitive comparison. */ TRIO_STRING_PUBLIC int trio_equal_case_max TRIO_ARGS3((first, max, second), TRIO_CONST char *first, size_t max, TRIO_CONST char *second) { assert(first); assert(second); if ((first != NULL) && (second != NULL)) { return (0 == strncmp(first, second, max)); } return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ /** Compare if two strings are equal. @param first First string. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Collating characters are considered equal. */ TRIO_STRING_PUBLIC int trio_equal_locale TRIO_ARGS2((first, second), TRIO_CONST char *first, TRIO_CONST char *second) { assert(first); assert(second); #if defined(LC_COLLATE) return (strcoll(first, second) == 0); #else return trio_equal(first, second); #endif } /** Compare if two strings up until the first @p max characters are equal. @param first First string. @param max Maximum number of characters to compare. @param second Second string. @return Boolean indicating whether the two strings are equal or not. Case-insensitive comparison. */ TRIO_STRING_PUBLIC int trio_equal_max TRIO_ARGS3((first, max, second), TRIO_CONST char *first, size_t max, TRIO_CONST char *second) { assert(first); assert(second); if ((first != NULL) && (second != NULL)) { #if defined(USE_STRNCASECMP) return (0 == strncasecmp(first, second, max)); #else /* Not adequately tested yet */ size_t cnt = 0; while ((*first != NIL) && (*second != NIL) && (cnt <= max)) { if (toupper(*first) != toupper(*second)) { break; } first++; second++; cnt++; } return ((cnt == max) || ((*first == NIL) && (*second == NIL))); #endif } return FALSE; } /** Provide a textual description of an error code (errno). @param error_number Error number. @return Textual description of @p error_number. */ TRIO_STRING_PUBLIC TRIO_CONST char * trio_error TRIO_ARGS1((error_number), int error_number) { #if defined(USE_STRERROR) return strerror(error_number); #else return "unknown"; #endif } #if !defined(TRIO_MINIMAL) /** Format the date/time according to @p format. @param target Target string. @param max Maximum number of characters to format. @param format Formatting string. @param datetime Date/time structure. @return Number of formatted characters. The formatting string accepts the same specifiers as the standard C function strftime. */ TRIO_STRING_PUBLIC size_t trio_format_date_max TRIO_ARGS4((target, max, format, datetime), char *target, size_t max, TRIO_CONST char *format, TRIO_CONST struct tm *datetime) { assert(target); assert(format); assert(datetime); assert(max > 0); return strftime(target, max, format, datetime); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Calculate a hash value for a string. @param string String to be calculated on. @param type Hash function. @return Calculated hash value. @p type can be one of the following @li @c TRIO_HASH_PLAIN Plain hash function. */ TRIO_STRING_PUBLIC unsigned long trio_hash TRIO_ARGS2((string, type), TRIO_CONST char *string, int type) { unsigned long value = 0L; char ch; assert(string); switch (type) { case TRIO_HASH_PLAIN: while ( (ch = *string++) != NIL ) { value *= 31; value += (unsigned long)ch; } break; default: assert(FALSE); break; } return value; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Find first occurrence of a character in a string. @param string String to be searched. @param character Character to be found. @param A pointer to the found character, or NULL if character was not found. */ TRIO_STRING_PUBLIC char * trio_index TRIO_ARGS2((string, character), TRIO_CONST char *string, int character) { assert(string); return strchr(string, character); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Find last occurrence of a character in a string. @param string String to be searched. @param character Character to be found. @param A pointer to the found character, or NULL if character was not found. */ TRIO_STRING_PUBLIC char * trio_index_last TRIO_ARGS2((string, character), TRIO_CONST char *string, int character) { assert(string); return strchr(string, character); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Convert the alphabetic letters in the string to lower-case. @param target String to be converted. @return Number of processed characters (converted or not). */ TRIO_STRING_PUBLIC int trio_lower TRIO_ARGS1((target), char *target) { assert(target); return trio_span_function(target, target, tolower); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Compare two strings using wildcards. @param string String to be searched. @param pattern Pattern, including wildcards, to search for. @return Boolean value indicating success or failure. Case-insensitive comparison. The following wildcards can be used @li @c * Match any number of characters. @li @c ? Match a single character. */ TRIO_STRING_PUBLIC int trio_match TRIO_ARGS2((string, pattern), TRIO_CONST char *string, TRIO_CONST char *pattern) { assert(string); assert(pattern); for (; ('*' != *pattern); ++pattern, ++string) { if (NIL == *string) { return (NIL == *pattern); } if ((toupper((int)*string) != toupper((int)*pattern)) && ('?' != *pattern)) { return FALSE; } } /* two-line patch to prevent *too* much recursiveness: */ while ('*' == pattern[1]) pattern++; do { if ( trio_match(string, &pattern[1]) ) { return TRUE; } } while (*string++); return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Compare two strings using wildcards. @param string String to be searched. @param pattern Pattern, including wildcards, to search for. @return Boolean value indicating success or failure. Case-sensitive comparison. The following wildcards can be used @li @c * Match any number of characters. @li @c ? Match a single character. */ TRIO_STRING_PUBLIC int trio_match_case TRIO_ARGS2((string, pattern), TRIO_CONST char *string, TRIO_CONST char *pattern) { assert(string); assert(pattern); for (; ('*' != *pattern); ++pattern, ++string) { if (NIL == *string) { return (NIL == *pattern); } if ((*string != *pattern) && ('?' != *pattern)) { return FALSE; } } /* two-line patch to prevent *too* much recursiveness: */ while ('*' == pattern[1]) pattern++; do { if ( trio_match_case(string, &pattern[1]) ) { return TRUE; } } while (*string++); return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Execute a function on each character in string. @param target Target string. @param source Source string. @param Function Function to be executed. @return Number of processed characters. */ TRIO_STRING_PUBLIC size_t trio_span_function TRIO_ARGS3((target, source, Function), char *target, TRIO_CONST char *source, int (*Function) TRIO_PROTO((int))) { size_t count = 0; assert(target); assert(source); assert(Function); while (*source != NIL) { *target++ = Function(*source++); count++; } return count; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Search for a substring in a string. @param string String to be searched. @param substring String to be found. @return Pointer to first occurrence of @p substring in @p string, or NULL if no match was found. */ TRIO_STRING_PUBLIC char * trio_substring TRIO_ARGS2((string, substring), TRIO_CONST char *string, TRIO_CONST char *substring) { assert(string); assert(substring); return strstr(string, substring); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Search for a substring in the first @p max characters of a string. @param string String to be searched. @param max Maximum characters to be searched. @param substring String to be found. @return Pointer to first occurrence of @p substring in @p string, or NULL if no match was found. */ TRIO_STRING_PUBLIC char * trio_substring_max TRIO_ARGS3((string, max, substring), TRIO_CONST char *string, size_t max, TRIO_CONST char *substring) { size_t count; size_t size; char *result = NULL; assert(string); assert(substring); size = trio_length(substring); if (size <= max) { for (count = 0; count <= max - size; count++) { if (trio_equal_max(substring, size, &string[count])) { result = (char *)&string[count]; break; } } } return result; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Tokenize string. @param string String to be tokenized. @param tokens String containing list of delimiting characters. @return Start of new token. @warning @p string will be destroyed. */ TRIO_STRING_PUBLIC char * trio_tokenize TRIO_ARGS2((string, delimiters), char *string, TRIO_CONST char *delimiters) { assert(delimiters); return strtok(string, delimiters); } #endif /* !defined(TRIO_MINIMAL) */ /** Convert string to floating-point number. @param source String to be converted. @param endp Pointer to end of the converted string. @return A floating-point number. The following Extended Backus-Naur form is used @verbatim double ::= [ ] ( | | ) [ [ ] ] number ::= 1*( ) digit ::= ( '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ) exponential ::= ( 'e' | 'E' ) sign ::= ( '-' | '+' ) decimal_point ::= '.' @endverbatim */ /* FIXME: Add EBNF for hex-floats */ TRIO_STRING_PUBLIC trio_long_double_t trio_to_long_double TRIO_ARGS2((source, endp), TRIO_CONST char *source, char **endp) { #if defined(USE_STRTOLD) return strtold(source, endp); #else int isNegative = FALSE; int isExponentNegative = FALSE; trio_long_double_t integer = 0.0; trio_long_double_t fraction = 0.0; unsigned long exponent = 0; trio_long_double_t base; trio_long_double_t fracdiv = 1.0; trio_long_double_t value = 0.0; /* First try hex-floats */ if ((source[0] == '0') && ((source[1] == 'x') || (source[1] == 'X'))) { base = 16.0; source += 2; while (isxdigit((int)*source)) { integer *= base; integer += (isdigit((int)*source) ? (*source - '0') : 10 + (toupper((int)*source) - 'A')); source++; } if (*source == '.') { source++; while (isxdigit((int)*source)) { fracdiv /= base; fraction += fracdiv * (isdigit((int)*source) ? (*source - '0') : 10 + (toupper((int)*source) - 'A')); source++; } if ((*source == 'p') || (*source == 'P')) { source++; if ((*source == '+') || (*source == '-')) { isExponentNegative = (*source == '-'); source++; } while (isdigit((int)*source)) { exponent *= (int)base; exponent += (*source - '0'); source++; } } } } else /* Then try normal decimal floats */ { base = 10.0; isNegative = (*source == '-'); /* Skip sign */ if ((*source == '+') || (*source == '-')) source++; /* Integer part */ while (isdigit((int)*source)) { integer *= base; integer += (*source - '0'); source++; } if (*source == '.') { source++; /* skip decimal point */ while (isdigit((int)*source)) { fracdiv /= base; fraction += (*source - '0') * fracdiv; source++; } } if ((*source == 'e') || (*source == 'E') #if TRIO_MICROSOFT || (*source == 'd') || (*source == 'D') #endif ) { source++; /* Skip exponential indicator */ isExponentNegative = (*source == '-'); if ((*source == '+') || (*source == '-')) source++; while (isdigit((int)*source)) { exponent *= (int)base; exponent += (*source - '0'); source++; } } } value = integer + fraction; if (exponent != 0) { if (isExponentNegative) value /= pow(base, (double)exponent); else value *= pow(base, (double)exponent); } if (isNegative) value = -value; if (endp) *endp = (char *)source; return value; #endif } /** Convert string to floating-point number. @param source String to be converted. @param endp Pointer to end of the converted string. @return A floating-point number. See @ref trio_to_long_double. */ TRIO_STRING_PUBLIC double trio_to_double TRIO_ARGS2((source, endp), TRIO_CONST char *source, char **endp) { #if defined(USE_STRTOD) return strtod(source, endp); #else return (double)trio_to_long_double(source, endp); #endif } #if !defined(TRIO_MINIMAL) /** Convert string to floating-point number. @param source String to be converted. @param endp Pointer to end of the converted string. @return A floating-point number. See @ref trio_to_long_double. */ TRIO_STRING_PUBLIC float trio_to_float TRIO_ARGS2((source, endp), TRIO_CONST char *source, char **endp) { #if defined(USE_STRTOF) return strtof(source, endp); #else return (float)trio_to_long_double(source, endp); #endif } #endif /* !defined(TRIO_MINIMAL) */ /** Convert string to signed integer. @param string String to be converted. @param endp Pointer to end of converted string. @param base Radix number of number. */ TRIO_STRING_PUBLIC long trio_to_long TRIO_ARGS3((string, endp, base), TRIO_CONST char *string, char **endp, int base) { assert(string); assert((base >= 2) && (base <= 36)); return strtol(string, endp, base); } #if !defined(TRIO_MINIMAL) /** Convert string to unsigned integer. @param string String to be converted. @param endp Pointer to end of converted string. @param base Radix number of number. */ TRIO_STRING_PUBLIC unsigned long trio_to_unsigned_long TRIO_ARGS3((string, endp, base), TRIO_CONST char *string, char **endp, int base) { assert(string); assert((base >= 2) && (base <= 36)); return strtoul(string, endp, base); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /** Convert the alphabetic letters in the string to upper-case. @param target The string to be converted. @return The number of processed characters (converted or not). */ TRIO_STRING_PUBLIC int trio_upper TRIO_ARGS1((target), char *target) { assert(target); return trio_span_function(target, target, toupper); } #endif /* !defined(TRIO_MINIMAL) */ /** @} End of StaticStrings */ /************************************************************************* * Dynamic String Functions */ #if defined(TRIO_DOCUMENTATION) # include "doc/doc_dynamic.h" #endif /** @addtogroup DynamicStrings @{ */ /* * TrioStringAlloc */ TRIO_STRING_PRIVATE trio_string_t * TrioStringAlloc(TRIO_NOARGS) { trio_string_t *self; self = (trio_string_t *)TRIO_MALLOC(sizeof(trio_string_t)); if (self) { self->content = NULL; self->length = 0; self->allocated = 0; } return self; } /* * TrioStringGrow * * The size of the string will be increased by 'delta' characters. If * 'delta' is zero, the size will be doubled. */ TRIO_STRING_PRIVATE BOOLEAN_T TrioStringGrow TRIO_ARGS2((self, delta), trio_string_t *self, size_t delta) { BOOLEAN_T status = FALSE; char *new_content; size_t new_size; new_size = (delta == 0) ? ( (self->allocated == 0) ? 1 : self->allocated * 2 ) : self->allocated + delta; new_content = (char *)TRIO_REALLOC(self->content, new_size); if (new_content) { self->content = new_content; self->allocated = new_size; status = TRUE; } return status; } /* * TrioStringGrowTo * * The size of the string will be increased to 'length' plus one characters. * If 'length' is less than the original size, the original size will be * used (that is, the size of the string is never decreased). */ TRIO_STRING_PRIVATE BOOLEAN_T TrioStringGrowTo TRIO_ARGS2((self, length), trio_string_t *self, size_t length) { length++; /* Room for terminating zero */ return (self->allocated < length) ? TrioStringGrow(self, length - self->allocated) : TRUE; } #if !defined(TRIO_MINIMAL) /** Create a new dynamic string. @param initial_size Initial size of the buffer. @return Newly allocated dynamic string, or NULL if memory allocation failed. */ TRIO_STRING_PUBLIC trio_string_t * trio_string_create TRIO_ARGS1((initial_size), int initial_size) { trio_string_t *self; self = TrioStringAlloc(); if (self) { if (TrioStringGrow(self, (size_t)((initial_size > 0) ? initial_size : 1))) { self->content[0] = (char)0; self->allocated = initial_size; } else { trio_string_destroy(self); self = NULL; } } return self; } #endif /* !defined(TRIO_MINIMAL) */ /** Deallocate the dynamic string and its contents. @param self Dynamic string */ TRIO_STRING_PUBLIC void trio_string_destroy TRIO_ARGS1((self), trio_string_t *self) { assert(self); if (self) { trio_destroy(self->content); TRIO_FREE(self); } } #if !defined(TRIO_MINIMAL) /** Get a pointer to the content. @param self Dynamic string. @param offset Offset into content. @return Pointer to the content. @p Offset can be zero, positive, or negative. If @p offset is zero, then the start of the content will be returned. If @p offset is positive, then a pointer to @p offset number of characters from the beginning of the content is returned. If @p offset is negative, then a pointer to @p offset number of characters from the ending of the string, starting at the terminating zero, is returned. */ TRIO_STRING_PUBLIC char * trio_string_get TRIO_ARGS2((self, offset), trio_string_t *self, int offset) { char *result = NULL; assert(self); if (self->content != NULL) { if (self->length == 0) { (void)trio_string_length(self); } if (offset >= 0) { if (offset > (int)self->length) { offset = self->length; } } else { offset += self->length + 1; if (offset < 0) { offset = 0; } } result = &(self->content[offset]); } return result; } #endif /* !defined(TRIO_MINIMAL) */ /** Extract the content. @param self Dynamic String @return Content of dynamic string. The content is removed from the dynamic string. This enables destruction of the dynamic string without deallocation of the content. */ TRIO_STRING_PUBLIC char * trio_string_extract TRIO_ARGS1((self), trio_string_t *self) { char *result; assert(self); result = self->content; /* FIXME: Allocate new empty buffer? */ self->content = NULL; self->length = self->allocated = 0; return result; } #if !defined(TRIO_MINIMAL) /** Set the content of the dynamic string. @param self Dynamic String @param buffer The new content. Sets the content of the dynamic string to a copy @p buffer. An existing content will be deallocated first, if necessary. @remark This function will make a copy of @p buffer. You are responsible for deallocating @p buffer yourself. */ TRIO_STRING_PUBLIC void trio_xstring_set TRIO_ARGS2((self, buffer), trio_string_t *self, char *buffer) { assert(self); trio_destroy(self->content); self->content = trio_duplicate(buffer); } #endif /* !defined(TRIO_MINIMAL) */ /* * trio_string_size */ TRIO_STRING_PUBLIC int trio_string_size TRIO_ARGS1((self), trio_string_t *self) { assert(self); return self->allocated; } /* * trio_string_terminate */ TRIO_STRING_PUBLIC void trio_string_terminate TRIO_ARGS1((self), trio_string_t *self) { trio_xstring_append_char(self, 0); } #if !defined(TRIO_MINIMAL) /** Append the second string to the first. @param self Dynamic string to be modified. @param other Dynamic string to copy from. @return Boolean value indicating success or failure. */ TRIO_STRING_PUBLIC int trio_string_append TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { size_t length; assert(self); assert(other); length = self->length + other->length; if (!TrioStringGrowTo(self, length)) goto error; trio_copy(&self->content[self->length], other->content); self->length = length; return TRUE; error: return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_append */ TRIO_STRING_PUBLIC int trio_xstring_append TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { size_t length; assert(self); assert(other); length = self->length + trio_length(other); if (!TrioStringGrowTo(self, length)) goto error; trio_copy(&self->content[self->length], other); self->length = length; return TRUE; error: return FALSE; } #endif /* !defined(TRIO_MINIMAL) */ /* * trio_xstring_append_char */ TRIO_STRING_PUBLIC int trio_xstring_append_char TRIO_ARGS2((self, character), trio_string_t *self, char character) { assert(self); if ((int)self->length >= trio_string_size(self)) { if (!TrioStringGrow(self, 0)) goto error; } self->content[self->length] = character; self->length++; return TRUE; error: return FALSE; } #if !defined(TRIO_MINIMAL) /** Search for the first occurrence of second parameter in the first. @param self Dynamic string to be modified. @param other Dynamic string to copy from. @return Boolean value indicating success or failure. */ TRIO_STRING_PUBLIC int trio_string_contains TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_contains(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_contains */ TRIO_STRING_PUBLIC int trio_xstring_contains TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_contains(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_copy */ TRIO_STRING_PUBLIC int trio_string_copy TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); self->length = 0; return trio_string_append(self, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_copy */ TRIO_STRING_PUBLIC int trio_xstring_copy TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); self->length = 0; return trio_xstring_append(self, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_duplicate */ TRIO_STRING_PUBLIC trio_string_t * trio_string_duplicate TRIO_ARGS1((other), trio_string_t *other) { trio_string_t *self; assert(other); self = TrioStringAlloc(); if (self) { self->content = TrioDuplicateMax(other->content, other->length); if (self->content) { self->length = other->length; self->allocated = self->length + 1; } else { self->length = self->allocated = 0; } } return self; } #endif /* !defined(TRIO_MINIMAL) */ /* * trio_xstring_duplicate */ TRIO_STRING_PUBLIC trio_string_t * trio_xstring_duplicate TRIO_ARGS1((other), TRIO_CONST char *other) { trio_string_t *self; assert(other); self = TrioStringAlloc(); if (self) { self->content = TrioDuplicateMax(other, trio_length(other)); if (self->content) { self->length = trio_length(self->content); self->allocated = self->length + 1; } else { self->length = self->allocated = 0; } } return self; } #if !defined(TRIO_MINIMAL) /* * trio_string_equal */ TRIO_STRING_PUBLIC int trio_string_equal TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_equal(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_equal */ TRIO_STRING_PUBLIC int trio_xstring_equal TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_equal(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_equal_max */ TRIO_STRING_PUBLIC int trio_string_equal_max TRIO_ARGS3((self, max, other), trio_string_t *self, size_t max, trio_string_t *other) { assert(self); assert(other); return trio_equal_max(self->content, max, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_equal_max */ TRIO_STRING_PUBLIC int trio_xstring_equal_max TRIO_ARGS3((self, max, other), trio_string_t *self, size_t max, TRIO_CONST char *other) { assert(self); assert(other); return trio_equal_max(self->content, max, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_equal_case */ TRIO_STRING_PUBLIC int trio_string_equal_case TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_equal_case(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_equal_case */ TRIO_STRING_PUBLIC int trio_xstring_equal_case TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_equal_case(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_equal_case_max */ TRIO_STRING_PUBLIC int trio_string_equal_case_max TRIO_ARGS3((self, max, other), trio_string_t *self, size_t max, trio_string_t *other) { assert(self); assert(other); return trio_equal_case_max(self->content, max, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_equal_case_max */ TRIO_STRING_PUBLIC int trio_xstring_equal_case_max TRIO_ARGS3((self, max, other), trio_string_t *self, size_t max, TRIO_CONST char *other) { assert(self); assert(other); return trio_equal_case_max(self->content, max, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_format_data_max */ TRIO_STRING_PUBLIC size_t trio_string_format_date_max TRIO_ARGS4((self, max, format, datetime), trio_string_t *self, size_t max, TRIO_CONST char *format, TRIO_CONST struct tm *datetime) { assert(self); return trio_format_date_max(self->content, max, format, datetime); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_index */ TRIO_STRING_PUBLIC char * trio_string_index TRIO_ARGS2((self, character), trio_string_t *self, int character) { assert(self); return trio_index(self->content, character); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_index_last */ TRIO_STRING_PUBLIC char * trio_string_index_last TRIO_ARGS2((self, character), trio_string_t *self, int character) { assert(self); return trio_index_last(self->content, character); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_length */ TRIO_STRING_PUBLIC int trio_string_length TRIO_ARGS1((self), trio_string_t *self) { assert(self); if (self->length == 0) { self->length = trio_length(self->content); } return self->length; } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_lower */ TRIO_STRING_PUBLIC int trio_string_lower TRIO_ARGS1((self), trio_string_t *self) { assert(self); return trio_lower(self->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_match */ TRIO_STRING_PUBLIC int trio_string_match TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_match(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_match */ TRIO_STRING_PUBLIC int trio_xstring_match TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_match(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_match_case */ TRIO_STRING_PUBLIC int trio_string_match_case TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_match_case(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_match_case */ TRIO_STRING_PUBLIC int trio_xstring_match_case TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_match_case(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_substring */ TRIO_STRING_PUBLIC char * trio_string_substring TRIO_ARGS2((self, other), trio_string_t *self, trio_string_t *other) { assert(self); assert(other); return trio_substring(self->content, other->content); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_xstring_substring */ TRIO_STRING_PUBLIC char * trio_xstring_substring TRIO_ARGS2((self, other), trio_string_t *self, TRIO_CONST char *other) { assert(self); assert(other); return trio_substring(self->content, other); } #endif /* !defined(TRIO_MINIMAL) */ #if !defined(TRIO_MINIMAL) /* * trio_string_upper */ TRIO_STRING_PUBLIC int trio_string_upper TRIO_ARGS1((self), trio_string_t *self) { assert(self); return trio_upper(self->content); } #endif /* !defined(TRIO_MINIMAL) */ /** @} End of DynamicStrings */ lftp-4.6.3a/trio/triop.h0000644000015000007670000001315612122061101012026 00000000000000/************************************************************************* * * $Id: triop.h,v 1.12 2002/06/23 11:58:06 breese Exp $ * * Copyright (C) 2000 Bjorn Reese and Daniel Stenberg. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * ************************************************************************ * * Private functions, types, etc. used for callback functions. * * The ref pointer is an opaque type and should remain as such. * Private data must only be accessible through the getter and * setter functions. * ************************************************************************/ #ifndef TRIO_TRIOP_H #define TRIO_TRIOP_H #include "triodef.h" #include #if defined(TRIO_COMPILER_ANCIENT) # include #else # include #endif #ifdef __cplusplus extern "C" { #endif #ifndef TRIO_C99 # define TRIO_C99 1 #endif #ifndef TRIO_BSD # define TRIO_BSD 1 #endif #ifndef TRIO_GNU # define TRIO_GNU 1 #endif #ifndef TRIO_MISC # define TRIO_MISC 1 #endif #ifndef TRIO_UNIX98 # define TRIO_UNIX98 1 #endif #ifndef TRIO_MICROSOFT # define TRIO_MICROSOFT 0 #endif #ifndef TRIO_EXTENSION # define TRIO_EXTENSION 1 #endif #ifndef TRIO_WIDECHAR /* Does not work yet. Do not enable */ # define TRIO_WIDECHAR 0 #endif #ifndef TRIO_ERRORS # define TRIO_ERRORS 1 #endif #ifndef TRIO_MALLOC # define TRIO_MALLOC(n) malloc(n) #endif #ifndef TRIO_REALLOC # define TRIO_REALLOC(x,n) realloc((x),(n)) #endif #ifndef TRIO_FREE # define TRIO_FREE(x) free(x) #endif /************************************************************************* * User-defined specifiers */ typedef int (*trio_callback_t) TRIO_PROTO((trio_pointer_t)); trio_pointer_t trio_register TRIO_PROTO((trio_callback_t callback, const char *name)); void trio_unregister TRIO_PROTO((trio_pointer_t handle)); TRIO_CONST char *trio_get_format TRIO_PROTO((trio_pointer_t ref)); trio_pointer_t trio_get_argument TRIO_PROTO((trio_pointer_t ref)); /* Modifiers */ int trio_get_width TRIO_PROTO((trio_pointer_t ref)); void trio_set_width TRIO_PROTO((trio_pointer_t ref, int width)); int trio_get_precision TRIO_PROTO((trio_pointer_t ref)); void trio_set_precision TRIO_PROTO((trio_pointer_t ref, int precision)); int trio_get_base TRIO_PROTO((trio_pointer_t ref)); void trio_set_base TRIO_PROTO((trio_pointer_t ref, int base)); int trio_get_padding TRIO_PROTO((trio_pointer_t ref)); void trio_set_padding TRIO_PROTO((trio_pointer_t ref, int is_padding)); int trio_get_short TRIO_PROTO((trio_pointer_t ref)); /* h */ void trio_set_shortshort TRIO_PROTO((trio_pointer_t ref, int is_shortshort)); int trio_get_shortshort TRIO_PROTO((trio_pointer_t ref)); /* hh */ void trio_set_short TRIO_PROTO((trio_pointer_t ref, int is_short)); int trio_get_long TRIO_PROTO((trio_pointer_t ref)); /* l */ void trio_set_long TRIO_PROTO((trio_pointer_t ref, int is_long)); int trio_get_longlong TRIO_PROTO((trio_pointer_t ref)); /* ll */ void trio_set_longlong TRIO_PROTO((trio_pointer_t ref, int is_longlong)); int trio_get_longdouble TRIO_PROTO((trio_pointer_t ref)); /* L */ void trio_set_longdouble TRIO_PROTO((trio_pointer_t ref, int is_longdouble)); int trio_get_alternative TRIO_PROTO((trio_pointer_t ref)); /* # */ void trio_set_alternative TRIO_PROTO((trio_pointer_t ref, int is_alternative)); int trio_get_alignment TRIO_PROTO((trio_pointer_t ref)); /* - */ void trio_set_alignment TRIO_PROTO((trio_pointer_t ref, int is_leftaligned)); int trio_get_spacing TRIO_PROTO((trio_pointer_t ref)); /* TRIO_PROTO((space) */ void trio_set_spacing TRIO_PROTO((trio_pointer_t ref, int is_space)); int trio_get_sign TRIO_PROTO((trio_pointer_t ref)); /* + */ void trio_set_sign TRIO_PROTO((trio_pointer_t ref, int is_showsign)); int trio_get_quote TRIO_PROTO((trio_pointer_t ref)); /* ' */ void trio_set_quote TRIO_PROTO((trio_pointer_t ref, int is_quote)); int trio_get_upper TRIO_PROTO((trio_pointer_t ref)); void trio_set_upper TRIO_PROTO((trio_pointer_t ref, int is_upper)); #if TRIO_C99 int trio_get_largest TRIO_PROTO((trio_pointer_t ref)); /* j */ void trio_set_largest TRIO_PROTO((trio_pointer_t ref, int is_largest)); int trio_get_ptrdiff TRIO_PROTO((trio_pointer_t ref)); /* t */ void trio_set_ptrdiff TRIO_PROTO((trio_pointer_t ref, int is_ptrdiff)); int trio_get_size TRIO_PROTO((trio_pointer_t ref)); /* z / Z */ void trio_set_size TRIO_PROTO((trio_pointer_t ref, int is_size)); #endif /* Printing */ int trio_print_ref TRIO_PROTO((trio_pointer_t ref, const char *format, ...)); int trio_vprint_ref TRIO_PROTO((trio_pointer_t ref, const char *format, va_list args)); int trio_printv_ref TRIO_PROTO((trio_pointer_t ref, const char *format, trio_pointer_t *args)); void trio_print_int TRIO_PROTO((trio_pointer_t ref, int number)); void trio_print_uint TRIO_PROTO((trio_pointer_t ref, unsigned int number)); /* void trio_print_long TRIO_PROTO((trio_pointer_t ref, long number)); */ /* void trio_print_ulong TRIO_PROTO((trio_pointer_t ref, unsigned long number)); */ void trio_print_double TRIO_PROTO((trio_pointer_t ref, double number)); void trio_print_string TRIO_PROTO((trio_pointer_t ref, char *string)); void trio_print_pointer TRIO_PROTO((trio_pointer_t ref, trio_pointer_t pointer)); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* TRIO_TRIOP_H */ lftp-4.6.3a/BUGS0000644000015000007670000000020512131752152010232 00000000000000This file describes some limitations or misfeatures lftp has. * FISH upload to Digital Unix V5.1 does not work correctly (dd bug?). lftp-4.6.3a/NEWS0000644000015000007670000025464712540233601010270 00000000000000Version 4.6.3 - 2015-06-17 * new mirror setting mirror:overwrite and options --overwrite/--no-overwrite. * new mirror option --upload-older. * new mirror option --recursion={always,never,missing,newer}. * try to download zero sized files as they may be non-empty. * torrent: new options --only-new, --only-incomplete. * torrent: fixed endless loop in FD deallocation. * fixed a memleak when parsing a directory listing with special files. * fixed one byte buffer overflow in cls. * fixed cmd:fail-exit description in the man page. * fixed large stack usage when parsing fish directory listings. Version 4.6.2 - 2015-04-16 * new command "edit" instead of the edit alias. * new setting ssl:priority for disabling selected protocols. * new settings fish:auto-confirm and sftp:auto-confirm. * new setting file:use-lock to lock local files before accessing. * ftp: fixed disconnecting on timeout (broken in 4.6.0). * http: enclose ipv6 address in brackets in URLs and Host header. * fixed mirror for http protocol with redirections. * fixed `bookmark edit' to use correct XDG path if XDG is used. * fixed a wildcard certificate validation vulnerability (CVE-2014-0139). * fixed proxy authentication for CONNECT method. * fixed exit code of `help' command. * fixed sftp to show file names with slashes. * fixed pget status display when all chunks are done except the first one. * Ukrainian translation updated (Yuri Chornoivan). * Russian translation updated. Version 4.6.1 - 2014-12-29 * new mirror option --scan-all-first. * mirror --Remove-source-files now removes files already present at the target. * added a workaround for FUSE with HadoopFS I/O error during rename(2). * fixed du to round file size up to block size. * fixed compilation with libressl. * fixed OPTS MLST, removed trailing semicolon. * fixed put to sftp with special files (like /dev/stdin). * fixed ftp to copy SID properly with GnuTLS (Tim Kosse). * fixed mirror to follow redirections to files (Tomas Hozza). Version 4.6.0 - 2014-10-13 * new torrent --share option. * new setting mirror:require-source. * new settings xfer:use-temp-file and xfer:temp-file-name. * ftp: wait for QUIT reply before closing control socket. Version 4.5.6 - 2014-10-13 * display valid IDN in URLs without percent encoding. * ftp: shutdown SSL connection before closing control socket. * ftp: avoid duplication of PROT command. * fixed debug -o to append to the log file. * fixed compilation without SSL. * http: don't uncompress files ending with .gz, .Z or .tgz * http: fixed inflation of some files. * minor fixes in torrent protocol. Version 4.5.5 - 2014-09-04 * added support for internationalized domain names. * added lftp --norc option. * added mirror "Finished" message. * added ftp:catch-size setting. * fixed net:max-retries setting. * fixed byte counters in mirror status. * fixed a segfault in ftps. * fixed a spurious error message in fxp and ftp. Version 4.5.4 - 2014-08-07 * new setting mirror:sort-by (name, size, date). * torrent: reduced cpu and memory usage. * fixed occasional "BUG:deadlock" message. * fixed a segfault when a directory contains duplicate file names. * fixed a memory leak in torrent. * fixed byte counters in mirror --depth-first. * fixed timeout checks in FISH. * translations updated (pl). Version 4.5.3 - 2014-07-06 * new setting ftp:site. * don't uncompress http body when Contrent-Type is compressed. * check source address of DHT replies. * discard disconnected torrent peers only after a timeout. Version 4.5.2 - 2014-06-11 * fixed a coredump on startup when compiled with certain gcc versions. * mkdir -q option for quiet operation. * glob --exist and --not-exist options. * improved torrent status, show piece availability statistics. * remove unconnectable torrent peers on trackerless torrents. Version 4.5.1 - 2014-06-02 * show piece availabilty in torrent status. * fixed a coredump in ftp when data connection fails. * fixed default values of some settings. * fixed http redirection handling. * fixed compilation with gcc-4.8.3. Version 4.5.0 - 2014-05-23 * optimized cpu usage for 10Gb/s transfers by using better data structures and algorithms. * new open option --env-password to take password from LFTP_PASSWORD environment variable. * new `exit parent' subcommand. * new settings http:accept-encoding, http:decode. * new setting xfer:max-log-size to limit transfer log size. * show last disconnect cause for a few seconds in the session status. * improved mirror status to display real-time aggregated byte count and rate. * save torrent matadata on disk and load if available when needed. * improved torrent DHT search. * fixed exit behavior to flush buffered commands. * fixed transfer rate reporting for mirror --parallel. Version 4.4.16 - 2014-05-07 * fixed mirror --loop to re-check base directory contents. * fixed sftp and fish authentication by password with FreeBSD server. * fixed directory index parsing for some http servers. * fixed find command output to avoid extra slash for plain files. * fixed several bugs which could cause segfault. Version 4.4.15 - 2014-01-21 * new setting pget:min-chunk-size. * improved DHT search by preferring responded nodes. * allow UTC timezone in http timestamps. * fixed WebDAV rmdir operation. * fixed torrent hang on shutdown when a tracker is unresposive. * fixed adding too many slashes to URLs in http. Version 4.4.14 - 2013-12-13 * fixed HEAD/PROPFIND handling in http. * a minor memory leak fixed. Version 4.4.13 - 2013-11-26 * fixed a bug in file size checking code. Version 4.4.12 - 2013-11-26 * new option -l (--ls) for find command. * improve workaround for single NL replies from an FTP server. * Ukrainian translation updated (Yuri Chornoivan). * fixed spinning in "get" when no remote session is open. * don't pre-fetch file information in "get" when not needed. * fixed handling of 400/501 http codes for PROPFIND to switch to HEAD. * fixed a crash after cls. * added file size decrease checking. * used a newer libtool for ppc64le platform. Version 4.4.11 - 2013-11-11 * fixed a slow down in mirror from http (thanks to OGAWA Hirofumi). * fixed a coredump in sftp when accessing an inexistent file. Version 4.4.10 - 2013-10-11 * mirror new option --file/-f to mirror a single file. * mirror new option -O for get/put similarity. * WebDAV fixes and improvements. * new setting ftp:use-utf8 to disable utf-8 activation. * fixed handling of incorrect encoding of file names. * fixed compilation without libiconv. * fixed occasional hang in mirror. * kill ssh when terminating fish or sftp connection. Version 4.4.9 - 2013-08-23 * implemented support for mirror -L in sftp. * pass all 3 std file descriptors when attaching to lftp instance. * ftp: added a workaround for incorrectly formatted multiline replies. * sftp: added a workaround for RouterOS v6. * fixed mirror --no-empty-dirs to skip directories with no included files. * fixed segfault when there is no TERM environment variable. * fixed torrent for meta-info files with % in their names. * fixed compilation when IPV6_V6ONLY if not defined. * fixed compilation with older zlib. * fixed FD_CLOEXEC flag on cwd and transfer_log. * fixed MLSD parsing for semicolons in file names. * new translation: Ukrainian (thanks to Yuri Chornoivan). * man page updated. Version 4.4.8 - 2013-05-29 * add support for redirections in torrent metainfo fetching. * add support for gzip Content-Encoding in http. * fixed an endless loop in mirror from sftp. Version 4.4.7 - 2013-05-23 * translations update (pl, cs). * fixed "get -c" looping in some cases. * fixed translations encoding (pl, it, es, pt_BR). * fixed occasional file corruption and garbage logging in Fish protocol. Version 4.4.6 - 2013-05-17 * improved sftp backend with symlink info retrieving (readlink). * new cls option -a to show dot files. * new setting cmd:cls-exact-time. * fixed NULL dereference when torrent:use-dht is off. * fixed torrent for info_hash with NUL character (broken in 4.4.4). Version 4.4.5 - 2013-03-14 * user/group name lookup performance fixed. Version 4.4.4 - 2013-02-27 * added support for TLS SNI extension. * added UDP tracker support. * added cls -a option to show dot files. * new setting cmd:show-status. Version 4.4.3 - 2013-02-07 * fixed an increased CPU usage in case of many cached directories. * fixed a configure problem with included regex. Version 4.4.2 - 2013-02-01 * new settings cmd:at-background, cmd:at-terminate. * fixed plus sign handling in URLs. * fixed uninstall to remove modules. Version 4.4.1 - 2013-01-29 * use XDG directories if ~/.lftp (or $LFTP_HOME) does not exist. * fixed non-interactive mode to skip showing status line. * fixed assert in ftpclass.cc. * fixed coredump after trying to start a duplicate torrent. * fixed verbose status message of some jobs. * fixed some buffers to limit the buffer size. * fixed DHT cache saving. Version 4.4.0 - 2012-09-27 * implemented bittorrent extensions (FAST, DHT, LTEP, ut_metadata, ut_pex). * allow torrent downloading by magnet links. * new setting torrent:use-dht. * new torrent option --dht-bootstrap for manual bootstrapping. * add support for name.utf-8 and path.utf-8 in torrent metadata. * now net:limit-rate and net:limit-total-rate settings can use suffixes, e.g. `set net:limit-total-rate 1M:500k'. * allow numeric user names. * don't try to upload if ALLO fails. * send PROT to ftp servers always when AUTH is activated. * fixed gnutls non-fatal error checking. * fixed execution of at-finish and at-queue-finish in certain cases. * fixed termcap coredump. * fixed opie on 64-bit machines. Version 4.3.8 - 2012-07-03 * treat gnutls decryption error as non-fatal. * fixed core dump in `bm:' pseudo-URL opening. * fixed PROPFIND result parsing (WebDAV). Version 4.3.7 - 2012-05-30 * fixed script execution. * cls fixed to show correct time always. * torrent fixed for large PIDs. * don't check hostname in openssl case with ssl:check-hostname off. Version 4.3.6 - 2012-04-01 * added explicit retracker support (new setting torrent:retracker). * added support for http status code 429 Too Many Requests. * improved ftp login error handling. * fixed errors reported by -Werror=format-security. * fixed http error reporting. Version 4.3.5 - 2012-01-24 * fixed ascii mode uploads to sftp. * fixed "local" command without arguments. * fixed compilation without ssl. * fixed https. * fixed large memory consumption in ftp when target disk is full. Version 4.3.4 - 2011-12-30 * new settings cmd:at-exit-bg, cmd:at-finish, cmd:at-queue-finish. * added timestamps in readline history. * improved attach command to remove stale sockets. * fixed core dump when ftp server does not return valid PWD result. * fixed a special ftp cd case when real cwd equals to the new cwd. * fixed torrent status command line. * fixed torrent to open files with CLOEXEC flag. * fixed exit code of queue command. * fixed mirror to follow local symlinks with -L option. * fixed a crash with https. Version 4.3.3 - 2011-10-20 * new setting ftp:use-tvfs (yes, no, auto). * improved ftp path handling for servers without TVFS feature. * improved closure matching, now *.EXT matches URLs ending with ".EXT". * updated man page. * updated translations. * fixed mirror target directory naming. Version 4.3.2 - 2011-09-16 * fixed fish protocol synchronization when ls fails on the server. * fixed torrent shutting down when the tracker fails. * fixed compilation on Solaris. Version 4.3.1 - 2011-06-28 * fixed a coredump in torrent on linux with a ppp interface. * translation updated (ru). Version 4.3.0 - 2011-06-17 * new command `attach' to control a backgrounded lftp. * automatically fill torrent:ipv6 setting. * slightly improved torrent status display. * fixed reconnect interval (it was sometimes uninitialized). * several fixes for the case of cmd:parallel>1 (Fernando Gutierrez). Version 4.2.3 - 2011-04-29 * don't write passwords to transfer_log. * new setting mirror:no-empty-dirs. * allow `jobs' output to be redirected. * don't list not connected torrent peers by default. * show torrent validation rate and ETA. Version 4.2.2 - 2011-04-11 * fixed `cd -'. * fixed pget for URLs with special symbols. * translations updated (cs, ru). Version 4.2.1 - 2011-03-30 * new setting ftp:use-ip-tos. * optimized torrent validation. * fixed fallocate call. * got rid of sprintf calls. Version 4.2.0 - 2011-03-03 * changed ssl:verify-certificate default to yes. * check certificate common name in openssl case (code from curl). * disable weak algorithms in openssl (Ludwig Nussel ). * new setting xfer:log-file (Timur Sufiev). * support for netkey pasword in ftp (Ryan Thomas ). * added torrent ipv6 support (new setting torrent:ipv6) * don't accept new connections when no torrent can accept them. * allow to specify job numbers in `jobs' command. * fixed a segfault in pget when an error happens on second chunk. Version 4.1.3 - 2011-01-17 * fixed a coredump in torrent (introduced in 4.1.2). Version 4.1.2 - 2010-12-31 * new command ln [-s], supported by FTP (SITE [SYM]LINK), FISH, SFTP, and locally via file: schema. * create remote symlinks in mirror -R if supported by server. * detect and remove duplicate peers in torrent. Version 4.1.1 - 2010-11-24 * fixed job command line display. * fixed some warnings and compilation with old gcc compilers (Openwall). Version 4.1.0 - 2010-11-22 * send path components to ftp server separately, unless TVFS is in FEAT reply. * save pget status at the very beginning of pget execution. * allow mirror pget continuation (mirror -c --use-pget). * allow multiple torrent startup at once (e.g. torrent *.torrent). * pre-allocate disk space in torrent, if posix_fallocate(3) is supported. * new command prefix `local'. It makes the following command use local session instead of remote. * added torrent multi-tracker support. * fixed convert-mozilla-cookies cookie duplication. Version 4.0.10 - 2010-09-01 * use cached file set, don't parse file listing again. * updated convert-netscape-cookies. * fixed a problem with zeroed errno in http. * fixed coredump on mirror --log=file when the file cannot be opened. * translations updated (de, ru). Version 4.0.9 - 2010-06-10 * torrent: don't try to re-download invalid piece from the same peer. * added a short lftp.conf(5) man page (Jiri Skala). * fixed a problem with zeroed errno (Gabriele Balducci). * fixed status of mget from file: schema. * fixed a compilation problem on AIX (Claus K. Larsen). Version 4.0.8 - 2010-05-24 * fixed get/mget -c when xfer:clobber is off. * fixed file verification in pget. * fixed ftp encoding for servers with LANG but without UTF8 feature. Version 4.0.7 - 2010-04-29 * make xfer:clobber off by default. * limit number of attempts to upload a file (net:max-retries). * handle 426 ftp reply to STOR specially. * retry FEAT after login even after non-standard 5xx reply. Version 4.0.6 - 2010-03-25 * use O_EXCL flag when xfer:clobber is off. * better validation of server-provided file name. * new setting xfer:auto-rename (off by default). * new setting ftp:ssl-copy-sid (for some broken servers). * fixed CCC ftp command to shutdown SSL connection properly. * fixed `pget -c' on complete files. Version 4.0.5 - 2009-12-21 * added support for lighttpd listings. * fixed sftp rename. * fixed a core dump on `kill all' with pget. * fixed interrupting of a torrent with unresponsive tracker. * Czech translation updated (Petr Pisar). Version 4.0.4 - 2009-11-19 * added dnssec support (Robert Story). * new setting cmd:stifle-rl-history to limit command history size. Version 4.0.3 - 2009-10-20 * fixed exit code of mget/mput. * fixed compilation on some systems. * fixed crash of `cls -s' on MacOS X x64. Version 4.0.2 - 2009-09-23 * torrent: don't try to connect back to peers which connected to us. Version 4.0.1 - 2009-09-17 * ignore `Status of' line in STAT output (ftp). * fixed handling of files starting with a tilde in ftp. * fixed an infinite bind-loop in ftp. * fixed iconv translit usage for NetBSD. Version 4.0.0 - 2009-09-11 * added torrent client. * automatically set time precision on FAT-like FS (linux only). * fixed timestamps in `mirror --ignore-time'. Version 3.7.15 - 2009-07-21 * fixed http ls when a file name has encoded characters (Jiri Skala). * fixed core dump on `help' command. Version 3.7.14 - 2009-05-15 * use line buffering for mirror log file. * fixed `chmod' command mode calculation. * fixed status line of `repeat' command. * fixed sftp charset translation in file listings. * fixed output ordering by flushing stdout before calling external programs. * fixed coredump in sftp when ssh process gets killed. Version 3.7.13 - 2009-04-30 * fixed a coredump in some commands printing to screen. Version 3.7.12 - 2009-04-28 * fixed core dump on `mput -d' command. * fixed a core dump on `kill' command. * fixed mkdir -p for sftp protocol. * fixed some signed/unsigned conversion bugs. Version 3.7.11 - 2009-03-20 * add dynamic commands in abc order (as output by help). * fixed eta display (broken in 3.7.10). Version 3.7.10 - 2009-03-18 * fixed pget -c. * fixed `exit kill' command. * show sleep time left in status. * make ftp:prefer-epsv off by default. * recognize a specific error message and turn off REST command. Version 3.7.9 - 2009-03-03 * new setting ftp:prefer-epsv. * add support for IPv6 scope for link-local addresses (Arkadiusz Miskiewicz). * fixed compilation on OpenBSD (Kevin Lo). * fixed parsing of NT unix-like listings where hour is one digit. * gnulib sources updated, vsnprintf-posix module imported. Version 3.7.8 - 2009-01-23 * fixed upload via ftps in encrypted mode. * gnulib sources updated. Version 3.7.7 - 2008-12-12 * new ftp proxy auth type: proxy-user@host. * new setting ftp:trust-feat (default no). * changed GPL version to 3 (as gnulib modules require it). Version 3.7.6 - 2008-11-17 * fixed memory corruption in zmore. * fixed compilation on some systems. Version 3.7.5 - 2008-11-07 * new setting cmd:move-background-detach. * added support for number suffixes in settings (k - kibi, m - mebi, etc). * shutdown SSL connection before closing the socket on upload. * fixed mirror -RP. * fixed another problem with `kill all'. * fixed sftp directory listing with unknown entries. * updated gnulib. Version 3.7.4 - 2008-08-06 * fixed a coredump in `kill all'. * fixed compilation problems on some systems. * used getdate from gnulib. Version 3.7.3 - 2008-05-23 * added support for 2-argument SITE UTIME and MFMT commands. * added a workaround for paramiko sftp server. * included newer gnulib sources using gnulib-tool. * Polish translation updated (Jakub Bogusz). * fixed German translation encoding. Version 3.7.2 - 2008-05-07 * fixed core dump when sending http cookies. * fixed assertion failure for ftp over http proxy (CONNECT mode). * fixed cwd tracking for ftps. Version 3.7.1 - 2008-04-18 * use time 12:00:00 instead of 12:00:30 when the time is unknown. * make sftp:use-full-path on by default. * fixed sftp du on non-existent files. * GNU Lib sources updated (Nix ). * fixed compilation on cygwin (Arkady Sherman ). * French translation updated (Alain PORTAL ). * German translation updated (Moritz Moeller-Herrmann ). Version 3.7.0 - 2008-03-07 * new setting ftp:proxy-auth-type and two new ftp proxy modes (joined-acct, open) (partly based on patch from David Wolfe ). * don't add the same network address multiple times; report resolved addresses. * added new open -s option; help for "slot" command (Laurent MONIN ). * added a workaround for proftpd NLST bug. * added a workaround for servers sending single NL. * handle host key verification error in fish and sftp. * handle http codes 307 and 303. * fixed a core dump when doing "open host>file". * fixed CCC handling in secure ftp. * fixed spinning when cmd:fail-exit is true in a script. * included zh_HK translation (Abel Cheung ). Version 3.6.3 - 2008-01-28 * new setting sftp:use-full-path to send full path instead of home-relative. * don't use sftp FSETSTAT when not needed. * fixed core dump on `kill all' with mirror. * fixed sftp:charset setting. * fixed debug printing of sftp file handle. * fixed unsetting of fish:charset setting. * fixed compilation on systems lacking wcwidth. Version 3.6.2 - 2008-01-03 * added a workaround for ftp servers which don't open data connection in certain conditions. * don't decode URL escapes in get/put when no URL schema used. * fixed counting of file removal errors in mirror. * fixed a 2-byte buffer overflow when showing transfer percents. * fixed a problem with incorrect port/host name in http requests. * fixed coredump in du command with long paths on some systems. * fixed coredump in html parser on empty links. * fixed compilation on some systems. Version 3.6.1 - 2007-11-09 * repeat --weak option to terminate the loop automatically when exiting lftp. * ftp:use-stat-for-list is off by default. * slot command fixed. * fixed timeout handling in ftp. * french and polish translations updated. Version 3.6.0 - 2007-10-19 * major code cleanup. * new setting ftp:use-stat-for-list allows faster directory listing. * new command `eval' with -f option allows complex aliases. * send encoded parts of ftp URLs untranslated to ftp server. * new mirror options --on-change, --depth-first, --no-empty-dirs, --ascii. * new mirror option --only-existing (Damon Harper). * new setting xfer:log, log successful transfers if true to ~/.lftp/tarnsfer_log. * new setting ssl:check-hostname. * fixed cls exit code in case of an error. Version 3.5.15 - 2007-10-19 * fixed timeout handling when waiting for 150 or 125 ftp reply. * fixed a bug occuring when turning off proxy server setting. Version 3.5.14 - 2007-08-31 * handle ftp reply with code 125 same as code 150 (Craig Ruff). * french translation updated (Alain PORTAL). Version 3.5.13 - 2007-08-23 * fixed ftps not to access data socket before 150 reply. * fixed sftp to send properly sized packets on upload. * fixed infinite retrying on upload. * fixed compilation without iconv. * fixed buffering in ascii mode transfers. Version 3.5.12 - 2007-07-26 * hex-encode all non-ascii characters in URLs. * allow cross-compilation without iconv (Jakob Truelsen). * french translation updated (Alain PORTAL). Version 3.5.11 - 2007-04-11 * fixed mirror for MDTM-less ftp servers. * fixed readline prompt for \[\] (visible on win32). * fixed compilation with Sun native compiler (Yann Rouillard). Version 3.5.10 - 2007-03-26 * fixed core dump when doing ls on file: connection. * fixed core dump when doing pget to write-protected directory. Version 3.5.9 - 2007-01-09 * fixed `mirror --script' which generated improperly quoted shell commands (potential security vulnerability, when someone executes the resulting script). Version 3.5.8 - 2006-12-28 * fixed `sleep' command. Version 3.5.7 - 2006-12-08 * Fixed a spurious timeout when uploading a file. Version 3.5.6 - 2006-10-12 * fixed a coredump in mget. Version 3.5.5 - 2006-10-05 * new settings cmd:parallel and cmd:queue-parallel to set number of jobs executed in parallel in non-interactive mode and in a queue. * new mirror option --skip-noaccess and setting mirror:skip-noaccess. * fixed a coredump when lftp was compiled with a non-gcc compiler. * fixed compilation when stdbool.h is missing. * fixed a failed assertion. * fixed coredump when doing `ls ..' on a http site. * fixed memory and file descriptor leak in mget/mput. Version 3.5.4 - 2006-08-09 * new setting mirror:include-regex. * load ssl keys for protected data connection as well; use new option ftp:ssl-data-use-keys to disable it. * fixed human-readable options of du and cls. * fixed compilation on certain systems. Version 3.5.3 - 2006-08-04 * fixed a core dump in ftps with gnu tls. * fixed random queue duplication. * fixed compilation with modules and socks. * fixed installation with modules. * added configure --enable-packager-mode option (Daniel Black ). Version 3.5.2 - 2006-07-28 * strip CRs from ls output, as before. * updated help for pget. * fixed mirror -c and get -c hang. * fixed mirror timestamps for hftp and http. * fixed mirror for files starting with a tilde. * fixed use of PROPFIND when http:use-propfind is no. * fixed directory listing and globbing for ftp over http proxy. * updated gnulib sources (Nix ). Version 3.5.1 - 2006-07-05 * fixed a coredump in pget. Version 3.5.0 - 2006-07-05 * implemented pget -c (continue) with a status file. (`set pget:save-status never' to disable periodic saving of the status). * new options of `repeat' command: --count (-c), --delay (-d), --while-ok, --until-ok. * listing and dns cache optimized; added per host enable/disable for caching. * made ABOR more robust. * added support for ALLO command and ftp:use-allo setting. * use binary mode for `quote' (e.g. `quote POST' for http). * sped up uploading in fish protocol. * fixed coredump in pget when terminal lacks prev_line capability. * fixed pget for URLs with question sign. Version 3.4.7 - 2006-05-18 * get1 can now automatically rename files to server suggested file name. * new settings fish:charset and sftp:charset (for sftp version<4). * fixed http chunked transfers with explicit Content-Length. * fixed compilation with sun c++ compiler. * fixed compilation without ssl. Version 3.4.6 - 2006-04-25 * fixed opening sites with explicitly specified port (it could either use default port or spin). * fixed ftps over http proxy with CONNECT method. Version 3.4.5 - 2006-04-22 * handle ftp PRET errors. * send ssh password twice if needed, this fixes a problem with encoded secret keys. * updated programming examples. * fixed cross-references between jobs/tasks libraries and lftp. Version 3.4.4 - 2006-04-06 * new setting mirror:dereference. * new exit options: top, kill. * fixed stalling when uploading empty files with ftps. * fixed lftp exit code when cmd:at-exit is set. * fixed a rare spinning. Version 3.4.3 - 2006-03-15 * don't create target file when source file does not exist. * show done jobs before exit. * changed default for http:use-propfind to no. * fixed condition for getting exact time for cls. * fixed coredump with non-absolute http redirection. * fixed coredump when exiting lftp with a done job. Version 3.4.2 - 2006-02-08 * fixed a coredump in cls (option parsing). * import TIME_STYLE environment variable to cmd:time-style. Version 3.4.1 - 2006-02-07 * new cls option --time-style, new setting cmd:time-style. * use PROPFIND first to check directory existence (http). * fixed CCC - don't try to shutdown ssl connection gracefully. * fixed an abortion when completing with cmd:remote-completion set to false. Version 3.4.0 - 2005-12-31 * flush cache when changing ftp:charset. * show all queued commands on `queue' command. * support open ranges for `mirror --size-range'. * new setting dns:max-retries. * change dns:fatal-timeout setting to accept time interval suffixes. * prefer getaddrinfo over gethostbyname2. * treat GNUTLS_E_UNEXPECTED_PACKET_LENGTH as EOF indicator - this fixes secure ftp with ProFTPD server. * fixed netrc usage when no user name is given. Version 3.3.5 - 2005-12-02 * added mirror --older-than, --size-range and --max-errors options. * improved CCC support - allowed protected transfers after CCC. * added support for sftp v5 and v6 (experimental). * added configure option --with-pager. * fixed file uploading via protected ftp with openssl. * fixed compilation on cygwin. * fixed compilation with sun c++. Version 3.3.4 - 2005-11-15 * added support for CCC command and ftp:ssl-use-ccc setting. * remove password from URLs when showing them on status line. * fixed `open -u' with an URL. * fixed a rare spinning. * fixed compilation on HP-UX. * fixed handling of 334 reply to AUTH command. Version 3.3.3 - 2005-10-21 * added support for LFTP_HOME environment variable. * added workaround for proftpd's empty directories. * fixed `open file:/path'. * fixed some bugs introduced in 3.3.2. Version 3.3.2 - 2005-10-17 * fixed a coredump caused by double-free. Version 3.3.1 - 2005-10-12 * new setting xfer:destination-directory (default for -O option of get, mget). * fixed path+file combination in http - avoid double slash. * fixed url composition in hftp, a slash was missed. * fixed `open ftp.example.com/path'. * fixed a coredump when a bookmark contained lots of quotable characters. * fixed a coredump when an error happened while loading CA or CRL certificates. * fixed uploading of empty files via ftp with ftp:ssl-protect-data on. * fixed exit code of slot command. * fixed a coredump with `kill all'. * fixed path extraction from html files (broken in 3.3.0). Version 3.3.0 - 2005-08-12 * now plain files can be current location in http protocol. * report total bytes transferred and transfer rate in mirror. * included a script for file verification (verify-file). It can check crc32, md5sum, gzip, bzip2, rpm, unzip and other things. * new settings xfer:verify, xfer:verify-command. When xfer:verify is on, verify-command is launched after successful file transfer (to local disk) to check the file consistency. * fixed `source -e' to allow subprocess reading from the terminal. * fixed `source' to return error exit code if the file is unreadable. * fixed `source' on large command files - some commands were truncated. Version 3.2.1 - 2005-05-25 * fixed handling of file names starting with a tilde in sftp protocol. * fixed minor problem with `lftp -u user --help'. * fixed compilation with modules. * fixed compilation without OpenSSL and GnuTLS. * fixed compilation with certain compiler versions. * relaxed version requirement on GnuTLS. Version 3.2.0 - 2005-05-14 * added support for gnutls library. Now OpenSSL is only used if explicitly configured with option --with-openssl, and by default gnutls is used. * added parser for AS/400 ftp listing. * fixed a coredump in mirror when symbolic link target is unknown. * fixed tilde expansion in get -O argument. Version 3.1.3 - 2005-04-15 * added mirror --loop option to re-mirror until no changes found. * fixed mirror creating too many children mirrors. * fixed cls and mirror with http backend, when PROPFIND returns 404 error. * fixed mirror --use-cache with sftp backend. * fixed a rare hang in sftp. Version 3.1.2 - 2005-04-04 * cache negative results, new setting cache:expire-negative. * set http:use-propfind and http:use-mkcol automatically if those methods are unsupported, so that they will not be retried. * handle DAV:creator-displayname in PROPFIND parser. * parse incorrect XML returned for PROPFIND requests as HTML. * fixed coredump and href handling in PROPFIND result parsing. * fixed sftp transfer of growing files. * fixed compilation with socks5 on freebsd. Version 3.1.1 - 2005-03-23 * new setting ftp:ignore-pasv-address. * use IP TOS for ftp connections. * new `quote' command extentions for http: `quote move' and `quote copy' for DAV operations. E.g. `quote copy index.html http://x.org/index2.html'. * fixed timeout handling when waiting for FXP source confirmation. * fixed http DAV method MOVE (use full URL in Destination; fixed stall). Version 3.1.0 - 2005-02-25 * http DAV support added (PROPFIND, MKCOL, DELETE, MOVE). * new setting mirror:set-permissions. * added cls -r option (reverse sorting). * ignore non fatal STAT and FSTAT errors in sftp. * fixed globbing for file names starting with a tilde. * fixed fish and sftp for solaris 9 ssh. * fixed SITE UTIME and overloaded MDTM in ftp protocol. * fixed spinning when local disk is full. * fixed passive ftp mode for some broken servers. * fixed wrong year in cls output when the time is several hours in the future. * fixed Last-Modified parsing in non-english locales. * optimized memory usage for large directories. * compilation fixes for some compilers. Version 3.0.13 - 2004-12-20 * man page updated. * fixed mirror option --no-symlinks (sense reversed). * fixed a coredump. Version 3.0.12 - 2004-12-03 * new setting ftps:initial-prot to workaround broken ftps servers. Default is empty so that lftp would assume it is not known, and if PROT command is not implemented then clear data transfers would be assumed. * ftp over http proxies with CONNECT method can now use proxy authorization. * mirror fixed not to chmod unchanged files (should help incremental backups). * fixed excluding files for sftp protocol (mirror -x). * fixed transfer of growing files over fish protocol. * fixed mkdir over hftp. * fixed delay between connection attempts (broken in 3.0.10). * Polish translation updated. Version 3.0.11 - 2004-11-03 * new mirror option --no-symlinks. * implemented transfer continue in fish protocol (thanks to Loic Le Loarer). * improved completion for aliases. * fixed file removing in mirror --delete-first. * fixed FXP transfer mode (broken in 3.0.7). Version 3.0.10 - 2004-10-20 * better mirror -R completion added. * fixed upload retry corruption bug. * fixed rare coredump in parallel mirror. * don't retry on wrong password in fish and sftp protocols. * don't send empty Cache-Control http header. * don't unconditionally chmod files in mirror. Version 3.0.9 - 2004-09-20 * fixed a hang up when filtering output via an external command (the bug appeared in 3.0.8). * don't use ftp:port-ipv4 in FXP mode. Version 3.0.8 - 2004-09-14 * made http:cache-control host specific; added hftp:cache-control. * new setting http:authorization. * fixed sftp and fish protocols working with FreeBSD servers. * fixed transfer of zero length files when modification time is not known. * fixed put over fish protocol when source file grows. * fixed a core dump in FXP transfer mode. Version 3.0.7 - 2004-08-09 * slow-start in sftp implemented. * ftp proxy which expects user@proxy-user@host is now supported with new boolean setting ftp:proxy-auth-joined. * key passphrase for sftp is now supported. * new setting http:cache-control to set corresponding request header. * don't send FEAT to ftp proxy before login. * fixed timeout handling after FEAT command. * fixed find and du to show status line correctly when output goes to screen. * fixed shell (!) command to return proper error code. * fixed binding ftp data socket in non-passive mode. Version 3.0.6 - 2004-06-12 * completion for bm: URL scheme implemented. * fixed `du' command with large files >2Gb. * fixed saving old directory when no cd verification is performed. * compilation on HP-UX fixed. Version 3.0.5 - 2004-05-31 * new URL scheme bm:bookmark_name[/path] to specify bookmarked URLs. * fixed encrypted FXP in certain server combinations. * fixed ftp retrying on 4xx code when data connection was already closed. * fixed compilation without SSL. Version 3.0.4 - 2004-05-24 * encrypted FXP is now supported with CPSV or SSCN commands. * new setting ftp:ssl-protect-fxp (default is no). * cpu usage optimizations, sftp speed-up. * fixed uploading of zero sized files over ftp. * fixed coredump when AUTH SSL was used and the server refused to setup ssl connection. * fixed coredump on unexpected extra ftp server reply. * added workaround for ftp servers violating RFC2389 (format of FEAT reply). * added workaround for ftp servers which refuse to switch to utf-8 before login. * fixed compilation on systems without strtok_r. Version 3.0.3 - 2004-04-23 * cls for sftp can now print symbolic user, group and number of hard links. * make `cd dir/' check if dir exists. * follow ftp:ssl-force even if ftp server does not advertise AUTH in FEAT reply. * fixed excessive STAT commands in FXP transfer. * fixed core dump when disconnecting with active FXP transfer. * fixed memory leak in sftp uploading and file renaming. Version 3.0.2 - 2004-04-15 * support for ftp commands CLNT, HOST and OPTS MLST added. * ftp command MLSD disabled by default as it does not return symlink info. * added workaround for MLSD format bug in NcFTPd. * fixed spinning in cls when output stalls (e.g. cls|less). * fixed coredump when ftp:proxy was specified without protocol name. * fixed assertion failure when using ftp over http proxy with CONNECT method. * fixed timeout message in sftp when it is disconnected. * fixed compilation on systems lacking atoll function. Version 3.0.1 - 2004-04-06 * fixed timeout handling in sftp. * fixed a coredump in case of some network errors. * fixed compilation with gcc-2.95. * fixed compilation with socks. * fixed compilation without ssl. Version 3.0.0 - 2004-04-02 * sftp protocol support (use `sftp://user@host' URLs). sftp is a protocol implemented as ssh2 subsystem, it is binary and works over a secure channel. * faster directory caching, no re-parsing each time. * ftp now follows RFC2640; FEAT, LANG, UTF8 support; new settings ftp:use-feat and ftp:lang. * ftp can set modification time on remote files using either SITE UTIME or two argument MDTM command (off by default); new settings ftp:use-site-utime and ftp:use-mdtm-overloaded. * ftp can now use MLSD to get machine parseable file listing (ftp:use-mlsd). * charset translation in ftp protocol, new setting ftp:charset. * new mirror option --delete-first to remove old files before transferring new files. By default mirror removes old files after the transfers. * now mirror can replace directories with plain files or symbolic links if --delete (-e) option is specified. * ftp can now use CONNECT method of http proxies (when ftp:use-hftp is false). * mirror open --newer-than can now take time specification like that of at(1) command, like `week ago', `now-7days' or `2004-01-01'. * new mirror options --ignore-size and --only-missing. * new mirror option --use-pget[-n=N] to make mirror use pget to transfer files. * debug output can now include date and time on each line (debug -t). When lftp goes to background, this is turned on by default, along with pid (-p) and context (-c). Try `debug -tcp' and see. * get1 command has now --source-region and --target-position options to get a part of a file. * better handling of ~/.netrc - multiple logins for the same machine are allowed, proper password is taken automatically from netrc if a login matches. * pget has now a progress bar which shows file download state. * new source option -e to execute output of an external program. * chmod -R fixed. * fixed cache invalidation when file name being invalidated ends with a slash. Version 2.6.12 - 2004-01-23 * fixed put over https protocol. * fixed spinning in bg mode when an external program was still running at the time of moving to background. * fixed compilation with IRIX MIPSPro compiler. Version 2.6.11 - 2003-12-22 * fixed mirror for empty files. * a rare coredump fixed in http 0.9 handling, when first line of reply is empty. * compilation fixes for compilers other than gcc. * translations update. Version 2.6.10 - 2003-12-11 * security fixes in html parsing code. * fxp between ftps session is now possible (unencrypted yet). * fixed a rare bug with access to freed memory in ftp. * fixed a bug in mirror, now it does not incorrectly append directory name when target directory is the root. * fixed compilation on AIX. * Polish translation updated. Version 2.6.9 - 2003-11-19 * new setting ftp:ssl-protect-list for encrypting file listings selectively. * don't use PRET again if it is not supported. * added cls --sort=time option (alias for sort=date). * don't set file modification time if it grew while downloading. * new setting cmd:verify-path-cached. * added long options for `open' command. Version 2.6.8 - 2003-10-10 * better multibyte character support. * experimental ftp protocol command PRET added; new setting ftp:use-pret. * unblock SIGCLD signal when running external programs. * fixed included readline compilation. * fixed compilation with socks. Version 2.6.7 - 2003-08-29 * new settings ftp:use-size, ftp:use-mdtm, ftp:use-telnet-iac. * optimized writing to local disk by increasing write size. * fixed size catching from 150 ftp server reply. * correct exit code of commands help, lftp (reported by trancefx). * hftp improvements from Johannes Zellner: CSM proxy support; colored listings; do not print hour:minute if not known. * translations updated. * fixed a bug with saving last working directory for a site. * fixed a bug with FXP of zero sized files. * fixed a bug happening when a 5xx reply is received after QUIT is sent. * readline updated to version 4.3. Version 2.6.6 - 2003-05-28 * raised sane mirror connection limit to 64. * fixed hftp file information retrieval when use-head is off (reported by Robert A. Thompson). * ignore zero size reported by SIZE (for sunsolve.sun.com). * fixed a bug with exclude/include of directories in reverse mirror. * several bugs with mirror --script fixed (reported by Olaf Kaehler). * fixed a bug with unterminated string in HTML parsing; add wwwoffle support (AIDA Shinra). * fixed a bug with ssl settings pointing to files and directories (Diego Reyes). * fixed a bug with sending empty path in HTTP protocol (Geoffrey Lee). * fixed catching of file size from ftp server message 150. * fixed hftp with password - now it should work with all proxies as it sends password in URI even when Authorization header is used. * new debugging command .tasks to show number of tasks. * now lftp does not load/save histories until it interacts with user. E.g. `lftp -c command' does not update ~/.lftp/rl_history now. Version 2.6.5 - 2003-02-28 * new mirror options --log= and --script= to produce lftp commands equivalent to the actions done (log) or to be done (script) by mirror. `-' as file name means stdout. * fixed a dead-lock when resuming FXP with passive source. * re-get file size and date after HTTP redirect. * added workarounds for proftpd. * handle EPIPE (Broken pipe) error as temporary network error. * fixed a dead-lock in HTTP retrieval after redirect. * added cls option --sort=date (Oskar Liljeblad). * fixed compilation on OpenBSD and older Solaris. * fixed handling of symbolic links in find. * lftp -f and -c options can now be combined with -d. * fixed slot handling in non-interactive mode. * fixed large file support in cat command. * fixed dante socks compilation (now lftp does not use poll with dante). * fixed data connection abort with ssl connection to wu-ftpd. Version 2.6.4 - 2002-12-26 * new settings net:socket-bind-ipv4 and net:socket-bind-ipv6 to bind sockets to a specific address (useful to select a specific network interface to use). * now reget does not start transfer if not needed. * ssl:verify-certificate set to no by default. * fixed ~ handling in find and mirror. Version 2.6.3 - 2002-11-04 * fixed wrong eta calculation. * fixed cls when redirected output file was not writable. * fixed uploading of zero sized files over fish protocol. * fixed timezone manipulation on linux. * fixed a compilation problem on hp/ux. Version 2.6.2 - 2002-09-10 * readline history is now stored in a file. * handle full-disk condition as fatal if the file is removed. * recursive deletion (rm -r) fixed. It used DELE instead of RMD. * fixed a rare core dump, usually happening on completion. * fixed compilation with modules. Version 2.6.1 - 2002-08-10 * fixed core dump when handling Content-Disposition. * fixed core dump when specifying zero queue position (Glenn Maynard). * fixed ETA rounding - it was possible to see 1h60m (reported by Igor Zhbanov ). * a number of compile problems fixed. Version 2.6.0 - 2002-08-02 * separated rate limitations for download and upload (set limit-rate 200:100). * added SSL certificate support and several SSL related settings. * connection slot support. Now you can switch sessions with Meta-[123...] or with command `slot '. You can also use slot: as a pseudo-URL. * per-slot queues. Now you can have several queues for the same site using different slots. * queue can be stopped now. Use `queue' with no args to create a stopped queue, `queue start' to run it, `queue stop' to stop it. When you exit lftp, the queue will start automatically. * mirror now appends source base name to target if target ends with a slash. * improved hftp:proxy setting. Now it defaults to http:proxy and is not needed if ftp:proxy is set to `http://...'. * fixed mirror in case of server without MDTM command (Glenn Maynard). * mirror could start multiple transfers if it could not cd to a direcory, even without --parallel (test case by Glenn Maynard). * fixed fd leak in `(commands)' structure (Glenn Maynard). * fixed memory leak in '(commands)'. Version 2.5.4 - 2002-06-05 * fixed double free problem introduced in version 2.5.3. * compilation fixes (Glenn Maynard). Version 2.5.3 - 2002-06-02 * security fix: long error message from ftp server could cause buffer overflow. * fixed ftp:fix-pasv-address. Now the address should be fixed properly. * handle HTTP `100 Continue' in any open mode. * status line fixed: don't write a space to last screen column. * security fix: check that addresses have proper length (Michail Litvak). * migrated to gettext-0.11.2 and automake-1.6.1. Version 2.5.2 - 2002-05-07 * new setting ftp:fxp-force to disable copying data over client. * new settings cache:enable, cache:expire and cache:size for cache control. * create parent directories of target mirror directory. * ignore any error 550 for NLST if no file name is given. * fixed ftp request to http proxy - port number could be missing. * change http request to GET after redirection from a POST request. * handle relative redirect location from a POST request correctly. * try next peer address if server disconnects without greeting message. * a memory leak fixed (Glenn Maynard). * fixed compilation on case-insensitive systems. Version 2.5.1 - 2002-04-16 * translations updated. * fixed a failed assertion when cls redirection could not create file. * fixed a rare coredump when host name becomes unresolvable. * fixed occasional spinning in mirror. * fixed some bugs in trio_sscanf function. * fixed flood of waitpid errors when lftp forks into background. Version 2.5.0a - 2002-03-12 * make it compile without ssl. Version 2.5.0 - 2002-03-06 * mirror understands URLs now. It can mirror between two ftp sites, for example: `mirror ftp://site1/path1 ftp://site2/path2'. It will use FXP if possible. * mirror can now upload/download certain files first based on pattern list, new setting mirror:order contains the pattern list. * mirror has now options -X and -I which allow to specify exclude and include as shell glob patterns. E.g. `mirror -X *.bak'. * mirror can now set file owner/group if it can (--allow-chown option). * mirror options -t, -T, --time-prec and --loose-time-prec are now obsolete, so are settings mirror:time-prec and mirror:loose-time-prec. * find can now understand URLs and plain files specified on command line (Glenn Maynard, Alexander Lukyanov) * chmod can now handle symbolic modes and can work recursively (Glenn Maynard). * now plain ls can also use color for file names. * new setting xfer:disk-full-fatal. When it is false, lftp waits for more disk space instead of cancelling transfers in case of full disk (Glenn Maynard, Alexander Lukyanov). * cls improved (Glenn Maynard). * `bookmark list' hides passwords now. Version 2.4.10a - 2002-03-10 * missed file triostr.h was added. Version 2.4.10 - 2002-02-26 * newer trio library with scanf fix. * try another FXP mode (fxp-passive-source on/off) on any 425 reply. * translations updated. * fixed lftpget -v. Version 2.4.9 - 2002-01-30 * use trio library if system's printf is broken with %lld. * fixed single quote escaping in several places. * fixed coredump if service is unknown. * fixed keep-alive for http/1.1. * fixed uploading in ssl enabled ftp when data connection is protected. * don't send AUTH TLS to ftp proxy. * fixed fish protocol module. Version 2.4.8 - 2001-12-04 * fixed rm and rmdir - they were actually interchanged in 2.4.7. * fixed listing parser in Fish protocol, now it extracts all information. * force LC_NUMERIC to C, this fixes floating point settings initialization. * fixed assertion failure when setting ftp proxy after establishing connection to an ftp server. * fixed a memory leak and some other bugs in cls (Glenn Maynard). Version 2.4.7 - 2001-11-12 * du command (Glenn Maynard). * fixed coredump in `mget -E', introduced in 2.4.6. * speed-optimized directory listing parsing. * fixed EPLF listings. Version 2.4.6 - 2001-10-30 * new setting ftp:timezone to select time zone of file listings. * new setting fish:shell to select remote shell, default is /bin/sh. * translation updates. * optimized cpu usage in ascii mode transfer (Glenn Maynard). * restore prompt when remote completion is interrupted with ^C. * fixed local tilde completion. * compilation fixes. Version 2.4.5 - 2001-10-17 * fish protocol support improved. Now password can be used for authentication. * new command `cls' - colored ls (Glenn Maynard). * colored completion file list, like cls (Glenn Maynard). * `ls' and `cls' now display status before listing is printed. * accept @ in URL passwords (Jonas Jensen). * added a workaround for WarFTPD ABOR glitch. * new configure option --with-included-readline. * powerpc fixes (Aaron Schrab). * fixed a coredump on exit. * fixed home directory glitches (reported by Glenn Maynard). Version 2.4.4 - 2001-09-13 * sometimes lftp forgot to send CWD to restore working directory after reconnect - fixed (bug introduced in 2.4.2). * trio updated. Version 2.4.3 - 2001-09-05 * man page updated. * sometimes lftp did not expand tilde in remote path - fixed. * fixed `bookmark add' in cygwin port. Version 2.4.2 - 2001-08-23 * new setting ftp:home to specify starting directory explicitly. Set it to `/' to override RFC1738 ftp url semantics if you don't like the look of `ftp://host/%2Fpath'. * fixed validation of ftp:ssl-auth. * fixed a coredump with assertion "res==Ftp::OK" failed. * improved abort sequence for passive mode, now wu-ftpd does not hang. * compile proto-fish.so properly when configured with modules. * compilation fixes. Version 2.4.1 - 2001-08-08 * translation updates. * fixed a coredump due to incorrect memory allocation. * compilation fixes. Version 2.4.0 - 2001-07-30 * fish protocol support (over plain ssh connection). * use CONNECT method for https over http proxy. * support for variable name completion (Nicolas Noble). * queue editing support (Glenn F. Maynard). * support http keep-alive in case of chunked transfer encoding. * terminate some never-ending jobs before moving to background. * included trio for systems lacking vsnprintf (Albert Chin). * support for HTTP/1.1 416 reply code. * support for ftp ACCT command (ftp:acct variable) and for SITE GROUP command (ftp:site-group variable). E.g. `set ftp:acct/user@host account/password'. * new setting ftp:port-ipv4 to specify explicitly IP address sent with PORT command (suggested by Julien Oster and Jonas Jensen with patches). * new setting ftp:ssl-auth to specify AUTH argument to use (SSL, TLS, TLS-C or TLS-P). * roxen directory listing support. * fixed reget of non-existent files. * fixed restart of transfer in FXP mode. * fixed rare live-lock in open (it required dns:use-fork=no and happened rarely). * fixed a memory leak happening in resolver when dns:use-fork=no. * fixed debug redirection to a file (debug LEVEL -o log). * fixed glob for */* in http. * fixed a memory leak in find/mirror for ftp protocol (reported by Glenn F. Maynard) * fixed handling of range-end==-1 in http header Content-Range:. Version 2.3.11 - 2001-05-24 * new settings ftp:retry-530 and ftp:retry-530-anonymous. Retry on server reply 530 for PASS command if text matches these regular expressions. These settings should be useful to distinguish between overloaded server (temporary condition) and incorrect password (permanent condition). * retry ftp login quickly on next address if the server has many (works well on ftp.redhat.com, for example). * improved fuzzy variable name matching. Exact prefix and exact name after prefix are taken into account separately. E.g. http:pro is not ambigous now between http:proxy and https:proxy. * implemented -c option for reverse mirror (mirror -R -c). * french translation updated (Nicolas Noble). Version 2.3.10 - 2001-05-11 * used libtool to build modules (finally). * allow open "" to switch to disconnected dummy session. * allow adding bookmark for disconnected dummy session. * fixed ftp listing time conversion for DST. * fixed http Referer generation: don't add extra /. * fixed two buffer overflows (reported by Julie PELAT <42@wanadoo.fr>) * fixed rare deadlock message in case of ftp timeout. * included gettext-0.10.37. * included readline-4.2. * new translation zh_TW (by R.I.P. Deaddog ). * made `lftp@' the default ftp password. Version 2.3.9 - 2001-03-22 * new setting module:path, path to look for modules. * new setting http:referer to send Referer: header, `.' expands to current directory URL. * new setting hftp:use-type to disable `;type=' url suffix. * terminal status line support (Glenn F. Maynard ) * fixed mirror exclude/include options for hftp and http. * ignore certain file locking errors, don't print messages. Version 2.3.8 - 2001-02-16 * miscellaneous improvements. * fixed rate limit with closure (net:limit-rate/ftp.host.com). * don't bind data socket to loopback address. * fixed core dump after asking for ftp:proxy password. * fixed rare spinning in dns child process when parent terminates. * portability fix: make it work on SCO UNIX. * CygWin port: allow command files to be in ascii mode (CRLF). Version 2.3.7 - 2001-01-15 * fixed OPIE/SKEY automatic password generation. * fixed put over http or hftp when server replies `100 Continue'. Version 2.3.6 - 2001-01-02 * new setting cmd:save-cwd-history. * new setting ftp:fix-pasv-address, don't fix PASV address by default. (this fixes a problem with certain masquerading firewalls). * new setting hftp:use-authorization for some proxies (default is yes). * send port in Host: HTTP header. * check net:no-proxy before using hftp instead of ftp. * new commands bzcat, bzmore (Chmouel Boudjnah). Version 2.3.5 - 2000-11-25 * implemented [ipv6::address]:port as specified by rfc2732. * fixed local tilde globbing. * don't wait for file lock forever; print warning if locking fails. * save cwd_history only if needed. * `queue' command now sets last job number to itself. * optimize number of poll calls during ftp transfer. * fixed mput for directory case (continue loop instead of returning). * don't queue up too much MDTM/SIZE commands in sync mode. * fixed --with-modules compilation. Version 2.3.4 - 2000-10-13 * fixed completion and globbing for file names starting with tilde. * some compilation fixes. Version 2.3.3 - 2000-10-01 * fixed `ls|head'. * new setting ftp:bind-data-socket (bool) to disable binding of local end of data connection in passive mode. * japanese translation (Masayuki Hatta) Version 2.3.2 - 2000-09-28 * fixed bug in mirror - some files were not downloaded. * fixed very rare bug with assert(rate_limit!=0). Version 2.3.1 - 2000-09-25 * fixed cmd:move-background handling. * fixed `cd ... &' in queue command. * fixed passive mode IPv6 ftp (Arkadiusz Miskiewicz). * fixed module configuration for https and ftps. * allow ssl path to be specified in --with-ssl=/path (David Champion). * spanish translation updated (Nicolás Lichtmaier). Version 2.3.0 - 2000-09-18 * https and ftps protocols support (openssl library is needed for that). * completion now appends a slash to remote directories (finally!). * new mirror option --parallel=[N] to download several files in parallel. * ask for password for ftp:proxy if not supplied. * now if you set ftp:proxy to http://proxy.host:port, hftp will be used automatically instead of ftp, but pwd will still show ftp://. * large file (>2G) support added. * full http keep-alive support. * new settings http:put-method (PUT or POST), http:put-content-type, http:post-content-type. * new setting xfer:max-redirections for http redirections following. * automatic cookie accepting (off by default). New setting http:set-cookies. * two http specific quote commands: `quote set-cookie' and `quote post'. (e.g. `quote set-cookie var=value' or `quote post /cgi-bin/script.cgi var=value > output'. * send encoded path in http protocol as it was entered by user in URL. (e.g. `get http://www.server.net/abc.cgi?arg=cba -o cba') * new settings http:accept, http:accept-charset, http:accept-language. * new setting cmd:move-background to disable automatic moving to background; `exit bg' forces moving to background. * `wait all' waits for termination of all jobs. * show QUIT reply in debug output. * new setting ftp:use-quit. * new setting net:persist-retries (ignore this number of hard errors). * new setting ftp:auto-sync-mode (extended regex) to match first server reply. * try to connect to original IP when PASV returns address from private network and original IP is not in private network. * mirror can return error code now. * add workarounds for hftp over apache proxy. * use getipnodebyname or getaddrinfo when gethostbyname2 is unavailable. * invalidate dir listing cache on chmod. * fixed pget's eta (sometimes it was not shown). * fixed max-retries and reconnect delay handling when uploading. * fixed `open -u ... -p ... bookmark_name'. Version 2.2.6 - 2000-09-07 * compile fix for AIX (Gombas Gabor). * reformat EPLF even if modification time if absent (Matthias Andree). * russian translation updated (Alexander Lukyanov). * deutsch translation updated (Moritz Moeller-Herrmann). * french translation included (Nicolas Noble). Version 2.2.5 - 2000-07-31 * fixed coredump on completion and globbing on empty directory or when directory listing cannot be completely parsed. * fixed coredump on FreeBSD in `mirror -x/-i'. The bug was found by Andriy I Pilipenko . * fixed coredump on ^V^C^C keyboard sequence. * Spanish translation updated. Version 2.2.4 - 2000-07-12 * fixed chmod and removing old directories in `mirror -R'. * fixed a deadlock in `pget'. * fixed a compile problem in Http.cc. * italian translation updated. Version 2.2.3 - 2000-06-08 * cmd:prompt is now sensitive to TERM variable, e.g. cmd:prompt/xterm. * fixed: send un-localized Last-Modified in http PUT request. * fixed bug in file:/ accessing (which caused hang). * fixed buffer allocation in http. * fixed symlink handling in hftp squid listing. * fixed rare spinning in ascii mode. Version 2.2.2 - 2000-04-29 * added http:cookie setting. * italian and german translations updated. * fixed handling of http timeout - don't always disable ranges. * fixed handling of old (0.9) http servers reply. * fixed stall problem with `glob' command. * really fixed handling of ^Z during `cd' command. Version 2.2.1a - 2000-04-20 * Use http:user-agent for hftp, this fixes hftp core dump. Version 2.2.1 - 2000-04-19 * mirror --Remove-source-files and --loose-time-precision new options. * new settings mirror:time-precision and mirror:loose-time-precision. * new setting http:user-agent. * new setting cmd:interactive. * A bug in error checking fixed, which lead to infinite loops on upload in passive mode when the file could not be created. * pget hang maybe fixed. * fixed handling of ^Z during `cd' command. Version 2.2.0a - 2000-03-29 * A bug in ftp code fixed, it could lead to connection hang. Version 2.2.0 - 2000-03-28 * URLs are now handled in more places: `get URL1 -o URL2', `login URL', `glob URL', `cat URL', `mget URL/*', etc. Setting xfer:use-urls is obsolete, option -u is also obsolete but accepted for compatibility. Completion also works on URLs. `login URL' can be used to cache password for further URL usage. * new settings xfer:eta-period and xfer:rate-period for calculation of eta and current rate. * ascii mode transfers - `get -a', `put -a' etc. * new settings net:connection-limit and net:connection-takeover to limit number of connections to the same site and allow take-over of background connections being used to do foreground operations. * new setting ftp:use-abor. (default: yes) If set to no, lftp does not send ABOR command but closes data connection immediately. * new settings net:reconnect-interval-multiplier and net:reconnect-interval-max, reconnect-interval renamed to reconnect-interval-base. It is possible to use short names, e.g. recon-int-b, recon-int-mul, recon-int-max. * new setting ftp:list-options to append to every LIST command. E.g. it can be useful for some sites to set it to `-a'. Default is empty. * new setting ftp:rest-stor (default: yes) to avoid file corruption on some old and buggy ftp servers after restarted upload. * new setting net:no-proxy. It contains comma separated list of domains. Environment variable no_proxy is copied to net:no-proxy on startup. * `glob' command can now select files by type. By default wildcards are expanded to list of plain files, option `-d' makes it expand to directories and `-a' - to files and directories. * Commands `get', `put', `mget' and `mput' now have an option `-O base' which specifies base directory or URL to which the files should be placed. * ftp to ftp (FXP) copying is now easy, e.g. `get ftp://... -o ftp://...' or `put ftp://...'. The command `ftpcopy' is now obsolete. New settings: ftp:use-fxp, ftp:fxp-passive-source. It does not work for some servers, so use `set ftp:use-fxp no' for them. FXP is also tried both ways - with passive and active source, if both fail it falls back to simple copy. * now lftp remembers that commands MDTM, SIZE or SITE CHMOD are not supported by the server, and does not send them again. * if password is entered on command line it is supposed to be insecure and is printed on screen and entered into bookmarks automatically. * slightly better VMS support. * EPLF listing format is now understood. It is used by anonftpd (e.g. ftp://vgsn.glasnet.ru). * in globbing, if list restart is not used, don't skip list beginning but rather use it instead of previously received. * ftp and hftp URLs are now assumed to have home-relative path. To write root-relative path in such URLs, use ftp://site/%2Fpath. * new setting dns:use-fork. When true, lftp does fork before gethostbyname (as in previous versions) to allow instant interrupting and asynchronousity. (default is true) * new setting cmd:default-protocol. The value is used when open is used with just host name without protocol. Default is `ftp'. * new setting ftp:port-range for active mode port range (useful for firewalls). * mirror --use-cache to allow mirror to use directory listing cache. * check file names in ftp listings for slashes, don't use file names with slashes. * ftp REST bug workaround - send REST 0 if last REST was >0. * ftp server's 19100 in MDTM bug workaround. * fixed completion and file name globbing for wu-ftpd-2.6.0. A long standing bug with multiple path component globbing over ftp has also been fixed. * fixed coredump on `command' with no arguments. Version 2.1.10 - 2000-03-09 * fixed core dump on very long prompt. Version 2.1.9 - 2000-02-22 * fixed command `mv'. It was broken for a year. Version 2.1.8 - 2000-02-18 * fixed a stupid bug in PWD reply extraction. Version 2.1.7 - 2000-02-14 * fixed assertion failure in ftpclass.cc. * fixed handling of PWD reply when it does not include a quoted path. * `mirror -R' now checks time stamps again. Version 2.1.6 - 2000-01-13 * fixed html parser spinning on & in file names when no sequence matches. * fixed compilation on Solaris2.5.1. * korean translation updated. Version 2.1.5 - 2000-01-09 * fixed & and others handling in http links. * fixed sending of port to http proxy. * don't send queued command after 1xx reply in sync mode. * fixed `mget -e': session was Close()'d too early. * fixed connect() problem on NetBSD 1.4P Version 2.1.4 - 1999-10-23 * hftp support for non-anonymous user added * http Proxy-Authorization support added. * new setting hftp:use-head for proxies that don't properly handle HEAD requests for ftp:// URLs. * memory leak in http code fixed. * http/hftp PUT fixed. * a bug in parsing squid ftp listing fixed (some files were shown without info). * fixed handling of base-href in hftp listings. Version 2.1.3 - 1999-10-16 * documentation update. * get: don't create output file early. * http: check if extracted file info is valid. * http: list parser for Mini-Proxy added. * http: fixed core dump on certain html pages. * fixed closure handling in cmd: veriables. * fixed a bug with setting variables using shortened name. * fixed completion for files with spaces in name. Version 2.1.2 - 1999-10-09 * http: ls -F implemented, accept some other options. * hftp: parser for Netscape proxy added. * socks5 and dante support added (--with-socks5, --with-socksdante). * korean translation. * mget -d now uses 0777 mode on directories. * fixed a SEGV due to double freed memory. Version 2.1.1 - 1999-10-02 * close -a now really closes all connections, even if current protocol is http. * extra info in debug output when it goes to a file. * in http listings, strip slash in /~user links. * fixed compile problems on some systems in ResMgr.h, module.c. Version 2.1.0 - 1999-09-27 * ftp over http proxy support via hftp:// notation. * new command `queue' to queue commands for sequential execution. * rate limit for all connections in sum: settings net:limit-total-rate and net:limit-total-max. * dns cache implemented: settings dns:cache-{enable,expire,size}. Use `set dns:cache-expire never' to disable expiration. * improved completion of file names with wildcards. * debug output now clears and redraws the prompt. * mirror now does not overwrite just appeared/changed files. * added a possibility to specify protocol family explicitly in host name: inet6,ftp.hostname.com will resolve to only inet6 address. This can be also acheived by `set dns:order/ftp.hostname.com inet6'. * added xfer:clobber setting. When it is off, get does not overwrite files. * new command `repeat' to repeat a command. E.g. `repeat 1d mirror'. Version 2.0.5 - 1999-09-18 * new translation zh_CN. (by Wang Jian) * fixed unlimited memory usage on `ls -R' when the listing is too large to be cached. * fixed error with `Invalid argument' when kernel is compiled without ipv6 support and host has both ipv4 and ipv6 addresses. * fixed deadlock bug when doing put from named pipe and pipe is slower than network. Version 2.0.4 - 1999-08-11 * added ftp:rest-list setting to allow using of REST/LIST pair. By default it is off, since some ftp servers silently ignore REST before LIST. * ignore SIGXFSZ signal, print an error instead. * try to catch ftp server error "Too many open files". * added options -c, -v, -d to lftpget script. * in mirror, don't reset time stamps on unchanged files. * few fixes in html parser. * fixed get -u to decode %XX in default output file name. * fixed interrupting (^C) of `at' command. * fixed `at' command to quote its arguments for execution. * fixed NT listing parser for files with space in name. * fixed renlist, it was printing long list instead of short one. Version 2.0.3 - 1999-07-25 * added lftpget (get an URL) script to distribution. * fixed rare spining in ls (when pipe stalls). * fixed handling of HREF=/ in http ls. * fixed coredump on mrm without arguments. * fixed coredump from find command when pipe stalls. * fixed compilation problem with T_SRV on some systems. Version 2.0.2 - 1999-07-12 * when background job terminates and its cwd is different from current one, show the cwd in `Done' message. * cd and lcd without argument go to remote/local home directory. * send User-Agent in http request. * html parser improved. * dns SRV records support (`set dns:SRV-query y' to enable). * fixed port representation in URL - colon was missing. * fixed completion for nlist command - should use remote completion. Version 2.0.1 - 1999-06-27 * report ETA more precisely (e.g. 2h15m) * added verbose ETA option (set eta-terse no) * http ls -f file.html to extract links just as from index. * extract http links from frame src and area href too. * added http:cache option to disable server/proxy side cache. * fixed core dump in http ls on certain documents. * workaround for a readline bug causing core dump on certain completions. Version 2.0.0 - 1999-06-15 * command `module' to load shared objects at runtime * autoloading modules for protocols and for some commands (only mirror now) To build with modules use `configure --with-modules'. * http protocol support (via ipv6 too) * socks support (configure --with-socks) * cmd:verbose - show command's summary even in non-interactive mode. * command `lpwd'. * command `glob' to do globbing: e.g. `glob echo *'. * command `chmod'. * since `glob' now exists, `cat', `more', `zcat', `zmore' commands do not do globbing themself now; use `glob cat', or make alias `cat' -> `glob cat'. * mirror -R can now set permission on remote files, if server supports SITE CHMOD. * try all addresses of multihomed hosts. * remote globbing redesigned, now the wildcards are matched locally * finally implemented automatic cache invalidation on certain operations. * ftp over ipv6 support (uses EPSV/EPRT - RFC2428) * NT directory listing parser added * set now prints only altered settings, use set -a to see all * argument for `wait' is now optional. It waits for last bg job by default. * redial-interval is renamed to reconnect-interval * ftp:timeout and some others are renamed to net:... to be shared with http. you can still set them without net: prefix. * dns:timeout renamed to dns:fatal-timeout. * fixed bug with url special chars @/: encoding in user name and password * fixed bug with symbolic ports on little-endian machines * fixed bug with wrong ETA in pget * fixed bug which caused file times set by mirror to be non-precise. * fixed `quote' for certain commands, e.g. `quote stat .'. * fixed `ftpcopy' for the case of `set ftp:passive-mode yes' Version 1.2.4 - 1999-01-11 * small completion improvement: after mirror -N use local completion * now it is possible to do non-checking open and cd using & * few bugs hopefully fixed: sometimes ignoring response to USER, very rare (i.e. can't reproduce) using wrong cwd. Version 1.2.3 - 1998-12-24 * cmd:fail-exit setting. If true, exit when a command fails. Useful for scripts. * fix to "exit" if initial open fails. (was broken in 1.2.2) * fix for "put" to print more correct statistics (in some rare cases it said that negative amount was transferred) Version 1.2.2 - 1998-12-19 * cmd:at-exit setting. Execute given commands before exiting. * mget "" should now work (get all files), useful if `mget *' does not work. * refuse to add empty bookmarks. Version 1.2.1 - 1998-12-17 * updated translations: it (by Giovanni Bortolozzo), pl (by Arkadiusz Mi¶kiewicz) * fixed 'mirror -R' coredump Version 1.2 - 1998-12-08 * rate limit for each connection implemented. set ftp:limit-rate, ftp:limit-max. limit-max is maximum rate accumulated. 0 means unlimited. * path and host verification can be turned off via cmd:verify-* settings. Also verification can be stopped via ^Z. Then path will be set and checked later, same for host name. * added ftp:socket-maxseg option, 0 means system default. * mirror -L: follow symlinks (treat them as files) * completion for open from bookmarks * encode/decode %XX in URLs * rm -r (recursive - be careful) * Polish (pl || pl_PL) translation * don't use ls cache for mget * ftpcopy, sleep, at, find, command - new commands * abort data connection properly * ETA in status (original by jaeger@tekniq.net) * fixed `bookmark list' when there were no bookmarks * fixed `bookmark import' when there were no ~/.lftp/bookmarks * fixed `mirror -i/-x', the pattern was mangled when mirror is used second time. Version 1.1.1 - 1998-08-30 * fix connection leak. It happened when many connection to the same site were open, and then tried to be reused. * exclude "total *" from file name completion * fix error messages of mget/mput Version 1.1 - 1998-08-19 * `suspend' command * when doing `cd -', show real directory on status line * recognize tilde in `source' command * set ftp:verify-address - data connection peer address verification set ftp:verify-port - peer port verification (must be 20) - off by default * try to use cached 'ls' for completion (ls-in-completion setting) * add xfer:use-urls option to make get,mget etc recognize urls by default * add bmk:save-passwords option to save password on `bookmark add' command * make `bookmark delete' complain when bookmark does not exist * lftp -c option (execute command and exit) * set ftp:anon-user, ftp:anon-pass * set dns:timeout to limit host name lookup time * allow redirection for 'bookmark list': bo|grep, etc; same for `set' and `alias'. * print url on `pwd' command, allow redirection * echo command with redirection * skey/opie support (ftp:skey-allow, ftp:skey-force) (suggested/tested by Eugene B. Byrganov) * bookmark edit -- start an editor on bookmarks file bookmark import ncftp/netscape -- import foreign bookmarks (suggested by Sam Steingold) * exit if options given to lftp are incorrect, support --help and --version options for lftp (suggested by Sam Steingold) * use password from .netrc if given user name matches it * fixed memory leak in input routine * fixed spinning when output pipe is closed and data is not available yet Version 1.0.1 - 1998-05-28 * pt_BR translation bugs fixed: * fixed a bug with not expanding sometimes aliases * fixed coredump on (open ...; ls) * fixed a rare coredump in mirror Version 1.0 - 1998-04-29 * debug -o file N: redirect output to the file * builtin alias shell=!, the difference is that ! takes full line to eol * cd -, lcd - * old remote cwd is saved to ~/.lftp/cwd_history for each host separately and it is possible to do 'open host && cd -' to go to last directory * show cd status * mirror option --newer-than FILE: download only files newer than given one * mirror option --verbose, useful for background operation * ~/.lftp/rc - additional rc file * write log to ~/.lftp/log * bookmark command: maintain bookmark file ~/.lftp/bookmarks * close command: close all idle connections with current host * set idle: close idle connections locally * set max-retries: limit maximum number of operation retries (default 0=unlim) * i18n: spanish, russian and italian translations * ftp.kde.org is now accessible in sync mode * use sysconfdir for lftp.conf; /etc for prefix=/usr * output current transfer rate in `jobs', also in pget. * in pget, don't show chunks by default; use `jobs -v' to see them * limited pget status update rate bugs fixed: * several problems with reverse mirror fixed * fixed recursive alias expansion in case of 'alias a "x;a"' * fixed parse bug in line join construct * fixed a bug that forced re-creation of symlinks in mirror * fixed ^C for `more' when pager has not started yet Version 0.14.3 - 1998-03-10 * changed transfer statistics format (x bytes .. in y sec (z b/s)) bugs fixed: * fixed spinning in case relookup-always=on * disabled timeout in store mode when waiting for transfer completion * count bytes in 'put' more precisely on soft errors * 'open host:/;open host:/' bug fixed Version 0.14.2 - 1998-03-03 bugs fixed: * fixed 'lftp -u user' - now asks for password correctly * fixed sync mode: clear waiting flag only after complete response Version 0.14.1 - 1998-02-21 * man page corrected * broken fnmatch should be detected now (e.g. in solaris2.4) * limit transfer status update rate (from Sean Reifschneider) bugs fixed: * 'exit' in lftp -e option: now works again Version 0.14.0 - 1998-01-28 * mirror: default target directory is now basename of source instead of . * mirror: exclude files before MDTM's, don't set time/mode on excluded files * mirror: exclude/include regexp is matched against relative path now * show current minute average transfer speed * reset parser and readline on ^C * file size can be caught from text responce now * debug output is now more realistic in sync mode * reverse mirror (--reverse) (limited - no symlinks, no timestamps) * workaround for \0 characters in server replies (Jason Gunthorpe) * setting closure can now be specified using wildcards (fnmatch) * set ftp:proxy URL - now a user and a password can be used in the URL (protocol of url should be still `ftp' or omitted) * --verbose/--quiet options for ftpget (James Troup) * set ftp:nop-interval - seconds between NOOPs while downloading tail of a file (for broken servers) * `get/reget/pget/cat/zcat/more/zmore -u' recognize URLs now * automatically guess addrlen type (socklen_t/size_t/int) bugs fixed: * mirror could set wrong year on directories in some cases * pget did not set local mtime * lftp had problems with xmalloc on 64-bit platforms due to wrong prototype * fclose(0) could be executed Version 0.13.2 - 1997-11-14 bugs fixed: * sometimes wrong remote directory was used * ftpget -c did not work Version 0.13.1 * completion improved - handle aliases, incomplete commands; catch -o if extra space given. * some compatibility fixes * man page for lftp corrected * mirror: ignore size if the remote file is older and --only-newer is given bugs fixed: * in some cases `put' loose data on soft errors * zero length files could not be uploaded Version 0.13.0 - 1997-10-18 * ftp proxy support: set proxy pxhost:port - default proxy, set proxy/host pxhost:port - proxy for host, set proxy/host "" - no proxy for host * ls output is now line buffered * nlist and renlist commands implemented * compare file name with pattern to prevent untrusted server to fake file names * `lftp -f file' executes the file * mirror can now re-get files with certain conditions, option -c * if --include is specified and --exclude is not, assume to exclude all * moved functionality of parallelftp into lftp (pget command) * ftp:relookup-always (bool) - look up host address always before connecting * Meta-Tab does remote completion now (Tab still guesses completion type) * ^C on command group terminates current job of the group, not the interpreter * better external process handling - using process groups * rm, mrm, mget now use remote completion (James Troup) * rmdir/mkdir should use remote completion too * optional csh-style history expansion * allowed any characters (but \0) in password in .netrc via \ddd * skip macdef's in .netrc * mget -e - remove remote files after successful transfer * integrated patch for documentation/help from James Troup * replaced execl with execlp in ! (shell escape) handling * workaround for server sending ./ or // before file names * completion workaround for servers returning only file names without directory for 'nlist dir' * --without-libresolv to disable libresolv usage Bugs fixed: * should ignore 'Connection timed out' error (and retry) * mirror --no-perms should create directories with default mode * fixed site and quote commands to work with filter correctly * coredump when starting ls in background with a pipe to external command * realloc size in PrependCmd corrected - could coredump * -d option handling for mget fixed * coredump in mirror when using 'jobs -v' * coredump when using shortened subcommands for `cache' * occasional coredump in CatchSIZE_opt/CatchDATE_opt * in some rare cases lftp ate cpu time in background mode * in some cases aliases were not expanded properly * fixed readline-2.1/Makefile.in to enable compiling on `make install' * fixed MirrorJob to create directories with permission to write to them. * default entry of .netrc was used instead of the previous one * `cd ~user' fixed Version 0.12.2 - 1997-07-19 * file 'missing' replaced with common one * readline completion improved to understand quoting properly Bugs fixed: * reput was broken Version 0.12.1 * fail configure when no tgetent function found * print to log that background lftp finished; print pid in the final message `Moving to background' * append / to file name in cd command completion * disconnect on unexpected extra responces * handle remote timeout message better Bugs fixed: * core-dump when receiving error responce after downloading some data fixed * object leak in mput, cat on ^C (caused cpu-eating) fixed Version 0.12.0 * more flexible settings system, now it is possible to tune parameters for each host separately (ex: set sync/ftp.host.org y) * rearranged printing of error messages so that they don't mess with status line * quote command implemented (thanks to Hugo Van den Berg ) * ls cache can now expire * passwords can now appear in URLs; host:/path is recognized * passive mode ftp connection is now supported * command lines can now be joined with \eol * mrm command implemented (globbing rm) Bugs fixed: * `cd ~..' bug fixed * `mput & lcd' bug fixed * memory allocation bug in PrependCmd (calles by `source') fixed * mput did not initialize make_dirs (the variable for -d option). fixed * integer overflow in percent printing for large files fixed * symbolic port was ignored - fixed Version 0.11.1 - 1997-05-12 * timeout and redial-interval are now global * gethostbyname is now done in a separate process, thus allowing instant interrupt and parallelness. Bugs fixed: * fixed a bug in `put' which prevented correct restart of transfer * kill subjobs when they don't have a jobno (else they can't be killed) * alias expansion could cause buffer overflow/core dump (fixed) * completion sometimes opened another ftp connection (fixed) Version 0.11.0 * automake used * various options for mirror * allowed comments # * optimized file date/size retrieve (parallel with RETR) * allowed wildcards in cat, more, zcat, zmore * allowed help for command abbreviations * log errors to ~/.lftp_log when moved to background * cache ls output, rels to re-ls * `cache' command to control cache * show percents completed * allow kill for any job; not kill subjobs but rather reparent them * expand ~ in get/put * when `get rfile -o lfile' used and lfile is a directory, write to file named as basename of rfile in the directory lfile. * sync-mode is the default now, so it should work always. If you want speed and it works for you, turn it off (set sync-mode n). * improved printing debug slightly - now it does not mess up with status * added several escapes in prompt (Suggested by Ed Grimm) * mkdir -p * debug printing control now works globally * exit now can return exit code to system * poll.h replaced Bugs fixed: * a bug caused spinning when mirror dealt with symlink - fixed * `user' did not reset home dir - fixed * corrected multiline responce handling - terminate with the same code as it started. * `open -u user' sometimes did not ask for password - fixed * directory count corrected in mirror Version 0.10.7 - 1997-03-09 * unitialized variable could cause unneeded SIZE or MDTM commands or coredump * bug in configure which prevented use of preinstalled readline - fixed Version 0.10.6 * home-relative paths were handled incorrectly since 0.10.5 * expand shortened commands to use correct argv0 Version 0.10.5 * path handling - fix for //dir * Buffer overrun sometimes caused 'not supported protocol' errors * blocking logic corrected for GetJob Version 0.10.4 * in some rare cases it did not catch EAGAIN errors and printed 'Resource temporary unavailable' - fixed * a bug in REST command handling could cause some cpu-eating * ignore local directories . and .. in mirror.cc * restore Ftp flags from env vars after Connect (CmdExec.cc) * inherit env vars when creating sub-CmdExec * put command name in error messages (XferJob.cc) Version 0.10.3 * make Connect less blocking (external loop) * reimplemented reconnect on timeout (occasionally dropped in 0.10.0) * set mode on newly created files in mirror * improve error handling in RemoteGlob * add options --delete, --allow-suid for mirror * don't retrive file date when it is impossible to set it locally * awful bug in reput (namely `reput' not `put -c') (file was truncated) fixed Version 0.10.2 * stupid forgotten case caused abort() * `open' (and Ftp::Connect) did not reset home - fixed * error code DO_AGAIN simplified handling of Ftp errors * #ifdef S_ISLNK for Unixware and such. Version 0.10.1 * in ftpclass.cc, FlushSendQueue, errors were effectively ignored - fixed (this one could lead to time-eating) * `put' skipped next file after error - fixed * `get' could break after dl error - fixed * man pages (Christoph Lameter ) * read /etc/lftp.conf on startup Version lftp-0.10.0 * The package renamed to lftp * help improved * readline from bash-2.0 used (hook for rl_getc) * mv * mirror * `long-running' parameter * `timeout' parameter * `redial-interval' parameter * alias listing on `alias' * parameters handling improvement (shortened names allowed) * site command * () command groupping (like in shell) * && and || command separation (like in shell) * wait command * Complete rewrite for new object model * open doesn't turn off debugging Version ftpclass-0.5.4 * dosish style path recognition * ignore intermediate responces 1xy * command on cmd line of lftp (-e option) * don't use SIZE when in norest_mode (ftptransfer.cc) * fixed rate calc for put (ftptransfer.cc) * fixed hanging in FtpTransfer::waitpid for filter_pid * added -w option for get,put,mget (wait for a transfer) Version 0.5.3 * wait_fg should print `done' when the transfer is complete * FtpTransfer::Step cleanup * not destroying foreground dession in close_transfer * help ca/anon did not output LF * don't give data to program until REST result is known * long options for ftpget * ask password in ftpget if not given * NOREST_MODE - dumb but it works Version 0.5.2 * don't call all_transfers_check_done from wait_fg_transfer * don't print password on debug * don't disconnect on "Broken pipe" responce * ftptransfer rewrite * added mkdir,rmdir,rm (MAKE_DIR,REMOVE_DIR,REMOVE) * now lftp uses .netrc for default login * now it should work if ftpd doesn't ask for password Version 0.5.1 * non-sync mode should not be default :) * fixed GetPollVector to notice SYNC_WAIT Version 0.5.0 * readline completion support * was disconnecting on NO_FILE condition - fixed * foreground session was left open after cd - fixed * url support - open ftp://host/path, cd ftp://host/path * synchronous mode operation -- works with buggy NT ftp server and with old one at ftp.sunlabs.com. Use 'set sync_mode y' to turn it on. Version 0.4.6 * was wrongly printing status when doing cat - fixed * did not close data socket in Ftp::Close - fixed * lftp: added 'source' command * lftp: disconnect foreground session before moving to background Version 0.4.5 * not closing files in 'mget' - fixed * don't close ftp session when downloading several files in chain Version 0.4.4 * lftp: help improvement (no long desc yet) * lftp: command separation with ';' * 'cd ok, cwd=' another fix (hopefully the last) * lftp: ~/ handling in lcd * lftp: fixed options handling in mget * ftpclass: anon_pass inheritance * Ftp::operator= * Used readline from bash-1.14.7, stock 2.0 had problems with FreeBSD * configure changes - now all handled in one configure Version 0.4.3 * fixed changing wait_chain in close_transfer_session (affected 'kill') * fixed REST&NLST, NLST mode&Transfer complete * fixed falling back to non-waiting transfer in add_transfer * lftp: added mget * lftp and ftpclass: added handling of ~/ * ftpclass: portability fix: timezone/tm_gmtoff autoconf (for FreeBSD) Version 0.4.2 * lftp: set prompt * lftp: wait chains * ftpclass: SendEOT ... many small changes which I don't remember Version 0.4.1 ... no change log was being written lftp-4.6.3a/AUTHORS0000644000015000007670000000022012122054516010613 00000000000000Primary author (idea, most of the code): Alexander V. Lukyanov Major contributors: Glenn F. Maynard lftp-4.6.3a/lftp.lsm0000644000015000007670000000276712540300657011253 00000000000000Begin3 Title: LFTP command line file transfer program Version: 4.6.3a Entered-date: 2015-06-17 Description: LFTP is a shell-like command line file transfer program. It is reliable: can retry operations and does reget automatically. It can do several transfers simultaneously in background. You can start a transfer in background and continue browsing the ftp site or another one. This all is done in one process. Background jobs will be completed in nohup mode if you exit or close modem connection. Lftp has reput, mirror, reverse mirror among its features. Since version 2.0 it also supports http protocol. Other features include: ipv6 support, context sensitive completion, output redirection to files or to pipe, SOCKS support (configure option), ftp and http proxy support, transfer rate throttling for each connection and for all connections in sum, job queueing, job execution at specified time, opie/skey support in ftp protocol, ssl for http and ftp, fxp transfers. Version 3.0 supports sftp v3 and v4 protocols. Version 4.0 supports BitTorrent protocol. Keywords: ftp, client, readline, reliable, background, parallel, http, protocol, network, fish, sftp, https, ftps, torrent Author: lav@yars.free.net (Alexander V. Lukyanov) Maintained-by: lav@yars.free.net (Alexander V. Lukyanov) Primary-site: ftp.yars.free.net /pub/source/lftp 2584 kB lftp-4.6.3a.tar.gz Alternate-site: metalab.unc.edu /pub/Linux/system/network/file-transfer Platforms: Unix, G++ Copying-policy: GNU GPL End lftp-4.6.3a/ABOUT-NLS0000644000015000007670000026713312540234024011012 000000000000001 Notes on the Free Translation Project *************************************** Free software is going international! The Free Translation Project is a way to get maintainers of free software, translators, and users all together, so that free software will gradually become able to speak many languages. A few packages already provide translations for their messages. If you found this `ABOUT-NLS' file inside a distribution, you may assume that the distributed package does use GNU `gettext' internally, itself available at your nearest GNU archive site. But you do _not_ need to install GNU `gettext' prior to configuring, installing or using this package with messages translated. Installers will find here some useful hints. These notes also explain how users should proceed for getting the programs to use the available translations. They tell how people wanting to contribute and work on translations can contact the appropriate team. 1.1 INSTALL Matters =================== Some packages are "localizable" when properly installed; the programs they contain can be made to speak your own native language. Most such packages use GNU `gettext'. Other packages have their own ways to internationalization, predating GNU `gettext'. By default, this package will be installed to allow translation of messages. It will automatically detect whether the system already provides the GNU `gettext' functions. Installers may use special options at configuration time for changing the default behaviour. The command: ./configure --disable-nls will _totally_ disable translation of messages. When you already have GNU `gettext' installed on your system and run configure without an option for your new package, `configure' will probably detect the previously built and installed `libintl' library and will decide to use it. If not, you may have to to use the `--with-libintl-prefix' option to tell `configure' where to look for it. Internationalized packages usually have many `po/LL.po' files, where LL gives an ISO 639 two-letter code identifying the language. Unless translations have been forbidden at `configure' time by using the `--disable-nls' switch, all available translations are installed together with the package. However, the environment variable `LINGUAS' may be set, prior to configuration, to limit the installed set. `LINGUAS' should then contain a space separated list of two-letter codes, stating which languages are allowed. 1.2 Using This Package ====================== As a user, if your language has been installed for this package, you only have to set the `LANG' environment variable to the appropriate `LL_CC' combination. If you happen to have the `LC_ALL' or some other `LC_xxx' environment variables set, you should unset them before setting `LANG', otherwise the setting of `LANG' will not have the desired effect. Here `LL' is an ISO 639 two-letter language code, and `CC' is an ISO 3166 two-letter country code. For example, let's suppose that you speak German and live in Germany. At the shell prompt, merely execute `setenv LANG de_DE' (in `csh'), `export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). This can be done from your `.login' or `.profile' file, once and for all. You might think that the country code specification is redundant. But in fact, some languages have dialects in different countries. For example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The country code serves to distinguish the dialects. The locale naming convention of `LL_CC', with `LL' denoting the language and `CC' denoting the country, is the one use on systems based on GNU libc. On other systems, some variations of this scheme are used, such as `LL' or `LL_CC.ENCODING'. You can get the list of locales supported by your system for your language by running the command `locale -a | grep '^LL''. Not all programs have translations for all languages. By default, an English message is shown in place of a nonexistent translation. If you understand other languages, you can set up a priority list of languages. This is done through a different environment variable, called `LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' for the purpose of message handling, but you still need to have `LANG' set to the primary language; this is required by other parts of the system libraries. For example, some Swedish users who would rather read translations in German than English for when Swedish is not available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. Special advice for Norwegian users: The language code for Norwegian bokma*l changed from `no' to `nb' recently (in 2003). During the transition period, while some message catalogs for this language are installed under `nb' and some older ones under `no', it's recommended for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and older translations are used. In the `LANGUAGE' environment variable, but not in the `LANG' environment variable, `LL_CC' combinations can be abbreviated as `LL' to denote the language's main dialect. For example, `de' is equivalent to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' (Portuguese as spoken in Portugal) in this context. 1.3 Translating Teams ===================== For the Free Translation Project to be a success, we need interested people who like their own language and write it well, and who are also able to synergize with other translators speaking the same language. Each translation team has its own mailing list. The up-to-date list of teams can be found at the Free Translation Project's homepage, `http://translationproject.org/', in the "Teams" area. If you'd like to volunteer to _work_ at translating messages, you should become a member of the translating team for your own language. The subscribing address is _not_ the same as the list itself, it has `-request' appended. For example, speakers of Swedish can send a message to `sv-request@li.org', having this message body: subscribe Keep in mind that team members are expected to participate _actively_ in translations, or at solving translational difficulties, rather than merely lurking around. If your team does not exist yet and you want to start one, or if you are unsure about what to do or how to get started, please write to `coordinator@translationproject.org' to reach the coordinator for all translator teams. The English team is special. It works at improving and uniformizing the terminology in use. Proven linguistic skills are praised more than programming skills, here. 1.4 Available Packages ====================== Languages are not equally supported in all packages. The following matrix shows the current state of internationalization, as of June 2010. The matrix shows, in regard of each package, for which languages PO files have been submitted to translation coordination, with a translation percentage of at least 50%. Ready PO files af am an ar as ast az be be@latin bg bn_IN bs ca +--------------------------------------------------+ a2ps | [] [] | aegis | | ant-phone | | anubis | | aspell | [] [] | bash | | bfd | | bibshelf | [] | binutils | | bison | | bison-runtime | [] | bluez-pin | [] [] | bombono-dvd | | buzztard | | cflow | | clisp | | coreutils | [] [] | cpio | | cppi | | cpplib | [] | cryptsetup | | dfarc | | dialog | [] [] | dico | | diffutils | [] | dink | | doodle | | e2fsprogs | [] | enscript | [] | exif | | fetchmail | [] | findutils | [] | flex | [] | freedink | | gas | | gawk | [] [] | gcal | [] | gcc | | gettext-examples | [] [] [] [] | gettext-runtime | [] [] | gettext-tools | [] [] | gip | [] | gjay | | gliv | [] | glunarclock | [] [] | gnubiff | | gnucash | [] | gnuedu | | gnulib | | gnunet | | gnunet-gtk | | gnutls | | gold | | gpe-aerial | | gpe-beam | | gpe-bluetooth | | gpe-calendar | | gpe-clock | [] | gpe-conf | | gpe-contacts | | gpe-edit | | gpe-filemanager | | gpe-go | | gpe-login | | gpe-ownerinfo | [] | gpe-package | | gpe-sketchbook | | gpe-su | [] | gpe-taskmanager | [] | gpe-timesheet | [] | gpe-today | [] | gpe-todo | | gphoto2 | | gprof | [] | gpsdrive | | gramadoir | | grep | | grub | [] [] | gsasl | | gss | | gst-plugins-bad | [] | gst-plugins-base | [] | gst-plugins-good | [] | gst-plugins-ugly | [] | gstreamer | [] [] [] | gtick | | gtkam | [] | gtkorphan | [] | gtkspell | [] [] [] | gutenprint | | hello | [] | help2man | | hylafax | | idutils | | indent | [] [] | iso_15924 | | iso_3166 | [] [] [] [] [] [] [] | iso_3166_2 | | iso_4217 | | iso_639 | [] [] [] [] | iso_639_3 | | jwhois | | kbd | | keytouch | [] | keytouch-editor | | keytouch-keyboa... | [] | klavaro | [] | latrine | | ld | [] | leafpad | [] [] | libc | [] [] | libexif | () | libextractor | | libgnutls | | libgpewidget | | libgpg-error | | libgphoto2 | | libgphoto2_port | | libgsasl | | libiconv | [] | libidn | | lifelines | | liferea | [] [] | lilypond | | linkdr | [] | lordsawar | | lprng | | lynx | [] | m4 | | mailfromd | | mailutils | | make | | man-db | | man-db-manpages | | minicom | | mkisofs | | myserver | | nano | [] [] | opcodes | | parted | | pies | | popt | | psmisc | | pspp | [] | pwdutils | | radius | [] | recode | [] [] | rosegarden | | rpm | | rush | | sarg | | screem | | scrollkeeper | [] [] [] | sed | [] [] | sharutils | [] [] | shishi | | skencil | | solfege | | solfege-manual | | soundtracker | | sp | | sysstat | | tar | [] | texinfo | | tin | | unicode-han-tra... | | unicode-transla... | | util-linux-ng | [] | vice | | vmm | | vorbis-tools | | wastesedge | | wdiff | | wget | [] [] | wyslij-po | | xchat | [] [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] | +--------------------------------------------------+ af am an ar as ast az be be@latin bg bn_IN bs ca 6 0 1 2 3 19 1 10 3 28 3 1 38 crh cs da de el en en_GB en_ZA eo es et eu fa +-------------------------------------------------+ a2ps | [] [] [] [] [] [] [] | aegis | [] [] [] | ant-phone | [] () | anubis | [] [] | aspell | [] [] [] [] [] | bash | [] [] [] | bfd | [] | bibshelf | [] [] [] | binutils | [] | bison | [] [] | bison-runtime | [] [] [] [] | bluez-pin | [] [] [] [] [] [] | bombono-dvd | [] | buzztard | [] [] [] | cflow | [] [] | clisp | [] [] [] [] | coreutils | [] [] [] [] | cpio | | cppi | | cpplib | [] [] [] | cryptsetup | [] | dfarc | [] [] [] | dialog | [] [] [] [] [] | dico | | diffutils | [] [] [] [] [] [] | dink | [] [] [] | doodle | [] | e2fsprogs | [] [] [] | enscript | [] [] [] | exif | () [] [] | fetchmail | [] [] () [] [] [] | findutils | [] [] [] | flex | [] [] | freedink | [] [] [] | gas | [] | gawk | [] [] [] | gcal | [] | gcc | [] [] | gettext-examples | [] [] [] [] | gettext-runtime | [] [] [] [] | gettext-tools | [] [] [] | gip | [] [] [] [] | gjay | [] | gliv | [] [] [] | glunarclock | [] [] | gnubiff | () | gnucash | [] () () () () | gnuedu | [] [] | gnulib | [] [] | gnunet | | gnunet-gtk | [] | gnutls | [] [] | gold | [] | gpe-aerial | [] [] [] [] | gpe-beam | [] [] [] [] | gpe-bluetooth | [] [] | gpe-calendar | [] | gpe-clock | [] [] [] [] | gpe-conf | [] [] [] | gpe-contacts | [] [] [] | gpe-edit | [] [] | gpe-filemanager | [] [] [] | gpe-go | [] [] [] [] | gpe-login | [] [] | gpe-ownerinfo | [] [] [] [] | gpe-package | [] [] [] | gpe-sketchbook | [] [] [] [] | gpe-su | [] [] [] [] | gpe-taskmanager | [] [] [] [] | gpe-timesheet | [] [] [] [] | gpe-today | [] [] [] [] | gpe-todo | [] [] [] | gphoto2 | [] [] () [] [] [] | gprof | [] [] [] | gpsdrive | [] [] [] | gramadoir | [] [] [] | grep | [] | grub | [] [] | gsasl | [] | gss | | gst-plugins-bad | [] [] [] [] [] | gst-plugins-base | [] [] [] [] [] | gst-plugins-good | [] [] [] [] [] [] | gst-plugins-ugly | [] [] [] [] [] [] | gstreamer | [] [] [] [] [] | gtick | [] () [] | gtkam | [] [] () [] [] | gtkorphan | [] [] [] [] | gtkspell | [] [] [] [] [] [] [] | gutenprint | [] [] [] | hello | [] [] [] [] | help2man | [] | hylafax | [] [] | idutils | [] [] | indent | [] [] [] [] [] [] [] | iso_15924 | [] () [] [] | iso_3166 | [] [] [] [] () [] [] [] () | iso_3166_2 | () | iso_4217 | [] [] [] () [] [] | iso_639 | [] [] [] [] () [] [] | iso_639_3 | [] | jwhois | [] | kbd | [] [] [] [] [] | keytouch | [] [] | keytouch-editor | [] [] | keytouch-keyboa... | [] | klavaro | [] [] [] [] | latrine | [] () | ld | [] [] | leafpad | [] [] [] [] [] [] | libc | [] [] [] [] | libexif | [] [] () | libextractor | | libgnutls | [] | libgpewidget | [] [] | libgpg-error | [] [] | libgphoto2 | [] () | libgphoto2_port | [] () [] | libgsasl | | libiconv | [] [] [] [] [] | libidn | [] [] [] | lifelines | [] () | liferea | [] [] [] [] [] | lilypond | [] [] [] | linkdr | [] [] [] | lordsawar | [] | lprng | | lynx | [] [] [] [] | m4 | [] [] [] [] | mailfromd | | mailutils | [] | make | [] [] [] | man-db | | man-db-manpages | | minicom | [] [] [] [] | mkisofs | | myserver | | nano | [] [] [] | opcodes | [] [] | parted | [] [] | pies | | popt | [] [] [] [] [] | psmisc | [] [] [] | pspp | [] | pwdutils | [] | radius | [] | recode | [] [] [] [] [] [] | rosegarden | () () () | rpm | [] [] [] | rush | | sarg | | screem | | scrollkeeper | [] [] [] [] [] | sed | [] [] [] [] [] [] | sharutils | [] [] [] [] | shishi | | skencil | [] () [] | solfege | [] [] [] | solfege-manual | [] [] | soundtracker | [] [] [] | sp | [] | sysstat | [] [] [] | tar | [] [] [] [] | texinfo | [] [] [] | tin | [] [] | unicode-han-tra... | | unicode-transla... | | util-linux-ng | [] [] [] [] | vice | () () | vmm | [] | vorbis-tools | [] [] | wastesedge | [] | wdiff | [] [] | wget | [] [] [] | wyslij-po | | xchat | [] [] [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] [] [] [] [] | +-------------------------------------------------+ crh cs da de el en en_GB en_ZA eo es et eu fa 5 64 105 117 18 1 8 0 28 89 18 19 0 fi fr ga gl gu he hi hr hu hy id is it ja ka kn +----------------------------------------------------+ a2ps | [] [] [] [] | aegis | [] [] | ant-phone | [] [] | anubis | [] [] [] [] | aspell | [] [] [] [] | bash | [] [] [] [] | bfd | [] [] [] | bibshelf | [] [] [] [] [] | binutils | [] [] [] | bison | [] [] [] [] | bison-runtime | [] [] [] [] [] [] | bluez-pin | [] [] [] [] [] [] [] [] | bombono-dvd | [] | buzztard | [] | cflow | [] [] [] | clisp | [] | coreutils | [] [] [] [] [] | cpio | [] [] [] [] | cppi | [] [] | cpplib | [] [] [] | cryptsetup | [] [] [] | dfarc | [] [] [] | dialog | [] [] [] [] [] [] [] | dico | | diffutils | [] [] [] [] [] [] [] [] [] | dink | [] | doodle | [] [] | e2fsprogs | [] [] | enscript | [] [] [] [] | exif | [] [] [] [] [] [] | fetchmail | [] [] [] [] | findutils | [] [] [] [] [] [] | flex | [] [] [] | freedink | [] [] [] | gas | [] [] | gawk | [] [] [] [] () [] | gcal | [] | gcc | [] | gettext-examples | [] [] [] [] [] [] [] | gettext-runtime | [] [] [] [] [] [] | gettext-tools | [] [] [] [] | gip | [] [] [] [] [] [] | gjay | [] | gliv | [] () | glunarclock | [] [] [] [] | gnubiff | () [] () | gnucash | () () () () () [] | gnuedu | [] [] | gnulib | [] [] [] [] [] [] | gnunet | | gnunet-gtk | [] | gnutls | [] [] | gold | [] [] | gpe-aerial | [] [] [] | gpe-beam | [] [] [] [] | gpe-bluetooth | [] [] [] [] | gpe-calendar | [] [] | gpe-clock | [] [] [] [] [] | gpe-conf | [] [] [] [] | gpe-contacts | [] [] [] [] | gpe-edit | [] [] [] | gpe-filemanager | [] [] [] [] | gpe-go | [] [] [] [] [] | gpe-login | [] [] [] | gpe-ownerinfo | [] [] [] [] [] | gpe-package | [] [] [] | gpe-sketchbook | [] [] [] [] | gpe-su | [] [] [] [] [] [] | gpe-taskmanager | [] [] [] [] [] | gpe-timesheet | [] [] [] [] [] | gpe-today | [] [] [] [] [] [] [] | gpe-todo | [] [] [] | gphoto2 | [] [] [] [] [] [] | gprof | [] [] [] [] | gpsdrive | [] [] [] | gramadoir | [] [] [] | grep | [] [] | grub | [] [] [] [] | gsasl | [] [] [] [] [] | gss | [] [] [] [] [] | gst-plugins-bad | [] [] [] [] [] [] | gst-plugins-base | [] [] [] [] [] [] | gst-plugins-good | [] [] [] [] [] [] | gst-plugins-ugly | [] [] [] [] [] [] | gstreamer | [] [] [] [] [] | gtick | [] [] [] [] [] | gtkam | [] [] [] [] [] | gtkorphan | [] [] [] | gtkspell | [] [] [] [] [] [] [] [] [] | gutenprint | [] [] [] [] | hello | [] [] [] | help2man | [] [] | hylafax | [] | idutils | [] [] [] [] [] [] | indent | [] [] [] [] [] [] [] [] | iso_15924 | [] () [] [] | iso_3166 | [] () [] [] [] [] [] [] [] [] [] [] | iso_3166_2 | () [] [] [] | iso_4217 | [] () [] [] [] [] | iso_639 | [] () [] [] [] [] [] [] [] | iso_639_3 | () [] [] | jwhois | [] [] [] [] [] | kbd | [] [] | keytouch | [] [] [] [] [] [] | keytouch-editor | [] [] [] [] [] | keytouch-keyboa... | [] [] [] [] [] | klavaro | [] [] | latrine | [] [] [] | ld | [] [] [] [] | leafpad | [] [] [] [] [] [] [] () | libc | [] [] [] [] [] | libexif | [] | libextractor | | libgnutls | [] [] | libgpewidget | [] [] [] [] | libgpg-error | [] [] | libgphoto2 | [] [] [] | libgphoto2_port | [] [] [] | libgsasl | [] [] [] [] [] | libiconv | [] [] [] [] [] [] | libidn | [] [] [] [] | lifelines | () | liferea | [] [] [] [] | lilypond | [] [] | linkdr | [] [] [] [] [] | lordsawar | | lprng | [] | lynx | [] [] [] [] [] | m4 | [] [] [] [] [] [] | mailfromd | | mailutils | [] [] | make | [] [] [] [] [] [] [] [] [] | man-db | [] [] | man-db-manpages | [] | minicom | [] [] [] [] [] | mkisofs | [] [] [] [] | myserver | | nano | [] [] [] [] [] [] | opcodes | [] [] [] [] | parted | [] [] [] [] | pies | | popt | [] [] [] [] [] [] [] [] [] | psmisc | [] [] [] | pspp | | pwdutils | [] [] | radius | [] [] | recode | [] [] [] [] [] [] [] [] | rosegarden | () () () () () | rpm | [] [] | rush | | sarg | [] | screem | [] [] | scrollkeeper | [] [] [] [] | sed | [] [] [] [] [] [] [] [] | sharutils | [] [] [] [] [] [] [] | shishi | [] | skencil | [] | solfege | [] [] [] [] | solfege-manual | [] [] | soundtracker | [] [] | sp | [] () | sysstat | [] [] [] [] [] | tar | [] [] [] [] [] [] [] | texinfo | [] [] [] [] | tin | [] | unicode-han-tra... | | unicode-transla... | [] [] | util-linux-ng | [] [] [] [] [] [] | vice | () () () | vmm | [] | vorbis-tools | [] | wastesedge | () () | wdiff | [] | wget | [] [] [] [] [] [] [] [] | wyslij-po | [] [] [] | xchat | [] [] [] [] [] [] [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] [] [] [] | +----------------------------------------------------+ fi fr ga gl gu he hi hr hu hy id is it ja ka kn 105 121 53 20 4 8 3 5 53 2 120 5 84 67 0 4 ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne +-----------------------------------------------+ a2ps | [] | aegis | | ant-phone | | anubis | [] [] | aspell | [] | bash | | bfd | | bibshelf | [] [] | binutils | | bison | [] | bison-runtime | [] [] [] [] [] | bluez-pin | [] [] [] [] [] | bombono-dvd | | buzztard | | cflow | | clisp | | coreutils | [] | cpio | | cppi | | cpplib | | cryptsetup | | dfarc | [] | dialog | [] [] [] [] [] | dico | | diffutils | [] [] | dink | | doodle | | e2fsprogs | | enscript | | exif | [] | fetchmail | | findutils | | flex | | freedink | [] | gas | | gawk | | gcal | | gcc | | gettext-examples | [] [] [] [] | gettext-runtime | [] | gettext-tools | [] | gip | [] [] | gjay | | gliv | | glunarclock | [] | gnubiff | | gnucash | () () () () | gnuedu | | gnulib | | gnunet | | gnunet-gtk | | gnutls | [] | gold | | gpe-aerial | [] | gpe-beam | [] | gpe-bluetooth | [] [] | gpe-calendar | [] | gpe-clock | [] [] [] [] [] | gpe-conf | [] [] | gpe-contacts | [] [] | gpe-edit | [] | gpe-filemanager | [] [] | gpe-go | [] [] [] | gpe-login | [] | gpe-ownerinfo | [] [] | gpe-package | [] [] | gpe-sketchbook | [] [] | gpe-su | [] [] [] [] [] [] | gpe-taskmanager | [] [] [] [] [] [] | gpe-timesheet | [] [] | gpe-today | [] [] [] [] | gpe-todo | [] [] | gphoto2 | | gprof | [] | gpsdrive | | gramadoir | | grep | | grub | | gsasl | | gss | | gst-plugins-bad | [] [] [] [] | gst-plugins-base | [] [] | gst-plugins-good | [] [] | gst-plugins-ugly | [] [] [] [] [] | gstreamer | | gtick | | gtkam | [] | gtkorphan | [] [] | gtkspell | [] [] [] [] [] [] [] | gutenprint | | hello | [] [] [] | help2man | | hylafax | | idutils | | indent | | iso_15924 | [] [] | iso_3166 | [] [] () [] [] [] [] [] | iso_3166_2 | | iso_4217 | [] [] | iso_639 | [] [] | iso_639_3 | [] | jwhois | [] | kbd | | keytouch | [] | keytouch-editor | [] | keytouch-keyboa... | [] | klavaro | [] | latrine | [] | ld | | leafpad | [] [] [] | libc | [] | libexif | | libextractor | | libgnutls | [] | libgpewidget | [] [] | libgpg-error | | libgphoto2 | | libgphoto2_port | | libgsasl | | libiconv | | libidn | | lifelines | | liferea | | lilypond | | linkdr | | lordsawar | | lprng | | lynx | | m4 | | mailfromd | | mailutils | | make | [] | man-db | | man-db-manpages | | minicom | [] | mkisofs | | myserver | | nano | [] [] | opcodes | | parted | | pies | | popt | [] [] [] | psmisc | | pspp | | pwdutils | | radius | | recode | | rosegarden | | rpm | | rush | | sarg | | screem | | scrollkeeper | [] [] | sed | | sharutils | | shishi | | skencil | | solfege | [] | solfege-manual | | soundtracker | | sp | | sysstat | [] | tar | [] | texinfo | [] | tin | | unicode-han-tra... | | unicode-transla... | | util-linux-ng | | vice | | vmm | | vorbis-tools | | wastesedge | | wdiff | | wget | [] | wyslij-po | | xchat | [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] [] | +-----------------------------------------------+ ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne 20 5 10 1 13 48 4 2 2 4 24 10 20 3 1 nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr +---------------------------------------------------+ a2ps | [] [] [] [] [] [] [] [] | aegis | [] [] [] | ant-phone | [] [] | anubis | [] [] [] | aspell | [] [] [] [] [] | bash | [] [] | bfd | [] | bibshelf | [] [] | binutils | [] [] | bison | [] [] [] | bison-runtime | [] [] [] [] [] [] [] | bluez-pin | [] [] [] [] [] [] [] [] | bombono-dvd | [] () | buzztard | [] [] | cflow | [] | clisp | [] [] | coreutils | [] [] [] [] [] [] | cpio | [] [] [] | cppi | [] | cpplib | [] | cryptsetup | [] | dfarc | [] | dialog | [] [] [] [] | dico | [] | diffutils | [] [] [] [] [] [] | dink | () | doodle | [] [] | e2fsprogs | [] [] | enscript | [] [] [] [] [] | exif | [] [] [] () [] | fetchmail | [] [] [] [] | findutils | [] [] [] [] [] | flex | [] [] [] [] [] | freedink | [] [] | gas | | gawk | [] [] [] [] | gcal | | gcc | [] | gettext-examples | [] [] [] [] [] [] [] [] | gettext-runtime | [] [] [] [] [] [] [] [] [] | gettext-tools | [] [] [] [] [] [] | gip | [] [] [] [] [] | gjay | | gliv | [] [] [] [] [] [] | glunarclock | [] [] [] [] [] | gnubiff | [] () | gnucash | [] () () () | gnuedu | [] | gnulib | [] [] [] [] | gnunet | | gnunet-gtk | | gnutls | [] [] | gold | | gpe-aerial | [] [] [] [] [] [] [] | gpe-beam | [] [] [] [] [] [] [] | gpe-bluetooth | [] [] | gpe-calendar | [] [] [] [] | gpe-clock | [] [] [] [] [] [] [] [] | gpe-conf | [] [] [] [] [] [] [] | gpe-contacts | [] [] [] [] [] | gpe-edit | [] [] [] | gpe-filemanager | [] [] [] | gpe-go | [] [] [] [] [] [] [] [] | gpe-login | [] [] | gpe-ownerinfo | [] [] [] [] [] [] [] [] | gpe-package | [] [] | gpe-sketchbook | [] [] [] [] [] [] [] | gpe-su | [] [] [] [] [] [] [] [] | gpe-taskmanager | [] [] [] [] [] [] [] [] | gpe-timesheet | [] [] [] [] [] [] [] [] | gpe-today | [] [] [] [] [] [] [] [] | gpe-todo | [] [] [] [] [] | gphoto2 | [] [] [] [] [] [] [] [] | gprof | [] [] [] | gpsdrive | [] [] | gramadoir | [] [] | grep | [] [] [] [] | grub | [] [] [] | gsasl | [] [] [] [] | gss | [] [] [] | gst-plugins-bad | [] [] [] [] [] [] | gst-plugins-base | [] [] [] [] [] | gst-plugins-good | [] [] [] [] [] | gst-plugins-ugly | [] [] [] [] [] [] | gstreamer | [] [] [] [] [] | gtick | [] [] [] | gtkam | [] [] [] [] [] [] | gtkorphan | [] | gtkspell | [] [] [] [] [] [] [] [] [] [] | gutenprint | [] [] | hello | [] [] [] [] | help2man | [] [] | hylafax | [] | idutils | [] [] [] [] [] | indent | [] [] [] [] [] [] [] | iso_15924 | [] [] [] [] | iso_3166 | [] [] [] [] [] () [] [] [] [] [] [] [] [] | iso_3166_2 | [] [] [] | iso_4217 | [] [] [] [] [] [] [] [] | iso_639 | [] [] [] [] [] [] [] [] [] | iso_639_3 | [] [] | jwhois | [] [] [] [] | kbd | [] [] [] | keytouch | [] [] [] | keytouch-editor | [] [] [] | keytouch-keyboa... | [] [] [] | klavaro | [] [] | latrine | [] [] | ld | | leafpad | [] [] [] [] [] [] [] [] [] | libc | [] [] [] [] | libexif | [] [] () [] | libextractor | | libgnutls | [] [] | libgpewidget | [] [] [] | libgpg-error | [] [] | libgphoto2 | [] [] | libgphoto2_port | [] [] [] [] [] | libgsasl | [] [] [] [] [] | libiconv | [] [] [] [] [] | libidn | [] [] | lifelines | [] [] | liferea | [] [] [] [] [] () () [] | lilypond | [] | linkdr | [] [] [] | lordsawar | | lprng | [] | lynx | [] [] [] | m4 | [] [] [] [] [] | mailfromd | [] | mailutils | [] | make | [] [] [] [] | man-db | [] [] [] | man-db-manpages | [] [] [] | minicom | [] [] [] [] | mkisofs | [] [] [] | myserver | | nano | [] [] [] [] | opcodes | [] [] | parted | [] [] [] [] | pies | [] | popt | [] [] [] [] | psmisc | [] [] [] | pspp | [] [] | pwdutils | [] | radius | [] [] [] | recode | [] [] [] [] [] [] [] [] | rosegarden | () () | rpm | [] [] [] | rush | [] [] | sarg | | screem | | scrollkeeper | [] [] [] [] [] [] [] [] | sed | [] [] [] [] [] [] [] [] [] | sharutils | [] [] [] [] | shishi | [] | skencil | [] [] | solfege | [] [] [] [] | solfege-manual | [] [] [] | soundtracker | [] | sp | | sysstat | [] [] [] [] | tar | [] [] [] [] | texinfo | [] [] [] [] | tin | [] | unicode-han-tra... | | unicode-transla... | | util-linux-ng | [] [] [] [] [] | vice | [] | vmm | [] | vorbis-tools | [] [] | wastesedge | [] | wdiff | [] [] | wget | [] [] [] [] [] [] [] | wyslij-po | [] [] [] | xchat | [] [] [] [] [] [] [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] [] | +---------------------------------------------------+ nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr 135 10 4 7 105 1 29 62 47 91 3 54 46 9 37 sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW +---------------------------------------------------+ a2ps | [] [] [] [] [] | 27 aegis | [] | 9 ant-phone | [] [] [] [] | 9 anubis | [] [] [] [] | 15 aspell | [] [] [] | 20 bash | [] [] [] | 12 bfd | [] | 6 bibshelf | [] [] [] | 16 binutils | [] [] | 8 bison | [] [] | 12 bison-runtime | [] [] [] [] [] [] | 29 bluez-pin | [] [] [] [] [] [] [] [] | 37 bombono-dvd | [] | 4 buzztard | [] | 7 cflow | [] [] [] | 9 clisp | | 10 coreutils | [] [] [] [] | 22 cpio | [] [] [] [] [] [] | 13 cppi | [] [] | 5 cpplib | [] [] [] [] [] [] | 14 cryptsetup | [] [] | 7 dfarc | [] | 9 dialog | [] [] [] [] [] [] [] | 30 dico | [] | 2 diffutils | [] [] [] [] [] [] | 30 dink | | 4 doodle | [] [] | 7 e2fsprogs | [] [] [] | 11 enscript | [] [] [] [] | 17 exif | [] [] [] | 16 fetchmail | [] [] [] | 17 findutils | [] [] [] [] [] | 20 flex | [] [] [] [] | 15 freedink | [] | 10 gas | [] | 4 gawk | [] [] [] [] | 18 gcal | [] [] | 5 gcc | [] [] [] | 7 gettext-examples | [] [] [] [] [] [] [] | 34 gettext-runtime | [] [] [] [] [] [] [] | 29 gettext-tools | [] [] [] [] [] [] | 22 gip | [] [] [] [] | 22 gjay | [] | 3 gliv | [] [] [] | 14 glunarclock | [] [] [] [] [] | 19 gnubiff | [] [] | 4 gnucash | () [] () [] () | 10 gnuedu | [] [] | 7 gnulib | [] [] [] [] | 16 gnunet | [] | 1 gnunet-gtk | [] [] [] | 5 gnutls | [] [] [] | 10 gold | [] | 4 gpe-aerial | [] [] [] | 18 gpe-beam | [] [] [] | 19 gpe-bluetooth | [] [] [] | 13 gpe-calendar | [] [] [] [] | 12 gpe-clock | [] [] [] [] [] | 28 gpe-conf | [] [] [] [] | 20 gpe-contacts | [] [] [] | 17 gpe-edit | [] [] [] | 12 gpe-filemanager | [] [] [] [] | 16 gpe-go | [] [] [] [] [] | 25 gpe-login | [] [] [] | 11 gpe-ownerinfo | [] [] [] [] [] | 25 gpe-package | [] [] [] | 13 gpe-sketchbook | [] [] [] | 20 gpe-su | [] [] [] [] [] | 30 gpe-taskmanager | [] [] [] [] [] | 29 gpe-timesheet | [] [] [] [] [] | 25 gpe-today | [] [] [] [] [] [] | 30 gpe-todo | [] [] [] [] | 17 gphoto2 | [] [] [] [] [] | 24 gprof | [] [] [] | 15 gpsdrive | [] [] [] | 11 gramadoir | [] [] [] | 11 grep | [] [] [] | 10 grub | [] [] [] | 14 gsasl | [] [] [] [] | 14 gss | [] [] [] | 11 gst-plugins-bad | [] [] [] [] | 26 gst-plugins-base | [] [] [] [] [] | 24 gst-plugins-good | [] [] [] [] | 24 gst-plugins-ugly | [] [] [] [] [] | 29 gstreamer | [] [] [] [] | 22 gtick | [] [] [] | 13 gtkam | [] [] [] | 20 gtkorphan | [] [] [] | 14 gtkspell | [] [] [] [] [] [] [] [] [] | 45 gutenprint | [] | 10 hello | [] [] [] [] [] [] | 21 help2man | [] [] | 7 hylafax | [] | 5 idutils | [] [] [] [] | 17 indent | [] [] [] [] [] [] | 30 iso_15924 | () [] () [] [] | 16 iso_3166 | [] [] () [] [] () [] [] [] () | 53 iso_3166_2 | () [] () [] | 9 iso_4217 | [] () [] [] () [] [] | 26 iso_639 | [] [] [] () [] () [] [] [] [] | 38 iso_639_3 | [] () | 8 jwhois | [] [] [] [] [] | 16 kbd | [] [] [] [] [] | 15 keytouch | [] [] [] | 16 keytouch-editor | [] [] [] | 14 keytouch-keyboa... | [] [] [] | 14 klavaro | [] | 11 latrine | [] [] [] | 10 ld | [] [] [] [] | 11 leafpad | [] [] [] [] [] [] | 33 libc | [] [] [] [] [] | 21 libexif | [] () | 7 libextractor | [] | 1 libgnutls | [] [] [] | 9 libgpewidget | [] [] [] | 14 libgpg-error | [] [] [] | 9 libgphoto2 | [] [] | 8 libgphoto2_port | [] [] [] [] | 14 libgsasl | [] [] [] | 13 libiconv | [] [] [] [] | 21 libidn | () [] [] | 11 lifelines | [] | 4 liferea | [] [] [] | 21 lilypond | [] | 7 linkdr | [] [] [] [] [] | 17 lordsawar | | 1 lprng | [] | 3 lynx | [] [] [] [] | 17 m4 | [] [] [] [] | 19 mailfromd | [] [] | 3 mailutils | [] | 5 make | [] [] [] [] | 21 man-db | [] [] [] | 8 man-db-manpages | | 4 minicom | [] [] | 16 mkisofs | [] [] | 9 myserver | | 0 nano | [] [] [] [] | 21 opcodes | [] [] [] | 11 parted | [] [] [] [] [] | 15 pies | [] [] | 3 popt | [] [] [] [] [] [] | 27 psmisc | [] [] | 11 pspp | | 4 pwdutils | [] [] | 6 radius | [] [] | 9 recode | [] [] [] [] | 28 rosegarden | () | 0 rpm | [] [] [] | 11 rush | [] [] | 4 sarg | | 1 screem | [] | 3 scrollkeeper | [] [] [] [] [] | 27 sed | [] [] [] [] [] | 30 sharutils | [] [] [] [] [] | 22 shishi | [] | 3 skencil | [] [] | 7 solfege | [] [] [] [] | 16 solfege-manual | [] | 8 soundtracker | [] [] [] | 9 sp | [] | 3 sysstat | [] [] | 15 tar | [] [] [] [] [] [] | 23 texinfo | [] [] [] [] [] | 17 tin | | 4 unicode-han-tra... | | 0 unicode-transla... | | 2 util-linux-ng | [] [] [] [] | 20 vice | () () | 1 vmm | [] | 4 vorbis-tools | [] | 6 wastesedge | | 2 wdiff | [] [] | 7 wget | [] [] [] [] [] | 26 wyslij-po | [] [] | 8 xchat | [] [] [] [] [] [] | 36 xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] | 63 xkeyboard-config | [] [] [] | 22 +---------------------------------------------------+ 85 teams sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW 178 domains 119 1 3 3 0 10 65 51 155 17 98 7 41 2618 Some counters in the preceding matrix are higher than the number of visible blocks let us expect. This is because a few extra PO files are used for implementing regional variants of languages, or language dialects. For a PO file in the matrix above to be effective, the package to which it applies should also have been internationalized and distributed as such by its maintainer. There might be an observable lag between the mere existence a PO file and its wide availability in a distribution. If June 2010 seems to be old, you may fetch a more recent copy of this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date matrix with full percentage details can be found at `http://translationproject.org/extra/matrix.html'. 1.5 Using `gettext' in new packages =================================== If you are writing a freely available program and want to internationalize it you are welcome to use GNU `gettext' in your package. Of course you have to respect the GNU Library General Public License which covers the use of the GNU `gettext' library. This means in particular that even non-free programs can use `libintl' as a shared library, whereas only free software can use `libintl' as a static library or use modified versions of `libintl'. Once the sources are changed appropriately and the setup can handle the use of `gettext' the only thing missing are the translations. The Free Translation Project is also available for packages which are not developed inside the GNU project. Therefore the information given above applies also for every other Free Software Project. Contact `coordinator@translationproject.org' to make the `.pot' files available to the translation teams. lftp-4.6.3a/README.dnssec0000644000015000007670000001347312122056633011721 00000000000000DNSSEC Validation for lftp ========================== This patch adds local DNSSEC validation to lftp, along with an option to enable it. The is code is only compiled if the configure option --dnssec-local-validation is specified. The libraries libval and libsres from DNSSEC-Tools are prequisites. Additional options may be needed to point configure at the correct directory for these libraries. When compiled in, the option is still off by default. The new boolean option 'dns:strict-dnssec' must be enabled by the user. Once strict DNSSEC checking is enabled, DNSSEC validation is done according to the configuration in the DNSSEC-tool configuration file dnsval.conf. Please refer to the DNSSEC-Tools documentation for more information. http://www.dnssec-tools.org/ Testing ======= By default, DNSSEC-Tools' configuration file should be validation all zones. A few zones are signed, but most are not. You can use the test zone provided by DNSSEC-Tools for verifying correct operation. First, configure lftp to require validation. $ echo "set dns:strict-dnssec 1" > ~/.lftprc Next, simpy run lftp with a few domains. Here we use the DNSSEC-Tools domain as a known-good domain, and a domain in the DNSSEC-Tools test zone as a domain that will fail DNSSEC validation checks. $ lftp www.dnssec-tools.org cd ok, cwd=/ lftp www.dnssec-tools.org:/> $ lftp baddata-a.test.dnssec-tools.org lftp: baddata-a.test.dnssec-tools.org: DNS resoloution not trusted. Viewing Details ================ To see some debug output from the validation process, you can set the VAL_LOG_TARGET environment variable. (Higher numbers will result in more output. 5 is a good start, 7 is more than you really want.) $ export VAL_LOG_TARGET="5:stdout" $ lftp www.dnssec-tools.org 20120904::16:44:31 Validation result for {www.dnssec-tools.org, IN(1), A(1)}: VAL_SUCCESS:128 (Validated) 20120904::16:44:31 name=www.dnssec-tools.org class=IN type=A from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=dnssec-tools.org class=IN type=DNSKEY[tag=34816] from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=dnssec-tools.org class=IN type=DS from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=org class=IN type=DNSKEY[tag=21366] from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=org class=IN type=DS from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=. class=IN type=DNSKEY from-server=192.168.122.1 status=VAL_AC_TRUST:12 20120904::16:44:31 Validation result for {www.dnssec-tools.org, IN(1), AAAA(28)}: VAL_NONEXISTENT_TYPE:133 (Validated) 20120904::16:44:31 Proof of non-existence [1 of 1] 20120904::16:44:31 name=www.dnssec-tools.org class=IN type=NSEC from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=dnssec-tools.org class=IN type=DNSKEY[tag=34816] from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=dnssec-tools.org class=IN type=DS from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=org class=IN type=DNSKEY[tag=21366] from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=org class=IN type=DS from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::16:44:31 name=. class=IN type=DNSKEY from-server=192.168.122.1 status=VAL_AC_TRUST:12 cd ok, cwd=/ lftp www.dnssec-tools.org:/> $ lftp baddata-a.test.dnssec-tools.org 20120904::13:29:20 Validation result for {baddata-a.test.dnssec-tools.org, IN(1), A(1)}: VAL_BOGUS:1 (Untrusted) 20120904::13:29:20 name=baddata-a.test.dnssec-tools.org class=IN type=A from-server=168.150.236.43 status=VAL_AC_NOT_VERIFIED:18 20120904::13:29:20 name=test.dnssec-tools.org class=IN type=DNSKEY[tag=28827] from-server=168.150.236.43 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=test.dnssec-tools.org class=IN type=DS from-server=168.150.236.43 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=dnssec-tools.org class=IN type=DNSKEY[tag=34816] from-server=168.150.236.43 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=dnssec-tools.org class=IN type=DS from-server=199.249.120.1 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=org class=IN type=DNSKEY[tag=21366] from-server=199.249.120.1 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=org class=IN type=DS from-server=198.41.0.4 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=. class=IN type=DNSKEY from-server=198.41.0.4 status=VAL_AC_TRUST:12 20120904::13:29:20 Validation result for {baddata-a.test.dnssec-tools.org, IN(1), AAAA(28)}: VAL_NONEXISTENT_TYPE:133 (Validated) 20120904::13:29:20 Proof of non-existence [1 of 1] 20120904::13:29:20 name=baddata-a.test.dnssec-tools.org class=IN type=NSEC from-server=192.168.122.1 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=test.dnssec-tools.org class=IN type=DNSKEY[tag=28827] from-server=168.150.236.43 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=test.dnssec-tools.org class=IN type=DS from-server=168.150.236.43 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=dnssec-tools.org class=IN type=DNSKEY[tag=34816] from-server=168.150.236.43 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=dnssec-tools.org class=IN type=DS from-server=199.249.120.1 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=org class=IN type=DNSKEY[tag=21366] from-server=199.249.120.1 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=org class=IN type=DS from-server=198.41.0.4 status=VAL_AC_VERIFIED:31 20120904::13:29:20 name=. class=IN type=DNSKEY from-server=198.41.0.4 status=VAL_AC_TRUST:12 lftp: baddata-a.test.dnssec-tools.org: DNS resoloution not trusted. lftp-4.6.3a/THANKS0000644000015000007670000000642712401553665010506 00000000000000The following people contributed to lftp in various ways: testing, suggesting useful improvements, sending patches. Listed in abc order. Andreas Metzler Andy Eskilsson for testing and suggestions. Andy Lutomirski Arkadiusz Miskiewicz Arkady Sherman Artur Frysiak Bozo Dragojevic for testing with an ftp proxy, patch. Brandon Hume Chmouel Boudjnah Christoph Junghans Christoph Lameter for initial man pages Claus K. Larsen Damon Harper Daniel Black Daniel Fazekas Darren Stuart Embry David Binderman David Champion David Wolfe Dejan Muhamedagic Edward Grimm for testing and suggestions. Eugene Exarevsky Fernando Gutierrez Ganael LAPLANCHE Gabriele Balducci gARetH baBB Glenn F. Maynard for du, cls, major code contributions. Henry Hu Hugo Van den Berg for tip about quote command, patch. Igor Vinokurov for suggestions. Iida J Kalevi Suominen James Troup for documentation update, other patches. Jason Vas Dias for Red Hat package maintenance; patches. Jim Pick Jiri Skala Jonas Jensen Julien Oster Justin Piszcz Laurent MONIN Ludwig Nussel Manoj Kasichainula Marc Bevand Marco Calmar Mark S Bilk Mark Pulford Matt E Richards for a fix. Matthias Andree Michael Handler Michael Ross Naofumi Yasufuku Nate Sutton Nicolás Lichtmaier for i18n, Debian package maintenance. Nicolas Noble Nix OGAWA Hirofumi Pascal Bleser Robert de Bath Robert Story Roger Pixley Ryan Thomas Sam Steingold Sami Farin Serge Bezzubov for extensive testing. Simon Ruderich Slama YA Solar Designer Thomas Glanzmann Tillmann Steinbrecher Timur Sufiev Uhus for testing and suggestions. Victor Sudakov Yann Rouillard bash developers for pieces of code and example of how to use readline. Thanks to all who wrote to me about lftp. lftp-4.6.3a/COPYING0000644000015000007670000010451312122054516010610 00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . lftp-4.6.3a/src/0000755000015000007670000000000012540300656010423 500000000000000lftp-4.6.3a/src/lftp_ssl.cc0000644000015000007670000014316212536303521012506 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #if USE_SSL #include #include #include #include #include #include #include #include "lftp_ssl.h" #include "xmalloc.h" #include "ResMgr.h" #include "log.h" #include "misc.h" #include "network.h" #include "buffer.h" extern "C" { #include "c-ctype.h" #include "quotearg.h" #include "quote.h" } lftp_ssl_base::lftp_ssl_base(int fd1,handshake_mode_t m,const char *h) : hostname(h) { fd=fd1; handshake_done=false; handshake_mode=m; fatal=false; cert_error=false; } void lftp_ssl_base::set_error(const char *s1,const char *s2) { if(s2) error.vset(s1,": ",s2,NULL); else error.set(s1); } void lftp_ssl_base::set_cert_error(const char *s) { bool verify=ResMgr::QueryBool("ssl:verify-certificate",hostname); const char *const warn=verify?"ERROR":"WARNING"; Log::global->Format(0,"%s: Certificate verification: %s\n",warn,s); if(verify && !error) { set_error("Certificate verification",s); fatal=true; cert_error=true; } } #if USE_GNUTLS /* Helper functions to load a certificate and key * files into memory. They use mmap for simplicity. */ static gnutls_datum_t mmap_file(const char *file) { int fd; gnutls_datum_t mmaped_file = { NULL, 0 }; struct stat stat_st; void *ptr; fd = open(file, 0); if (fd == -1) return mmaped_file; fstat(fd, &stat_st); if ((ptr = mmap(NULL, stat_st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { close(fd); return mmaped_file; } close(fd); mmaped_file.data = (unsigned char*)ptr; mmaped_file.size = stat_st.st_size; return mmaped_file; } static void munmap_file(gnutls_datum_t data) { munmap(data.data, data.size); } #if LFTP_LIBGNUTLS_VERSION_CODE < 0x010201 #define gnutls_x509_crt_list_import lftp_gnutls_x509_crt_list_import #define GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED 1 static int gnutls_x509_crt_list_import(gnutls_x509_crt_t *certs, unsigned int* cert_max, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format, unsigned int flags); #endif void lftp_ssl_gnutls_instance::LoadCA() { // free CA first for(unsigned i=0; iFormat(0,"%s: %s\n",ca_file,strerror(errno)); return; } ca_list_size=64; ca_list=(gnutls_x509_crt_t*)xmalloc(ca_list_size*sizeof(gnutls_x509_crl_t)); int res=gnutls_x509_crt_list_import(ca_list,&ca_list_size,&ca_pem,GNUTLS_X509_FMT_PEM,GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED); if(res==GNUTLS_E_SHORT_MEMORY_BUFFER) { ca_list=(gnutls_x509_crt_t*)xrealloc(ca_list,ca_list_size*sizeof(gnutls_x509_crl_t)); res=gnutls_x509_crt_list_import(ca_list,&ca_list_size,&ca_pem,GNUTLS_X509_FMT_PEM,0); } if(res<0) { Log::global->Format(0,"gnutls_x509_crt_list_import: %s\n",gnutls_strerror(res)); xfree(ca_list); ca_list=0; ca_list_size=0; } munmap_file(ca_pem); } void lftp_ssl_gnutls_instance::LoadCRL() { // free CRL first for(unsigned i=0; iFormat(0,"%s: %s\n",crl_file,strerror(errno)); return; } crl_list_size=1; crl_list=(gnutls_x509_crl_t*)xmalloc(crl_list_size*sizeof(gnutls_x509_crl_t)); int res=gnutls_x509_crl_import(crl_list[0],&crl_pem,GNUTLS_X509_FMT_PEM); if(res<0) { Log::global->Format(0,"gnutls_x509_crl_import: %s\n",gnutls_strerror(res)); xfree(crl_list); crl_list=0; crl_list_size=0; } munmap_file(crl_pem); } void lftp_ssl_gnutls_instance::Reconfig(const char *name) { if(!name || !strcmp(name,"ssl:ca-file")) LoadCA(); if(!name || !strcmp(name,"ssl:crl-file")) LoadCRL(); } static const char *lftp_ssl_find_ca_file() { // a few possible locations of ca-bundle.crt static const char *const ca_file_location[]={ "/etc/pki/tls/certs/ca-bundle.crt", "/etc/certs/ca-bundle.crt", "/usr/share/ssl/certs/ca-bundle.crt", "/etc/ssl/certs/ca-certificates.crt", "/usr/local/ssl/certs/ca-bundle.crt", "/etc/apache/ssl.crt/ca-bundle.crt", "/usr/share/curl/curl-ca-bundle.crt", 0}; for(int i=0; ca_file_location[i]; i++) { if(access(ca_file_location[i], R_OK)==0) return ca_file_location[i]; } return 0; } static void lftp_ssl_gnutls_log_func(int level, const char *msg) { if(!strncmp(msg,"ASSERT",6) || !strncmp(msg,"READ",4) || !strncmp(msg,"WRITE",5)) level+=10; Log::global->Format(9+level,"GNUTLS: %s",msg); } lftp_ssl_gnutls_instance::lftp_ssl_gnutls_instance() { ca_list=0; ca_list_size=0; crl_list=0; crl_list_size=0; Suspend(); gnutls_global_init(); gnutls_global_set_log_function(lftp_ssl_gnutls_log_func); gnutls_global_set_log_level(9); const char *ca_file=ResMgr::Query("ssl:ca-file",0); if(!ca_file || !ca_file[0]) ResMgr::Set("ssl:ca-file",0,lftp_ssl_find_ca_file()); Reconfig(0); } lftp_ssl_gnutls_instance::~lftp_ssl_gnutls_instance() { gnutls_global_deinit(); } lftp_ssl_gnutls_instance *lftp_ssl_gnutls::instance; void lftp_ssl_gnutls::global_init() { if(!instance) instance=new lftp_ssl_gnutls_instance(); } void lftp_ssl_gnutls::global_deinit() { SMTask::Delete(instance); instance=0; } lftp_ssl_gnutls::lftp_ssl_gnutls(int fd1,handshake_mode_t m,const char *h) : lftp_ssl_base(fd1,m,h) { global_init(); cred=0; gnutls_init(&session,(m==CLIENT?GNUTLS_CLIENT:GNUTLS_SERVER)); gnutls_set_default_priority(session); gnutls_transport_set_ptr(session,(gnutls_transport_ptr_t)fd); const char *priority=ResMgr::Query("ssl:priority", 0); if(priority && *priority) { int res = gnutls_priority_set_direct(session, priority, 0); if(res != GNUTLS_E_SUCCESS) Log::global->Format(0,"gnutls_priority_set_direct(`%s'): %s\n",priority,gnutls_strerror(res)); } else { // hack for some ftp servers const char *auth=ResMgr::Query("ftp:ssl-auth", hostname); if(auth && !strncmp(auth, "SSL", 3)) gnutls_priority_set_direct(session, "NORMAL:+SSL3.0:-TLS1.0:-TLS1.1:-TLS1.2",0); } if(h && ResMgr::QueryBool("ssl:use-sni",h)) { if(gnutls_server_name_set(session, GNUTLS_NAME_DNS, h, xstrlen(h)) < 0) fprintf(stderr,"WARNING: failed to configure server name indication (SNI) TLS extension\n"); } } void lftp_ssl_gnutls::load_keys() { gnutls_certificate_allocate_credentials(&cred); int res; #if 0 const char *ca_file=ResMgr::Query("ssl:ca-file",hostname); const char *ca_file0=ResMgr::Query("ssl:ca-file",0); if(ca_file && ca_file[0] && xstrcmp(ca_file,ca_file0)) { res=gnutls_certificate_set_x509_trust_file(cred,ca_file,GNUTLS_X509_FMT_PEM); if(res<0) Log::global->Format(0,"gnutls_certificate_set_x509_trust_file(%s): %s\n",ca_file,gnutls_strerror(res)); } const char *crl_file=ResMgr::Query("ssl:crl-file",hostname); const char *crl_file0=ResMgr::Query("ssl:crl-file",0); if(crl_file && crl_file[0] && xstrcmp(crl_file,crl_file0)) { res=gnutls_certificate_set_x509_crl_file(cred,crl_file,GNUTLS_X509_FMT_PEM); if(res<0) Log::global->Format(0,"gnutls_certificate_set_x509_crl_file(%s): %s\n",crl_file,gnutls_strerror(res)); } #endif const char *key_file =ResMgr::Query("ssl:key-file",hostname); const char *cert_file=ResMgr::Query("ssl:cert-file",hostname); if(key_file && key_file[0] && cert_file && cert_file[0]) { res=gnutls_certificate_set_x509_key_file(cred,cert_file,key_file,GNUTLS_X509_FMT_PEM); if(res<0) Log::global->Format(0,"gnutls_certificate_set_x509_key_file(%s,%s): %s\n",cert_file,key_file,gnutls_strerror(res)); } gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred); } void lftp_ssl_gnutls::shutdown() { if(handshake_done) gnutls_bye(session,GNUTLS_SHUT_RDWR); // FIXME - E_AGAIN } lftp_ssl_gnutls::~lftp_ssl_gnutls() { if(cred) gnutls_certificate_free_credentials(cred); gnutls_deinit(session); session=0; } /* This function will try to verify the peer's certificate chain, and * also check if the hostname matches, and the activation, expiration dates. */ void lftp_ssl_gnutls::verify_certificate_chain(const gnutls_datum_t *cert_chain,int cert_chain_length) { int i; gnutls_x509_crt_t *cert=(gnutls_x509_crt_t*)alloca(cert_chain_length*sizeof(gnutls_x509_crt_t)); /* Import all the certificates in the chain to * native certificate format. */ for (i = 0; i < cert_chain_length; i++) { gnutls_x509_crt_init(&cert[i]); gnutls_x509_crt_import(cert[i],&cert_chain[i],GNUTLS_X509_FMT_DER); } /* Now verify the certificates against their issuers * in the chain. */ for (i = 1; i < cert_chain_length; i++) verify_cert2(cert[i - 1], cert[i]); /* Here we must verify the last certificate in the chain against * our trusted CA list. */ verify_last_cert(cert[cert_chain_length - 1]); /* Check if the name in the first certificate matches our destination! */ bool check_hostname = ResMgr::QueryBool("ssl:check-hostname", hostname); if(check_hostname) { if(!gnutls_x509_crt_check_hostname(cert[0], hostname)) set_cert_error(xstring::format("certificate common name doesn't match requested host name %s",quote(hostname))); } else { Log::global->Format(0, "WARNING: Certificate verification: hostname checking disabled\n"); } for (i = 0; i < cert_chain_length; i++) gnutls_x509_crt_deinit(cert[i]); } /* Verifies a certificate against an other certificate * which is supposed to be it's issuer. Also checks the * crl_list if the certificate is revoked. */ void lftp_ssl_gnutls::verify_cert2(gnutls_x509_crt_t crt,gnutls_x509_crt_t issuer) { int ret; time_t now = SMTask::now; size_t name_size; char name[256]; /* Print information about the certificates to * be checked. */ name_size = sizeof(name); gnutls_x509_crt_get_dn(crt, name, &name_size); Log::global->Format(9, "Certificate: %s\n", name); name_size = sizeof(name); gnutls_x509_crt_get_issuer_dn(crt, name, &name_size); Log::global->Format(9, " Issued by: %s\n", name); /* Get the DN of the issuer cert. */ name_size = sizeof(name); gnutls_x509_crt_get_dn(issuer, name, &name_size); Log::global->Format(9, " Checking against: %s\n", name); /* Do the actual verification. */ unsigned crt_status=0; unsigned issuer_status=0; gnutls_x509_crt_verify(crt, &issuer, 1, 0, &crt_status); if(crt_status&GNUTLS_CERT_SIGNER_NOT_CA) { // recheck the issuer certificate against CA gnutls_x509_crt_verify(issuer, instance->ca_list, instance->ca_list_size, 0, &issuer_status); if(issuer_status==0) crt_status&=~GNUTLS_CERT_SIGNER_NOT_CA; if(crt_status==GNUTLS_CERT_INVALID) crt_status=0; } if (crt_status & GNUTLS_CERT_INVALID) { char msg[256]; strcpy(msg,"Not trusted"); if(crt_status & GNUTLS_CERT_SIGNER_NOT_FOUND) strcat(msg,": no issuer was found"); if(crt_status & GNUTLS_CERT_SIGNER_NOT_CA) strcat(msg,": issuer is not a CA"); set_cert_error(msg); } else Log::global->Format(9, " Trusted\n"); /* Now check the expiration dates. */ if (gnutls_x509_crt_get_activation_time(crt) > now) set_cert_error("Not yet activated"); if (gnutls_x509_crt_get_expiration_time(crt) < now) set_cert_error("Expired"); /* Check if the certificate is revoked. */ ret = gnutls_x509_crt_check_revocation(crt, instance->crl_list, instance->crl_list_size); if (ret == 1) { /* revoked */ set_cert_error("Revoked"); } } /* Verifies a certificate against the trusted CA list. * Also checks the crl_list if the certificate is revoked. */ void lftp_ssl_gnutls::verify_last_cert(gnutls_x509_crt_t crt) { unsigned int crt_status; int ret; time_t now = SMTask::now; size_t name_size; char name[256]; /* Print information about the certificates to * be checked. */ name_size = sizeof(name); gnutls_x509_crt_get_dn(crt, name, &name_size); Log::global->Format(9, "Certificate: %s\n", name); name_size = sizeof(name); gnutls_x509_crt_get_issuer_dn(crt, name, &name_size); Log::global->Format(9, " Issued by: %s\n", name); /* Do the actual verification. */ gnutls_x509_crt_verify(crt, instance->ca_list, instance->ca_list_size, GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT, &crt_status); if (crt_status & GNUTLS_CERT_INVALID) { char msg[256]; strcpy(msg,"Not trusted"); if (crt_status & GNUTLS_CERT_SIGNER_NOT_CA) strcat(msg,": Issuer is not a CA"); set_cert_error(msg); } else Log::global->Format(9, " Trusted\n"); /* Now check the expiration dates. */ if(gnutls_x509_crt_get_activation_time(crt) > now) set_cert_error("Not yet activated"); if(gnutls_x509_crt_get_expiration_time(crt) < now) set_cert_error("Expired"); /* Check if the certificate is revoked. */ ret = gnutls_x509_crt_check_revocation(crt, instance->crl_list, instance->crl_list_size); if (ret == 1) { /* revoked */ set_cert_error("Revoked"); } } bool lftp_ssl_gnutls::check_fatal(int res) { if(!gnutls_error_is_fatal(res)) return false; if((res==GNUTLS_E_UNEXPECTED_PACKET_LENGTH || res==GNUTLS_E_PUSH_ERROR || res==GNUTLS_E_PULL_ERROR || res==GNUTLS_E_DECRYPTION_FAILED) && (!errno || temporary_network_error(errno))) return false; return true; } int lftp_ssl_gnutls::do_handshake() { if(handshake_done) return DONE; errno=0; int res=gnutls_handshake(session); if(res<0) { if(res==GNUTLS_E_AGAIN || res==GNUTLS_E_INTERRUPTED) return RETRY; else // error { fatal=check_fatal(res); set_error("gnutls_handshake",gnutls_strerror(res)); return ERROR; } } handshake_done=true; SMTask::current->Timeout(0); if(gnutls_certificate_type_get(session)!=GNUTLS_CRT_X509) { set_cert_error("Unsupported certificate type"); return DONE; // FIXME: handle openpgp as well } unsigned cert_list_size=0; const gnutls_datum_t *cert_list=gnutls_certificate_get_peers(session,&cert_list_size); if(cert_list==NULL || cert_list_size==0) set_cert_error("No certificate was found!"); else verify_certificate_chain(cert_list,cert_list_size); return DONE; } #ifndef GNUTLS_E_PREMATURE_TERMINATION // for gnutls < 3.0 # define GNUTLS_E_PREMATURE_TERMINATION GNUTLS_E_UNEXPECTED_PACKET_LENGTH #endif int lftp_ssl_gnutls::read(char *buf,int size) { if(error) return ERROR; int res=do_handshake(); if(res!=DONE) return res; errno=0; res=gnutls_record_recv(session,buf,size); if(res<0) { if(res==GNUTLS_E_AGAIN || res==GNUTLS_E_INTERRUPTED) return RETRY; else if(res==GNUTLS_E_UNEXPECTED_PACKET_LENGTH || res==GNUTLS_E_PREMATURE_TERMINATION) { Log::global->Format(7,"gnutls_record_recv: %s Assuming EOF.\n",gnutls_strerror(res)); return 0; } else // error { fatal=check_fatal(res); set_error("gnutls_record_recv",gnutls_strerror(res)); return ERROR; } } return res; } int lftp_ssl_gnutls::write(const char *buf,int size) { if(error) return ERROR; int res=do_handshake(); if(res!=DONE) return res; if(size==0) return 0; errno=0; res=gnutls_record_send(session,buf,size); if(res<0) { if(res==GNUTLS_E_AGAIN || res==GNUTLS_E_INTERRUPTED) return RETRY; else // error { fatal=check_fatal(res); set_error("gnutls_record_send",gnutls_strerror(res)); return ERROR; } } return res; } bool lftp_ssl_gnutls::want_in() { return gnutls_record_get_direction(session)==0; } bool lftp_ssl_gnutls::want_out() { return gnutls_record_get_direction(session)==1; } void lftp_ssl_gnutls::copy_sid(const lftp_ssl_gnutls *o) { size_t session_data_size; void *session_data; int res=gnutls_session_get_data(o->session,NULL,&session_data_size); if(res!=GNUTLS_E_SUCCESS && res!=GNUTLS_E_SHORT_MEMORY_BUFFER) return; session_data=xmalloc(session_data_size); if(gnutls_session_get_data(o->session,session_data,&session_data_size)!=GNUTLS_E_SUCCESS) return; gnutls_session_set_data(session,session_data,session_data_size); } #if LFTP_LIBGNUTLS_VERSION_CODE < 0x010201 #define PEM_CERT_SEP2 "-----BEGIN X509 CERTIFICATE" #define PEM_CERT_SEP "-----BEGIN CERTIFICATE" #define CLEAR_CERTS \ for(j=0;jdata, data->size, PEM_CERT_SEP, sizeof(PEM_CERT_SEP) - 1); if (ptr == NULL) ptr = (const char *)memmem(data->data, data->size, PEM_CERT_SEP2, sizeof(PEM_CERT_SEP2) - 1); if (ptr == NULL) { return GNUTLS_E_BASE64_DECODING_ERROR; } size = data->size - (ptr - (char*)data->data); count = 0; do { if (count >= *cert_max) { if (!(flags & GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED)) break; else nocopy = 1; } if (!nocopy) { ret = gnutls_x509_crt_init( &certs[count]); if (ret < 0) { goto error; } tmp.data = (unsigned char*)ptr; tmp.size = size; ret = gnutls_x509_crt_import( certs[count], &tmp, GNUTLS_X509_FMT_PEM); if (ret < 0) { goto error; } } /* now we move ptr after the pem header */ ptr++; /* find the next certificate (if any) */ size = data->size - (ptr - (char*)data->data); if (size > 0) { const char *ptr2; ptr2 = (const char *)memmem(ptr, size, PEM_CERT_SEP, sizeof(PEM_CERT_SEP) - 1); if (ptr2 == NULL) ptr2 = (const char *)memmem(ptr, size, PEM_CERT_SEP2, sizeof(PEM_CERT_SEP2) - 1); ptr = ptr2; } else ptr = NULL; count++; } while (ptr != NULL); *cert_max = count; if (nocopy==0) return count; else return GNUTLS_E_SHORT_MEMORY_BUFFER; error: CLEAR_CERTS; return ret; } #endif /*=============================== OpenSSL ====================================*/ #elif USE_OPENSSL //static int lftp_ssl_passwd_callback(char *buf,int size,int rwflag,void *userdata); lftp_ssl_openssl_instance *lftp_ssl_openssl::instance; static char file[256]; static void lftp_ssl_write_rnd() { RAND_write_file(file); } void lftp_ssl_openssl::global_init() { if(!instance) instance=new lftp_ssl_openssl_instance(); } void lftp_ssl_openssl::global_deinit() { delete instance; instance=0; } #ifndef SSL_OP_NO_TICKET # define SSL_OP_NO_TICKET 0 #endif lftp_ssl_openssl_instance::lftp_ssl_openssl_instance() { crl_store=0; ssl_ctx=0; #ifdef WINDOWS RAND_screen(); #endif RAND_file_name(file,sizeof(file)); if(RAND_load_file(file,-1) && RAND_status()!=0) atexit(lftp_ssl_write_rnd); #if SSLEAY_VERSION_NUMBER < 0x0800 ssl_ctx=SSL_CTX_new(); X509_set_default_verify_paths(ssl_ctx->cert); #else SSLeay_add_ssl_algorithms(); ssl_ctx=SSL_CTX_new(SSLv23_client_method()); long options=SSL_OP_ALL|SSL_OP_NO_TICKET|SSL_OP_NO_SSLv2; const char *priority=ResMgr::Query("ssl:priority", 0); if(priority && *priority) { static const struct ssl_option { const char name[8]; long option; } opt_table[]={ {"-SSL3.0",SSL_OP_NO_SSLv3}, {"-TLS1.0",SSL_OP_NO_TLSv1}, {"-TLS1.1",SSL_OP_NO_TLSv1_1}, {"-TLS1.2",SSL_OP_NO_TLSv1_2}, {"",0} }; char *to_parse=alloca_strdup(priority); for(char *ptr=strtok(to_parse,":"); ptr; ptr=strtok(NULL,":")) { for(const ssl_option *opt=opt_table; opt->name[0]; opt++) { if(!strcmp(ptr,opt->name)) { options|=opt->option; Log::global->Format(9,"ssl: applied %s option\n",ptr); break; } } } } SSL_CTX_set_options(ssl_ctx, options); SSL_CTX_set_cipher_list(ssl_ctx, "ALL:!aNULL:!eNULL:!SSLv2:!LOW:!EXP:!MD5:@STRENGTH"); SSL_CTX_set_verify(ssl_ctx,SSL_VERIFY_PEER,lftp_ssl_openssl::verify_callback); // SSL_CTX_set_default_passwd_cb(ssl_ctx,lftp_ssl_passwd_callback); const char *ca_file=ResMgr::Query("ssl:ca-file",0); const char *ca_path=ResMgr::Query("ssl:ca-path",0); if(ca_file && !*ca_file) ca_file=0; if(ca_path && !*ca_path) ca_path=0; if(ca_file || ca_path) { if(!SSL_CTX_load_verify_locations(ssl_ctx,ca_file,ca_path)) { fprintf(stderr,"WARNING: SSL_CTX_load_verify_locations(%s,%s) failed\n", ca_file?ca_file:"NULL", ca_path?ca_path:"NULL"); SSL_CTX_set_default_verify_paths(ssl_ctx); } } else { SSL_CTX_set_default_verify_paths(ssl_ctx); } const char *crl_file=ResMgr::Query("ssl:crl-file",0); const char *crl_path=ResMgr::Query("ssl:crl-path",0); if(crl_file && !*crl_file) crl_file=0; if(crl_path && !*crl_path) crl_path=0; if(crl_file || crl_path) { crl_store=X509_STORE_new(); if(!X509_STORE_load_locations(crl_store,crl_file,crl_path)) { fprintf(stderr,"WARNING: X509_STORE_load_locations(%s,%s) failed\n", crl_file?crl_file:"NULL", crl_path?crl_path:"NULL"); } } #endif /* SSLEAY_VERSION_NUMBER < 0x0800 */ } lftp_ssl_openssl_instance::~lftp_ssl_openssl_instance() { SSL_CTX_free(ssl_ctx); X509_STORE_free(crl_store); } lftp_ssl_openssl::lftp_ssl_openssl(int fd1,handshake_mode_t m,const char *h) : lftp_ssl_base(fd1,m,h) { if(!instance) global_init(); ssl=SSL_new(instance->ssl_ctx); SSL_set_fd(ssl,fd); SSL_ctrl(ssl,SSL_CTRL_MODE,SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER,0); if(h && ResMgr::QueryBool("ssl:use-sni",h)) { if(!SSL_set_tlsext_host_name(ssl, h)) fprintf(stderr,"WARNING: failed to configure server name indication (SNI) TLS extension\n"); } } void lftp_ssl_openssl::load_keys() { const char *key_file =ResMgr::Query("ssl:key-file",hostname); const char *cert_file=ResMgr::Query("ssl:cert-file",hostname); if(key_file && !*key_file) key_file=0; if(cert_file && !*cert_file) cert_file=0; if(cert_file) { if(!key_file) key_file=cert_file; if(SSL_use_certificate_file(ssl,cert_file,SSL_FILETYPE_PEM)<=0) { // FIXME } if(SSL_use_PrivateKey_file(ssl,key_file,SSL_FILETYPE_PEM)<=0) { // FIXME } if(!SSL_check_private_key(ssl)) { // FIXME } } } void lftp_ssl_openssl::shutdown() { if(handshake_done) SSL_shutdown(ssl); } lftp_ssl_openssl::~lftp_ssl_openssl() { SSL_free(ssl); ssl=0; } static const char *verify_callback_host; static int lftp_ssl_connect(SSL *ssl,const char *h) { verify_callback_host=h; int res=SSL_connect(ssl); verify_callback_host=0; return res; } bool lftp_ssl_openssl::check_fatal(int res) { return !(SSL_get_error(ssl,res)==SSL_ERROR_SYSCALL && (ERR_get_error()==0 || temporary_network_error(errno))); } int lftp_ssl_openssl::do_handshake() { if(handshake_done) return DONE; if(handshake_mode==SERVER) { // FIXME: SSL_accept return RETRY; } errno=0; int res=lftp_ssl_connect(ssl,hostname); if(res<=0) { if(BIO_sock_should_retry(res)) return RETRY; else if (SSL_want_x509_lookup(ssl)) return RETRY; else // error { fatal=check_fatal(res); set_error("SSL_connect",strerror()); return ERROR; } } handshake_done=true; check_certificate(); SMTask::current->Timeout(0); return DONE; } int lftp_ssl_openssl::read(char *buf,int size) { if(error) return ERROR; int res=do_handshake(); if(res!=DONE) return res; errno=0; res=SSL_read(ssl,buf,size); if(res<0) { if(BIO_sock_should_retry(res)) return RETRY; else if (SSL_want_x509_lookup(ssl)) return RETRY; else // error { fatal=check_fatal(res); set_error("SSL_read",strerror()); return ERROR; } } return res; } int lftp_ssl_openssl::write(const char *buf,int size) { if(error) return ERROR; int res=do_handshake(); if(res!=DONE) return res; if(size==0) return 0; errno=0; res=SSL_write(ssl,buf,size); if(res<0) { if(BIO_sock_should_retry(res)) return RETRY; else if (SSL_want_x509_lookup(ssl)) return RETRY; else // error { fatal=check_fatal(res); set_error("SSL_write",strerror()); return ERROR; } } return res; } bool lftp_ssl_openssl::want_in() { return SSL_want_read(ssl); } bool lftp_ssl_openssl::want_out() { return SSL_want_write(ssl); } void lftp_ssl_openssl::copy_sid(const lftp_ssl_openssl *o) { SSL_copy_session_id(ssl,o->ssl); } static int certificate_verify_error; const char *lftp_ssl_openssl::strerror() { SSL_load_error_strings(); int error=ERR_get_error(); const char *ssl_error=0; if(ERR_GET_LIB(error)==ERR_LIB_SSL && ERR_GET_REASON(error)==SSL_R_CERTIFICATE_VERIFY_FAILED) ssl_error=X509_verify_cert_error_string(certificate_verify_error); else if(ERR_GET_LIB(error)==ERR_LIB_SSL) ssl_error=ERR_reason_error_string(error); else ssl_error=ERR_error_string(error,NULL); if(!ssl_error) ssl_error="error"; return ssl_error; } /* This one is (very much!) based on work by Ralf S. Engelschall . * Comments by Ralf. */ int lftp_ssl_openssl::verify_crl(X509_STORE_CTX *ctx) { X509_OBJECT obj; X509_NAME *subject; X509_NAME *issuer; X509 *xs; X509_CRL *crl; X509_REVOKED *revoked; X509_STORE_CTX store_ctx; long serial; int i, n, rc; char *cp; /* * Unless a revocation store for CRLs was created we * cannot do any CRL-based verification, of course. */ if (!instance->crl_store) return 1; /* * Determine certificate ingredients in advance */ xs = X509_STORE_CTX_get_current_cert(ctx); subject = X509_get_subject_name(xs); issuer = X509_get_issuer_name(xs); /* * OpenSSL provides the general mechanism to deal with CRLs but does not * use them automatically when verifying certificates, so we do it * explicitly here. We will check the CRL for the currently checked * certificate, if there is such a CRL in the store. * * We come through this procedure for each certificate in the certificate * chain, starting with the root-CA's certificate. At each step we've to * both verify the signature on the CRL (to make sure it's a valid CRL) * and it's revocation list (to make sure the current certificate isn't * revoked). But because to check the signature on the CRL we need the * public key of the issuing CA certificate (which was already processed * one round before), we've a little problem. But we can both solve it and * at the same time optimize the processing by using the following * verification scheme (idea and code snippets borrowed from the GLOBUS * project): * * 1. We'll check the signature of a CRL in each step when we find a CRL * through the _subject_ name of the current certificate. This CRL * itself will be needed the first time in the next round, of course. * But we do the signature processing one round before this where the * public key of the CA is available. * * 2. We'll check the revocation list of a CRL in each step when * we find a CRL through the _issuer_ name of the current certificate. * This CRLs signature was then already verified one round before. * * This verification scheme allows a CA to revoke its own certificate as * well, of course. */ /* * Try to retrieve a CRL corresponding to the _subject_ of * the current certificate in order to verify it's integrity. */ memset((char *)&obj, 0, sizeof(obj)); X509_STORE_CTX_init(&store_ctx, instance->crl_store, NULL, NULL); rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, subject, &obj); X509_STORE_CTX_cleanup(&store_ctx); crl = obj.data.crl; if (rc > 0 && crl != NULL) { /* * Verify the signature on this CRL */ if (X509_CRL_verify(crl, X509_get_pubkey(xs)) <= 0) { Log::global->Format(0,"Invalid signature on CRL!\n"); X509_STORE_CTX_set_error(ctx, X509_V_ERR_CRL_SIGNATURE_FAILURE); X509_OBJECT_free_contents(&obj); return 0; } /* * Check date of CRL to make sure it's not expired */ i = X509_cmp_current_time(X509_CRL_get_nextUpdate(crl)); if (i == 0) { Log::global->Format(0,"Found CRL has invalid nextUpdate field.\n"); X509_STORE_CTX_set_error(ctx, X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD); X509_OBJECT_free_contents(&obj); return 0; } if (i < 0) { Log::global->Format(0,"Found CRL is expired - revoking all certificates until you get updated CRL.\n"); X509_STORE_CTX_set_error(ctx, X509_V_ERR_CRL_HAS_EXPIRED); X509_OBJECT_free_contents(&obj); return 0; } X509_OBJECT_free_contents(&obj); } /* * Try to retrieve a CRL corresponding to the _issuer_ of * the current certificate in order to check for revocation. */ memset((char *)&obj, 0, sizeof(obj)); X509_STORE_CTX_init(&store_ctx, instance->crl_store, NULL, NULL); rc = X509_STORE_get_by_subject(&store_ctx, X509_LU_CRL, issuer, &obj); X509_STORE_CTX_cleanup(&store_ctx); crl = obj.data.crl; if (rc > 0 && crl != NULL) { /* * Check if the current certificate is revoked by this CRL */ n = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl)); for (i = 0; i < n; i++) { revoked = sk_X509_REVOKED_value(X509_CRL_get_REVOKED(crl), i); if (ASN1_INTEGER_cmp(revoked->serialNumber, X509_get_serialNumber(xs)) == 0) { serial = ASN1_INTEGER_get(revoked->serialNumber); cp = X509_NAME_oneline(issuer, NULL, 0); Log::global->Format(0, "Certificate with serial %ld (0x%lX) revoked per CRL from issuer %s\n", serial, serial, cp ? cp : "(ERROR)"); free(cp); X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_REVOKED); X509_OBJECT_free_contents(&obj); return 0; } } X509_OBJECT_free_contents(&obj); } return 1; } static bool convert_from_utf8(char *str,int len) { DirectedBuffer translate(DirectedBuffer::GET); translate.SetTranslation("UTF-8",false); translate.PutTranslated(str,len); const char *str1,*str2; int len1,len2; translate.Get(&str1,&len1); if(len1>len) return false; // no room to store expanded string // be safe and try to convert back to UTF-8 DirectedBuffer translate_back(DirectedBuffer::PUT); translate_back.SetTranslation("UTF-8",false); translate_back.PutTranslated(str1,len1); translate_back.Get(&str2,&len2); if(len2!=len || memcmp(str2,str,len)) return false; // conversion error memcpy(str,str1,len1); str[len1]=0; return true; } /* begin curl code */ /* Copyright (c) 1998 - 2014, Daniel Stenberg, */ #define Curl_raw_toupper c_toupper #define Curl_raw_equal !strcmp #define Curl_raw_nequal !strncmp #define Curl_inet_pton inet_pton #if INET6 # define ENABLE_IPV6 1 #endif /* * Match a hostname against a wildcard pattern. * E.g. * "foo.host.com" matches "*.host.com". * * We use the matching rule described in RFC6125, section 6.4.3. * http://tools.ietf.org/html/rfc6125#section-6.4.3 * * In addition: ignore trailing dots in the host names and wildcards, so that * the names are used normalized. This is what the browsers do. * * Do not allow wildcard matching on IP numbers. There are apparently * certificates being used with an IP address in the CN field, thus making no * apparent distinction between a name and an IP. We need to detect the use of * an IP address and not wildcard match on such names. * * NOTE: hostmatch() gets called with copied buffers so that it can modify the * contents at will. */ #define CURL_HOST_NOMATCH 0 #define CURL_HOST_MATCH 1 static int hostmatch(char *hostname, char *pattern) { const char *pattern_label_end, *pattern_wildcard, *hostname_label_end; int wildcard_enabled; size_t prefixlen, suffixlen; struct in_addr ignored; #ifdef ENABLE_IPV6 struct sockaddr_in6 si6; #endif /* normalize pattern and hostname by stripping off trailing dots */ size_t len = strlen(hostname); if(hostname[len-1]=='.') hostname[len-1]=0; len = strlen(pattern); if(pattern[len-1]=='.') pattern[len-1]=0; pattern_wildcard = strchr(pattern, '*'); if(pattern_wildcard == NULL) return Curl_raw_equal(pattern, hostname) ? CURL_HOST_MATCH : CURL_HOST_NOMATCH; /* detect IP address as hostname and fail the match if so */ if(Curl_inet_pton(AF_INET, hostname, &ignored) > 0) return CURL_HOST_NOMATCH; #ifdef ENABLE_IPV6 else if(Curl_inet_pton(AF_INET6, hostname, &si6.sin6_addr) > 0) return CURL_HOST_NOMATCH; #endif /* We require at least 2 dots in pattern to avoid too wide wildcard match. */ wildcard_enabled = 1; pattern_label_end = strchr(pattern, '.'); if(pattern_label_end == NULL || strchr(pattern_label_end+1, '.') == NULL || pattern_wildcard > pattern_label_end || Curl_raw_nequal(pattern, "xn--", 4)) { wildcard_enabled = 0; } if(!wildcard_enabled) return Curl_raw_equal(pattern, hostname) ? CURL_HOST_MATCH : CURL_HOST_NOMATCH; hostname_label_end = strchr(hostname, '.'); if(hostname_label_end == NULL || !Curl_raw_equal(pattern_label_end, hostname_label_end)) return CURL_HOST_NOMATCH; /* The wildcard must match at least one character, so the left-most label of the hostname is at least as large as the left-most label of the pattern. */ if(hostname_label_end - hostname < pattern_label_end - pattern) return CURL_HOST_NOMATCH; prefixlen = pattern_wildcard - pattern; suffixlen = pattern_label_end - (pattern_wildcard+1); return Curl_raw_nequal(pattern, hostname, prefixlen) && Curl_raw_nequal(pattern_wildcard+1, hostname_label_end - suffixlen, suffixlen) ? CURL_HOST_MATCH : CURL_HOST_NOMATCH; } static int cert_hostcheck(const char *match_pattern, const char *hostname) { char *matchp; char *hostp; int res = 0; if(!match_pattern || !*match_pattern || !hostname || !*hostname) /* sanity check */ ; else { matchp = strdup(match_pattern); if(matchp) { hostp = strdup(hostname); if(hostp) { if(hostmatch(hostp, matchp) == CURL_HOST_MATCH) res= 1; free(hostp); } free(matchp); } } return res; } /* Quote from RFC2818 section 3.1 "Server Identity" If a subjectAltName extension of type dNSName is present, that MUST be used as the identity. Otherwise, the (most specific) Common Name field in the Subject field of the certificate MUST be used. Although the use of the Common Name is existing practice, it is deprecated and Certification Authorities are encouraged to use the dNSName instead. Matching is performed using the matching rules specified by [RFC2459]. If more than one identity of a given type is present in the certificate (e.g., more than one dNSName name, a match in any one of the set is considered acceptable.) Names may contain the wildcard character * which is considered to match any single domain name component or component fragment. E.g., *.a.com matches foo.a.com but not bar.foo.a.com. f*.com matches foo.com but not bar.com. In some cases, the URI is specified as an IP address rather than a hostname. In this case, the iPAddress subjectAltName must be present in the certificate and must exactly match the IP in the URI. */ void lftp_ssl_openssl::check_certificate() { X509 *server_cert = SSL_get_peer_certificate (ssl); if (!server_cert) { set_cert_error(xstring::format(_("No certificate presented by %s.\n"), quotearg_style (escape_quoting_style, hostname))); return; } bool check_hostname = ResMgr::QueryBool("ssl:check-hostname", hostname); if(!check_hostname) { Log::global->Format(0, "WARNING: Certificate verification: hostname checking disabled\n"); return; } int matched = -1; /* -1 is no alternative match yet, 1 means match and 0 means mismatch */ int target = GEN_DNS; /* target type, GEN_DNS or GEN_IPADD */ size_t addrlen = 0; STACK_OF(GENERAL_NAME) *altnames; #ifdef ENABLE_IPV6 struct in6_addr addr; #else struct in_addr addr; #endif sockaddr_u fd_addr; socklen_t fd_addr_len = sizeof(fd_addr); getsockname(fd,&fd_addr.sa,&fd_addr_len); #ifdef ENABLE_IPV6 if(fd_addr.sa.sa_family==AF_INET6 && Curl_inet_pton(AF_INET6, hostname, &addr)) { target = GEN_IPADD; addrlen = sizeof(struct in6_addr); } else #endif if(Curl_inet_pton(AF_INET, hostname, &addr)) { target = GEN_IPADD; addrlen = sizeof(struct in_addr); } /* get a "list" of alternative names */ altnames = (STACK_OF(GENERAL_NAME)*)X509_get_ext_d2i(server_cert, NID_subject_alt_name, NULL, NULL); if(altnames) { int numalts; int i; /* get amount of alternatives, RFC2459 claims there MUST be at least one, but we don't depend on it... */ numalts = sk_GENERAL_NAME_num(altnames); /* loop through all alternatives while none has matched */ for (i=0; (itype == target) { /* get data and length */ const char *altptr = (char *)ASN1_STRING_data(check->d.ia5); size_t altlen = (size_t) ASN1_STRING_length(check->d.ia5); switch(target) { case GEN_DNS: /* name/pattern comparison */ /* The OpenSSL man page explicitly says: "In general it cannot be assumed that the data returned by ASN1_STRING_data() is null terminated or does not contain embedded nulls." But also that "The actual format of the data will depend on the actual string type itself: for example for and IA5String the data will be ASCII" Gisle researched the OpenSSL sources: "I checked the 0.9.6 and 0.9.8 sources before my patch and it always 0-terminates an IA5String." */ if((altlen == strlen(altptr)) && /* if this isn't true, there was an embedded zero in the name string and we cannot match it. */ cert_hostcheck(altptr, hostname)) matched = 1; else matched = 0; break; case GEN_IPADD: /* IP address comparison */ /* compare alternative IP address if the data chunk is the same size our server IP address is */ if((altlen == addrlen) && !memcmp(altptr, &addr, altlen)) matched = 1; else matched = 0; break; } } } GENERAL_NAMES_free(altnames); } if(matched == 1) /* an alternative name matched the server hostname */ Log::global->Format(9, "Certificate verification: subjectAltName: %s matched\n", quote(hostname)); else if(matched == 0) { /* an alternative name field existed, but didn't match and then we MUST fail */ set_cert_error(xstring::format("subjectAltName does not match %s", quote(hostname))); } else { /* we have to look to the last occurence of a commonName in the distinguished one to get the most significant one. */ int j,i=-1 ; /* The following is done because of a bug in 0.9.6b */ unsigned char *nulstr = (unsigned char *)""; unsigned char *peer_CN = nulstr; X509_NAME *name = X509_get_subject_name(server_cert) ; if(name) while((j = X509_NAME_get_index_by_NID(name, NID_commonName, i))>=0) i=j; /* we have the name entry and we will now convert this to a string that we can use for comparison. Doing this we support BMPstring, UTF8 etc. */ if(i>=0) { ASN1_STRING *tmp = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,i)); /* In OpenSSL 0.9.7d and earlier, ASN1_STRING_to_UTF8 fails if the input is already UTF-8 encoded. We check for this case and copy the raw string manually to avoid the problem. This code can be made conditional in the future when OpenSSL has been fixed. Work-around brought by Alexis S. L. Carvalho. */ if(tmp) { if(ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) { j = ASN1_STRING_length(tmp); if(j >= 0) { peer_CN = (unsigned char*)OPENSSL_malloc(j+1); if(peer_CN) { memcpy(peer_CN, ASN1_STRING_data(tmp), j); peer_CN[j] = '\0'; } } } else /* not a UTF8 name */ j = ASN1_STRING_to_UTF8(&peer_CN, tmp); if(peer_CN && ((int)strlen((char *)peer_CN) != j)) { /* there was a terminating zero before the end of string, this cannot match and we return failure! */ set_cert_error("illegal cert name field (contains NUL character)"); } } } if(peer_CN == nulstr) peer_CN = NULL; else { /* convert peer_CN from UTF8 */ if(!convert_from_utf8((char*)peer_CN, strlen((char*)peer_CN))) set_cert_error("invalid cert name field (cannot convert from UTF8)"); } if(cert_error) /* error already detected, pass through */ ; else if(!peer_CN) { set_cert_error("unable to obtain common name from peer certificate"); } else if(!cert_hostcheck((const char *)peer_CN, hostname)) { set_cert_error(xstring::format("certificate subject name %s does not match " "target host name %s", quote_n(0,(const char *)peer_CN), quote_n(1,hostname))); } else { Log::global->Format(9, "Certificate verification: common name: %s matched\n", quote((char*)peer_CN)); } if(peer_CN) OPENSSL_free(peer_CN); } } /* end curl code */ /* begin wget-1.12 code */ #if 0 #define ASTERISK_EXCLUDES_DOT /* mandated by rfc2818 */ /* Return true is STRING (case-insensitively) matches PATTERN, false otherwise. The recognized wildcard character is "*", which matches any character in STRING except ".". Any number of the "*" wildcard may be present in the pattern. This is used to match of hosts as indicated in rfc2818: "Names may contain the wildcard character * which is considered to match any single domain name component or component fragment. E.g., *.a.com matches foo.a.com but not bar.foo.a.com. f*.com matches foo.com but not bar.com [or foo.bar.com]." If the pattern contain no wildcards, pattern_match(a, b) is equivalent to !strcasecmp(a, b). */ static bool pattern_match (const char *pattern, const char *string) { const char *p = pattern, *n = string; char c; for (; (c = c_tolower (*p++)) != '\0'; n++) if (c == '*') { for (c = c_tolower (*p); c == '*'; c = c_tolower (*++p)) ; for (; *n != '\0'; n++) if (c_tolower (*n) == c && pattern_match (p, n)) return true; #ifdef ASTERISK_EXCLUDES_DOT else if (*n == '.') return false; #endif return c == '\0'; } else { if (c != c_tolower (*n)) return false; } return *n == '\0'; } /* Verify the validity of the certificate presented by the server. Also check that the "common name" of the server, as presented by its certificate, corresponds to HOST. (HOST typically comes from the URL and is what the user thinks he's connecting to.) This assumes that ssl_connect_wget has successfully finished, i.e. that the SSL handshake has been performed and that FD is connected to an SSL handle. If opt.check_cert is true (the default), this returns 1 if the certificate is valid, 0 otherwise. If opt.check_cert is 0, the function always returns 1, but should still be called because it warns the user about any problems with the certificate. */ void lftp_ssl_openssl::check_certificate_wget () { X509 *cert; char common_name[256]; cert = SSL_get_peer_certificate (ssl); if (!cert) { set_cert_error(xstring::format(_("No certificate presented by %s.\n"), quotearg_style (escape_quoting_style, hostname))); return; } /* LAV: certificate validity is already checked in callback. */ /* Check that HOST matches the common name in the certificate. #### The following remains to be done: - It should use dNSName/ipAddress subjectAltName extensions if available; according to rfc2818: "If a subjectAltName extension of type dNSName is present, that MUST be used as the identity." - When matching against common names, it should loop over all common names and choose the most specific one, i.e. the last one, not the first one, which the current code picks. - Ensure that ASN1 strings from the certificate are encoded as UTF-8 which can be meaningfully compared to HOST. */ X509_NAME *xname = X509_get_subject_name(cert); common_name[0] = '\0'; X509_NAME_get_text_by_NID (xname, NID_commonName, common_name, sizeof (common_name)); if (!pattern_match (common_name, hostname)) { set_cert_error(xstring::format(_("certificate common name %s doesn't match requested host name %s"), quote_n (0, common_name), quote_n (1, hostname))); } else { /* We now determine the length of the ASN1 string. If it differs from * common_name's length, then there is a \0 before the string terminates. * This can be an instance of a null-prefix attack. * * https://www.blackhat.com/html/bh-usa-09/bh-usa-09-archives.html#Marlinspike * */ int i = -1, j; X509_NAME_ENTRY *xentry; ASN1_STRING *sdata; if (xname) { for (;;) { j = X509_NAME_get_index_by_NID (xname, NID_commonName, i); if (j == -1) break; i = j; } } xentry = X509_NAME_get_entry(xname,i); sdata = X509_NAME_ENTRY_get_data(xentry); if (strlen (common_name) != (size_t)ASN1_STRING_length (sdata)) set_cert_error(_("certificate common name is invalid (contains a NUL character)")); } X509_free (cert); } #endif /* end wget code */ int lftp_ssl_openssl::verify_callback(int ok,X509_STORE_CTX *ctx) { static X509 *prev_cert=0; X509 *cert=X509_STORE_CTX_get_current_cert(ctx); if(cert!=prev_cert) { int depth = X509_STORE_CTX_get_error_depth(ctx); X509_NAME *subject = X509_get_subject_name(cert); X509_NAME *issuer = X509_get_issuer_name(cert); char *subject_line = X509_NAME_oneline(subject, NULL, 0); char *issuer_line = X509_NAME_oneline(issuer, NULL, 0); Log::global->Format(3,"Certificate depth: %d; subject: %s; issuer: %s\n", depth,subject_line,issuer_line); free(subject_line); free(issuer_line); } if(ok && !verify_crl(ctx)) ok=0; int error=X509_STORE_CTX_get_error(ctx); bool verify=ResMgr::QueryBool("ssl:verify-certificate",verify_callback_host); if(!ok) { Log::global->Format(0,"%s: Certificate verification: %s\n", verify?"ERROR":"WARNING", X509_verify_cert_error_string(error)); } if(!verify) ok=1; if(!ok) certificate_verify_error=error; prev_cert=cert; return ok; } #endif // USE_OPENSSL #endif // USE_SSL lftp-4.6.3a/src/StatusLine.h0000644000015000007670000000403512122060701012577 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef STATUSLINE_H #define STATUSLINE_H #include "SMTask.h" #include "Timer.h" #include "StringSet.h" class StatusLine : public SMTask { int fd; StringSet shown; bool not_term; Timer update_timer; StringSet to_be_shown; char def_title[0x800]; bool update_delayed; void update(const char *const *,int); void update(const char *s) { update(&s,1); } int LastWidth; int LastHeight; bool next_update_title_only; static const char *to_status_line, *from_status_line, *prev_line; protected: void WriteTitle(const char *s, int fd) const; public: int GetWidth(); int GetHeight(); int GetWidthDelayed() const { return LastWidth; } int GetHeightDelayed() const { return LastHeight; } void NextUpdateTitleOnly() { next_update_title_only=true; } void DefaultTitle(const char *s); void ShowN(const char *const* newstr,int n); void Show(const char *f,...) PRINTF_LIKE(2,3); void Show(const StringSet &s) { ShowN(s.Set(),s.Count()); } void Show(const StringSet *s) { Show(*s); } void WriteLine(const char *f,...) PRINTF_LIKE(2,3); void Clear(bool title_also=true); bool CanShowNow() { return update_timer.Stopped(); } int getfd() const { return fd; } StatusLine(int new_fd); ~StatusLine(); int Do(); }; #endif // STATUSLINE_H lftp-4.6.3a/src/netkey.c0000644000015000007670000004546412122054516012020 00000000000000#include #include #include #include #include typedef unsigned char uchar; #define NAMELEN 28 enum { DESKEYLEN= 7, /* length of a des key for encrypt/decrypt */ CHALLEN= 8, /* length of a challenge */ NETCHLEN= 16, /* max network challenge length */ }; /************ crypt.c *************/ /* * Data Encryption Standard * D.P.Mitchell 83/06/08. * * block_cipher(key, block, decrypting) */ static int ip_low(char [8]); static int ip_high(char [8]); static void fp(int, int, char[8]); static void key_setup(char[DESKEYLEN], char[128]); static void block_cipher(char[128], char[8], int); /* * destructively encrypt the buffer, which * must be at least 8 characters long. */ int encrypt9(void *key, void *vbuf, int n) { char ekey[128], *buf; int i, r; if(n < 8) return 0; key_setup(key, ekey); buf = vbuf; n--; r = n % 7; n /= 7; for(i = 0; i < n; i++){ block_cipher(ekey, buf, 0); buf += 7; } if(r) block_cipher(ekey, buf - 7 + r, 0); return 1; } /* * destructively decrypt the buffer, which * must be at least 8 characters long. */ int decrypt(void *key, void *vbuf, int n) { char ekey[128], *buf; int i, r; if(n < 8) return 0; key_setup(key, ekey); buf = vbuf; n--; r = n % 7; n /= 7; buf += n * 7; if(r) block_cipher(ekey, buf - 7 + r, 1); for(i = 0; i < n; i++){ buf -= 7; block_cipher(ekey, buf, 1); } return 1; } /* * Tables for Combined S and P Boxes */ static const int s0p[] = { 0x00410100,0x00010000,0x40400000,0x40410100,0x00400000,0x40010100,0x40010000,0x40400000, 0x40010100,0x00410100,0x00410000,0x40000100,0x40400100,0x00400000,0x00000000,0x40010000, 0x00010000,0x40000000,0x00400100,0x00010100,0x40410100,0x00410000,0x40000100,0x00400100, 0x40000000,0x00000100,0x00010100,0x40410000,0x00000100,0x40400100,0x40410000,0x00000000, 0x00000000,0x40410100,0x00400100,0x40010000,0x00410100,0x00010000,0x40000100,0x00400100, 0x40410000,0x00000100,0x00010100,0x40400000,0x40010100,0x40000000,0x40400000,0x00410000, 0x40410100,0x00010100,0x00410000,0x40400100,0x00400000,0x40000100,0x40010000,0x00000000, 0x00010000,0x00400000,0x40400100,0x00410100,0x40000000,0x40410000,0x00000100,0x40010100, }; static const int s1p[] = { 0x08021002,0x00000000,0x00021000,0x08020000,0x08000002,0x00001002,0x08001000,0x00021000, 0x00001000,0x08020002,0x00000002,0x08001000,0x00020002,0x08021000,0x08020000,0x00000002, 0x00020000,0x08001002,0x08020002,0x00001000,0x00021002,0x08000000,0x00000000,0x00020002, 0x08001002,0x00021002,0x08021000,0x08000002,0x08000000,0x00020000,0x00001002,0x08021002, 0x00020002,0x08021000,0x08001000,0x00021002,0x08021002,0x00020002,0x08000002,0x00000000, 0x08000000,0x00001002,0x00020000,0x08020002,0x00001000,0x08000000,0x00021002,0x08001002, 0x08021000,0x00001000,0x00000000,0x08000002,0x00000002,0x08021002,0x00021000,0x08020000, 0x08020002,0x00020000,0x00001002,0x08001000,0x08001002,0x00000002,0x08020000,0x00021000, }; static const int s2p[] = { 0x20800000,0x00808020,0x00000020,0x20800020,0x20008000,0x00800000,0x20800020,0x00008020, 0x00800020,0x00008000,0x00808000,0x20000000,0x20808020,0x20000020,0x20000000,0x20808000, 0x00000000,0x20008000,0x00808020,0x00000020,0x20000020,0x20808020,0x00008000,0x20800000, 0x20808000,0x00800020,0x20008020,0x00808000,0x00008020,0x00000000,0x00800000,0x20008020, 0x00808020,0x00000020,0x20000000,0x00008000,0x20000020,0x20008000,0x00808000,0x20800020, 0x00000000,0x00808020,0x00008020,0x20808000,0x20008000,0x00800000,0x20808020,0x20000000, 0x20008020,0x20800000,0x00800000,0x20808020,0x00008000,0x00800020,0x20800020,0x00008020, 0x00800020,0x00000000,0x20808000,0x20000020,0x20800000,0x20008020,0x00000020,0x00808000, }; static const int s3p[] = { 0x00080201,0x02000200,0x00000001,0x02080201,0x00000000,0x02080000,0x02000201,0x00080001, 0x02080200,0x02000001,0x02000000,0x00000201,0x02000001,0x00080201,0x00080000,0x02000000, 0x02080001,0x00080200,0x00000200,0x00000001,0x00080200,0x02000201,0x02080000,0x00000200, 0x00000201,0x00000000,0x00080001,0x02080200,0x02000200,0x02080001,0x02080201,0x00080000, 0x02080001,0x00000201,0x00080000,0x02000001,0x00080200,0x02000200,0x00000001,0x02080000, 0x02000201,0x00000000,0x00000200,0x00080001,0x00000000,0x02080001,0x02080200,0x00000200, 0x02000000,0x02080201,0x00080201,0x00080000,0x02080201,0x00000001,0x02000200,0x00080201, 0x00080001,0x00080200,0x02080000,0x02000201,0x00000201,0x02000000,0x02000001,0x02080200, }; static const int s4p[] = { 0x01000000,0x00002000,0x00000080,0x01002084,0x01002004,0x01000080,0x00002084,0x01002000, 0x00002000,0x00000004,0x01000004,0x00002080,0x01000084,0x01002004,0x01002080,0x00000000, 0x00002080,0x01000000,0x00002004,0x00000084,0x01000080,0x00002084,0x00000000,0x01000004, 0x00000004,0x01000084,0x01002084,0x00002004,0x01002000,0x00000080,0x00000084,0x01002080, 0x01002080,0x01000084,0x00002004,0x01002000,0x00002000,0x00000004,0x01000004,0x01000080, 0x01000000,0x00002080,0x01002084,0x00000000,0x00002084,0x01000000,0x00000080,0x00002004, 0x01000084,0x00000080,0x00000000,0x01002084,0x01002004,0x01002080,0x00000084,0x00002000, 0x00002080,0x01002004,0x01000080,0x00000084,0x00000004,0x00002084,0x01002000,0x01000004, }; static const int s5p[] = { 0x10000008,0x00040008,0x00000000,0x10040400,0x00040008,0x00000400,0x10000408,0x00040000, 0x00000408,0x10040408,0x00040400,0x10000000,0x10000400,0x10000008,0x10040000,0x00040408, 0x00040000,0x10000408,0x10040008,0x00000000,0x00000400,0x00000008,0x10040400,0x10040008, 0x10040408,0x10040000,0x10000000,0x00000408,0x00000008,0x00040400,0x00040408,0x10000400, 0x00000408,0x10000000,0x10000400,0x00040408,0x10040400,0x00040008,0x00000000,0x10000400, 0x10000000,0x00000400,0x10040008,0x00040000,0x00040008,0x10040408,0x00040400,0x00000008, 0x10040408,0x00040400,0x00040000,0x10000408,0x10000008,0x10040000,0x00040408,0x00000000, 0x00000400,0x10000008,0x10000408,0x10040400,0x10040000,0x00000408,0x00000008,0x10040008, }; static const int s6p[] = { 0x00000800,0x00000040,0x00200040,0x80200000,0x80200840,0x80000800,0x00000840,0x00000000, 0x00200000,0x80200040,0x80000040,0x00200800,0x80000000,0x00200840,0x00200800,0x80000040, 0x80200040,0x00000800,0x80000800,0x80200840,0x00000000,0x00200040,0x80200000,0x00000840, 0x80200800,0x80000840,0x00200840,0x80000000,0x80000840,0x80200800,0x00000040,0x00200000, 0x80000840,0x00200800,0x80200800,0x80000040,0x00000800,0x00000040,0x00200000,0x80200800, 0x80200040,0x80000840,0x00000840,0x00000000,0x00000040,0x80200000,0x80000000,0x00200040, 0x00000000,0x80200040,0x00200040,0x00000840,0x80000040,0x00000800,0x80200840,0x00200000, 0x00200840,0x80000000,0x80000800,0x80200840,0x80200000,0x00200840,0x00200800,0x80000800, }; static const int s7p[] = { 0x04100010,0x04104000,0x00004010,0x00000000,0x04004000,0x00100010,0x04100000,0x04104010, 0x00000010,0x04000000,0x00104000,0x00004010,0x00104010,0x04004010,0x04000010,0x04100000, 0x00004000,0x00104010,0x00100010,0x04004000,0x04104010,0x04000010,0x00000000,0x00104000, 0x04000000,0x00100000,0x04004010,0x04100010,0x00100000,0x00004000,0x04104000,0x00000010, 0x00100000,0x00004000,0x04000010,0x04104010,0x00004010,0x04000000,0x00000000,0x00104000, 0x04100010,0x04004010,0x04004000,0x00100010,0x04104000,0x00000010,0x00100010,0x04004000, 0x04104010,0x00100000,0x04100000,0x04000010,0x00104000,0x00004010,0x04004010,0x04100000, 0x00000010,0x04104000,0x00104010,0x00000000,0x04000000,0x04100010,0x00004000,0x00104010, }; /* * DES electronic codebook encryption of one block */ static void block_cipher(char expanded_key[128], char text[8], int decrypting) { char *key; int crypto, temp, right, left; int i, key_offset; key = expanded_key; left = ip_low(text); right = ip_high(text); if (decrypting) { key_offset = 16; key = key + 128 - 8; } else key_offset = 0; for (i = 0; i < 16; i++) { temp = (right << 1) | ((right >> 31) & 1); crypto = s0p[(temp & 0x3f) ^ *key++]; crypto |= s1p[((temp >> 4) & 0x3f) ^ *key++]; crypto |= s2p[((temp >> 8) & 0x3f) ^ *key++]; crypto |= s3p[((temp >> 12) & 0x3f) ^ *key++]; crypto |= s4p[((temp >> 16) & 0x3f) ^ *key++]; crypto |= s5p[((temp >> 20) & 0x3f) ^ *key++]; crypto |= s6p[((temp >> 24) & 0x3f) ^ *key++]; temp = ((right & 1) << 5) | ((right >> 27) & 0x1f); crypto |= s7p[temp ^ *key++]; temp = left; left = right; right = temp ^ crypto; key -= key_offset; } /* * standard final permutation (IPI) * left and right are reversed here */ fp(right, left, text); } /* * Initial Permutation */ static const int iptab[] = { 0x00000000, 0x00008000, 0x00000000, 0x00008000, 0x00000080, 0x00008080, 0x00000080, 0x00008080 }; static int ip_low(char block[8]) { int i; int l; l = 0; for(i = 0; i < 8; i++){ l |= iptab[(block[i] >> 4) & 7] >> i; l |= iptab[block[i] & 7] << (16 - i); } return l; } static int ip_high(char block[8]) { int i; int l; l = 0; for(i = 0; i < 8; i++){ l |= iptab[(block[i] >> 5) & 7] >> i; l |= iptab[(block[i] >> 1) & 7] << (16 - i); } return l; } /* * Final Permutation */ static const unsigned int fptab[] = { 0x00000000,0x80000000,0x00800000,0x80800000,0x00008000,0x80008000,0x00808000,0x80808000, 0x00000080,0x80000080,0x00800080,0x80800080,0x00008080,0x80008080,0x00808080,0x80808080, }; static void fp(int left, int right, char text[8]) { unsigned int ta[2], t, v[2]; int i, j, sh; ta[0] = right; ta[1] = left; v[0] = v[1] = 0; for(i = 0; i < 2; i++){ t = ta[i]; sh = i; for(j = 0; j < 4; j++){ v[1] |= fptab[t & 0xf] >> sh; t >>= 4; v[0] |= fptab[t & 0xf] >> sh; t >>= 4; sh += 2; } } for(i = 0; i < 2; i++) for(j = 0; j < 4; j++){ *text++ = (char)(v[i]&0xff); v[i] >>= 8; } } /* * Key set-up */ static const uchar keyexpand[][15][2] = { { 3, 2, 9, 8, 18, 8, 27, 32, 33, 2, 42, 16, 48, 8, 65, 16, 74, 2, 80, 2, 89, 4, 99, 16, 104, 4, 122, 32, 0, 0, }, { 1, 4, 8, 1, 18, 4, 25, 32, 34, 32, 41, 8, 50, 8, 59, 32, 64, 16, 75, 4, 90, 1, 97, 16, 106, 2, 112, 2, 123, 1, }, { 2, 1, 19, 8, 35, 1, 40, 1, 50, 4, 57, 32, 75, 2, 80, 32, 89, 1, 96, 16, 107, 4, 120, 8, 0, 0, 0, 0, 0, 0, }, { 4, 32, 20, 2, 31, 4, 37, 32, 47, 1, 54, 1, 63, 2, 68, 1, 78, 4, 84, 8, 101, 16, 108, 4, 119, 16, 126, 8, 0, 0, }, { 5, 4, 15, 4, 21, 32, 31, 1, 38, 1, 47, 2, 53, 2, 68, 8, 85, 16, 92, 4, 103, 16, 108, 32, 118, 32, 124, 2, 0, 0, }, { 15, 2, 21, 2, 39, 8, 46, 16, 55, 32, 61, 1, 71, 16, 76, 32, 86, 32, 93, 4, 102, 2, 108, 16, 117, 8, 126, 1, 0, 0, }, { 14, 16, 23, 32, 29, 1, 38, 8, 52, 2, 63, 4, 70, 2, 76, 16, 85, 8, 100, 1, 110, 4, 116, 8, 127, 8, 0, 0, 0, 0, }, { 1, 8, 8, 32, 17, 1, 24, 16, 35, 4, 50, 1, 57, 16, 67, 8, 83, 1, 88, 1, 98, 4, 105, 32, 114, 32, 123, 2, 0, 0, }, { 0, 1, 11, 16, 16, 4, 35, 2, 40, 32, 49, 1, 56, 16, 65, 2, 74, 16, 80, 8, 99, 8, 115, 1, 121, 4, 0, 0, 0, 0, }, { 9, 16, 18, 2, 24, 2, 33, 4, 43, 16, 48, 4, 66, 32, 73, 8, 82, 8, 91, 32, 97, 2, 106, 16, 112, 8, 122, 1, 0, 0, }, { 14, 32, 21, 4, 30, 2, 36, 16, 45, 8, 60, 1, 69, 2, 87, 8, 94, 16, 103, 32, 109, 1, 118, 8, 124, 32, 0, 0, 0, 0, }, { 7, 4, 14, 2, 20, 16, 29, 8, 44, 1, 54, 4, 60, 8, 71, 8, 78, 16, 87, 32, 93, 1, 102, 8, 116, 2, 125, 4, 0, 0, }, { 7, 2, 12, 1, 22, 4, 28, 8, 45, 16, 52, 4, 63, 16, 70, 8, 84, 2, 95, 4, 101, 32, 111, 1, 118, 1, 0, 0, 0, 0, }, { 6, 16, 13, 16, 20, 4, 31, 16, 36, 32, 46, 32, 53, 4, 62, 2, 69, 32, 79, 1, 86, 1, 95, 2, 101, 2, 119, 8, 0, 0, }, { 0, 32, 10, 8, 19, 32, 25, 2, 34, 16, 40, 8, 59, 8, 66, 2, 72, 2, 81, 4, 91, 16, 96, 4, 115, 2, 121, 8, 0, 0, }, { 3, 16, 10, 4, 17, 32, 26, 32, 33, 8, 42, 8, 51, 32, 57, 2, 67, 4, 82, 1, 89, 16, 98, 2, 104, 2, 113, 4, 120, 1, }, { 1, 16, 11, 8, 27, 1, 32, 1, 42, 4, 49, 32, 58, 32, 67, 2, 72, 32, 81, 1, 88, 16, 99, 4, 114, 1, 0, 0, 0, 0, }, { 6, 32, 12, 2, 23, 4, 29, 32, 39, 1, 46, 1, 55, 2, 61, 2, 70, 4, 76, 8, 93, 16, 100, 4, 111, 16, 116, 32, 0, 0, }, { 6, 2, 13, 32, 23, 1, 30, 1, 39, 2, 45, 2, 63, 8, 77, 16, 84, 4, 95, 16, 100, 32, 110, 32, 117, 4, 127, 4, 0, 0, }, { 4, 1, 13, 2, 31, 8, 38, 16, 47, 32, 53, 1, 62, 8, 68, 32, 78, 32, 85, 4, 94, 2, 100, 16, 109, 8, 127, 2, 0, 0, }, { 5, 16, 15, 32, 21, 1, 30, 8, 44, 2, 55, 4, 61, 32, 68, 16, 77, 8, 92, 1, 102, 4, 108, 8, 126, 16, 0, 0, 0, 0, }, { 2, 8, 9, 1, 16, 16, 27, 4, 42, 1, 49, 16, 58, 2, 75, 1, 80, 1, 90, 4, 97, 32, 106, 32, 113, 8, 120, 32, 0, 0, }, { 2, 4, 8, 4, 27, 2, 32, 32, 41, 1, 48, 16, 59, 4, 66, 16, 72, 8, 91, 8, 107, 1, 112, 1, 123, 16, 0, 0, 0, 0, }, { 3, 8, 10, 2, 16, 2, 25, 4, 35, 16, 40, 4, 59, 2, 65, 8, 74, 8, 83, 32, 89, 2, 98, 16, 104, 8, 121, 16, 0, 0, }, { 4, 2, 13, 4, 22, 2, 28, 16, 37, 8, 52, 1, 62, 4, 79, 8, 86, 16, 95, 32, 101, 1, 110, 8, 126, 32, 0, 0, 0, 0, }, { 5, 32, 12, 16, 21, 8, 36, 1, 46, 4, 52, 8, 70, 16, 79, 32, 85, 1, 94, 8, 108, 2, 119, 4, 126, 2, 0, 0, 0, 0, }, { 5, 2, 14, 4, 20, 8, 37, 16, 44, 4, 55, 16, 60, 32, 76, 2, 87, 4, 93, 32, 103, 1, 110, 1, 119, 2, 124, 1, 0, 0, }, { 7, 32, 12, 4, 23, 16, 28, 32, 38, 32, 45, 4, 54, 2, 60, 16, 71, 1, 78, 1, 87, 2, 93, 2, 111, 8, 118, 16, 125, 16, }, { 1, 1, 11, 32, 17, 2, 26, 16, 32, 8, 51, 8, 64, 2, 73, 4, 83, 16, 88, 4, 107, 2, 112, 32, 122, 8, 0, 0, 0, 0, }, { 0, 4, 9, 32, 18, 32, 25, 8, 34, 8, 43, 32, 49, 2, 58, 16, 74, 1, 81, 16, 90, 2, 96, 2, 105, 4, 115, 16, 122, 4, }, { 2, 2, 19, 1, 24, 1, 34, 4, 41, 32, 50, 32, 57, 8, 64, 32, 73, 1, 80, 16, 91, 4, 106, 1, 113, 16, 123, 8, 0, 0, }, { 3, 4, 10, 16, 16, 8, 35, 8, 51, 1, 56, 1, 67, 16, 72, 4, 91, 2, 96, 32, 105, 1, 112, 16, 121, 2, 0, 0, 0, 0, }, { 4, 16, 15, 1, 22, 1, 31, 2, 37, 2, 55, 8, 62, 16, 69, 16, 76, 4, 87, 16, 92, 32, 102, 32, 109, 4, 118, 2, 125, 32, }, { 6, 4, 23, 8, 30, 16, 39, 32, 45, 1, 54, 8, 70, 32, 77, 4, 86, 2, 92, 16, 101, 8, 116, 1, 125, 2, 0, 0, 0, 0, }, { 4, 4, 13, 1, 22, 8, 36, 2, 47, 4, 53, 32, 63, 1, 69, 8, 84, 1, 94, 4, 100, 8, 117, 16, 127, 32, 0, 0, 0, 0, }, { 3, 32, 8, 16, 19, 4, 34, 1, 41, 16, 50, 2, 56, 2, 67, 1, 72, 1, 82, 4, 89, 32, 98, 32, 105, 8, 114, 8, 121, 1, }, { 1, 32, 19, 2, 24, 32, 33, 1, 40, 16, 51, 4, 64, 8, 83, 8, 99, 1, 104, 1, 114, 4, 120, 4, 0, 0, 0, 0, 0, 0, }, { 8, 2, 17, 4, 27, 16, 32, 4, 51, 2, 56, 32, 66, 8, 75, 32, 81, 2, 90, 16, 96, 8, 115, 8, 122, 2, 0, 0, 0, 0, }, { 2, 16, 18, 1, 25, 16, 34, 2, 40, 2, 49, 4, 59, 16, 66, 4, 73, 32, 82, 32, 89, 8, 98, 8, 107, 32, 113, 2, 123, 4, }, { 7, 1, 13, 8, 28, 1, 38, 4, 44, 8, 61, 16, 71, 32, 77, 1, 86, 8, 100, 2, 111, 4, 117, 32, 124, 16, 0, 0, 0, 0, }, { 12, 8, 29, 16, 36, 4, 47, 16, 52, 32, 62, 32, 68, 2, 79, 4, 85, 32, 95, 1, 102, 1, 111, 2, 117, 2, 126, 4, 0, 0, }, { 5, 1, 15, 16, 20, 32, 30, 32, 37, 4, 46, 2, 52, 16, 61, 8, 70, 1, 79, 2, 85, 2, 103, 8, 110, 16, 119, 32, 124, 4, }, { 0, 16, 9, 2, 18, 16, 24, 8, 43, 8, 59, 1, 65, 4, 75, 16, 80, 4, 99, 2, 104, 32, 113, 1, 123, 32, 0, 0, 0, 0, }, { 10, 32, 17, 8, 26, 8, 35, 32, 41, 2, 50, 16, 56, 8, 66, 1, 73, 16, 82, 2, 88, 2, 97, 4, 107, 16, 112, 4, 121, 32, }, { 0, 2, 11, 1, 16, 1, 26, 4, 33, 32, 42, 32, 49, 8, 58, 8, 65, 1, 72, 16, 83, 4, 98, 1, 105, 16, 114, 2, 0, 0, }, { 8, 8, 27, 8, 43, 1, 48, 1, 58, 4, 64, 4, 83, 2, 88, 32, 97, 1, 104, 16, 115, 4, 122, 16, 0, 0, 0, 0, 0, 0, }, { 5, 8, 14, 1, 23, 2, 29, 2, 47, 8, 54, 16, 63, 32, 68, 4, 79, 16, 84, 32, 94, 32, 101, 4, 110, 2, 116, 16, 127, 1, }, { 4, 8, 15, 8, 22, 16, 31, 32, 37, 1, 46, 8, 60, 2, 69, 4, 78, 2, 84, 16, 93, 8, 108, 1, 118, 4, 0, 0, 0, 0, }, { 7, 16, 14, 8, 28, 2, 39, 4, 45, 32, 55, 1, 62, 1, 76, 1, 86, 4, 92, 8, 109, 16, 116, 4, 125, 1, 0, 0, 0, 0, }, { 1, 2, 11, 4, 26, 1, 33, 16, 42, 2, 48, 2, 57, 4, 64, 1, 74, 4, 81, 32, 90, 32, 97, 8, 106, 8, 115, 32, 120, 16, }, { 2, 32, 11, 2, 16, 32, 25, 1, 32, 16, 43, 4, 58, 1, 75, 8, 91, 1, 96, 1, 106, 4, 113, 32, 0, 0, 0, 0, 0, 0, }, { 3, 1, 9, 4, 19, 16, 24, 4, 43, 2, 48, 32, 57, 1, 67, 32, 73, 2, 82, 16, 88, 8, 107, 8, 120, 2, 0, 0, 0, 0, }, { 0, 8, 10, 1, 17, 16, 26, 2, 32, 2, 41, 4, 51, 16, 56, 4, 65, 32, 74, 32, 81, 8, 90, 8, 99, 32, 105, 2, 114, 16, }, { 6, 1, 20, 1, 30, 4, 36, 8, 53, 16, 60, 4, 69, 1, 78, 8, 92, 2, 103, 4, 109, 32, 119, 1, 125, 8, 0, 0, 0, 0, }, { 7, 8, 21, 16, 28, 4, 39, 16, 44, 32, 54, 32, 61, 4, 71, 4, 77, 32, 87, 1, 94, 1, 103, 2, 109, 2, 124, 8, 0, 0, }, { 6, 8, 12, 32, 22, 32, 29, 4, 38, 2, 44, 16, 53, 8, 71, 2, 77, 2, 95, 8, 102, 16, 111, 32, 117, 1, 127, 16, 0, 0, } }; static void key_setup(char key[DESKEYLEN], char *ek) { int i, j, k, mask; const uchar (*x)[2]; memset(ek, 0, 128); x = keyexpand[0]; for(i = 0; i < 7; i++){ k = key[i]; for(mask = 0x80; mask; mask >>= 1){ if(k & mask) for(j = 0; j < 15; j++) ek[x[j][0]] |= x[j][1]; x += 15; } } } /************ netkey main.c *************/ int passtokey(char *key, const char *p) { uchar buf[NAMELEN], *t; int i, n; n = strlen(p); if(n >= NAMELEN) n = NAMELEN-1; memset(buf, ' ', 8); t = buf; strncpy((char*)t, p, n); t[n] = '\0'; memset(key, 0, DESKEYLEN); for(;;){ for(i = 0; i < DESKEYLEN; i++) key[i] = (t[i] >> i) + (t[i+1] << (8 - (i+1))); if(n <= 8) return 1; n -= 8; t += 8; if(n < 8){ t -= 8 - n; n = 8; } encrypt9(key, t, 8); } return 1; /* not reached */ } int netcrypt(void *key, void *chal) { uchar buf[8], *p; strncpy((char*)buf, chal, 7); buf[7] = '\0'; for(p = buf; *p && *p != '\n'; p++) ; *p = '\0'; encrypt9(key, buf, 8); sprintf(chal, "%.2x%.2x%.2x%.2x", buf[0], buf[1], buf[2], buf[3]); return 1; } char * calculate_netkey_response( const char* pass, const char* challenge ) { char key[DESKEYLEN]; static char response[32]; passtokey( key, pass ); strcpy( response, challenge ); netcrypt( key, response ); return response; } lftp-4.6.3a/src/IdNameCache.cc0000644000015000007670000001014212246113705012731 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include "IdNameCache.h" void IdNameCache::init() { memset(table_id,0,sizeof(table_id)); memset(table_name,0,sizeof(table_name)); } void IdNameCache::free_list(IdNamePair *list) { while(list) { IdNamePair *next=list->next; delete list; list=next; } } void IdNameCache::free() { for(int i=0; inext=p[h]; p[h]=r; } IdNamePair *IdNameCache::lookup(int id) { unsigned h=hash(id); for(IdNamePair *scan=table_id[h]; scan; scan=scan->next) if(id==scan->id) return scan; IdNamePair *r=get_record(id); if(!r) r=new IdNamePair(id,0); add(h,table_id,r); if(r->name) add(hash(r->name),table_name,new IdNamePair(r)); return r; } IdNamePair *IdNameCache::lookup(const char *name) { unsigned h=hash(name); for(IdNamePair *scan=table_name[h]; scan; scan=scan->next) if(!xstrcmp(name,scan->name)) return scan; IdNamePair *r=get_record(name); if(!r) r=new IdNamePair(-1,name); add(h,table_name,r); if(r->id!=-1) add(hash(r->id),table_id,new IdNamePair(r)); return r; } const char *IdNameCache::Lookup(int id) { const char *name=lookup(id)->name; if(name && name[0]) return name; static char buf[32]; snprintf(buf,sizeof(buf),"%d",id); return buf; } int IdNameCache::Lookup(const char *name) { return lookup(name)->id; } IdNameCache::IdNameCache() { init(); } IdNameCache::~IdNameCache() { free(); } int IdNameCache::Do() { if(expire_timer && expire_timer->Stopped()) Delete(this); return STALL; } unsigned IdNameCache::hash(int id) { return unsigned(id)%table_size; } unsigned IdNameCache::hash(const char *name) { unsigned h=0; while(*name) h+=(h<<4)+*name++; return h%table_size; } IdNamePair *PasswdCache::get_record(int id) { struct passwd *p=getpwuid(id); if(!p) return 0; return new IdNamePair(p->pw_uid,p->pw_name); } IdNamePair *GroupCache::get_record(int id) { struct group *p=getgrgid(id); if(!p) return 0; return new IdNamePair(p->gr_gid,p->gr_name); } IdNamePair *IdNameCache::get_record(const char *name) { int id,n; if(sscanf(name,"%d%n",&id,&n)==1 && !name[n]) return new IdNamePair(id,name); return 0; } IdNamePair *PasswdCache::get_record(const char *name) { struct passwd *p=getpwnam(name); if(p) return new IdNamePair(p->pw_uid,name); return IdNameCache::get_record(name); } IdNamePair *GroupCache::get_record(const char *name) { struct group *p=getgrnam(name); if(p) return new IdNamePair(p->gr_gid,name); return IdNameCache::get_record(name); } PasswdCache *PasswdCache::instance; GroupCache *GroupCache::instance; PasswdCache *PasswdCache::GetInstance() { if(instance) return instance; instance=new PasswdCache(); instance->SetExpireTimer(new Timer(30)); return instance; } GroupCache *GroupCache::GetInstance() { if(instance) return instance; instance=new GroupCache(); instance->SetExpireTimer(new Timer(30)); return instance; } PasswdCache::~PasswdCache() { if(this==instance) instance=0; } GroupCache::~GroupCache() { if(this==instance) instance=0; } lftp-4.6.3a/src/FtpListInfo.h0000644000015000007670000000213312122057737012721 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FTPLISTINFO_H #define FTPLISTINFO_H #include "NetAccess.h" class FtpListInfo : public GenericParseListInfo { FileSet *ParseShortList(const char *buf,int len); public: virtual FileSet *Parse(const char *buf,int len); FtpListInfo(FileAccess *session,const char *path) : GenericParseListInfo(session,path) {} }; #endif//FTPLISTINFO_H lftp-4.6.3a/src/FtpDirList.h0000644000015000007670000000240212122057715012537 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FTPDIRLIST_H #define FTPDIRLIST_H class FtpDirList : public DirList { SMTaskRef ubuf; xstring_ca pattern; bool TryEPLF(const char *line,int len); bool TryMLSD(const char *line,int len); bool TryColor(const char *line,int len); void FormatGeneric(class FileInfo *); public: FtpDirList(FileAccess *s,ArgV *a) : DirList(s,a), pattern(args->Combine(1)) {} const char *Status(); int Do(); void SuspendInternal(); void ResumeInternal(); }; #endif//FTPDIRLIST_H lftp-4.6.3a/src/import-netscape0000755000015000007670000000153112122054516013400 00000000000000#!/bin/sh # This script is based on draft by Sam Steingold # Copyright (c) 1998 by Alexander V. Lukyanov # This script can be distributed and modified freely under GNU GPL, see COPYING set -e NS="$HOME/.netscape/bookmarks.html" OLD="${LFTP_HOME:-$HOME/.lftp}/bookmarks" NEW="$OLD.new.$$" prepend_hash() { n=$$ while read line; do u=`echo $line | sed -e 's|\(ftp://[^:]*\):[^@]*@|\1|'` t=`expr "$u" : "ftp://\([^.]*\)"` if [ "$t" = ftp -o -z "$t" ]; then t=`expr "$u" : "ftp://[^.]*.\([^.]*\)"` if [ "$t" = ftp -o -z "$t" ]; then t="$n" n=`expr $n + 1` fi fi echo "NS-$t $line" done } grep ftp:// "$NS" | cut "-d\"" -f2 | prepend_hash > "$NEW" if [ -f "$OLD" ]; then sort -u "$OLD" "$NEW" -o "$NEW" mv -f "$OLD" "$OLD~" # backup else sort -u "$NEW" -o "$NEW" fi mv -f "$NEW" "$OLD" lftp-4.6.3a/src/convert-mozilla-cookies0000755000015000007670000000336212122054516015051 00000000000000#!/usr/bin/perl # Copyright (c) 2001,2005,2007,2010 Alexander V. Lukyanov # See COPYING file (GNU GPL) for complete license. # This script converts mozilla-style cookies to lftp set commands. use strict; use DBI; my $file=$ARGV[0] if defined $ARGV[0]; $file=qx{ ls -t \$HOME/.netscape/cookies \\ `find \$HOME/.mozilla -name cookies.txt -or -name cookies.sqlite` | head -1 },chomp $file if !defined $file; print "# converted from $file\n"; my %cookie; sub add_cookie($$$$$) { my ($domain,$path,$secure_bool,$name,$value)=@_; for($domain,$path,$name,$value) { s/"/\\"/g; s/'/\\'/g; s/ /%20/g; } my $secure=''; $secure=';secure' if $secure_bool eq 'TRUE' || $secure_bool eq '1'; $domain="*$domain" if $domain =~ /^\./; $path='' if $path eq '/'; $path=";path=$path" if $path ne ''; $value="=$value" if $name ne ''; $cookie{"$domain$path$secure"}.=" $name$value"; } if($file=~/\.sqlite$/) { my $file1="$file.$$.tmp"; $SIG{__DIE__}=sub { unlink $file1 }; system('cp',$file,$file1); my $dbh=DBI->connect("dbi:SQLite:dbname=$file1",'',''); unlink $file1; my $q=$dbh->prepare("select host,path,isSecure,name,value from moz_cookies"); $q->execute; $q->bind_columns(\my($domain,$path,$secure_bool,$name,$value)); while($q->fetch) { add_cookie($domain,$path,$secure_bool,$name,$value); } } else { open COOKIES,'<',$file or die "open($file): $!"; while() { chomp; next if /^#/ or /^$/; my ($domain,undef,$path,$secure_bool,$expires,$name,$value)=split /\t/; add_cookie($domain,$path,$secure_bool,$name,$value); } } foreach(sort keys %cookie) { $cookie{$_}=~s/^ //; my $c=($_=~/;/?qq{"$_"}:$_); print qq{set http:cookie/$c "$cookie{$_}"\n}; } lftp-4.6.3a/src/ftp-opie.c0000644000015000007670000016450712122057743012251 00000000000000/* Opie (s/key) support for FTP. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GNU Wget. GNU Wget 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. GNU Wget 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 Wget. If not, see . Additional permission under GNU GPL version 3 section 7 If you modify this program, or any covered work, by linking or combining it with the OpenSSL project's OpenSSL library (or a modified version of that library), containing parts covered by the terms of the OpenSSL or SSLeay licenses, the Free Software Foundation grants you additional permission to convey the resulting work. Corresponding Source for a non-source form of such a combination shall include the source code for the parts of OpenSSL used as well as that of the covered work. */ #include #include #include #include #include "md5.h" /* Dictionary for integer-word translations. Available in appendix D of rfc2289. */ static char Wp[2048][4] = { { 'A', '\0', '\0', '\0' }, { 'A', 'B', 'E', '\0' }, { 'A', 'C', 'E', '\0' }, { 'A', 'C', 'T', '\0' }, { 'A', 'D', '\0', '\0' }, { 'A', 'D', 'A', '\0' }, { 'A', 'D', 'D', '\0' }, { 'A', 'G', 'O', '\0' }, { 'A', 'I', 'D', '\0' }, { 'A', 'I', 'M', '\0' }, { 'A', 'I', 'R', '\0' }, { 'A', 'L', 'L', '\0' }, { 'A', 'L', 'P', '\0' }, { 'A', 'M', '\0', '\0' }, { 'A', 'M', 'Y', '\0' }, { 'A', 'N', '\0', '\0' }, { 'A', 'N', 'A', '\0' }, { 'A', 'N', 'D', '\0' }, { 'A', 'N', 'N', '\0' }, { 'A', 'N', 'T', '\0' }, { 'A', 'N', 'Y', '\0' }, { 'A', 'P', 'E', '\0' }, { 'A', 'P', 'S', '\0' }, { 'A', 'P', 'T', '\0' }, { 'A', 'R', 'C', '\0' }, { 'A', 'R', 'E', '\0' }, { 'A', 'R', 'K', '\0' }, { 'A', 'R', 'M', '\0' }, { 'A', 'R', 'T', '\0' }, { 'A', 'S', '\0', '\0' }, { 'A', 'S', 'H', '\0' }, { 'A', 'S', 'K', '\0' }, { 'A', 'T', '\0', '\0' }, { 'A', 'T', 'E', '\0' }, { 'A', 'U', 'G', '\0' }, { 'A', 'U', 'K', '\0' }, { 'A', 'V', 'E', '\0' }, { 'A', 'W', 'E', '\0' }, { 'A', 'W', 'K', '\0' }, { 'A', 'W', 'L', '\0' }, { 'A', 'W', 'N', '\0' }, { 'A', 'X', '\0', '\0' }, { 'A', 'Y', 'E', '\0' }, { 'B', 'A', 'D', '\0' }, { 'B', 'A', 'G', '\0' }, { 'B', 'A', 'H', '\0' }, { 'B', 'A', 'M', '\0' }, { 'B', 'A', 'N', '\0' }, { 'B', 'A', 'R', '\0' }, { 'B', 'A', 'T', '\0' }, { 'B', 'A', 'Y', '\0' }, { 'B', 'E', '\0', '\0' }, { 'B', 'E', 'D', '\0' }, { 'B', 'E', 'E', '\0' }, { 'B', 'E', 'G', '\0' }, { 'B', 'E', 'N', '\0' }, { 'B', 'E', 'T', '\0' }, { 'B', 'E', 'Y', '\0' }, { 'B', 'I', 'B', '\0' }, { 'B', 'I', 'D', '\0' }, { 'B', 'I', 'G', '\0' }, { 'B', 'I', 'N', '\0' }, { 'B', 'I', 'T', '\0' }, { 'B', 'O', 'B', '\0' }, { 'B', 'O', 'G', '\0' }, { 'B', 'O', 'N', '\0' }, { 'B', 'O', 'O', '\0' }, { 'B', 'O', 'P', '\0' }, { 'B', 'O', 'W', '\0' }, { 'B', 'O', 'Y', '\0' }, { 'B', 'U', 'B', '\0' }, { 'B', 'U', 'D', '\0' }, { 'B', 'U', 'G', '\0' }, { 'B', 'U', 'M', '\0' }, { 'B', 'U', 'N', '\0' }, { 'B', 'U', 'S', '\0' }, { 'B', 'U', 'T', '\0' }, { 'B', 'U', 'Y', '\0' }, { 'B', 'Y', '\0', '\0' }, { 'B', 'Y', 'E', '\0' }, { 'C', 'A', 'B', '\0' }, { 'C', 'A', 'L', '\0' }, { 'C', 'A', 'M', '\0' }, { 'C', 'A', 'N', '\0' }, { 'C', 'A', 'P', '\0' }, { 'C', 'A', 'R', '\0' }, { 'C', 'A', 'T', '\0' }, { 'C', 'A', 'W', '\0' }, { 'C', 'O', 'D', '\0' }, { 'C', 'O', 'G', '\0' }, { 'C', 'O', 'L', '\0' }, { 'C', 'O', 'N', '\0' }, { 'C', 'O', 'O', '\0' }, { 'C', 'O', 'P', '\0' }, { 'C', 'O', 'T', '\0' }, { 'C', 'O', 'W', '\0' }, { 'C', 'O', 'Y', '\0' }, { 'C', 'R', 'Y', '\0' }, { 'C', 'U', 'B', '\0' }, { 'C', 'U', 'E', '\0' }, { 'C', 'U', 'P', '\0' }, { 'C', 'U', 'R', '\0' }, { 'C', 'U', 'T', '\0' }, { 'D', 'A', 'B', '\0' }, { 'D', 'A', 'D', '\0' }, { 'D', 'A', 'M', '\0' }, { 'D', 'A', 'N', '\0' }, { 'D', 'A', 'R', '\0' }, { 'D', 'A', 'Y', '\0' }, { 'D', 'E', 'E', '\0' }, { 'D', 'E', 'L', '\0' }, { 'D', 'E', 'N', '\0' }, { 'D', 'E', 'S', '\0' }, { 'D', 'E', 'W', '\0' }, { 'D', 'I', 'D', '\0' }, { 'D', 'I', 'E', '\0' }, { 'D', 'I', 'G', '\0' }, { 'D', 'I', 'N', '\0' }, { 'D', 'I', 'P', '\0' }, { 'D', 'O', '\0', '\0' }, { 'D', 'O', 'E', '\0' }, { 'D', 'O', 'G', '\0' }, { 'D', 'O', 'N', '\0' }, { 'D', 'O', 'T', '\0' }, { 'D', 'O', 'W', '\0' }, { 'D', 'R', 'Y', '\0' }, { 'D', 'U', 'B', '\0' }, { 'D', 'U', 'D', '\0' }, { 'D', 'U', 'E', '\0' }, { 'D', 'U', 'G', '\0' }, { 'D', 'U', 'N', '\0' }, { 'E', 'A', 'R', '\0' }, { 'E', 'A', 'T', '\0' }, { 'E', 'D', '\0', '\0' }, { 'E', 'E', 'L', '\0' }, { 'E', 'G', 'G', '\0' }, { 'E', 'G', 'O', '\0' }, { 'E', 'L', 'I', '\0' }, { 'E', 'L', 'K', '\0' }, { 'E', 'L', 'M', '\0' }, { 'E', 'L', 'Y', '\0' }, { 'E', 'M', '\0', '\0' }, { 'E', 'N', 'D', '\0' }, { 'E', 'S', 'T', '\0' }, { 'E', 'T', 'C', '\0' }, { 'E', 'V', 'A', '\0' }, { 'E', 'V', 'E', '\0' }, { 'E', 'W', 'E', '\0' }, { 'E', 'Y', 'E', '\0' }, { 'F', 'A', 'D', '\0' }, { 'F', 'A', 'N', '\0' }, { 'F', 'A', 'R', '\0' }, { 'F', 'A', 'T', '\0' }, { 'F', 'A', 'Y', '\0' }, { 'F', 'E', 'D', '\0' }, { 'F', 'E', 'E', '\0' }, { 'F', 'E', 'W', '\0' }, { 'F', 'I', 'B', '\0' }, { 'F', 'I', 'G', '\0' }, { 'F', 'I', 'N', '\0' }, { 'F', 'I', 'R', '\0' }, { 'F', 'I', 'T', '\0' }, { 'F', 'L', 'O', '\0' }, { 'F', 'L', 'Y', '\0' }, { 'F', 'O', 'E', '\0' }, { 'F', 'O', 'G', '\0' }, { 'F', 'O', 'R', '\0' }, { 'F', 'R', 'Y', '\0' }, { 'F', 'U', 'M', '\0' }, { 'F', 'U', 'N', '\0' }, { 'F', 'U', 'R', '\0' }, { 'G', 'A', 'B', '\0' }, { 'G', 'A', 'D', '\0' }, { 'G', 'A', 'G', '\0' }, { 'G', 'A', 'L', '\0' }, { 'G', 'A', 'M', '\0' }, { 'G', 'A', 'P', '\0' }, { 'G', 'A', 'S', '\0' }, { 'G', 'A', 'Y', '\0' }, { 'G', 'E', 'E', '\0' }, { 'G', 'E', 'L', '\0' }, { 'G', 'E', 'M', '\0' }, { 'G', 'E', 'T', '\0' }, { 'G', 'I', 'G', '\0' }, { 'G', 'I', 'L', '\0' }, { 'G', 'I', 'N', '\0' }, { 'G', 'O', '\0', '\0' }, { 'G', 'O', 'T', '\0' }, { 'G', 'U', 'M', '\0' }, { 'G', 'U', 'N', '\0' }, { 'G', 'U', 'S', '\0' }, { 'G', 'U', 'T', '\0' }, { 'G', 'U', 'Y', '\0' }, { 'G', 'Y', 'M', '\0' }, { 'G', 'Y', 'P', '\0' }, { 'H', 'A', '\0', '\0' }, { 'H', 'A', 'D', '\0' }, { 'H', 'A', 'L', '\0' }, { 'H', 'A', 'M', '\0' }, { 'H', 'A', 'N', '\0' }, { 'H', 'A', 'P', '\0' }, { 'H', 'A', 'S', '\0' }, { 'H', 'A', 'T', '\0' }, { 'H', 'A', 'W', '\0' }, { 'H', 'A', 'Y', '\0' }, { 'H', 'E', '\0', '\0' }, { 'H', 'E', 'M', '\0' }, { 'H', 'E', 'N', '\0' }, { 'H', 'E', 'R', '\0' }, { 'H', 'E', 'W', '\0' }, { 'H', 'E', 'Y', '\0' }, { 'H', 'I', '\0', '\0' }, { 'H', 'I', 'D', '\0' }, { 'H', 'I', 'M', '\0' }, { 'H', 'I', 'P', '\0' }, { 'H', 'I', 'S', '\0' }, { 'H', 'I', 'T', '\0' }, { 'H', 'O', '\0', '\0' }, { 'H', 'O', 'B', '\0' }, { 'H', 'O', 'C', '\0' }, { 'H', 'O', 'E', '\0' }, { 'H', 'O', 'G', '\0' }, { 'H', 'O', 'P', '\0' }, { 'H', 'O', 'T', '\0' }, { 'H', 'O', 'W', '\0' }, { 'H', 'U', 'B', '\0' }, { 'H', 'U', 'E', '\0' }, { 'H', 'U', 'G', '\0' }, { 'H', 'U', 'H', '\0' }, { 'H', 'U', 'M', '\0' }, { 'H', 'U', 'T', '\0' }, { 'I', '\0', '\0', '\0' }, { 'I', 'C', 'Y', '\0' }, { 'I', 'D', 'A', '\0' }, { 'I', 'F', '\0', '\0' }, { 'I', 'K', 'E', '\0' }, { 'I', 'L', 'L', '\0' }, { 'I', 'N', 'K', '\0' }, { 'I', 'N', 'N', '\0' }, { 'I', 'O', '\0', '\0' }, { 'I', 'O', 'N', '\0' }, { 'I', 'Q', '\0', '\0' }, { 'I', 'R', 'A', '\0' }, { 'I', 'R', 'E', '\0' }, { 'I', 'R', 'K', '\0' }, { 'I', 'S', '\0', '\0' }, { 'I', 'T', '\0', '\0' }, { 'I', 'T', 'S', '\0' }, { 'I', 'V', 'Y', '\0' }, { 'J', 'A', 'B', '\0' }, { 'J', 'A', 'G', '\0' }, { 'J', 'A', 'M', '\0' }, { 'J', 'A', 'N', '\0' }, { 'J', 'A', 'R', '\0' }, { 'J', 'A', 'W', '\0' }, { 'J', 'A', 'Y', '\0' }, { 'J', 'E', 'T', '\0' }, { 'J', 'I', 'G', '\0' }, { 'J', 'I', 'M', '\0' }, { 'J', 'O', '\0', '\0' }, { 'J', 'O', 'B', '\0' }, { 'J', 'O', 'E', '\0' }, { 'J', 'O', 'G', '\0' }, { 'J', 'O', 'T', '\0' }, { 'J', 'O', 'Y', '\0' }, { 'J', 'U', 'G', '\0' }, { 'J', 'U', 'T', '\0' }, { 'K', 'A', 'Y', '\0' }, { 'K', 'E', 'G', '\0' }, { 'K', 'E', 'N', '\0' }, { 'K', 'E', 'Y', '\0' }, { 'K', 'I', 'D', '\0' }, { 'K', 'I', 'M', '\0' }, { 'K', 'I', 'N', '\0' }, { 'K', 'I', 'T', '\0' }, { 'L', 'A', '\0', '\0' }, { 'L', 'A', 'B', '\0' }, { 'L', 'A', 'C', '\0' }, { 'L', 'A', 'D', '\0' }, { 'L', 'A', 'G', '\0' }, { 'L', 'A', 'M', '\0' }, { 'L', 'A', 'P', '\0' }, { 'L', 'A', 'W', '\0' }, { 'L', 'A', 'Y', '\0' }, { 'L', 'E', 'A', '\0' }, { 'L', 'E', 'D', '\0' }, { 'L', 'E', 'E', '\0' }, { 'L', 'E', 'G', '\0' }, { 'L', 'E', 'N', '\0' }, { 'L', 'E', 'O', '\0' }, { 'L', 'E', 'T', '\0' }, { 'L', 'E', 'W', '\0' }, { 'L', 'I', 'D', '\0' }, { 'L', 'I', 'E', '\0' }, { 'L', 'I', 'N', '\0' }, { 'L', 'I', 'P', '\0' }, { 'L', 'I', 'T', '\0' }, { 'L', 'O', '\0', '\0' }, { 'L', 'O', 'B', '\0' }, { 'L', 'O', 'G', '\0' }, { 'L', 'O', 'P', '\0' }, { 'L', 'O', 'S', '\0' }, { 'L', 'O', 'T', '\0' }, { 'L', 'O', 'U', '\0' }, { 'L', 'O', 'W', '\0' }, { 'L', 'O', 'Y', '\0' }, { 'L', 'U', 'G', '\0' }, { 'L', 'Y', 'E', '\0' }, { 'M', 'A', '\0', '\0' }, { 'M', 'A', 'C', '\0' }, { 'M', 'A', 'D', '\0' }, { 'M', 'A', 'E', '\0' }, { 'M', 'A', 'N', '\0' }, { 'M', 'A', 'O', '\0' }, { 'M', 'A', 'P', '\0' }, { 'M', 'A', 'T', '\0' }, { 'M', 'A', 'W', '\0' }, { 'M', 'A', 'Y', '\0' }, { 'M', 'E', '\0', '\0' }, { 'M', 'E', 'G', '\0' }, { 'M', 'E', 'L', '\0' }, { 'M', 'E', 'N', '\0' }, { 'M', 'E', 'T', '\0' }, { 'M', 'E', 'W', '\0' }, { 'M', 'I', 'D', '\0' }, { 'M', 'I', 'N', '\0' }, { 'M', 'I', 'T', '\0' }, { 'M', 'O', 'B', '\0' }, { 'M', 'O', 'D', '\0' }, { 'M', 'O', 'E', '\0' }, { 'M', 'O', 'O', '\0' }, { 'M', 'O', 'P', '\0' }, { 'M', 'O', 'S', '\0' }, { 'M', 'O', 'T', '\0' }, { 'M', 'O', 'W', '\0' }, { 'M', 'U', 'D', '\0' }, { 'M', 'U', 'G', '\0' }, { 'M', 'U', 'M', '\0' }, { 'M', 'Y', '\0', '\0' }, { 'N', 'A', 'B', '\0' }, { 'N', 'A', 'G', '\0' }, { 'N', 'A', 'N', '\0' }, { 'N', 'A', 'P', '\0' }, { 'N', 'A', 'T', '\0' }, { 'N', 'A', 'Y', '\0' }, { 'N', 'E', '\0', '\0' }, { 'N', 'E', 'D', '\0' }, { 'N', 'E', 'E', '\0' }, { 'N', 'E', 'T', '\0' }, { 'N', 'E', 'W', '\0' }, { 'N', 'I', 'B', '\0' }, { 'N', 'I', 'L', '\0' }, { 'N', 'I', 'P', '\0' }, { 'N', 'I', 'T', '\0' }, { 'N', 'O', '\0', '\0' }, { 'N', 'O', 'B', '\0' }, { 'N', 'O', 'D', '\0' }, { 'N', 'O', 'N', '\0' }, { 'N', 'O', 'R', '\0' }, { 'N', 'O', 'T', '\0' }, { 'N', 'O', 'V', '\0' }, { 'N', 'O', 'W', '\0' }, { 'N', 'U', '\0', '\0' }, { 'N', 'U', 'N', '\0' }, { 'N', 'U', 'T', '\0' }, { 'O', '\0', '\0', '\0' }, { 'O', 'A', 'F', '\0' }, { 'O', 'A', 'K', '\0' }, { 'O', 'A', 'R', '\0' }, { 'O', 'A', 'T', '\0' }, { 'O', 'D', 'D', '\0' }, { 'O', 'D', 'E', '\0' }, { 'O', 'F', '\0', '\0' }, { 'O', 'F', 'F', '\0' }, { 'O', 'F', 'T', '\0' }, { 'O', 'H', '\0', '\0' }, { 'O', 'I', 'L', '\0' }, { 'O', 'K', '\0', '\0' }, { 'O', 'L', 'D', '\0' }, { 'O', 'N', '\0', '\0' }, { 'O', 'N', 'E', '\0' }, { 'O', 'R', '\0', '\0' }, { 'O', 'R', 'B', '\0' }, { 'O', 'R', 'E', '\0' }, { 'O', 'R', 'R', '\0' }, { 'O', 'S', '\0', '\0' }, { 'O', 'T', 'T', '\0' }, { 'O', 'U', 'R', '\0' }, { 'O', 'U', 'T', '\0' }, { 'O', 'V', 'A', '\0' }, { 'O', 'W', '\0', '\0' }, { 'O', 'W', 'E', '\0' }, { 'O', 'W', 'L', '\0' }, { 'O', 'W', 'N', '\0' }, { 'O', 'X', '\0', '\0' }, { 'P', 'A', '\0', '\0' }, { 'P', 'A', 'D', '\0' }, { 'P', 'A', 'L', '\0' }, { 'P', 'A', 'M', '\0' }, { 'P', 'A', 'N', '\0' }, { 'P', 'A', 'P', '\0' }, { 'P', 'A', 'R', '\0' }, { 'P', 'A', 'T', '\0' }, { 'P', 'A', 'W', '\0' }, { 'P', 'A', 'Y', '\0' }, { 'P', 'E', 'A', '\0' }, { 'P', 'E', 'G', '\0' }, { 'P', 'E', 'N', '\0' }, { 'P', 'E', 'P', '\0' }, { 'P', 'E', 'R', '\0' }, { 'P', 'E', 'T', '\0' }, { 'P', 'E', 'W', '\0' }, { 'P', 'H', 'I', '\0' }, { 'P', 'I', '\0', '\0' }, { 'P', 'I', 'E', '\0' }, { 'P', 'I', 'N', '\0' }, { 'P', 'I', 'T', '\0' }, { 'P', 'L', 'Y', '\0' }, { 'P', 'O', '\0', '\0' }, { 'P', 'O', 'D', '\0' }, { 'P', 'O', 'E', '\0' }, { 'P', 'O', 'P', '\0' }, { 'P', 'O', 'T', '\0' }, { 'P', 'O', 'W', '\0' }, { 'P', 'R', 'O', '\0' }, { 'P', 'R', 'Y', '\0' }, { 'P', 'U', 'B', '\0' }, { 'P', 'U', 'G', '\0' }, { 'P', 'U', 'N', '\0' }, { 'P', 'U', 'P', '\0' }, { 'P', 'U', 'T', '\0' }, { 'Q', 'U', 'O', '\0' }, { 'R', 'A', 'G', '\0' }, { 'R', 'A', 'M', '\0' }, { 'R', 'A', 'N', '\0' }, { 'R', 'A', 'P', '\0' }, { 'R', 'A', 'T', '\0' }, { 'R', 'A', 'W', '\0' }, { 'R', 'A', 'Y', '\0' }, { 'R', 'E', 'B', '\0' }, { 'R', 'E', 'D', '\0' }, { 'R', 'E', 'P', '\0' }, { 'R', 'E', 'T', '\0' }, { 'R', 'I', 'B', '\0' }, { 'R', 'I', 'D', '\0' }, { 'R', 'I', 'G', '\0' }, { 'R', 'I', 'M', '\0' }, { 'R', 'I', 'O', '\0' }, { 'R', 'I', 'P', '\0' }, { 'R', 'O', 'B', '\0' }, { 'R', 'O', 'D', '\0' }, { 'R', 'O', 'E', '\0' }, { 'R', 'O', 'N', '\0' }, { 'R', 'O', 'T', '\0' }, { 'R', 'O', 'W', '\0' }, { 'R', 'O', 'Y', '\0' }, { 'R', 'U', 'B', '\0' }, { 'R', 'U', 'E', '\0' }, { 'R', 'U', 'G', '\0' }, { 'R', 'U', 'M', '\0' }, { 'R', 'U', 'N', '\0' }, { 'R', 'Y', 'E', '\0' }, { 'S', 'A', 'C', '\0' }, { 'S', 'A', 'D', '\0' }, { 'S', 'A', 'G', '\0' }, { 'S', 'A', 'L', '\0' }, { 'S', 'A', 'M', '\0' }, { 'S', 'A', 'N', '\0' }, { 'S', 'A', 'P', '\0' }, { 'S', 'A', 'T', '\0' }, { 'S', 'A', 'W', '\0' }, { 'S', 'A', 'Y', '\0' }, { 'S', 'E', 'A', '\0' }, { 'S', 'E', 'C', '\0' }, { 'S', 'E', 'E', '\0' }, { 'S', 'E', 'N', '\0' }, { 'S', 'E', 'T', '\0' }, { 'S', 'E', 'W', '\0' }, { 'S', 'H', 'E', '\0' }, { 'S', 'H', 'Y', '\0' }, { 'S', 'I', 'N', '\0' }, { 'S', 'I', 'P', '\0' }, { 'S', 'I', 'R', '\0' }, { 'S', 'I', 'S', '\0' }, { 'S', 'I', 'T', '\0' }, { 'S', 'K', 'I', '\0' }, { 'S', 'K', 'Y', '\0' }, { 'S', 'L', 'Y', '\0' }, { 'S', 'O', '\0', '\0' }, { 'S', 'O', 'B', '\0' }, { 'S', 'O', 'D', '\0' }, { 'S', 'O', 'N', '\0' }, { 'S', 'O', 'P', '\0' }, { 'S', 'O', 'W', '\0' }, { 'S', 'O', 'Y', '\0' }, { 'S', 'P', 'A', '\0' }, { 'S', 'P', 'Y', '\0' }, { 'S', 'U', 'B', '\0' }, { 'S', 'U', 'D', '\0' }, { 'S', 'U', 'E', '\0' }, { 'S', 'U', 'M', '\0' }, { 'S', 'U', 'N', '\0' }, { 'S', 'U', 'P', '\0' }, { 'T', 'A', 'B', '\0' }, { 'T', 'A', 'D', '\0' }, { 'T', 'A', 'G', '\0' }, { 'T', 'A', 'N', '\0' }, { 'T', 'A', 'P', '\0' }, { 'T', 'A', 'R', '\0' }, { 'T', 'E', 'A', '\0' }, { 'T', 'E', 'D', '\0' }, { 'T', 'E', 'E', '\0' }, { 'T', 'E', 'N', '\0' }, { 'T', 'H', 'E', '\0' }, { 'T', 'H', 'Y', '\0' }, { 'T', 'I', 'C', '\0' }, { 'T', 'I', 'E', '\0' }, { 'T', 'I', 'M', '\0' }, { 'T', 'I', 'N', '\0' }, { 'T', 'I', 'P', '\0' }, { 'T', 'O', '\0', '\0' }, { 'T', 'O', 'E', '\0' }, { 'T', 'O', 'G', '\0' }, { 'T', 'O', 'M', '\0' }, { 'T', 'O', 'N', '\0' }, { 'T', 'O', 'O', '\0' }, { 'T', 'O', 'P', '\0' }, { 'T', 'O', 'W', '\0' }, { 'T', 'O', 'Y', '\0' }, { 'T', 'R', 'Y', '\0' }, { 'T', 'U', 'B', '\0' }, { 'T', 'U', 'G', '\0' }, { 'T', 'U', 'M', '\0' }, { 'T', 'U', 'N', '\0' }, { 'T', 'W', 'O', '\0' }, { 'U', 'N', '\0', '\0' }, { 'U', 'P', '\0', '\0' }, { 'U', 'S', '\0', '\0' }, { 'U', 'S', 'E', '\0' }, { 'V', 'A', 'N', '\0' }, { 'V', 'A', 'T', '\0' }, { 'V', 'E', 'T', '\0' }, { 'V', 'I', 'E', '\0' }, { 'W', 'A', 'D', '\0' }, { 'W', 'A', 'G', '\0' }, { 'W', 'A', 'R', '\0' }, { 'W', 'A', 'S', '\0' }, { 'W', 'A', 'Y', '\0' }, { 'W', 'E', '\0', '\0' }, { 'W', 'E', 'B', '\0' }, { 'W', 'E', 'D', '\0' }, { 'W', 'E', 'E', '\0' }, { 'W', 'E', 'T', '\0' }, { 'W', 'H', 'O', '\0' }, { 'W', 'H', 'Y', '\0' }, { 'W', 'I', 'N', '\0' }, { 'W', 'I', 'T', '\0' }, { 'W', 'O', 'K', '\0' }, { 'W', 'O', 'N', '\0' }, { 'W', 'O', 'O', '\0' }, { 'W', 'O', 'W', '\0' }, { 'W', 'R', 'Y', '\0' }, { 'W', 'U', '\0', '\0' }, { 'Y', 'A', 'M', '\0' }, { 'Y', 'A', 'P', '\0' }, { 'Y', 'A', 'W', '\0' }, { 'Y', 'E', '\0', '\0' }, { 'Y', 'E', 'A', '\0' }, { 'Y', 'E', 'S', '\0' }, { 'Y', 'E', 'T', '\0' }, { 'Y', 'O', 'U', '\0' }, { 'A', 'B', 'E', 'D' }, { 'A', 'B', 'E', 'L' }, { 'A', 'B', 'E', 'T' }, { 'A', 'B', 'L', 'E' }, { 'A', 'B', 'U', 'T' }, { 'A', 'C', 'H', 'E' }, { 'A', 'C', 'I', 'D' }, { 'A', 'C', 'M', 'E' }, { 'A', 'C', 'R', 'E' }, { 'A', 'C', 'T', 'A' }, { 'A', 'C', 'T', 'S' }, { 'A', 'D', 'A', 'M' }, { 'A', 'D', 'D', 'S' }, { 'A', 'D', 'E', 'N' }, { 'A', 'F', 'A', 'R' }, { 'A', 'F', 'R', 'O' }, { 'A', 'G', 'E', 'E' }, { 'A', 'H', 'E', 'M' }, { 'A', 'H', 'O', 'Y' }, { 'A', 'I', 'D', 'A' }, { 'A', 'I', 'D', 'E' }, { 'A', 'I', 'D', 'S' }, { 'A', 'I', 'R', 'Y' }, { 'A', 'J', 'A', 'R' }, { 'A', 'K', 'I', 'N' }, { 'A', 'L', 'A', 'N' }, { 'A', 'L', 'E', 'C' }, { 'A', 'L', 'G', 'A' }, { 'A', 'L', 'I', 'A' }, { 'A', 'L', 'L', 'Y' }, { 'A', 'L', 'M', 'A' }, { 'A', 'L', 'O', 'E' }, { 'A', 'L', 'S', 'O' }, { 'A', 'L', 'T', 'O' }, { 'A', 'L', 'U', 'M' }, { 'A', 'L', 'V', 'A' }, { 'A', 'M', 'E', 'N' }, { 'A', 'M', 'E', 'S' }, { 'A', 'M', 'I', 'D' }, { 'A', 'M', 'M', 'O' }, { 'A', 'M', 'O', 'K' }, { 'A', 'M', 'O', 'S' }, { 'A', 'M', 'R', 'A' }, { 'A', 'N', 'D', 'Y' }, { 'A', 'N', 'E', 'W' }, { 'A', 'N', 'N', 'A' }, { 'A', 'N', 'N', 'E' }, { 'A', 'N', 'T', 'E' }, { 'A', 'N', 'T', 'I' }, { 'A', 'Q', 'U', 'A' }, { 'A', 'R', 'A', 'B' }, { 'A', 'R', 'C', 'H' }, { 'A', 'R', 'E', 'A' }, { 'A', 'R', 'G', 'O' }, { 'A', 'R', 'I', 'D' }, { 'A', 'R', 'M', 'Y' }, { 'A', 'R', 'T', 'S' }, { 'A', 'R', 'T', 'Y' }, { 'A', 'S', 'I', 'A' }, { 'A', 'S', 'K', 'S' }, { 'A', 'T', 'O', 'M' }, { 'A', 'U', 'N', 'T' }, { 'A', 'U', 'R', 'A' }, { 'A', 'U', 'T', 'O' }, { 'A', 'V', 'E', 'R' }, { 'A', 'V', 'I', 'D' }, { 'A', 'V', 'I', 'S' }, { 'A', 'V', 'O', 'N' }, { 'A', 'V', 'O', 'W' }, { 'A', 'W', 'A', 'Y' }, { 'A', 'W', 'R', 'Y' }, { 'B', 'A', 'B', 'E' }, { 'B', 'A', 'B', 'Y' }, { 'B', 'A', 'C', 'H' }, { 'B', 'A', 'C', 'K' }, { 'B', 'A', 'D', 'E' }, { 'B', 'A', 'I', 'L' }, { 'B', 'A', 'I', 'T' }, { 'B', 'A', 'K', 'E' }, { 'B', 'A', 'L', 'D' }, { 'B', 'A', 'L', 'E' }, { 'B', 'A', 'L', 'I' }, { 'B', 'A', 'L', 'K' }, { 'B', 'A', 'L', 'L' }, { 'B', 'A', 'L', 'M' }, { 'B', 'A', 'N', 'D' }, { 'B', 'A', 'N', 'E' }, { 'B', 'A', 'N', 'G' }, { 'B', 'A', 'N', 'K' }, { 'B', 'A', 'R', 'B' }, { 'B', 'A', 'R', 'D' }, { 'B', 'A', 'R', 'E' }, { 'B', 'A', 'R', 'K' }, { 'B', 'A', 'R', 'N' }, { 'B', 'A', 'R', 'R' }, { 'B', 'A', 'S', 'E' }, { 'B', 'A', 'S', 'H' }, { 'B', 'A', 'S', 'K' }, { 'B', 'A', 'S', 'S' }, { 'B', 'A', 'T', 'E' }, { 'B', 'A', 'T', 'H' }, { 'B', 'A', 'W', 'D' }, { 'B', 'A', 'W', 'L' }, { 'B', 'E', 'A', 'D' }, { 'B', 'E', 'A', 'K' }, { 'B', 'E', 'A', 'M' }, { 'B', 'E', 'A', 'N' }, { 'B', 'E', 'A', 'R' }, { 'B', 'E', 'A', 'T' }, { 'B', 'E', 'A', 'U' }, { 'B', 'E', 'C', 'K' }, { 'B', 'E', 'E', 'F' }, { 'B', 'E', 'E', 'N' }, { 'B', 'E', 'E', 'R' }, { 'B', 'E', 'E', 'T' }, { 'B', 'E', 'L', 'A' }, { 'B', 'E', 'L', 'L' }, { 'B', 'E', 'L', 'T' }, { 'B', 'E', 'N', 'D' }, { 'B', 'E', 'N', 'T' }, { 'B', 'E', 'R', 'G' }, { 'B', 'E', 'R', 'N' }, { 'B', 'E', 'R', 'T' }, { 'B', 'E', 'S', 'S' }, { 'B', 'E', 'S', 'T' }, { 'B', 'E', 'T', 'A' }, { 'B', 'E', 'T', 'H' }, { 'B', 'H', 'O', 'Y' }, { 'B', 'I', 'A', 'S' }, { 'B', 'I', 'D', 'E' }, { 'B', 'I', 'E', 'N' }, { 'B', 'I', 'L', 'E' }, { 'B', 'I', 'L', 'K' }, { 'B', 'I', 'L', 'L' }, { 'B', 'I', 'N', 'D' }, { 'B', 'I', 'N', 'G' }, { 'B', 'I', 'R', 'D' }, { 'B', 'I', 'T', 'E' }, { 'B', 'I', 'T', 'S' }, { 'B', 'L', 'A', 'B' }, { 'B', 'L', 'A', 'T' }, { 'B', 'L', 'E', 'D' }, { 'B', 'L', 'E', 'W' }, { 'B', 'L', 'O', 'B' }, { 'B', 'L', 'O', 'C' }, { 'B', 'L', 'O', 'T' }, { 'B', 'L', 'O', 'W' }, { 'B', 'L', 'U', 'E' }, { 'B', 'L', 'U', 'M' }, { 'B', 'L', 'U', 'R' }, { 'B', 'O', 'A', 'R' }, { 'B', 'O', 'A', 'T' }, { 'B', 'O', 'C', 'A' }, { 'B', 'O', 'C', 'K' }, { 'B', 'O', 'D', 'E' }, { 'B', 'O', 'D', 'Y' }, { 'B', 'O', 'G', 'Y' }, { 'B', 'O', 'H', 'R' }, { 'B', 'O', 'I', 'L' }, { 'B', 'O', 'L', 'D' }, { 'B', 'O', 'L', 'O' }, { 'B', 'O', 'L', 'T' }, { 'B', 'O', 'M', 'B' }, { 'B', 'O', 'N', 'A' }, { 'B', 'O', 'N', 'D' }, { 'B', 'O', 'N', 'E' }, { 'B', 'O', 'N', 'G' }, { 'B', 'O', 'N', 'N' }, { 'B', 'O', 'N', 'Y' }, { 'B', 'O', 'O', 'K' }, { 'B', 'O', 'O', 'M' }, { 'B', 'O', 'O', 'N' }, { 'B', 'O', 'O', 'T' }, { 'B', 'O', 'R', 'E' }, { 'B', 'O', 'R', 'G' }, { 'B', 'O', 'R', 'N' }, { 'B', 'O', 'S', 'E' }, { 'B', 'O', 'S', 'S' }, { 'B', 'O', 'T', 'H' }, { 'B', 'O', 'U', 'T' }, { 'B', 'O', 'W', 'L' }, { 'B', 'O', 'Y', 'D' }, { 'B', 'R', 'A', 'D' }, { 'B', 'R', 'A', 'E' }, { 'B', 'R', 'A', 'G' }, { 'B', 'R', 'A', 'N' }, { 'B', 'R', 'A', 'Y' }, { 'B', 'R', 'E', 'D' }, { 'B', 'R', 'E', 'W' }, { 'B', 'R', 'I', 'G' }, { 'B', 'R', 'I', 'M' }, { 'B', 'R', 'O', 'W' }, { 'B', 'U', 'C', 'K' }, { 'B', 'U', 'D', 'D' }, { 'B', 'U', 'F', 'F' }, { 'B', 'U', 'L', 'B' }, { 'B', 'U', 'L', 'K' }, { 'B', 'U', 'L', 'L' }, { 'B', 'U', 'N', 'K' }, { 'B', 'U', 'N', 'T' }, { 'B', 'U', 'O', 'Y' }, { 'B', 'U', 'R', 'G' }, { 'B', 'U', 'R', 'L' }, { 'B', 'U', 'R', 'N' }, { 'B', 'U', 'R', 'R' }, { 'B', 'U', 'R', 'T' }, { 'B', 'U', 'R', 'Y' }, { 'B', 'U', 'S', 'H' }, { 'B', 'U', 'S', 'S' }, { 'B', 'U', 'S', 'T' }, { 'B', 'U', 'S', 'Y' }, { 'B', 'Y', 'T', 'E' }, { 'C', 'A', 'D', 'Y' }, { 'C', 'A', 'F', 'E' }, { 'C', 'A', 'G', 'E' }, { 'C', 'A', 'I', 'N' }, { 'C', 'A', 'K', 'E' }, { 'C', 'A', 'L', 'F' }, { 'C', 'A', 'L', 'L' }, { 'C', 'A', 'L', 'M' }, { 'C', 'A', 'M', 'E' }, { 'C', 'A', 'N', 'E' }, { 'C', 'A', 'N', 'T' }, { 'C', 'A', 'R', 'D' }, { 'C', 'A', 'R', 'E' }, { 'C', 'A', 'R', 'L' }, { 'C', 'A', 'R', 'R' }, { 'C', 'A', 'R', 'T' }, { 'C', 'A', 'S', 'E' }, { 'C', 'A', 'S', 'H' }, { 'C', 'A', 'S', 'K' }, { 'C', 'A', 'S', 'T' }, { 'C', 'A', 'V', 'E' }, { 'C', 'E', 'I', 'L' }, { 'C', 'E', 'L', 'L' }, { 'C', 'E', 'N', 'T' }, { 'C', 'E', 'R', 'N' }, { 'C', 'H', 'A', 'D' }, { 'C', 'H', 'A', 'R' }, { 'C', 'H', 'A', 'T' }, { 'C', 'H', 'A', 'W' }, { 'C', 'H', 'E', 'F' }, { 'C', 'H', 'E', 'N' }, { 'C', 'H', 'E', 'W' }, { 'C', 'H', 'I', 'C' }, { 'C', 'H', 'I', 'N' }, { 'C', 'H', 'O', 'U' }, { 'C', 'H', 'O', 'W' }, { 'C', 'H', 'U', 'B' }, { 'C', 'H', 'U', 'G' }, { 'C', 'H', 'U', 'M' }, { 'C', 'I', 'T', 'E' }, { 'C', 'I', 'T', 'Y' }, { 'C', 'L', 'A', 'D' }, { 'C', 'L', 'A', 'M' }, { 'C', 'L', 'A', 'N' }, { 'C', 'L', 'A', 'W' }, { 'C', 'L', 'A', 'Y' }, { 'C', 'L', 'O', 'D' }, { 'C', 'L', 'O', 'G' }, { 'C', 'L', 'O', 'T' }, { 'C', 'L', 'U', 'B' }, { 'C', 'L', 'U', 'E' }, { 'C', 'O', 'A', 'L' }, { 'C', 'O', 'A', 'T' }, { 'C', 'O', 'C', 'A' }, { 'C', 'O', 'C', 'K' }, { 'C', 'O', 'C', 'O' }, { 'C', 'O', 'D', 'A' }, { 'C', 'O', 'D', 'E' }, { 'C', 'O', 'D', 'Y' }, { 'C', 'O', 'E', 'D' }, { 'C', 'O', 'I', 'L' }, { 'C', 'O', 'I', 'N' }, { 'C', 'O', 'K', 'E' }, { 'C', 'O', 'L', 'A' }, { 'C', 'O', 'L', 'D' }, { 'C', 'O', 'L', 'T' }, { 'C', 'O', 'M', 'A' }, { 'C', 'O', 'M', 'B' }, { 'C', 'O', 'M', 'E' }, { 'C', 'O', 'O', 'K' }, { 'C', 'O', 'O', 'L' }, { 'C', 'O', 'O', 'N' }, { 'C', 'O', 'O', 'T' }, { 'C', 'O', 'R', 'D' }, { 'C', 'O', 'R', 'E' }, { 'C', 'O', 'R', 'K' }, { 'C', 'O', 'R', 'N' }, { 'C', 'O', 'S', 'T' }, { 'C', 'O', 'V', 'E' }, { 'C', 'O', 'W', 'L' }, { 'C', 'R', 'A', 'B' }, { 'C', 'R', 'A', 'G' }, { 'C', 'R', 'A', 'M' }, { 'C', 'R', 'A', 'Y' }, { 'C', 'R', 'E', 'W' }, { 'C', 'R', 'I', 'B' }, { 'C', 'R', 'O', 'W' }, { 'C', 'R', 'U', 'D' }, { 'C', 'U', 'B', 'A' }, { 'C', 'U', 'B', 'E' }, { 'C', 'U', 'F', 'F' }, { 'C', 'U', 'L', 'L' }, { 'C', 'U', 'L', 'T' }, { 'C', 'U', 'N', 'Y' }, { 'C', 'U', 'R', 'B' }, { 'C', 'U', 'R', 'D' }, { 'C', 'U', 'R', 'E' }, { 'C', 'U', 'R', 'L' }, { 'C', 'U', 'R', 'T' }, { 'C', 'U', 'T', 'S' }, { 'D', 'A', 'D', 'E' }, { 'D', 'A', 'L', 'E' }, { 'D', 'A', 'M', 'E' }, { 'D', 'A', 'N', 'A' }, { 'D', 'A', 'N', 'E' }, { 'D', 'A', 'N', 'G' }, { 'D', 'A', 'N', 'K' }, { 'D', 'A', 'R', 'E' }, { 'D', 'A', 'R', 'K' }, { 'D', 'A', 'R', 'N' }, { 'D', 'A', 'R', 'T' }, { 'D', 'A', 'S', 'H' }, { 'D', 'A', 'T', 'A' }, { 'D', 'A', 'T', 'E' }, { 'D', 'A', 'V', 'E' }, { 'D', 'A', 'V', 'Y' }, { 'D', 'A', 'W', 'N' }, { 'D', 'A', 'Y', 'S' }, { 'D', 'E', 'A', 'D' }, { 'D', 'E', 'A', 'F' }, { 'D', 'E', 'A', 'L' }, { 'D', 'E', 'A', 'N' }, { 'D', 'E', 'A', 'R' }, { 'D', 'E', 'B', 'T' }, { 'D', 'E', 'C', 'K' }, { 'D', 'E', 'E', 'D' }, { 'D', 'E', 'E', 'M' }, { 'D', 'E', 'E', 'R' }, { 'D', 'E', 'F', 'T' }, { 'D', 'E', 'F', 'Y' }, { 'D', 'E', 'L', 'L' }, { 'D', 'E', 'N', 'T' }, { 'D', 'E', 'N', 'Y' }, { 'D', 'E', 'S', 'K' }, { 'D', 'I', 'A', 'L' }, { 'D', 'I', 'C', 'E' }, { 'D', 'I', 'E', 'D' }, { 'D', 'I', 'E', 'T' }, { 'D', 'I', 'M', 'E' }, { 'D', 'I', 'N', 'E' }, { 'D', 'I', 'N', 'G' }, { 'D', 'I', 'N', 'T' }, { 'D', 'I', 'R', 'E' }, { 'D', 'I', 'R', 'T' }, { 'D', 'I', 'S', 'C' }, { 'D', 'I', 'S', 'H' }, { 'D', 'I', 'S', 'K' }, { 'D', 'I', 'V', 'E' }, { 'D', 'O', 'C', 'K' }, { 'D', 'O', 'E', 'S' }, { 'D', 'O', 'L', 'E' }, { 'D', 'O', 'L', 'L' }, { 'D', 'O', 'L', 'T' }, { 'D', 'O', 'M', 'E' }, { 'D', 'O', 'N', 'E' }, { 'D', 'O', 'O', 'M' }, { 'D', 'O', 'O', 'R' }, { 'D', 'O', 'R', 'A' }, { 'D', 'O', 'S', 'E' }, { 'D', 'O', 'T', 'E' }, { 'D', 'O', 'U', 'G' }, { 'D', 'O', 'U', 'R' }, { 'D', 'O', 'V', 'E' }, { 'D', 'O', 'W', 'N' }, { 'D', 'R', 'A', 'B' }, { 'D', 'R', 'A', 'G' }, { 'D', 'R', 'A', 'M' }, { 'D', 'R', 'A', 'W' }, { 'D', 'R', 'E', 'W' }, { 'D', 'R', 'U', 'B' }, { 'D', 'R', 'U', 'G' }, { 'D', 'R', 'U', 'M' }, { 'D', 'U', 'A', 'L' }, { 'D', 'U', 'C', 'K' }, { 'D', 'U', 'C', 'T' }, { 'D', 'U', 'E', 'L' }, { 'D', 'U', 'E', 'T' }, { 'D', 'U', 'K', 'E' }, { 'D', 'U', 'L', 'L' }, { 'D', 'U', 'M', 'B' }, { 'D', 'U', 'N', 'E' }, { 'D', 'U', 'N', 'K' }, { 'D', 'U', 'S', 'K' }, { 'D', 'U', 'S', 'T' }, { 'D', 'U', 'T', 'Y' }, { 'E', 'A', 'C', 'H' }, { 'E', 'A', 'R', 'L' }, { 'E', 'A', 'R', 'N' }, { 'E', 'A', 'S', 'E' }, { 'E', 'A', 'S', 'T' }, { 'E', 'A', 'S', 'Y' }, { 'E', 'B', 'E', 'N' }, { 'E', 'C', 'H', 'O' }, { 'E', 'D', 'D', 'Y' }, { 'E', 'D', 'E', 'N' }, { 'E', 'D', 'G', 'E' }, { 'E', 'D', 'G', 'Y' }, { 'E', 'D', 'I', 'T' }, { 'E', 'D', 'N', 'A' }, { 'E', 'G', 'A', 'N' }, { 'E', 'L', 'A', 'N' }, { 'E', 'L', 'B', 'A' }, { 'E', 'L', 'L', 'A' }, { 'E', 'L', 'S', 'E' }, { 'E', 'M', 'I', 'L' }, { 'E', 'M', 'I', 'T' }, { 'E', 'M', 'M', 'A' }, { 'E', 'N', 'D', 'S' }, { 'E', 'R', 'I', 'C' }, { 'E', 'R', 'O', 'S' }, { 'E', 'V', 'E', 'N' }, { 'E', 'V', 'E', 'R' }, { 'E', 'V', 'I', 'L' }, { 'E', 'Y', 'E', 'D' }, { 'F', 'A', 'C', 'E' }, { 'F', 'A', 'C', 'T' }, { 'F', 'A', 'D', 'E' }, { 'F', 'A', 'I', 'L' }, { 'F', 'A', 'I', 'N' }, { 'F', 'A', 'I', 'R' }, { 'F', 'A', 'K', 'E' }, { 'F', 'A', 'L', 'L' }, { 'F', 'A', 'M', 'E' }, { 'F', 'A', 'N', 'G' }, { 'F', 'A', 'R', 'M' }, { 'F', 'A', 'S', 'T' }, { 'F', 'A', 'T', 'E' }, { 'F', 'A', 'W', 'N' }, { 'F', 'E', 'A', 'R' }, { 'F', 'E', 'A', 'T' }, { 'F', 'E', 'E', 'D' }, { 'F', 'E', 'E', 'L' }, { 'F', 'E', 'E', 'T' }, { 'F', 'E', 'L', 'L' }, { 'F', 'E', 'L', 'T' }, { 'F', 'E', 'N', 'D' }, { 'F', 'E', 'R', 'N' }, { 'F', 'E', 'S', 'T' }, { 'F', 'E', 'U', 'D' }, { 'F', 'I', 'E', 'F' }, { 'F', 'I', 'G', 'S' }, { 'F', 'I', 'L', 'E' }, { 'F', 'I', 'L', 'L' }, { 'F', 'I', 'L', 'M' }, { 'F', 'I', 'N', 'D' }, { 'F', 'I', 'N', 'E' }, { 'F', 'I', 'N', 'K' }, { 'F', 'I', 'R', 'E' }, { 'F', 'I', 'R', 'M' }, { 'F', 'I', 'S', 'H' }, { 'F', 'I', 'S', 'K' }, { 'F', 'I', 'S', 'T' }, { 'F', 'I', 'T', 'S' }, { 'F', 'I', 'V', 'E' }, { 'F', 'L', 'A', 'G' }, { 'F', 'L', 'A', 'K' }, { 'F', 'L', 'A', 'M' }, { 'F', 'L', 'A', 'T' }, { 'F', 'L', 'A', 'W' }, { 'F', 'L', 'E', 'A' }, { 'F', 'L', 'E', 'D' }, { 'F', 'L', 'E', 'W' }, { 'F', 'L', 'I', 'T' }, { 'F', 'L', 'O', 'C' }, { 'F', 'L', 'O', 'G' }, { 'F', 'L', 'O', 'W' }, { 'F', 'L', 'U', 'B' }, { 'F', 'L', 'U', 'E' }, { 'F', 'O', 'A', 'L' }, { 'F', 'O', 'A', 'M' }, { 'F', 'O', 'G', 'Y' }, { 'F', 'O', 'I', 'L' }, { 'F', 'O', 'L', 'D' }, { 'F', 'O', 'L', 'K' }, { 'F', 'O', 'N', 'D' }, { 'F', 'O', 'N', 'T' }, { 'F', 'O', 'O', 'D' }, { 'F', 'O', 'O', 'L' }, { 'F', 'O', 'O', 'T' }, { 'F', 'O', 'R', 'D' }, { 'F', 'O', 'R', 'E' }, { 'F', 'O', 'R', 'K' }, { 'F', 'O', 'R', 'M' }, { 'F', 'O', 'R', 'T' }, { 'F', 'O', 'S', 'S' }, { 'F', 'O', 'U', 'L' }, { 'F', 'O', 'U', 'R' }, { 'F', 'O', 'W', 'L' }, { 'F', 'R', 'A', 'U' }, { 'F', 'R', 'A', 'Y' }, { 'F', 'R', 'E', 'D' }, { 'F', 'R', 'E', 'E' }, { 'F', 'R', 'E', 'T' }, { 'F', 'R', 'E', 'Y' }, { 'F', 'R', 'O', 'G' }, { 'F', 'R', 'O', 'M' }, { 'F', 'U', 'E', 'L' }, { 'F', 'U', 'L', 'L' }, { 'F', 'U', 'M', 'E' }, { 'F', 'U', 'N', 'D' }, { 'F', 'U', 'N', 'K' }, { 'F', 'U', 'R', 'Y' }, { 'F', 'U', 'S', 'E' }, { 'F', 'U', 'S', 'S' }, { 'G', 'A', 'F', 'F' }, { 'G', 'A', 'G', 'E' }, { 'G', 'A', 'I', 'L' }, { 'G', 'A', 'I', 'N' }, { 'G', 'A', 'I', 'T' }, { 'G', 'A', 'L', 'A' }, { 'G', 'A', 'L', 'E' }, { 'G', 'A', 'L', 'L' }, { 'G', 'A', 'L', 'T' }, { 'G', 'A', 'M', 'E' }, { 'G', 'A', 'N', 'G' }, { 'G', 'A', 'R', 'B' }, { 'G', 'A', 'R', 'Y' }, { 'G', 'A', 'S', 'H' }, { 'G', 'A', 'T', 'E' }, { 'G', 'A', 'U', 'L' }, { 'G', 'A', 'U', 'R' }, { 'G', 'A', 'V', 'E' }, { 'G', 'A', 'W', 'K' }, { 'G', 'E', 'A', 'R' }, { 'G', 'E', 'L', 'D' }, { 'G', 'E', 'N', 'E' }, { 'G', 'E', 'N', 'T' }, { 'G', 'E', 'R', 'M' }, { 'G', 'E', 'T', 'S' }, { 'G', 'I', 'B', 'E' }, { 'G', 'I', 'F', 'T' }, { 'G', 'I', 'L', 'D' }, { 'G', 'I', 'L', 'L' }, { 'G', 'I', 'L', 'T' }, { 'G', 'I', 'N', 'A' }, { 'G', 'I', 'R', 'D' }, { 'G', 'I', 'R', 'L' }, { 'G', 'I', 'S', 'T' }, { 'G', 'I', 'V', 'E' }, { 'G', 'L', 'A', 'D' }, { 'G', 'L', 'E', 'E' }, { 'G', 'L', 'E', 'N' }, { 'G', 'L', 'I', 'B' }, { 'G', 'L', 'O', 'B' }, { 'G', 'L', 'O', 'M' }, { 'G', 'L', 'O', 'W' }, { 'G', 'L', 'U', 'E' }, { 'G', 'L', 'U', 'M' }, { 'G', 'L', 'U', 'T' }, { 'G', 'O', 'A', 'D' }, { 'G', 'O', 'A', 'L' }, { 'G', 'O', 'A', 'T' }, { 'G', 'O', 'E', 'R' }, { 'G', 'O', 'E', 'S' }, { 'G', 'O', 'L', 'D' }, { 'G', 'O', 'L', 'F' }, { 'G', 'O', 'N', 'E' }, { 'G', 'O', 'N', 'G' }, { 'G', 'O', 'O', 'D' }, { 'G', 'O', 'O', 'F' }, { 'G', 'O', 'R', 'E' }, { 'G', 'O', 'R', 'Y' }, { 'G', 'O', 'S', 'H' }, { 'G', 'O', 'U', 'T' }, { 'G', 'O', 'W', 'N' }, { 'G', 'R', 'A', 'B' }, { 'G', 'R', 'A', 'D' }, { 'G', 'R', 'A', 'Y' }, { 'G', 'R', 'E', 'G' }, { 'G', 'R', 'E', 'W' }, { 'G', 'R', 'E', 'Y' }, { 'G', 'R', 'I', 'D' }, { 'G', 'R', 'I', 'M' }, { 'G', 'R', 'I', 'N' }, { 'G', 'R', 'I', 'T' }, { 'G', 'R', 'O', 'W' }, { 'G', 'R', 'U', 'B' }, { 'G', 'U', 'L', 'F' }, { 'G', 'U', 'L', 'L' }, { 'G', 'U', 'N', 'K' }, { 'G', 'U', 'R', 'U' }, { 'G', 'U', 'S', 'H' }, { 'G', 'U', 'S', 'T' }, { 'G', 'W', 'E', 'N' }, { 'G', 'W', 'Y', 'N' }, { 'H', 'A', 'A', 'G' }, { 'H', 'A', 'A', 'S' }, { 'H', 'A', 'C', 'K' }, { 'H', 'A', 'I', 'L' }, { 'H', 'A', 'I', 'R' }, { 'H', 'A', 'L', 'E' }, { 'H', 'A', 'L', 'F' }, { 'H', 'A', 'L', 'L' }, { 'H', 'A', 'L', 'O' }, { 'H', 'A', 'L', 'T' }, { 'H', 'A', 'N', 'D' }, { 'H', 'A', 'N', 'G' }, { 'H', 'A', 'N', 'K' }, { 'H', 'A', 'N', 'S' }, { 'H', 'A', 'R', 'D' }, { 'H', 'A', 'R', 'K' }, { 'H', 'A', 'R', 'M' }, { 'H', 'A', 'R', 'T' }, { 'H', 'A', 'S', 'H' }, { 'H', 'A', 'S', 'T' }, { 'H', 'A', 'T', 'E' }, { 'H', 'A', 'T', 'H' }, { 'H', 'A', 'U', 'L' }, { 'H', 'A', 'V', 'E' }, { 'H', 'A', 'W', 'K' }, { 'H', 'A', 'Y', 'S' }, { 'H', 'E', 'A', 'D' }, { 'H', 'E', 'A', 'L' }, { 'H', 'E', 'A', 'R' }, { 'H', 'E', 'A', 'T' }, { 'H', 'E', 'B', 'E' }, { 'H', 'E', 'C', 'K' }, { 'H', 'E', 'E', 'D' }, { 'H', 'E', 'E', 'L' }, { 'H', 'E', 'F', 'T' }, { 'H', 'E', 'L', 'D' }, { 'H', 'E', 'L', 'L' }, { 'H', 'E', 'L', 'M' }, { 'H', 'E', 'R', 'B' }, { 'H', 'E', 'R', 'D' }, { 'H', 'E', 'R', 'E' }, { 'H', 'E', 'R', 'O' }, { 'H', 'E', 'R', 'S' }, { 'H', 'E', 'S', 'S' }, { 'H', 'E', 'W', 'N' }, { 'H', 'I', 'C', 'K' }, { 'H', 'I', 'D', 'E' }, { 'H', 'I', 'G', 'H' }, { 'H', 'I', 'K', 'E' }, { 'H', 'I', 'L', 'L' }, { 'H', 'I', 'L', 'T' }, { 'H', 'I', 'N', 'D' }, { 'H', 'I', 'N', 'T' }, { 'H', 'I', 'R', 'E' }, { 'H', 'I', 'S', 'S' }, { 'H', 'I', 'V', 'E' }, { 'H', 'O', 'B', 'O' }, { 'H', 'O', 'C', 'K' }, { 'H', 'O', 'F', 'F' }, { 'H', 'O', 'L', 'D' }, { 'H', 'O', 'L', 'E' }, { 'H', 'O', 'L', 'M' }, { 'H', 'O', 'L', 'T' }, { 'H', 'O', 'M', 'E' }, { 'H', 'O', 'N', 'E' }, { 'H', 'O', 'N', 'K' }, { 'H', 'O', 'O', 'D' }, { 'H', 'O', 'O', 'F' }, { 'H', 'O', 'O', 'K' }, { 'H', 'O', 'O', 'T' }, { 'H', 'O', 'R', 'N' }, { 'H', 'O', 'S', 'E' }, { 'H', 'O', 'S', 'T' }, { 'H', 'O', 'U', 'R' }, { 'H', 'O', 'V', 'E' }, { 'H', 'O', 'W', 'E' }, { 'H', 'O', 'W', 'L' }, { 'H', 'O', 'Y', 'T' }, { 'H', 'U', 'C', 'K' }, { 'H', 'U', 'E', 'D' }, { 'H', 'U', 'F', 'F' }, { 'H', 'U', 'G', 'E' }, { 'H', 'U', 'G', 'H' }, { 'H', 'U', 'G', 'O' }, { 'H', 'U', 'L', 'K' }, { 'H', 'U', 'L', 'L' }, { 'H', 'U', 'N', 'K' }, { 'H', 'U', 'N', 'T' }, { 'H', 'U', 'R', 'D' }, { 'H', 'U', 'R', 'L' }, { 'H', 'U', 'R', 'T' }, { 'H', 'U', 'S', 'H' }, { 'H', 'Y', 'D', 'E' }, { 'H', 'Y', 'M', 'N' }, { 'I', 'B', 'I', 'S' }, { 'I', 'C', 'O', 'N' }, { 'I', 'D', 'E', 'A' }, { 'I', 'D', 'L', 'E' }, { 'I', 'F', 'F', 'Y' }, { 'I', 'N', 'C', 'A' }, { 'I', 'N', 'C', 'H' }, { 'I', 'N', 'T', 'O' }, { 'I', 'O', 'N', 'S' }, { 'I', 'O', 'T', 'A' }, { 'I', 'O', 'W', 'A' }, { 'I', 'R', 'I', 'S' }, { 'I', 'R', 'M', 'A' }, { 'I', 'R', 'O', 'N' }, { 'I', 'S', 'L', 'E' }, { 'I', 'T', 'C', 'H' }, { 'I', 'T', 'E', 'M' }, { 'I', 'V', 'A', 'N' }, { 'J', 'A', 'C', 'K' }, { 'J', 'A', 'D', 'E' }, { 'J', 'A', 'I', 'L' }, { 'J', 'A', 'K', 'E' }, { 'J', 'A', 'N', 'E' }, { 'J', 'A', 'V', 'A' }, { 'J', 'E', 'A', 'N' }, { 'J', 'E', 'F', 'F' }, { 'J', 'E', 'R', 'K' }, { 'J', 'E', 'S', 'S' }, { 'J', 'E', 'S', 'T' }, { 'J', 'I', 'B', 'E' }, { 'J', 'I', 'L', 'L' }, { 'J', 'I', 'L', 'T' }, { 'J', 'I', 'V', 'E' }, { 'J', 'O', 'A', 'N' }, { 'J', 'O', 'B', 'S' }, { 'J', 'O', 'C', 'K' }, { 'J', 'O', 'E', 'L' }, { 'J', 'O', 'E', 'Y' }, { 'J', 'O', 'H', 'N' }, { 'J', 'O', 'I', 'N' }, { 'J', 'O', 'K', 'E' }, { 'J', 'O', 'L', 'T' }, { 'J', 'O', 'V', 'E' }, { 'J', 'U', 'D', 'D' }, { 'J', 'U', 'D', 'E' }, { 'J', 'U', 'D', 'O' }, { 'J', 'U', 'D', 'Y' }, { 'J', 'U', 'J', 'U' }, { 'J', 'U', 'K', 'E' }, { 'J', 'U', 'L', 'Y' }, { 'J', 'U', 'N', 'E' }, { 'J', 'U', 'N', 'K' }, { 'J', 'U', 'N', 'O' }, { 'J', 'U', 'R', 'Y' }, { 'J', 'U', 'S', 'T' }, { 'J', 'U', 'T', 'E' }, { 'K', 'A', 'H', 'N' }, { 'K', 'A', 'L', 'E' }, { 'K', 'A', 'N', 'E' }, { 'K', 'A', 'N', 'T' }, { 'K', 'A', 'R', 'L' }, { 'K', 'A', 'T', 'E' }, { 'K', 'E', 'E', 'L' }, { 'K', 'E', 'E', 'N' }, { 'K', 'E', 'N', 'O' }, { 'K', 'E', 'N', 'T' }, { 'K', 'E', 'R', 'N' }, { 'K', 'E', 'R', 'R' }, { 'K', 'E', 'Y', 'S' }, { 'K', 'I', 'C', 'K' }, { 'K', 'I', 'L', 'L' }, { 'K', 'I', 'N', 'D' }, { 'K', 'I', 'N', 'G' }, { 'K', 'I', 'R', 'K' }, { 'K', 'I', 'S', 'S' }, { 'K', 'I', 'T', 'E' }, { 'K', 'L', 'A', 'N' }, { 'K', 'N', 'E', 'E' }, { 'K', 'N', 'E', 'W' }, { 'K', 'N', 'I', 'T' }, { 'K', 'N', 'O', 'B' }, { 'K', 'N', 'O', 'T' }, { 'K', 'N', 'O', 'W' }, { 'K', 'O', 'C', 'H' }, { 'K', 'O', 'N', 'G' }, { 'K', 'U', 'D', 'O' }, { 'K', 'U', 'R', 'D' }, { 'K', 'U', 'R', 'T' }, { 'K', 'Y', 'L', 'E' }, { 'L', 'A', 'C', 'E' }, { 'L', 'A', 'C', 'K' }, { 'L', 'A', 'C', 'Y' }, { 'L', 'A', 'D', 'Y' }, { 'L', 'A', 'I', 'D' }, { 'L', 'A', 'I', 'N' }, { 'L', 'A', 'I', 'R' }, { 'L', 'A', 'K', 'E' }, { 'L', 'A', 'M', 'B' }, { 'L', 'A', 'M', 'E' }, { 'L', 'A', 'N', 'D' }, { 'L', 'A', 'N', 'E' }, { 'L', 'A', 'N', 'G' }, { 'L', 'A', 'R', 'D' }, { 'L', 'A', 'R', 'K' }, { 'L', 'A', 'S', 'S' }, { 'L', 'A', 'S', 'T' }, { 'L', 'A', 'T', 'E' }, { 'L', 'A', 'U', 'D' }, { 'L', 'A', 'V', 'A' }, { 'L', 'A', 'W', 'N' }, { 'L', 'A', 'W', 'S' }, { 'L', 'A', 'Y', 'S' }, { 'L', 'E', 'A', 'D' }, { 'L', 'E', 'A', 'F' }, { 'L', 'E', 'A', 'K' }, { 'L', 'E', 'A', 'N' }, { 'L', 'E', 'A', 'R' }, { 'L', 'E', 'E', 'K' }, { 'L', 'E', 'E', 'R' }, { 'L', 'E', 'F', 'T' }, { 'L', 'E', 'N', 'D' }, { 'L', 'E', 'N', 'S' }, { 'L', 'E', 'N', 'T' }, { 'L', 'E', 'O', 'N' }, { 'L', 'E', 'S', 'K' }, { 'L', 'E', 'S', 'S' }, { 'L', 'E', 'S', 'T' }, { 'L', 'E', 'T', 'S' }, { 'L', 'I', 'A', 'R' }, { 'L', 'I', 'C', 'E' }, { 'L', 'I', 'C', 'K' }, { 'L', 'I', 'E', 'D' }, { 'L', 'I', 'E', 'N' }, { 'L', 'I', 'E', 'S' }, { 'L', 'I', 'E', 'U' }, { 'L', 'I', 'F', 'E' }, { 'L', 'I', 'F', 'T' }, { 'L', 'I', 'K', 'E' }, { 'L', 'I', 'L', 'A' }, { 'L', 'I', 'L', 'T' }, { 'L', 'I', 'L', 'Y' }, { 'L', 'I', 'M', 'A' }, { 'L', 'I', 'M', 'B' }, { 'L', 'I', 'M', 'E' }, { 'L', 'I', 'N', 'D' }, { 'L', 'I', 'N', 'E' }, { 'L', 'I', 'N', 'K' }, { 'L', 'I', 'N', 'T' }, { 'L', 'I', 'O', 'N' }, { 'L', 'I', 'S', 'A' }, { 'L', 'I', 'S', 'T' }, { 'L', 'I', 'V', 'E' }, { 'L', 'O', 'A', 'D' }, { 'L', 'O', 'A', 'F' }, { 'L', 'O', 'A', 'M' }, { 'L', 'O', 'A', 'N' }, { 'L', 'O', 'C', 'K' }, { 'L', 'O', 'F', 'T' }, { 'L', 'O', 'G', 'E' }, { 'L', 'O', 'I', 'S' }, { 'L', 'O', 'L', 'A' }, { 'L', 'O', 'N', 'E' }, { 'L', 'O', 'N', 'G' }, { 'L', 'O', 'O', 'K' }, { 'L', 'O', 'O', 'N' }, { 'L', 'O', 'O', 'T' }, { 'L', 'O', 'R', 'D' }, { 'L', 'O', 'R', 'E' }, { 'L', 'O', 'S', 'E' }, { 'L', 'O', 'S', 'S' }, { 'L', 'O', 'S', 'T' }, { 'L', 'O', 'U', 'D' }, { 'L', 'O', 'V', 'E' }, { 'L', 'O', 'W', 'E' }, { 'L', 'U', 'C', 'K' }, { 'L', 'U', 'C', 'Y' }, { 'L', 'U', 'G', 'E' }, { 'L', 'U', 'K', 'E' }, { 'L', 'U', 'L', 'U' }, { 'L', 'U', 'N', 'D' }, { 'L', 'U', 'N', 'G' }, { 'L', 'U', 'R', 'A' }, { 'L', 'U', 'R', 'E' }, { 'L', 'U', 'R', 'K' }, { 'L', 'U', 'S', 'H' }, { 'L', 'U', 'S', 'T' }, { 'L', 'Y', 'L', 'E' }, { 'L', 'Y', 'N', 'N' }, { 'L', 'Y', 'O', 'N' }, { 'L', 'Y', 'R', 'A' }, { 'M', 'A', 'C', 'E' }, { 'M', 'A', 'D', 'E' }, { 'M', 'A', 'G', 'I' }, { 'M', 'A', 'I', 'D' }, { 'M', 'A', 'I', 'L' }, { 'M', 'A', 'I', 'N' }, { 'M', 'A', 'K', 'E' }, { 'M', 'A', 'L', 'E' }, { 'M', 'A', 'L', 'I' }, { 'M', 'A', 'L', 'L' }, { 'M', 'A', 'L', 'T' }, { 'M', 'A', 'N', 'A' }, { 'M', 'A', 'N', 'N' }, { 'M', 'A', 'N', 'Y' }, { 'M', 'A', 'R', 'C' }, { 'M', 'A', 'R', 'E' }, { 'M', 'A', 'R', 'K' }, { 'M', 'A', 'R', 'S' }, { 'M', 'A', 'R', 'T' }, { 'M', 'A', 'R', 'Y' }, { 'M', 'A', 'S', 'H' }, { 'M', 'A', 'S', 'K' }, { 'M', 'A', 'S', 'S' }, { 'M', 'A', 'S', 'T' }, { 'M', 'A', 'T', 'E' }, { 'M', 'A', 'T', 'H' }, { 'M', 'A', 'U', 'L' }, { 'M', 'A', 'Y', 'O' }, { 'M', 'E', 'A', 'D' }, { 'M', 'E', 'A', 'L' }, { 'M', 'E', 'A', 'N' }, { 'M', 'E', 'A', 'T' }, { 'M', 'E', 'E', 'K' }, { 'M', 'E', 'E', 'T' }, { 'M', 'E', 'L', 'D' }, { 'M', 'E', 'L', 'T' }, { 'M', 'E', 'M', 'O' }, { 'M', 'E', 'N', 'D' }, { 'M', 'E', 'N', 'U' }, { 'M', 'E', 'R', 'T' }, { 'M', 'E', 'S', 'H' }, { 'M', 'E', 'S', 'S' }, { 'M', 'I', 'C', 'E' }, { 'M', 'I', 'K', 'E' }, { 'M', 'I', 'L', 'D' }, { 'M', 'I', 'L', 'E' }, { 'M', 'I', 'L', 'K' }, { 'M', 'I', 'L', 'L' }, { 'M', 'I', 'L', 'T' }, { 'M', 'I', 'M', 'I' }, { 'M', 'I', 'N', 'D' }, { 'M', 'I', 'N', 'E' }, { 'M', 'I', 'N', 'I' }, { 'M', 'I', 'N', 'K' }, { 'M', 'I', 'N', 'T' }, { 'M', 'I', 'R', 'E' }, { 'M', 'I', 'S', 'S' }, { 'M', 'I', 'S', 'T' }, { 'M', 'I', 'T', 'E' }, { 'M', 'I', 'T', 'T' }, { 'M', 'O', 'A', 'N' }, { 'M', 'O', 'A', 'T' }, { 'M', 'O', 'C', 'K' }, { 'M', 'O', 'D', 'E' }, { 'M', 'O', 'L', 'D' }, { 'M', 'O', 'L', 'E' }, { 'M', 'O', 'L', 'L' }, { 'M', 'O', 'L', 'T' }, { 'M', 'O', 'N', 'A' }, { 'M', 'O', 'N', 'K' }, { 'M', 'O', 'N', 'T' }, { 'M', 'O', 'O', 'D' }, { 'M', 'O', 'O', 'N' }, { 'M', 'O', 'O', 'R' }, { 'M', 'O', 'O', 'T' }, { 'M', 'O', 'R', 'E' }, { 'M', 'O', 'R', 'N' }, { 'M', 'O', 'R', 'T' }, { 'M', 'O', 'S', 'S' }, { 'M', 'O', 'S', 'T' }, { 'M', 'O', 'T', 'H' }, { 'M', 'O', 'V', 'E' }, { 'M', 'U', 'C', 'H' }, { 'M', 'U', 'C', 'K' }, { 'M', 'U', 'D', 'D' }, { 'M', 'U', 'F', 'F' }, { 'M', 'U', 'L', 'E' }, { 'M', 'U', 'L', 'L' }, { 'M', 'U', 'R', 'K' }, { 'M', 'U', 'S', 'H' }, { 'M', 'U', 'S', 'T' }, { 'M', 'U', 'T', 'E' }, { 'M', 'U', 'T', 'T' }, { 'M', 'Y', 'R', 'A' }, { 'M', 'Y', 'T', 'H' }, { 'N', 'A', 'G', 'Y' }, { 'N', 'A', 'I', 'L' }, { 'N', 'A', 'I', 'R' }, { 'N', 'A', 'M', 'E' }, { 'N', 'A', 'R', 'Y' }, { 'N', 'A', 'S', 'H' }, { 'N', 'A', 'V', 'E' }, { 'N', 'A', 'V', 'Y' }, { 'N', 'E', 'A', 'L' }, { 'N', 'E', 'A', 'R' }, { 'N', 'E', 'A', 'T' }, { 'N', 'E', 'C', 'K' }, { 'N', 'E', 'E', 'D' }, { 'N', 'E', 'I', 'L' }, { 'N', 'E', 'L', 'L' }, { 'N', 'E', 'O', 'N' }, { 'N', 'E', 'R', 'O' }, { 'N', 'E', 'S', 'S' }, { 'N', 'E', 'S', 'T' }, { 'N', 'E', 'W', 'S' }, { 'N', 'E', 'W', 'T' }, { 'N', 'I', 'B', 'S' }, { 'N', 'I', 'C', 'E' }, { 'N', 'I', 'C', 'K' }, { 'N', 'I', 'L', 'E' }, { 'N', 'I', 'N', 'A' }, { 'N', 'I', 'N', 'E' }, { 'N', 'O', 'A', 'H' }, { 'N', 'O', 'D', 'E' }, { 'N', 'O', 'E', 'L' }, { 'N', 'O', 'L', 'L' }, { 'N', 'O', 'N', 'E' }, { 'N', 'O', 'O', 'K' }, { 'N', 'O', 'O', 'N' }, { 'N', 'O', 'R', 'M' }, { 'N', 'O', 'S', 'E' }, { 'N', 'O', 'T', 'E' }, { 'N', 'O', 'U', 'N' }, { 'N', 'O', 'V', 'A' }, { 'N', 'U', 'D', 'E' }, { 'N', 'U', 'L', 'L' }, { 'N', 'U', 'M', 'B' }, { 'O', 'A', 'T', 'H' }, { 'O', 'B', 'E', 'Y' }, { 'O', 'B', 'O', 'E' }, { 'O', 'D', 'I', 'N' }, { 'O', 'H', 'I', 'O' }, { 'O', 'I', 'L', 'Y' }, { 'O', 'I', 'N', 'T' }, { 'O', 'K', 'A', 'Y' }, { 'O', 'L', 'A', 'F' }, { 'O', 'L', 'D', 'Y' }, { 'O', 'L', 'G', 'A' }, { 'O', 'L', 'I', 'N' }, { 'O', 'M', 'A', 'N' }, { 'O', 'M', 'E', 'N' }, { 'O', 'M', 'I', 'T' }, { 'O', 'N', 'C', 'E' }, { 'O', 'N', 'E', 'S' }, { 'O', 'N', 'L', 'Y' }, { 'O', 'N', 'T', 'O' }, { 'O', 'N', 'U', 'S' }, { 'O', 'R', 'A', 'L' }, { 'O', 'R', 'G', 'Y' }, { 'O', 'S', 'L', 'O' }, { 'O', 'T', 'I', 'S' }, { 'O', 'T', 'T', 'O' }, { 'O', 'U', 'C', 'H' }, { 'O', 'U', 'S', 'T' }, { 'O', 'U', 'T', 'S' }, { 'O', 'V', 'A', 'L' }, { 'O', 'V', 'E', 'N' }, { 'O', 'V', 'E', 'R' }, { 'O', 'W', 'L', 'Y' }, { 'O', 'W', 'N', 'S' }, { 'Q', 'U', 'A', 'D' }, { 'Q', 'U', 'I', 'T' }, { 'Q', 'U', 'O', 'D' }, { 'R', 'A', 'C', 'E' }, { 'R', 'A', 'C', 'K' }, { 'R', 'A', 'C', 'Y' }, { 'R', 'A', 'F', 'T' }, { 'R', 'A', 'G', 'E' }, { 'R', 'A', 'I', 'D' }, { 'R', 'A', 'I', 'L' }, { 'R', 'A', 'I', 'N' }, { 'R', 'A', 'K', 'E' }, { 'R', 'A', 'N', 'K' }, { 'R', 'A', 'N', 'T' }, { 'R', 'A', 'R', 'E' }, { 'R', 'A', 'S', 'H' }, { 'R', 'A', 'T', 'E' }, { 'R', 'A', 'V', 'E' }, { 'R', 'A', 'Y', 'S' }, { 'R', 'E', 'A', 'D' }, { 'R', 'E', 'A', 'L' }, { 'R', 'E', 'A', 'M' }, { 'R', 'E', 'A', 'R' }, { 'R', 'E', 'C', 'K' }, { 'R', 'E', 'E', 'D' }, { 'R', 'E', 'E', 'F' }, { 'R', 'E', 'E', 'K' }, { 'R', 'E', 'E', 'L' }, { 'R', 'E', 'I', 'D' }, { 'R', 'E', 'I', 'N' }, { 'R', 'E', 'N', 'A' }, { 'R', 'E', 'N', 'D' }, { 'R', 'E', 'N', 'T' }, { 'R', 'E', 'S', 'T' }, { 'R', 'I', 'C', 'E' }, { 'R', 'I', 'C', 'H' }, { 'R', 'I', 'C', 'K' }, { 'R', 'I', 'D', 'E' }, { 'R', 'I', 'F', 'T' }, { 'R', 'I', 'L', 'L' }, { 'R', 'I', 'M', 'E' }, { 'R', 'I', 'N', 'G' }, { 'R', 'I', 'N', 'K' }, { 'R', 'I', 'S', 'E' }, { 'R', 'I', 'S', 'K' }, { 'R', 'I', 'T', 'E' }, { 'R', 'O', 'A', 'D' }, { 'R', 'O', 'A', 'M' }, { 'R', 'O', 'A', 'R' }, { 'R', 'O', 'B', 'E' }, { 'R', 'O', 'C', 'K' }, { 'R', 'O', 'D', 'E' }, { 'R', 'O', 'I', 'L' }, { 'R', 'O', 'L', 'L' }, { 'R', 'O', 'M', 'E' }, { 'R', 'O', 'O', 'D' }, { 'R', 'O', 'O', 'F' }, { 'R', 'O', 'O', 'K' }, { 'R', 'O', 'O', 'M' }, { 'R', 'O', 'O', 'T' }, { 'R', 'O', 'S', 'A' }, { 'R', 'O', 'S', 'E' }, { 'R', 'O', 'S', 'S' }, { 'R', 'O', 'S', 'Y' }, { 'R', 'O', 'T', 'H' }, { 'R', 'O', 'U', 'T' }, { 'R', 'O', 'V', 'E' }, { 'R', 'O', 'W', 'E' }, { 'R', 'O', 'W', 'S' }, { 'R', 'U', 'B', 'E' }, { 'R', 'U', 'B', 'Y' }, { 'R', 'U', 'D', 'E' }, { 'R', 'U', 'D', 'Y' }, { 'R', 'U', 'I', 'N' }, { 'R', 'U', 'L', 'E' }, { 'R', 'U', 'N', 'G' }, { 'R', 'U', 'N', 'S' }, { 'R', 'U', 'N', 'T' }, { 'R', 'U', 'S', 'E' }, { 'R', 'U', 'S', 'H' }, { 'R', 'U', 'S', 'K' }, { 'R', 'U', 'S', 'S' }, { 'R', 'U', 'S', 'T' }, { 'R', 'U', 'T', 'H' }, { 'S', 'A', 'C', 'K' }, { 'S', 'A', 'F', 'E' }, { 'S', 'A', 'G', 'E' }, { 'S', 'A', 'I', 'D' }, { 'S', 'A', 'I', 'L' }, { 'S', 'A', 'L', 'E' }, { 'S', 'A', 'L', 'K' }, { 'S', 'A', 'L', 'T' }, { 'S', 'A', 'M', 'E' }, { 'S', 'A', 'N', 'D' }, { 'S', 'A', 'N', 'E' }, { 'S', 'A', 'N', 'G' }, { 'S', 'A', 'N', 'K' }, { 'S', 'A', 'R', 'A' }, { 'S', 'A', 'U', 'L' }, { 'S', 'A', 'V', 'E' }, { 'S', 'A', 'Y', 'S' }, { 'S', 'C', 'A', 'N' }, { 'S', 'C', 'A', 'R' }, { 'S', 'C', 'A', 'T' }, { 'S', 'C', 'O', 'T' }, { 'S', 'E', 'A', 'L' }, { 'S', 'E', 'A', 'M' }, { 'S', 'E', 'A', 'R' }, { 'S', 'E', 'A', 'T' }, { 'S', 'E', 'E', 'D' }, { 'S', 'E', 'E', 'K' }, { 'S', 'E', 'E', 'M' }, { 'S', 'E', 'E', 'N' }, { 'S', 'E', 'E', 'S' }, { 'S', 'E', 'L', 'F' }, { 'S', 'E', 'L', 'L' }, { 'S', 'E', 'N', 'D' }, { 'S', 'E', 'N', 'T' }, { 'S', 'E', 'T', 'S' }, { 'S', 'E', 'W', 'N' }, { 'S', 'H', 'A', 'G' }, { 'S', 'H', 'A', 'M' }, { 'S', 'H', 'A', 'W' }, { 'S', 'H', 'A', 'Y' }, { 'S', 'H', 'E', 'D' }, { 'S', 'H', 'I', 'M' }, { 'S', 'H', 'I', 'N' }, { 'S', 'H', 'O', 'D' }, { 'S', 'H', 'O', 'E' }, { 'S', 'H', 'O', 'T' }, { 'S', 'H', 'O', 'W' }, { 'S', 'H', 'U', 'N' }, { 'S', 'H', 'U', 'T' }, { 'S', 'I', 'C', 'K' }, { 'S', 'I', 'D', 'E' }, { 'S', 'I', 'F', 'T' }, { 'S', 'I', 'G', 'H' }, { 'S', 'I', 'G', 'N' }, { 'S', 'I', 'L', 'K' }, { 'S', 'I', 'L', 'L' }, { 'S', 'I', 'L', 'O' }, { 'S', 'I', 'L', 'T' }, { 'S', 'I', 'N', 'E' }, { 'S', 'I', 'N', 'G' }, { 'S', 'I', 'N', 'K' }, { 'S', 'I', 'R', 'E' }, { 'S', 'I', 'T', 'E' }, { 'S', 'I', 'T', 'S' }, { 'S', 'I', 'T', 'U' }, { 'S', 'K', 'A', 'T' }, { 'S', 'K', 'E', 'W' }, { 'S', 'K', 'I', 'D' }, { 'S', 'K', 'I', 'M' }, { 'S', 'K', 'I', 'N' }, { 'S', 'K', 'I', 'T' }, { 'S', 'L', 'A', 'B' }, { 'S', 'L', 'A', 'M' }, { 'S', 'L', 'A', 'T' }, { 'S', 'L', 'A', 'Y' }, { 'S', 'L', 'E', 'D' }, { 'S', 'L', 'E', 'W' }, { 'S', 'L', 'I', 'D' }, { 'S', 'L', 'I', 'M' }, { 'S', 'L', 'I', 'T' }, { 'S', 'L', 'O', 'B' }, { 'S', 'L', 'O', 'G' }, { 'S', 'L', 'O', 'T' }, { 'S', 'L', 'O', 'W' }, { 'S', 'L', 'U', 'G' }, { 'S', 'L', 'U', 'M' }, { 'S', 'L', 'U', 'R' }, { 'S', 'M', 'O', 'G' }, { 'S', 'M', 'U', 'G' }, { 'S', 'N', 'A', 'G' }, { 'S', 'N', 'O', 'B' }, { 'S', 'N', 'O', 'W' }, { 'S', 'N', 'U', 'B' }, { 'S', 'N', 'U', 'G' }, { 'S', 'O', 'A', 'K' }, { 'S', 'O', 'A', 'R' }, { 'S', 'O', 'C', 'K' }, { 'S', 'O', 'D', 'A' }, { 'S', 'O', 'F', 'A' }, { 'S', 'O', 'F', 'T' }, { 'S', 'O', 'I', 'L' }, { 'S', 'O', 'L', 'D' }, { 'S', 'O', 'M', 'E' }, { 'S', 'O', 'N', 'G' }, { 'S', 'O', 'O', 'N' }, { 'S', 'O', 'O', 'T' }, { 'S', 'O', 'R', 'E' }, { 'S', 'O', 'R', 'T' }, { 'S', 'O', 'U', 'L' }, { 'S', 'O', 'U', 'R' }, { 'S', 'O', 'W', 'N' }, { 'S', 'T', 'A', 'B' }, { 'S', 'T', 'A', 'G' }, { 'S', 'T', 'A', 'N' }, { 'S', 'T', 'A', 'R' }, { 'S', 'T', 'A', 'Y' }, { 'S', 'T', 'E', 'M' }, { 'S', 'T', 'E', 'W' }, { 'S', 'T', 'I', 'R' }, { 'S', 'T', 'O', 'W' }, { 'S', 'T', 'U', 'B' }, { 'S', 'T', 'U', 'N' }, { 'S', 'U', 'C', 'H' }, { 'S', 'U', 'D', 'S' }, { 'S', 'U', 'I', 'T' }, { 'S', 'U', 'L', 'K' }, { 'S', 'U', 'M', 'S' }, { 'S', 'U', 'N', 'G' }, { 'S', 'U', 'N', 'K' }, { 'S', 'U', 'R', 'E' }, { 'S', 'U', 'R', 'F' }, { 'S', 'W', 'A', 'B' }, { 'S', 'W', 'A', 'G' }, { 'S', 'W', 'A', 'M' }, { 'S', 'W', 'A', 'N' }, { 'S', 'W', 'A', 'T' }, { 'S', 'W', 'A', 'Y' }, { 'S', 'W', 'I', 'M' }, { 'S', 'W', 'U', 'M' }, { 'T', 'A', 'C', 'K' }, { 'T', 'A', 'C', 'T' }, { 'T', 'A', 'I', 'L' }, { 'T', 'A', 'K', 'E' }, { 'T', 'A', 'L', 'E' }, { 'T', 'A', 'L', 'K' }, { 'T', 'A', 'L', 'L' }, { 'T', 'A', 'N', 'K' }, { 'T', 'A', 'S', 'K' }, { 'T', 'A', 'T', 'E' }, { 'T', 'A', 'U', 'T' }, { 'T', 'E', 'A', 'L' }, { 'T', 'E', 'A', 'M' }, { 'T', 'E', 'A', 'R' }, { 'T', 'E', 'C', 'H' }, { 'T', 'E', 'E', 'M' }, { 'T', 'E', 'E', 'N' }, { 'T', 'E', 'E', 'T' }, { 'T', 'E', 'L', 'L' }, { 'T', 'E', 'N', 'D' }, { 'T', 'E', 'N', 'T' }, { 'T', 'E', 'R', 'M' }, { 'T', 'E', 'R', 'N' }, { 'T', 'E', 'S', 'S' }, { 'T', 'E', 'S', 'T' }, { 'T', 'H', 'A', 'N' }, { 'T', 'H', 'A', 'T' }, { 'T', 'H', 'E', 'E' }, { 'T', 'H', 'E', 'M' }, { 'T', 'H', 'E', 'N' }, { 'T', 'H', 'E', 'Y' }, { 'T', 'H', 'I', 'N' }, { 'T', 'H', 'I', 'S' }, { 'T', 'H', 'U', 'D' }, { 'T', 'H', 'U', 'G' }, { 'T', 'I', 'C', 'K' }, { 'T', 'I', 'D', 'E' }, { 'T', 'I', 'D', 'Y' }, { 'T', 'I', 'E', 'D' }, { 'T', 'I', 'E', 'R' }, { 'T', 'I', 'L', 'E' }, { 'T', 'I', 'L', 'L' }, { 'T', 'I', 'L', 'T' }, { 'T', 'I', 'M', 'E' }, { 'T', 'I', 'N', 'A' }, { 'T', 'I', 'N', 'E' }, { 'T', 'I', 'N', 'T' }, { 'T', 'I', 'N', 'Y' }, { 'T', 'I', 'R', 'E' }, { 'T', 'O', 'A', 'D' }, { 'T', 'O', 'G', 'O' }, { 'T', 'O', 'I', 'L' }, { 'T', 'O', 'L', 'D' }, { 'T', 'O', 'L', 'L' }, { 'T', 'O', 'N', 'E' }, { 'T', 'O', 'N', 'G' }, { 'T', 'O', 'N', 'Y' }, { 'T', 'O', 'O', 'K' }, { 'T', 'O', 'O', 'L' }, { 'T', 'O', 'O', 'T' }, { 'T', 'O', 'R', 'E' }, { 'T', 'O', 'R', 'N' }, { 'T', 'O', 'T', 'E' }, { 'T', 'O', 'U', 'R' }, { 'T', 'O', 'U', 'T' }, { 'T', 'O', 'W', 'N' }, { 'T', 'R', 'A', 'G' }, { 'T', 'R', 'A', 'M' }, { 'T', 'R', 'A', 'Y' }, { 'T', 'R', 'E', 'E' }, { 'T', 'R', 'E', 'K' }, { 'T', 'R', 'I', 'G' }, { 'T', 'R', 'I', 'M' }, { 'T', 'R', 'I', 'O' }, { 'T', 'R', 'O', 'D' }, { 'T', 'R', 'O', 'T' }, { 'T', 'R', 'O', 'Y' }, { 'T', 'R', 'U', 'E' }, { 'T', 'U', 'B', 'A' }, { 'T', 'U', 'B', 'E' }, { 'T', 'U', 'C', 'K' }, { 'T', 'U', 'F', 'T' }, { 'T', 'U', 'N', 'A' }, { 'T', 'U', 'N', 'E' }, { 'T', 'U', 'N', 'G' }, { 'T', 'U', 'R', 'F' }, { 'T', 'U', 'R', 'N' }, { 'T', 'U', 'S', 'K' }, { 'T', 'W', 'I', 'G' }, { 'T', 'W', 'I', 'N' }, { 'T', 'W', 'I', 'T' }, { 'U', 'L', 'A', 'N' }, { 'U', 'N', 'I', 'T' }, { 'U', 'R', 'G', 'E' }, { 'U', 'S', 'E', 'D' }, { 'U', 'S', 'E', 'R' }, { 'U', 'S', 'E', 'S' }, { 'U', 'T', 'A', 'H' }, { 'V', 'A', 'I', 'L' }, { 'V', 'A', 'I', 'N' }, { 'V', 'A', 'L', 'E' }, { 'V', 'A', 'R', 'Y' }, { 'V', 'A', 'S', 'E' }, { 'V', 'A', 'S', 'T' }, { 'V', 'E', 'A', 'L' }, { 'V', 'E', 'D', 'A' }, { 'V', 'E', 'I', 'L' }, { 'V', 'E', 'I', 'N' }, { 'V', 'E', 'N', 'D' }, { 'V', 'E', 'N', 'T' }, { 'V', 'E', 'R', 'B' }, { 'V', 'E', 'R', 'Y' }, { 'V', 'E', 'T', 'O' }, { 'V', 'I', 'C', 'E' }, { 'V', 'I', 'E', 'W' }, { 'V', 'I', 'N', 'E' }, { 'V', 'I', 'S', 'E' }, { 'V', 'O', 'I', 'D' }, { 'V', 'O', 'L', 'T' }, { 'V', 'O', 'T', 'E' }, { 'W', 'A', 'C', 'K' }, { 'W', 'A', 'D', 'E' }, { 'W', 'A', 'G', 'E' }, { 'W', 'A', 'I', 'L' }, { 'W', 'A', 'I', 'T' }, { 'W', 'A', 'K', 'E' }, { 'W', 'A', 'L', 'E' }, { 'W', 'A', 'L', 'K' }, { 'W', 'A', 'L', 'L' }, { 'W', 'A', 'L', 'T' }, { 'W', 'A', 'N', 'D' }, { 'W', 'A', 'N', 'E' }, { 'W', 'A', 'N', 'G' }, { 'W', 'A', 'N', 'T' }, { 'W', 'A', 'R', 'D' }, { 'W', 'A', 'R', 'M' }, { 'W', 'A', 'R', 'N' }, { 'W', 'A', 'R', 'T' }, { 'W', 'A', 'S', 'H' }, { 'W', 'A', 'S', 'T' }, { 'W', 'A', 'T', 'S' }, { 'W', 'A', 'T', 'T' }, { 'W', 'A', 'V', 'E' }, { 'W', 'A', 'V', 'Y' }, { 'W', 'A', 'Y', 'S' }, { 'W', 'E', 'A', 'K' }, { 'W', 'E', 'A', 'L' }, { 'W', 'E', 'A', 'N' }, { 'W', 'E', 'A', 'R' }, { 'W', 'E', 'E', 'D' }, { 'W', 'E', 'E', 'K' }, { 'W', 'E', 'I', 'R' }, { 'W', 'E', 'L', 'D' }, { 'W', 'E', 'L', 'L' }, { 'W', 'E', 'L', 'T' }, { 'W', 'E', 'N', 'T' }, { 'W', 'E', 'R', 'E' }, { 'W', 'E', 'R', 'T' }, { 'W', 'E', 'S', 'T' }, { 'W', 'H', 'A', 'M' }, { 'W', 'H', 'A', 'T' }, { 'W', 'H', 'E', 'E' }, { 'W', 'H', 'E', 'N' }, { 'W', 'H', 'E', 'T' }, { 'W', 'H', 'O', 'A' }, { 'W', 'H', 'O', 'M' }, { 'W', 'I', 'C', 'K' }, { 'W', 'I', 'F', 'E' }, { 'W', 'I', 'L', 'D' }, { 'W', 'I', 'L', 'L' }, { 'W', 'I', 'N', 'D' }, { 'W', 'I', 'N', 'E' }, { 'W', 'I', 'N', 'G' }, { 'W', 'I', 'N', 'K' }, { 'W', 'I', 'N', 'O' }, { 'W', 'I', 'R', 'E' }, { 'W', 'I', 'S', 'E' }, { 'W', 'I', 'S', 'H' }, { 'W', 'I', 'T', 'H' }, { 'W', 'O', 'L', 'F' }, { 'W', 'O', 'N', 'T' }, { 'W', 'O', 'O', 'D' }, { 'W', 'O', 'O', 'L' }, { 'W', 'O', 'R', 'D' }, { 'W', 'O', 'R', 'E' }, { 'W', 'O', 'R', 'K' }, { 'W', 'O', 'R', 'M' }, { 'W', 'O', 'R', 'N' }, { 'W', 'O', 'V', 'E' }, { 'W', 'R', 'I', 'T' }, { 'W', 'Y', 'N', 'N' }, { 'Y', 'A', 'L', 'E' }, { 'Y', 'A', 'N', 'G' }, { 'Y', 'A', 'N', 'K' }, { 'Y', 'A', 'R', 'D' }, { 'Y', 'A', 'R', 'N' }, { 'Y', 'A', 'W', 'L' }, { 'Y', 'A', 'W', 'N' }, { 'Y', 'E', 'A', 'H' }, { 'Y', 'E', 'A', 'R' }, { 'Y', 'E', 'L', 'L' }, { 'Y', 'O', 'G', 'A' }, { 'Y', 'O', 'K', 'E' } }; /* Extract LENGTH bits from the char array S starting with bit number START. It always reads three consecutive octects, which means it can read past end of data when START is at the edge of the region. */ static uint32_t extract (const unsigned char *s, int start, int length) { unsigned char cl = s[start / 8]; unsigned char cc = s[start / 8 + 1]; unsigned char cr = s[start / 8 + 2]; uint32_t x; x = (uint32_t)(cl << 8 | cc) << 8 | cr; x >>= 24 - (length + (start % 8)); x &= (0xffff >> (16 - length)); return x; } /* Length of a string known to be at least 1 and at most 4 chars long. */ #define STRLEN_1_4(s) (!(s)[1] ? 1 : !(s)[2] ? 2 : !(s)[3] ? 3 : 4) /* Encode 8 bytes in C as a string of English words and store them to STORE. Returns STORE. */ static char * btoe (char *store, const unsigned char *c) { unsigned char cp[10]; /* add in room for the parity 2 bits + extract() slop. */ int p, i; char *store_beg = store; *store = '\0'; /* Workaround for extract() reads beyond end of data */ memset (cp, 0, sizeof(cp)); memcpy (cp, c, 8); /* Compute parity and append it to CP. */ for (p = 0, i = 0; i < 64; i += 2) p += extract (cp, i, 2); cp[8] = (char)p << 6; /* The 64 bits of input and the two parity bits comprise 66 bits of data that are now in CP. We convert that information, 11 bits at a time, to English words indexed from Wp. Since there are 2048 (2^11) words in Wp, every 11-bit combination corresponds to a distinct word. */ memcpy (store, &Wp[extract (cp, 0, 11)][0], 4); store += STRLEN_1_4 (store); *store++ = ' '; memcpy (store, &Wp[extract (cp, 11, 11)][0], 4); store += STRLEN_1_4 (store); *store++ = ' '; memcpy (store, &Wp[extract (cp, 22, 11)][0], 4); store += STRLEN_1_4 (store); *store++ = ' '; memcpy (store, &Wp[extract (cp, 33, 11)][0], 4); store += STRLEN_1_4 (store); *store++ = ' '; memcpy (store, &Wp[extract (cp, 44, 11)][0], 4); store += STRLEN_1_4 (store); *store++ = ' '; memcpy (store, &Wp[extract (cp, 55, 11)][0], 4); store[4] = '\0'; /* make sure the string is terminated */ /* DEBUGP (("wrote %s to STORE\n", quote (store_beg)));*/ return store_beg; } /* Calculate the SKEY response, based on the sequence, seed (challenge), and the secret password. The calculated response is used instead of the real password when logging in to SKEY-enabled servers. The result is calculated like this: + Concatenate SEED and PASS and calculate the 16-byte MD5 checksum. + Shorten the checksum to eight bytes by folding the second eight bytes onto the first eight using XOR. The resulting eight-byte sequence is the key. + MD5-process the key, fold the checksum to eight bytes and store it back to the key. Repeat this crunching SEQUENCE times. (Sequence is a number that gets decremented every time the user logs in to the server. Therefore an eavesdropper would have to invert the hash function in order to guess the next one-time password.) + Convert the resulting 64-bit key to 6 English words separated by spaces (see btoe for details) and return the resulting ASCII string. All this is described in section 6 of rfc2289 in more detail. */ const char * calculate_skey_response (int sequence, const char *seed, const char *pass) { unsigned char key[8]; /* Room to hold 6 four-letter words (heh), 5 space separators, and the terminating \0. 24+5+1 == 30 */ static char english[30]; struct md5_ctx ctx; uint32_t checksum[4]; md5_init_ctx (&ctx); md5_process_bytes ((const unsigned char *) seed, strlen (seed), &ctx); md5_process_bytes ((const unsigned char *) pass, strlen (pass), &ctx); md5_finish_ctx (&ctx, (unsigned char *) checksum); checksum[0] ^= checksum[2]; checksum[1] ^= checksum[3]; memcpy (key, checksum, 8); while (sequence-- > 0) { md5_init_ctx (&ctx); md5_process_bytes ((unsigned char *) key, 8, &ctx); md5_finish_ctx (&ctx, (unsigned char *) checksum); checksum[0] ^= checksum[2]; checksum[1] ^= checksum[3]; memcpy (key, checksum, 8); } return btoe (english, key); } lftp-4.6.3a/src/TreatFileJob.cc0000644000015000007670000000442012122060752013160 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "TreatFileJob.h" #include "StatusLine.h" #include "ArgV.h" #include "misc.h" TreatFileJob::TreatFileJob(FileAccess *s,ArgV *a) : FinderJob(s), args(a) { quiet=false; failed=file_count=0; Need(FileInfo::NAME); curr=0; set_maxdepth(0); op=args->a0(); Begin(a->getcurr()); } /* process a new directory */ void TreatFileJob::Begin(const char *d) { NextDir(d); } void TreatFileJob::Finish() { /* next? */ const char *d=args->getnext(); if(d) { /* we have another argument */ Begin(d); return; } } TreatFileJob::~TreatFileJob() { } TreatFileJob::prf_res TreatFileJob::ProcessFile(const char *d,const FileInfo *fi) { curr=fi; if(session->IsClosed()) { if(!first) first=new FileInfo(*fi); TreatCurrent(d,fi); } int res=session->Done(); if(res==FA::IN_PROGRESS) return PRF_LATER; curr=0; file_count++; if(res<0) { failed++; if(!quiet) eprintf("%s: %s\n",op,session->StrError(res)); } CurrentFinished(d,fi); session->Close(); return res<0? PRF_ERR:PRF_OK; } xstring& TreatFileJob::FormatStatus(xstring& s,int v,const char *prefix) { SessionJob::FormatStatus(s,v,prefix); if(Done() || !curr) return s; return s.appendf("\t`%s' [%s]\n",curr->name.get(),session->CurrentStatus()); } void TreatFileJob::ShowRunStatus(const SMTaskRef& s) { if(curr && !Done()) s->Show("%s `%s' [%s]",op,curr->name.get(),session->CurrentStatus()); } lftp-4.6.3a/src/FileCopy.h0000644000015000007670000002634412412737701012242 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ /* classes defined here: FileCopy FileCopyPeer +FileCopyPeerFA +FileCopyPeerFDStream \FileCopyPeerList */ #ifndef FILECOPY_H #define FILECOPY_H #include "SMTask.h" #include "buffer.h" #include "FileAccess.h" #include "Speedometer.h" #include "Timer.h" #include "log.h" class FileCopyPeer : public IOBuffer { protected: bool want_size; bool want_date; bool start_transfer; off_t size; off_t e_size; FileTimestamp date; off_t seek_pos; bool can_seek; bool can_seek0; bool date_set; bool do_set_date; bool do_verify; bool removing; bool file_removed; bool temp_file; bool done; bool ascii; bool use_cache; bool write_allowed; xstring_c suggested_filename; bool auto_rename; public: off_t range_start; // NOTE: ranges are implemented only partially. (FIXME) off_t range_limit; bool CanSeek() { return can_seek; } bool CanSeek0() { return can_seek0; } bool CanSeek(off_t p) { return p==0 ? CanSeek0() : CanSeek(); } off_t GetSeekPos() { return seek_pos; } virtual void Seek(off_t offs); virtual off_t GetRealPos() { return pos; } virtual int Buffered() { return Size(); } virtual bool IOReady() { return true; } virtual void WantDate() { want_date=true; date=NO_DATE_YET; } virtual void WantSize() { want_size=true; size=NO_SIZE_YET; } time_t GetDate() { return date; } off_t GetSize(); void SetDate(time_t d,int p=0); void SetSize(off_t s); void SetEntitySize(off_t s) { e_size=s; } void DontCopyDate() { do_set_date=false; } void DontVerify() { do_verify=false; } bool NeedDate() { return do_set_date; } void SetRange(const off_t s,const off_t lim); FileCopyPeer(dir_t m); virtual ~FileCopyPeer() {} bool Done(); void Ascii() { ascii=true; } virtual void NoCache() { use_cache=false; } virtual const char *GetStatus() { return 0; } virtual bool NeedSizeDateBeforehand() { return false; } virtual pid_t GetProcGroup() { return 0; } virtual void Kill(int sig) {} virtual void RemoveFile() { file_removed=true; } virtual void NeedSeek() {} // fd is shared, seek before access. void CannotSeek(int p) { can_seek=false; if(p==0) can_seek0=false; } // for fxp: virtual const FileAccessRef& GetSession() { return FileAccessRef::null; } virtual void OpenSession() {} virtual void SetFXP(bool) {} virtual void Fg() {} virtual void Bg() {} void AllowWrite(bool y=true) { write_allowed=y; } bool WriteAllowed() { return write_allowed; } bool WritePending() { return mode==PUT && Size()>0; } bool FileRemoved() { return file_removed; } void DontStartTransferYet() { start_transfer=false; } void StartTransfer() { start_transfer=true; } const char *GetDescriptionForLog() { return 0; } virtual const char *GetURL() { return 0; } virtual FileCopyPeer *Clone() { return 0; } virtual const Ref& GetLocal() const { return Ref::null; } const char *GetSuggestedFileName() { return suggested_filename; } void SetSuggestedFileName(const char *f) { if(f) suggested_filename.set(f); } void AutoRename(bool yes=true) { auto_rename=yes; } const char *UseTempFile(const char *); }; class FileCopy : public SMTask { public: SMTaskRef get; SMTaskRef put; protected: enum state_t { INITIAL, GET_INFO_WAIT, PUT_WAIT, DO_COPY, CONFIRM_WAIT, GET_DONE_WAIT, ALL_DONE } state; private: bool cont; xstring_c error_text; Speedometer rate; Speedometer rate_for_eta; int put_buf; off_t put_eof_pos; Time start_time; Time end_time; bool fail_if_cannot_seek; bool fail_if_broken; bool remove_source_later; bool remove_target_first; Ref line_buffer; int line_buffer_max; bool CheckFileSizeAtEOF() const; protected: void RateAdd(int a); void RateReset(); off_t bytes_count; public: off_t GetPos() const; off_t GetSize() const; int GetPercentDone() const; const char *GetPercentDoneStr() const; float GetRate(); const char *GetRateStr(); off_t GetBytesRemaining(); long GetETA() { return GetETA(GetBytesRemaining()); } long GetETA(off_t b); const char *GetETAStr(); const char *GetETAStrSFromTime(time_t t) { return rate_for_eta.GetETAStrSFromTime(t); } const char *GetStatus(); FgData *GetFgData(bool fg); pid_t GetProcGroup(); void Kill(int sig); off_t GetBytesCount() { return bytes_count; } double GetTimeSpent(); double GetTransferRate() { return rate.Get(); } void SetDate(time_t t,int p=0) { get->SetDate(t,p); } void SetDate(const FileTimestamp &t) { SetDate(t.ts,t.ts_prec); } void SetSize(off_t s) { get->SetSize(s); } bool SetContinue(bool new_cont) { return replace_value(cont,new_cont); } bool Done() { return state==ALL_DONE; } bool Error() { return error_text!=0; } const char *ErrorText() { return error_text; } void SetError(const char *str); void DontCopyDate() { put->DontCopyDate(); } void DontVerify() { put->DontVerify(); } void Ascii() { get->Ascii(); put->Ascii(); } void DontFailIfBroken() { fail_if_broken=false; } void FailIfCannotSeek() { fail_if_cannot_seek=true; } void SetRange(off_t s,off_t lim); void SetRangeLimit(off_t lim) { get->range_limit=lim; } off_t GetRangeStart() const { return get->range_start; } off_t GetRangeLimit() const { return get->range_limit; } void RemoveSourceLater() { remove_source_later=true; } void RemoveTargetFirst() { remove_target_first=true; put->Resume(); put->RemoveFile(); } void LineBuffered(int size=0x1000); bool IsLineBuffered() const { return line_buffer; } FileCopy(FileCopyPeer *src,FileCopyPeer *dst,bool cont); ~FileCopy(); int Do(); void SuspendInternal(); void ResumeInternal(); void Fg(); void Bg(); static FileCopy *New(FileCopyPeer *src,FileCopyPeer *dst,bool cont); static FileCopy *(*fxp_create)(FileCopyPeer *src,FileCopyPeer *dst,bool cont); void AllowWrite(bool y=true) { if(put) put->AllowWrite(y); } bool WriteAllowed() { return !put || put->WriteAllowed(); } bool WritePending() { return put && put->WritePending(); } void LogTransfer(); static SMTaskRef transfer_log; }; class FileVerificator : public SMTask { bool done; xstring error_text; SMTaskRef verify_buffer; Ref verify_process; void Init0(); void InitVerify(const char *f); public: FileVerificator(const char *f); FileVerificator(const FDStream *); FileVerificator(const FileAccess *,const char *f); ~FileVerificator(); int Do(); bool Done() { return done; } bool Error() { return error_text!=0; } const char *ErrorText() { return error_text; } const char *Status() { return _("Verifying..."); }; }; class FileCopyPeerFA : public FileCopyPeer { xstring_c file; xstring orig_url; FileAccessRef my_session; FileAccessRefC session; int FAmode; int Get_LL(int size); int Put_LL(const char *buf,int size); int PutEOF_LL(); // to read data in larger quantities, delay the read op Timer get_ll_timer; int get_delay; FileSet info; bool fxp; // FXP (ftp<=>ftp copy) active UploadState upload_state; int redirections; SMTaskRef verify; protected: void PrepareToDie(); ~FileCopyPeerFA(); public: void Init(); FileCopyPeerFA(FileAccess *s,const char *f,int m); FileCopyPeerFA(const FileAccessRef& s,const char *f,int m); FileCopyPeerFA(const class ParsedURL *u,int m); int Do(); bool IOReady(); off_t GetRealPos(); void Seek(off_t new_pos); int Buffered() { return Size()+session->Buffered(); } void SuspendInternal(); void ResumeInternal(); const char *GetStatus(); const char *GetProto() const { return session->GetProto(); } bool NeedSizeDateBeforehand() { return session->NeedSizeDateBeforehand(); } void WantSize(); void RemoveFile(); static FileCopyPeerFA *New(FA *s,const char *url,int m); static FileCopyPeerFA *New(const FileAccessRef& s,const char *url,int m); void OpenSession(); const FileAccessRef& GetSession() { return session; } void Fg() { session->SetPriority(1); } void Bg() { session->SetPriority(0); } void SetFXP(bool on) { fxp=on; } const char *GetDescriptionForLog() { return orig_url ? orig_url.get() : session->GetFileURL(file); } const char *GetURL() { return GetDescriptionForLog(); } FileCopyPeer *Clone(); }; class FileCopyPeerFDStream : public FileCopyPeer { Ref my_stream; const Ref& stream; off_t seek_base; Ref put_ll_timer; int Get_LL(int size); int Put_LL(const char *buf,int size); void Seek_LL(); int getfd(); bool create_fg_data; bool need_seek; bool close_when_done; SMTaskRef verify; public: void Init(); FileCopyPeerFDStream(const Ref& o,dir_t m); FileCopyPeerFDStream(FDStream *o,dir_t m); int Do(); bool IOReady(); void Seek(off_t new_pos); FgData *GetFgData(bool fg); pid_t GetProcGroup() { return stream->GetProcGroup(); } void Kill(int sig); void DontCreateFgData() { create_fg_data=false; } void NeedSeek() { need_seek=true; } void CloseWhenDone() { close_when_done=true; } void WantSize(); void RemoveFile(); void SetBase(off_t b) { seek_base=b; } const char *GetStatus(); static FileCopyPeerFDStream *NewPut(const char *file,bool cont=false); static FileCopyPeerFDStream *NewGet(const char *file); const char *GetDescriptionForLog() { return stream->name; } const char *GetURL() { return stream->full_name; } const Ref& GetLocal() const { return stream; } FileCopyPeer *Clone(); }; class FileCopyPeerDirList : public FileCopyPeer { private: FileAccessRef session; SMTaskRef dl; public: FileCopyPeerDirList(FA *s,ArgV *v); // consumes s and v. int Do(); void NoCache() { use_cache=false; if(dl) dl->UseCache(false); } void Fg() { session->SetPriority(1); } void Bg() { session->SetPriority(0); } const char *GetStatus() { return session->CurrentStatus(); } void UseColor(bool c=true) { if(dl) dl->UseColor(c); } }; class FileCopyPeerMemory : public FileCopyPeer { private: int max_size; public: FileCopyPeerMemory(int m) : FileCopyPeer(PUT), max_size(m) {} FileCopyPeerMemory(const xstring& s) : FileCopyPeer(GET), max_size(0) { Put(s); PutEOF(); size=s.length(); pos=0; } int Do(); bool Done() { return true; } }; #endif lftp-4.6.3a/src/FileSetOutput.h0000644000015000007670000000642612340617470013303 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FILESETOUTPUT_H #define FILESETOUTPUT_H #include "FileSet.h" #include "buffer.h" #include "keyvalue.h" #include "FileCopy.h" #include "GetFileInfo.h" #include "CopyJob.h" #include "OutputJob.h" #include "Job.h" class StatusLine; class FileSetOutput { const char *FileInfoSuffix(const FileInfo &fi) const; public: bool classify; // add / (dir) @ (link) // TODO: extra-optional * for exec? maybe not, some servers stick +x on everything int width; // width to output, 0 to force one column bool color; enum { NONE=0, PERMS = 0x1, SIZE = 0x2, DATE = 0x4, LINKS = 0x8, USER = 0x10, GROUP = 0x20, NLINKS = 0x40, ALL=PERMS|SIZE|DATE|LINKS|USER|GROUP|NLINKS }; int mode; xstring_c pat; xstring_c time_fmt; bool basenames; bool showdots; bool quiet; bool patterns_casefold; bool sort_casefold; bool sort_reverse; bool sort_dirs_first; bool size_filesonly; bool single_column; bool list_directories; bool need_exact_time; int output_block_size; int human_opts; FileSet::sort_e sort; FileSetOutput(): classify(0), width(0), color(false), mode(NONE), basenames(false), showdots(false), quiet(false), patterns_casefold(false), sort_casefold(false), sort_reverse(false), sort_dirs_first(false), size_filesonly(false), single_column(false), list_directories(false), need_exact_time(false), output_block_size(0), human_opts(0), sort(FileSet::BYNAME) { } void long_list(); void config(const OutputJob *fd); const char *parse_argv(const Ref& a); const char *parse_res(const char *res); static const char *ValidateArgv(xstring_c *s); int Need() const; void print(FileSet &fs, const JobRef& o) const; }; /* Job interface to FileSetOutput */ class clsJob : public SessionJob { JobRef output; Ref fso; Ref args; SMTaskRef list_info; xstring_c dir; xstring_c mask; bool done; bool use_cache; bool error; enum { INIT, START_LISTING, GETTING_LIST_INFO, DONE } state; public: clsJob(FA *s, ArgV *a, FileSetOutput *_opts, OutputJob *output); int Done(); int Do(); void UseCache(bool y=true) { use_cache=y; } void Fg() { session->SetPriority(1); output->Fg(); } void Bg() { session->SetPriority(0); output->Bg(); } void SuspendInternal(); void ResumeInternal(); int ExitCode() { return error||output->Error() ? 1 : 0; } void ShowRunStatus(const SMTaskRef&); xstring& FormatStatus(xstring&,int v,const char *); }; #endif lftp-4.6.3a/src/Cache.h0000644000015000007670000000317512122057137011524 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef CACHE_H #define CACHE_H #include "Timer.h" class CacheEntry : public Timer { friend class Cache; CacheEntry *next; public: CacheEntry() { next=0; } virtual int EstimateSize() const { return 1; } virtual ~CacheEntry() {} }; class Cache { const ResType *res_max_size; const ResType *res_enable; protected: CacheEntry *chain; CacheEntry **curr; CacheEntry *IterateFirst(); CacheEntry *IterateNext(); CacheEntry *IterateDelete(); public: void Trim(); void Flush(); Cache(const ResType *s,const ResType *e) { res_max_size=s; res_enable=e; chain=0; curr=0; } ~Cache() { Flush(); } bool IsEnabled(const char *closure) { return res_enable->QueryBool(closure); } long SizeLimit() { return res_max_size->Query(0); } void AddCacheEntry(CacheEntry *e) { e->next=chain; chain=e; } }; #endif//CACHE_H lftp-4.6.3a/src/DummyProto.cc0000644000015000007670000000424312252527531012777 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ /* $Id: DummyProto.cc,v 1.12 2009/03/20 12:28:04 lav Exp $ */ #include #include "DummyProto.h" #include DummyProto::DummyProto() {} DummyProto::~DummyProto() {} int DummyProto::Do() { return STALL; } int DummyProto::Done() { return NO_HOST; } const char *DummyProto::GetProto() const { return ""; } FileAccess *DummyProto::Clone() const { return new DummyProto; } int DummyProto::Read(Buffer *buf,int size) { return NO_HOST; }; int DummyProto::Write(const void *buf,int size) { return NO_HOST; }; int DummyProto::StoreStatus() { return NO_HOST; } class DummyDirList : public DirList { public: DummyDirList(FA *p1,ArgV *a) : DirList(p1,a) {} int Do() { SetError(session->StrError(FA::NO_HOST)); return STALL; } const char *Status() { return ""; } }; class DummyListInfo : public ListInfo { public: DummyListInfo(FA *p1) : ListInfo(p1,0) {} int Do() { SetError(session->StrError(FA::NO_HOST)); return STALL; } const char *Status() { return ""; } }; DirList *DummyProto::MakeDirList(ArgV *a) { return new DummyDirList(this,a); } ListInfo *DummyProto::MakeListInfo(const char *path) { return new DummyListInfo(this); } const char *DummyNoProto::GetProto() const { return proto; } FileAccess *DummyNoProto::Clone() const { return new DummyNoProto(proto); } const char *DummyNoProto::StrError(int) { static xstring str; str.vset(proto.get(),_(" - not supported protocol"),NULL); return str; } lftp-4.6.3a/src/bookmark.cc0000644000015000007670000000744212122057045012463 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "bookmark.h" #include #include #include #include #include "trio.h" #include "ResMgr.h" #include "misc.h" #include "url.h" #define super KeyValueDB Bookmark lftp_bookmarks; ResDecl res_auto_sync("bmk:auto-sync","yes",ResMgr::BoolValidate,ResMgr::NoClosure); Bookmark::Bookmark() { const char *home=get_lftp_data_dir(); if(home) bm_file.vset(home,"/bookmarks",NULL); bm_fd=-1; stamp=(time_t)-1; } Bookmark::~Bookmark() { Close(); } void Bookmark::Refresh() { if(!bm_file) return; struct stat st; if((bm_fd==-1 ? stat(bm_file,&st) : fstat(bm_fd,&st)) == -1) return; if(st.st_mtime==stamp) return; Load(); } void Bookmark::Load() { super::Empty(); if(!bm_file) return; if(bm_fd==-1) { bm_fd=open(bm_file,O_RDONLY); if(bm_fd==-1) return; fcntl(bm_fd,F_SETFD,FD_CLOEXEC); if(Lock(F_RDLCK)==-1) fprintf(stderr,"%s: lock for reading failed, trying to read anyway\n",bm_file.get()); } struct stat st; fstat(bm_fd,&st); stamp=st.st_mtime; lseek(bm_fd,0,SEEK_SET); super::Read(dup(bm_fd)); // Read closes file } static bool auto_sync; void Bookmark::PreModify() { if(!bm_file) return; auto_sync=ResMgr::QueryBool("bmk:auto-sync",0); if(!auto_sync) return; Close(); bm_fd=open(bm_file,O_RDWR|O_CREAT,0600); if(bm_fd==-1) return; if(Lock(F_WRLCK)==-1) { fprintf(stderr,"%s: lock for writing failed\n",bm_file.get()); Close(); return; } Refresh(); } void Bookmark::PostModify() { if(!bm_file) return; if(!auto_sync) return; // the file is already locked in PreModify. lseek(bm_fd,0,SEEK_SET); #ifdef HAVE_FTRUNCATE if(ftruncate(bm_fd,0)==-1) // note the following statement #endif close(open(bm_file,O_WRONLY|O_TRUNC)); super::Write(bm_fd); bm_fd=-1; // Write closes file } void Bookmark::UserSave() { if(!bm_file) return; Close(); bm_fd=open(bm_file,O_RDWR|O_CREAT|O_TRUNC,0600); if(bm_fd==-1) return; if(Lock(F_WRLCK)==-1) { fprintf(stderr,"%s: lock for writing failed\n",bm_file.get()); Close(); return; } super::Write(bm_fd); bm_fd=-1; // Write closes file } void Bookmark::Add(const char *key,const char *value) { PreModify(); super::Add(key,value); PostModify(); } void Bookmark::Remove(const char *key) { PreModify(); super::Remove(key); PostModify(); } void Bookmark::Close() { if(bm_fd!=-1) { close(bm_fd); bm_fd=-1; } } void Bookmark::AutoSync() { if(ResMgr::QueryBool("bmk:auto-sync",0)) { Refresh(); Close(); } } const char *Bookmark::Lookup(const char *key) { AutoSync(); return super::Lookup(key); } #if 0 void Bookmark::List() { Refresh(); Close(); super::Write(dup(0)); } #endif char *Bookmark::Format() { AutoSync(); return super::Format(); } char *Bookmark::FormatHidePasswords() { AutoSync(); return super::Format(url::hide_password); } lftp-4.6.3a/src/lftp_rl.h0000644000015000007670000000404712122060133012150 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef LFTP_RL_H #define LFTP_RL_H CDECL_BEGIN void lftp_readline_init (void); int lftp_history_expand (const char *, char **); char *lftp_readline (const char *prompt); void lftp_add_history_nodups(const char *cmd); void lftp_history_clear(); void lftp_history_list(int cnt); int lftp_history_write(const char *fn); int lftp_history_read(const char *fn); void lftp_rl_clear(void); void lftp_rl_redisplay_maybe(void); void lftp_rl_set_ignore_some_completions_function(int (*func)(char**)); char **lftp_rl_completion_matches(const char *text,char *(*compentry)(const char *,int)); void lftp_rl_add_defun(const char *name,int (*func)(int,int),int key); void lftp_rl_bind(const char *key,const char *func); void lftp_rl_set_prompt(const char *p); void lftp_rl_write_history(); void lftp_rl_read_history(); void lftp_rl_history_stifle(int s); void lftp_rl_init( const char *readline_name, char **(*attempted_completion_function)(const char *,int,int), int (*getc_function)(FILE*), const char *completer_quote_characters, const char *completer_word_break_characters, const char *filename_quote_characters, char *(*filename_quoting_function)(char *,int,char *), char *(*filename_dequoting_function)(const char *,int), int (*char_is_quoted_p)(const char *,int)); CDECL_END #endif /* LFTP_RL_H */ lftp-4.6.3a/src/keyvalue.cc0000644000015000007670000001002712122060066012471 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "keyvalue.h" #include #include "trio.h" #include #include int KeyValueDB::Read(int fd) { xstring key; xstring value; int c; FILE *f=fdopen(fd,"r"); for(;;) { c=getc(f); // skip leading space while(c!=EOF && (c==' ' || c=='\t')) c=getc(f); if(c==EOF) break; if(c=='\n') continue; // next line key.truncate(0); for(;;) { key.append(c); c=getc(f); if(c==EOF) break; if(c==' ' || c=='\t' || c=='\n') break; } if(c==EOF || c=='\n' || key.length()==0) break; // invalid line // skip space in mid while(c!=EOF && (c==' ' || c=='\t')) c=getc(f); if(c==EOF || c=='\n') break; value.truncate(0); for(;;) { value.append(c); c=getc(f); if(c==EOF) break; if(c=='\n') break; } Add(key,value); if(c==EOF) break; } fclose(f); return 0; } int KeyValueDB::VKeyCompare(const void *a,const void *b) { KeyValueDB::Pair *pa=*(KeyValueDB::Pair*const*)a; KeyValueDB::Pair *pb=*(KeyValueDB::Pair*const*)b; return KeyValueDB::KeyCompare(pa,pb); } void KeyValueDB::Sort() { int count=0; Pair *scan; for(scan=chain; scan; scan=scan->next) count++; if(count==0) return; Pair **arr=(Pair**)alloca(count*sizeof(*arr)); count=0; for(scan=chain; scan; scan=scan->next) arr[count++]=scan; qsort(arr,count,sizeof(*arr),&KeyValueDB::VKeyCompare); chain=0; while(count--) { arr[count]->next=chain; chain=arr[count]; } } char *KeyValueDB::Format(StringMangler value_mangle) { Sort(); Pair *p; int max_key_len=0; for(p=chain; p; p=p->next) { int len=strlen(p->key); if(len>max_key_len) max_key_len=len; } max_key_len&=~7; // save some bytes xstring buf(""); for(p=chain; p; p=p->next) buf.appendf("%-*s\t%s\n",max_key_len,p->key.get(),value_mangle(p->value)); return buf.borrow(); } int KeyValueDB::Write(int fd) { xstring_ca buf(Format()); int res=write(fd,buf,strlen(buf)); close(fd); return res; } void KeyValueDB::Add(const char *key,const char *value) { Pair **p=LookupPair(key); if(!p) AddPair(NewPair(key,value)); else p[0]->SetValue(value); } void KeyValueDB::Remove(const char *key) { Pair **p=LookupPair(key); if(p) Purge(p); } KeyValueDB::Pair **KeyValueDB::LookupPair(const char *key) const { for(const Pair * const*p=&chain; *p; p=&(*p)->next) { if((*p)->KeyCompare(key)==0) return const_cast(p); } return 0; } const char *KeyValueDB::Lookup(const char *key) const { const Pair * const*p=LookupPair(key); return p ? (*p)->value.get() : 0; } int KeyValueDB::Lock(int fd,int type) { struct flock lk; lk.l_type=type; lk.l_whence=0; lk.l_start=0; lk.l_len=0; int res=fcntl(fd,F_SETLK,&lk); if(res==-1 && E_RETRY(errno)) { int retries=5; bool echo=true; for(int i=0; i. */ #include #include "HttpDir.h" #include "log.h" #include "url.h" #include "misc.h" #if USE_EXPAT #include struct xml_context { xarray_s stack; Ref fs; Ref fi; xstring base_dir; void push(const char *); void pop(); void set_base_dir(const char *d) { base_dir.set(d); if(base_dir.length()>1) base_dir.chomp('/'); } const char *top(int i=0) { return stack.count()>i ? stack[stack.count()-i-1].get() : 0; } }; void xml_context::push(const char *s) { stack.append(s); } void xml_context::pop() { stack.chop(); } static void start_handle(void *data, const char *el, const char **attr) { xml_context *ctx=(xml_context*)data; ctx->push(el); if(!strcmp(ctx->top(), "DAV:response")) { delete ctx->fi; ctx->fi=new FileInfo; } else if(!strcmp(ctx->top(), "DAV:collection")) { ctx->fi->SetType(ctx->fi->DIRECTORY); ctx->fi->SetMode(0755); } } static void end_handle(void *data, const char *el) { xml_context *ctx=(xml_context*)data; if(!strcmp(ctx->top(), "DAV:response")) { if(ctx->fi && ctx->fi->name) { if(!ctx->fs) ctx->fs=new FileSet; ctx->fs->Add(ctx->fi.borrow()); } } ctx->pop(); } static void chardata_handle(void *data, const char *chardata, int len) { xml_context *ctx=(xml_context*)data; if(!ctx->fi) return; char *s=string_alloca(len+1); memcpy(s,chardata,len); s[len]=0; const char *tag=ctx->top(); if(!strcmp(tag, "DAV:href") && !xstrcmp(ctx->top(1), "DAV:response")) { ParsedURL u(s,true); s=alloca_strdup(u.path); int s_len=strlen(s); if(s_len>0 && s[s_len-1]=='/') { if(s_len>1) s[--s_len]=0; ctx->fi->SetType(ctx->fi->DIRECTORY); ctx->fi->SetMode(0755); } else { ctx->fi->SetType(ctx->fi->NORMAL); ctx->fi->SetMode(0644); } if(s[0]=='/' && s[1]=='~') s++; ctx->fi->SetName(ctx->base_dir.eq(s) ? "." : basename_ptr(s)); } else if(!strcmp(tag,"DAV:getcontentlength")) { long long size_ll=0; if(sscanf(s,"%lld",&size_ll)==1) ctx->fi->SetSize(size_ll); } else if(!strcmp(tag,"DAV:getlastmodified")) { time_t tm=Http::atotm(s); if(tm!=Http::ATOTM_ERROR) ctx->fi->SetDate(tm,0); } else if(!strcmp(tag,"DAV:creator-displayname")) { ctx->fi->SetUser(s); } else if(!strcmp(tag,"http://apache.org/dav/props/executable")) { if(s[0]=='T') ctx->fi->SetMode(0755); else if(s[0]=='F') ctx->fi->SetMode(0644); } } FileSet *HttpListInfo::ParseProps(const char *b,int len,const char *base_dir) { XML_Parser p = XML_ParserCreateNS(0,0); if(!p) return 0; xml_context ctx; ctx.set_base_dir(base_dir); XML_SetUserData(p,&ctx); XML_SetElementHandler(p, start_handle, end_handle); XML_SetCharacterDataHandler(p, chardata_handle); if(!XML_Parse(p, b, len, /*eof*/1)) { Log::global->Format(0, "XML Parse error at line %d: %s\n", (int)XML_GetCurrentLineNumber(p), XML_ErrorString(XML_GetErrorCode(p))); XML_ParserFree(p); return 0; } XML_ParserFree(p); return ctx.fs.borrow(); } void HttpDirList::ParsePropsFormat(const char *b,int len,bool eof) { if(len==0) goto end; if(!xml_p) { xml_p=XML_ParserCreateNS(0,0); xml_ctx=new xml_context; xml_ctx->set_base_dir(curr_url->path); XML_SetUserData(xml_p,xml_ctx); XML_SetElementHandler(xml_p, start_handle, end_handle); XML_SetCharacterDataHandler(xml_p, chardata_handle); } if(!XML_Parse(xml_p, b, len, eof)) { Log::global->Format(0, "XML Parse error at line %d: %s\n", (int)XML_GetCurrentLineNumber(xml_p), XML_ErrorString(XML_GetErrorCode(xml_p))); parse_as_html=true; return; } if(!xml_ctx->fs) goto end; xml_ctx->fs->rewind(); for(;;) { FileInfo *info=xml_ctx->fs->curr(); if(!info) break; info->MakeLongName(); buf->Put(info->longname); if(ls_options.append_type) { if(info->filetype==info->DIRECTORY) buf->Put("/"); else if(info->filetype==info->SYMLINK && !info->symlink) buf->Put("@"); } buf->Put("\n"); xml_ctx->fs->next(); } xml_ctx->fs->Empty(); end: if(eof && xml_p) { XML_ParserFree(xml_p); xml_p=0; delete xml_ctx; xml_ctx=0; } } #else // !USE_EXPAT FileSet *HttpListInfo::ParseProps(const char *b,int len,const char *base_dir) { return 0; } void HttpDirList::ParsePropsFormat(const char *b,int len,bool eof) {} #endif // !USE_EXPAT lftp-4.6.3a/src/StringSet.h0000644000015000007670000000423712410756256012453 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef STRINGSET_H #define STRINGSET_H #include "xarray.h" class StringSet { xarray_m set; const StringSet &operator=(const StringSet &); // disable assignment public: StringSet(); StringSet(const char *const *s,int n); StringSet(const StringSet &o); StringSet(const char *s); void Empty() { set.truncate(); } void Assign(const char *const *s,int n); void Assign(const char *s) { Assign(&s,1); } bool IsEqual(const char *const *s,int n) const; bool IsEqual(const StringSet &o) const { return IsEqual(o.Set(),o.Count()); } void Append(const char *); void AppendFormat(const char *,...) PRINTF_LIKE(2,3); void InsertBefore(int,const char *); void Replace(int,const char *); char *Pop(int i=0); void Remove(int i) { xfree(Pop(i)); } const char *const *Set() const { return set.get(); } char **SetNonConst() { return set.get_non_const(); } int Count() const { return set.count(); } const char *String(int i) const { return i>=0 && i::cmp_t cmp) { set.qsort(cmp); } static int default_cmp(const char **a,const char **b) { return strcmp(*a,*b); } void qsort() { qsort(default_cmp); } }; #endif // STRINGSET_H lftp-4.6.3a/src/HttpDir.cc0000644000015000007670000010374112314020600012221 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "ascii_ctype.h" #include #include "HttpDir.h" #include "url.h" #include "ArgV.h" #include "LsCache.h" #include "misc.h" #include "log.h" #include "DirColors.h" static bool token_eq(const char *buf,int len,const char *token) { int token_len=strlen(token); if(len=more) return false; if(!is_ascii_alnum(*scan)) { scan++; continue; } bool match=token_eq(scan,more-scan,name); while(is_ascii_alnum(*scan)) scan++; if(scan>=more) return false; if(*scan!='=') continue; scan++; char quote=0; if(*scan=='"' || *scan=='\'') quote=*scan++; if(match) store.set(""); while(scan=more) return false; if(quote) scan++; // skip closing quotation mark. } return false; } #if 0 // unused static const char *strncasestr(const char *buf,int len,const char *str) { int str_len=strlen(str); while(len>=str_len) { if(!strncasecmp(buf,str,str_len)) return buf; buf++; len--; } return 0; } #endif static const char *find_eol(const char *buf,int len,bool eof,int *eol_size) { const char *real_eol=find_char(buf,len,'\n'); // check if the tag after eol is or while(real_eol) { const char *scan=real_eol+1; while(scanbuf+len) { if(!eof) real_eol=0; break; } if(strncasecmp(scan,"'); if(more && !token_eq(less+1,rest,"br") && !token_eq(less+1,rest,"/tr") && !token_eq(less+1,rest,"tr")) { // if the tag is finished and not BR nor /TR nor TR, ignore it. less=0; more=0; } } // is real_eol past the tag? if(real_eol && less && real_eol>less) real_eol=0; // then ignore it. // real_eol not found? if(!real_eol) { // BR or /TR found? if(less && more) { *eol_size=more-less+1; return less; } *eol_size=0; if(eof) return buf+len; return 0; } *eol_size=1; if(real_eol>buf && real_eol[-1]=='\r') { real_eol--; (*eol_size)++; } return real_eol; } /* This function replaces & < > " to appropriate characters */ static void decode_amps(xstring& s) { static const struct pair { char str[7]; char ch; } table[]={ { "&", '&' }, { "<", '<' }, { ">", '>' }, { """, '"' }, { "", 0 } }; const struct pair *scan; for(const char *a=s; a; a=strchr(a,'&')) { for(scan=table; scan->ch; scan++) { int len=strlen(scan->str); if(!strncmp(a,scan->str,len)) { s.set_substr(a-s,len,&scan->ch,1); break; } } a++; } } class file_info { public: long long size; int year,month,day,hour,minute,second; xstring_c sym_link; bool is_sym_link; bool is_directory; char month_name[32]; char size_str[32]; char perms[12]; char user[32]; char group[32]; int nlink; time_t date; int date_prec; void clear(); bool validate(); file_info() { is_directory=false; clear(); } }; void file_info::clear() { size=-1; year=-1; month=-1; day=0; hour=-1; minute=-1; second=-1; month_name[0]=0; size_str[0]=0; perms[0]=0; sym_link.set(0); is_sym_link=false; user[0]=0; group[0]=0; nlink=0; date=NO_DATE; date_prec=-1; } bool file_info::validate() { if(year!=-1) { // server's y2000 problem :) if(year<37) year+=2000; else if(year<100) year+=1900; } if(day<1 || day>31 || hour<-1 || hour>23 || minute<-1 || minute>59 || (month==-1 && !is_ascii_alnum(month_name[0]))) return false; return true; } #define debug(str) Log::global->Format(10,"* %s\n",str) static bool try_apache_listing(file_info &info,const char *str) { info.clear(); // usual apache listing: DD-Mon-YYYY hh:mm size int n=sscanf(str,"%2d-%3s-%4d %2d:%2d %30s", &info.day,info.month_name,&info.year, &info.hour,&info.minute,info.size_str); if(n==6 && (info.size_str[0]=='-' || is_ascii_digit(info.size_str[0]))) { debug("apache listing matched"); return true; } return false; } static bool try_apache_listing_unusual(file_info &info,const char *str) { info.clear(); // unusual apache listing: size DD-Mon-YYYY int n=sscanf(str,"%30s %2d-%3s-%d", info.size_str,&info.day,info.month_name,&info.year); if(n==4 && (info.size_str[0]=='-' || is_ascii_digit(info.size_str[0]))) { debug("unusual apache listing matched"); return true; } return false; } static bool try_netscape_proxy(file_info &info,const char *str) { info.clear(); char size_unit[7]; char week_day[4]; // Netscape-Proxy 2.53 int n=sscanf(str,"%lld %6s %3s %3s %d %2d:%2d:%2d %4d", &info.size,size_unit,week_day, info.month_name,&info.day, &info.hour,&info.minute,&info.second,&info.year); if(n==9) { if(!strcasecmp(size_unit,"bytes") || !strcasecmp(size_unit,"byte")) snprintf(info.size_str,sizeof(info.size_str),"%lld",info.size); else { snprintf(info.size_str,sizeof(info.size_str),"%lld%s",info.size,size_unit); info.size=-1; } debug("Netscape-Proxy 2.53 listing matched"); return true; } n=sscanf(str,"%3s %3s %d %2d:%2d:%2d %4d %30s", week_day,info.month_name,&info.day, &info.hour,&info.minute,&info.second,&info.year,info.size_str); if(n==7 || (n==8 && !is_ascii_digit(info.size_str[0]))) { strcpy(info.size_str,"-"); if(!info.is_directory) info.is_sym_link=true; debug("Netscape-Proxy 2.53 listing matched (dir/symlink)"); return true; } return false; } static bool try_squid_eplf(file_info &info,const char *str) { info.clear(); char week_day[4]; int n=sscanf(str,"%3s %3s %d %2d:%2d:%2d %4d %30s", week_day,info.month_name,&info.day, &info.hour,&info.minute,&info.second,&info.year,info.size_str); if(n==8) // maybe squid's EPLF listing. { // no symlinks here. debug("squid EPLF listing matched"); return true; } return false; } static bool try_mini_proxy(file_info &info,const char *buf) { info.clear(); char PM[3]; // Mini-Proxy web server. if(7==sscanf(buf,"%d/%d/%d %d:%d %2s %30s", &info.month,&info.day,&info.year, &info.hour,&info.minute,PM,info.size_str)) { if(!strcasecmp(PM,"PM")) { info.hour+=12; if(info.hour==24) info.hour=0; } if(!is_ascii_digit(info.size_str[0])) { if(!strcasecmp(info.size_str,"")) info.is_directory=true; strcpy(info.size_str,"-"); } info.month--; debug("Mini-Proxy web server listing matched"); return true; } return false; } static bool try_apache_unixlike(file_info &info,const char *buf, const char *more,const char *more1,xstring& info_string) { info.clear(); // Apache Unix-like listing (from apache proxy): // Perms Nlnk user [group] size Mon DD (YYYY or hh:mm) char year_or_time[6]; int consumed; int n=sscanf(buf,"%11s %d %31s %31s %lld %3s %2d %5s%n",info.perms,&info.nlink, info.user,info.group,&info.size,info.month_name,&info.day, year_or_time,&consumed); if(n==4) // bsd-like listing without group? { info.group[0]=0; n=sscanf(buf,"%11s %d %31s %lld %3s %2d %5s%n",info.perms,&info.nlink, info.user,&info.size,info.month_name,&info.day,year_or_time,&consumed); } if(n>=7 && -1!=parse_perms(info.perms+1) && -1!=(info.month=parse_month(info.month_name)) && -1!=parse_year_or_time(year_or_time,&info.year,&info.hour,&info.minute)) { snprintf(info.size_str,sizeof(info.size_str),"%lld",info.size); if(info.perms[0]=='d') info.is_directory=true; else if(info.perms[0]=='l') { info.is_sym_link=true; char *str=string_alloca(more1-more); memcpy(str,more+1,more1-more-4); str[more1-more-4]=0; str=strstr(str," -> "); if(str) info.sym_link.set(str+4); } info_string.nset(buf,consumed); debug("apache ftp over http proxy listing matched"); return true; } return false; } static bool try_roxen(file_info &info,const char *str) { info.clear(); // Roxen listing ([size] {kb/Mb} application/octet-stream YYYY-MM-DD) // or (directory YYYY-MM-DD) char size_mod[6]; long size_mod_i=0; str=strchr(str+(*str=='\n'),'\n'); if(!str) return false; int n=sscanf(str,"%26s %5s %*[a-z0-9/-] %4d-%2d-%2d",info.size_str,size_mod, &info.year,&info.month,&info.day); if(n==5) { if(!strncmp(size_mod,"byte",4)) size_mod_i=1; else if(!strcmp(size_mod,"kb")) size_mod_i=1024; else if(!strcmp(size_mod,"Mb")) size_mod_i=1024*1024; else if(!strcmp(size_mod,"Gb")) size_mod_i=1024*1024*1024; if(size_mod_i) { const char *old_size_str=alloca_strdup(info.size_str); snprintf(info.size_str,sizeof(info.size_str),"%s%s",old_size_str,size_mod); debug("Roxen web server listing matched"); return true; } } strcpy(info.size_str,"-"); n=sscanf(str," directory %4d-%2d-%2d",&info.year,&info.month,&info.day); if(n==3) { debug("Roxen web server listing matched (directory)"); info.is_directory=true; return true; } return false; } static bool try_squid_ftp(file_info &info,const char *str,char *str_with_tags) { info.clear(); char year_or_time[6]; // squid's ftp listing: Mon DD (YYYY or hh:mm) [size] int n=sscanf(str,"%3s %2d %5s %30s",info.month_name,&info.day,year_or_time,info.size_str); if(n<3) return false; if(!is_ascii_digit(info.size_str[0])) strcpy(info.size_str,"-"); if(-1==parse_year_or_time(year_or_time,&info.year,&info.hour,&info.minute)) return false; if(-1==parse_month(info.month_name)) return false; // be strict. char *ptr; ptr=strstr(str_with_tags," -> =7 && -1!=parse_perms(info.perms+1) && -1!=(info.month=parse_month(info.month_name)) && -1!=parse_year_or_time(year_or_time,&info.year,&info.hour,&info.minute)) { snprintf(info.size_str,sizeof(info.size_str),"%lld",info.size); if(info.perms[0]=='d') info.is_directory=true; else if(info.perms[0]=='l') { info.is_sym_link=true; const char *p=strstr(ext,"-> "); if(p) info.sym_link.set(p+6); } info_string.nset(buf,consumed); debug("wwwoffle ftp over http proxy listing matched"); return true; } return false; } // 4096 Jun 25 23:48Directory| *** // 4096 Jun 23 2002Directory| *** // 50 Jul 9 18:37Symbolic Link| *** // 217 Jun 3 06:01Plain Text| *** // 40419 Jul 6 13:06Hypertext Markup Language| *** // 14289850 Jul 16 17:04Windows Bitmap| *** // 6668926 Jul 17 16:01Binary Executable| *** static bool try_csm_proxy(file_info &info,const char *str) { info.clear(); int n; int status = false; char additional_file_info[33]; int has_additional_file_info = false; memset(additional_file_info, '\0', sizeof (additional_file_info)); // try to match hour:minute if (5 <= (n = sscanf(str,"%lld %3s %d %2d:%2d%32s", &info.size, info.month_name, &info.day, &info.hour, &info.minute, additional_file_info))) { status = true; if (6 == n) has_additional_file_info = true; } else { // try to match year instead of hour:minute info.clear(); if (4 <= (n = sscanf(str,"%lld %3s %d %4d%32s", &info.size, info.month_name, &info.day, &info.year, additional_file_info))) { status = true; if (5 == n) has_additional_file_info = true; } } if (status) { debug("csm_proxy listing matched"); snprintf(info.size_str,sizeof(info.size_str),"%lld",info.size); if (has_additional_file_info && additional_file_info[0]) { if (!strncasecmp("Symbolic Link",additional_file_info,13)) { info.is_sym_link = true; } else if (!strncasecmp("Directory",additional_file_info,9)) { info.is_directory = true; } else { // fprintf(stderr, "try_csm_proxy: |%s|\n", additional_file_info); Log::global->Format(10, "* try_csm_proxy: unknown file type '%s'\n", additional_file_info); } } } return status; } // 2004-Oct-19 02:10:26 0.2K application/octet-stream static bool try_lighttpd_listing(file_info &info,char *str_with_tags) { info.clear(); if(str_with_tags[0]=='/') { info.is_directory=true; str_with_tags++; } const char *next=strstr(str_with_tags,"\"m\">"); if(!next) return false; next+=4; const char *end=strchr(next,'<'); if(!end) return false; xstring datetime(next,end-next); next=strstr(end,"\"s\">"); if(!next) return false; next+=4; end=strchr(next,'<'); if(!end) return false; xstring size(next,end-next); int n=sscanf(datetime,"%4d-%3s-%2d %2d:%2d:%2d", &info.year,info.month_name,&info.day, &info.hour,&info.minute,&info.second); if(n!=6) return false; if(is_ascii_digit(size[0])) { strncpy(info.size_str,size,sizeof(info.size_str)); info.size_str[sizeof(info.size_str)-1]=0; } debug("lighttpd listing matched"); return true; } // this procedure is highly inefficient in some cases, // esp. when it has to return for more data many times. static int parse_html(const char *buf,int buf_len,bool eof,const Ref& list, FileSet *set,FileSet *all_links,const ParsedURL *prefix,xstring_c *base_href, LsOptions *lsopt=0, int color = 0) { const char *end=buf+buf_len; const char *less=find_char(buf,buf_len,'<'); int eol_len=0; int skip_len=0; const char *eol; eol=find_eol(buf,buf_len,eof,&eol_len); if(eol) skip_len=eol-buf+eol_len; if(less==0) return skip_len; if(skip_len>0 && eol=3 && less[1]=='!' && less[2]=='-' && less[3]=='-') { // found comment if(end-less-4<3) return less-buf; const char *scan=less+4; for(;;) { const char *eoc=find_char(scan,end-scan,'>'); if(!eoc) { if(eof) // unterminated comment. return buf_len; return less-buf; } if(eoc>=less+4+2 && eoc[-1]=='-' && eoc[-2]=='-') return eoc+1-buf; scan=eoc+1; } } // FIXME: a > sign can be inside quoted value. (?) const char *more=find_char(less+1,end-less-1,'>'); if(more==0) { if(eof) return buf_len; return 0; } // we have found a tag int tag_len=more-buf+1; if(more-less<3) return tag_len; // too small if(less[1]=='/' || less[1]=='!') return tag_len; xstring link_target; static const struct tag_link { const char *tag, *link; } tag_list[]={ /* taken from wget-1.5.3: */ /* NULL-terminated list of tags and modifiers someone would want to follow -- feel free to edit to suit your needs: */ { "a", "href" }, { "img", "src" }, { "img", "href" }, { "body", "background" }, { "frame", "src" }, { "iframe", "src" }, { "fig", "src" }, { "overlay", "src" }, { "applet", "code" }, { "script", "src" }, { "embed", "src" }, { "bgsound", "src" }, { "area", "href" }, { "img", "lowsrc" }, { "input", "src" }, { "layer", "src" }, { "table", "background"}, { "th", "background"}, { "td", "background"}, /* Tags below this line are treated specially. */ { "base", "href" }, { "meta", "content" }, { NULL, NULL } }; // FIXME: a tag can have many links. const struct tag_link *tag_scan; for(tag_scan=tag_list; tag_scan->tag; tag_scan++) { if(token_eq(less+1,end-less-1,tag_scan->tag)) { if(find_value(less+1+strlen(tag_scan->tag),more, tag_scan->link,link_target)) break; } } if(tag_scan->tag==0) return tag_len; // not interesting const char *prefix_proto=0; if(prefix) prefix_proto=prefix->proto; if(!xstrcmp(prefix_proto,"hftp")) prefix_proto++; bool hftp=!xstrcmp(prefix_proto,"ftp"); // ok, found the target. decode_amps(link_target); // decode all & and similar if(hftp) { // workaround proxy bugs. const char *t=strstr(link_target,";type="); if(t && t[6] && t[7]=='/' && t[8]==0) link_target.truncate(t-link_target); const char *p=link_target+url::path_index(link_target); if(p[0]=='/' && p[1]=='/') link_target.set_substr(p-link_target+1,1,"%2F"); } Log::global->Format(10,"Found tag %s, link_target=%s\n",tag_scan->tag,link_target.get()); if(!strcasecmp(tag_scan->tag,"base")) { if(base_href) { base_href->set(link_target); Log::global->Format(10,"Using base href=%s\n",base_href->get()); } return tag_len; } if(!strcasecmp(tag_scan->tag,"meta")) { // skip 0; URL= link_target.rtrim(); const char *scan=link_target; while(*scan && is_ascii_digit(*scan)) scan++; if(*scan!=';') return tag_len; scan++; while(*scan && is_ascii_space(*scan)) scan++; if(strncasecmp(scan,"URL=",4)) return tag_len; scan+=4; int len=link_target.length()-(scan-link_target); if(link_target[0]=='\'') { // FIXME: maybe a more complex value parser is required. scan++; len--; if(len>0 && scan[len-1]=='\'') len--; } link_target.nset(scan,len); Log::global->Format(10,"Extracted `%s' from META tag\n",link_target.get()); } bool icon=false; if(!strcasecmp(tag_scan->tag,"img") && !strcasecmp(tag_scan->link,"src")) icon=true; bool a_href=false; if(!strcasecmp(tag_scan->tag,"a") && !strcasecmp(tag_scan->link,"href")) a_href=true; // check if the target is a relative and not a cgi if(strchr(link_target,'?')) return tag_len; // cgi link_target.truncate_at('#'); // strip the anchor if(link_target.length()==0) return tag_len; // no target ? // netscape internal icons if(icon && !strncasecmp(link_target,"internal-gopher",15)) return tag_len; if(link_target[0]=='/' && link_target[1]=='~') link_target.set_substr(0,1,0,0); bool base_href_applied=false; parse_url_again: ParsedURL link_url(link_target,/*proto_required=*/true); if(link_url.proto) { if(!prefix) return tag_len; // no way if(xstrcmp(link_url.proto,prefix_proto) || xstrcmp(link_url.host,prefix->host) || xstrcmp(link_url.user,prefix->user) || xstrcmp(link_url.port,prefix->port)) return tag_len; // no match } else { const char *scan_link=link_target; while(*scan_link) { if(scan_link>link_target && *scan_link==':') return tag_len; // special url, like mailto: if(!is_ascii_alpha(*scan_link)) break; scan_link++; } if(*link_target!='/' && base_href && *base_href && !base_href_applied) { const char *base_end=strrchr(*base_href,'/'); if(base_end) { link_target.set_substr(0,0,*base_href,(base_end+1-*base_href)); base_href_applied=true; goto parse_url_again; } } } // ok, it is good relative link if(link_url.path==0) link_target.set("/"); else link_target.set(link_url.path); if(link_target[0]=='/' && link_target[1]=='/' && hftp) { // workaround for apache proxy. link_target.set_substr(0,1,0,0); } file_info info; info.is_directory=(link_target.last_char()=='/'); if(link_target.length()>1) link_target.chomp('/'); FileAccess::Path::Optimize(link_target,(link_target[0]=='/' && link_target[1]=='~')); if(prefix) { const char *p_path_c=prefix->path; if(p_path_c==0) p_path_c="~"; char *p_path=alloca_strdup(p_path_c); int p_len=strlen(p_path); if(p_len>1 && p_path[p_len-1]=='/') p_path[--p_len]=0; if(p_len==1 && p_path[0]=='/' && link_target[0]=='/') { if(link_target.length()>1) { // strip leading slash link_target.set_substr(0,1,0,0); } } else if(p_len>0 && !strncmp(link_target,p_path,p_len)) { if(link_target[p_len]=='/') link_target.set_substr(0,p_len+1,0,0); else if(link_target[p_len]==0) link_target.set("."); if(link_target[0]=='.' && link_target[1]=='/') link_target.set_substr(0,2,0,0); } else { // try .. const char *rslash=strrchr(p_path,'/'); if(rslash) { p_len=rslash-p_path; if(p_len>0 && !strncmp(link_target,p_path,p_len) && link_target[p_len]==0) link_target.set(".."); } } } const char *type=strstr(link_target,";type="); if(type && type[6] && !type[7]) { if(!all_links || all_links->FindByName(xstring::get_tmp(link_target,type-link_target))) return tag_len; } if(link_target.length()==0) { link_target.set("."); info.is_directory=true; } bool show_in_list=true; if(icon && (link_target[0]=='/' || link_target[0]=='~')) show_in_list=false; // makes apache listings look better. skip_len=tag_len; // try to find file info { const char *more1; char *str,*str_with_tags, *str2; xstring line_add; xstring info_string; int type; if(!a_href) goto add_file_no_info; // only tags can have useful info. // try to extract file information more1=more; find_a_end: for(;;) { more1++; more1=find_char(more1,end-more1,'>'); if(!more1) { if(eof) goto add_file_no_info; if(end-more>2*1024) // too long a-href goto add_file_no_info; return 0; // no full a-href yet } if(!strncasecmp(more1-3,"more-less+10 && !strncmp(more1+2,less,more-less+1)) { more1=more1+2+(more-less); goto find_a_end; } if(more1[1]==' ') more1++; while(more1+1+2=0) { snprintf(info.month_name,sizeof(info.month_name),"%02d",info.month+1); if(info.year==-1) info.year=guess_year(info.month,info.day,info.hour,info.minute); } if(info.year!=-1 && info.month!=-1 && info.day!=-1) { struct tm tm; memset(&tm,0,sizeof(tm)); tm.tm_year=info.year-1900; tm.tm_mon=info.month; tm.tm_mday=info.day; tm.tm_hour=12; info.date_prec=43200; if(info.hour!=-1 && info.minute!=-1) { tm.tm_hour=info.hour; tm.tm_min=info.minute; tm.tm_sec=30; info.date_prec=30; if(info.second!=-1) { tm.tm_sec=info.second; info.date_prec=0; } } info.date=mktime_from_utc(&tm); } if(info.size==-1) { if(strspn(info.size_str,"0123456789")==strlen(info.size_str)) { long long size_ll=0; if(sscanf(info.size_str,"%lld",&size_ll)!=1) size_ll=0; info.size=size_ll; } } if(info.perms[0]==0) { if(info.is_directory) strcpy(info.perms,"drwxr-xr-x"); else if(info.is_sym_link) strcpy(info.perms,"lrwxrwxrwx"); else strcpy(info.perms,"-rw-r--r--"); } if(!list || !show_in_list) goto info_done; if(info_string) { line_add.vset(info_string.get()," ",link_target.get(),NULL); goto append_symlink_maybe; } line_add.setf("%s %11s %04d-%s-%02d", info.perms,info.size_str,info.year,info.month_name,info.day); if (info.hour >= 0 || info.minute >= 0) { if (info.hour >= 0) { line_add.appendf(" %02d:",info.hour); } else { line_add.append(" --:"); } if (info.minute >= 0) { line_add.appendf("%02d", info.minute); } else { line_add.append("--"); } } else { // neither hour nor minute are given line_add.append(" "); } line_add.append(" "); type = FileInfo::NORMAL; if(info.is_directory) type = FileInfo::DIRECTORY; else if(info.is_sym_link && !info.sym_link) type = FileInfo::SYMLINK; if (color && FileInfo::NORMAL != type && all_links && !all_links->FindByName(link_target)) { list->Put(line_add); DirColors::GetInstance()->PutColored(list, link_target, type); line_add.truncate(0); // reset } else { line_add.append(link_target); } append_symlink_maybe: if(info.sym_link) line_add.vappend(" -> ",info.sym_link.get(),NULL); append_type_maybe: if(lsopt && lsopt->append_type) { if(info.is_directory) line_add.append('/'); if(info.is_sym_link && !info.sym_link) line_add.append('@'); } line_add.append('\n'); if(!all_links->FindByName(link_target)) { list->Put(line_add); FileInfo *fi=new FileInfo(link_target); all_links->Add(fi); } } info_done: if(set && link_target[0]!='/' && link_target[0]!='~') { const char *slash=strchr(link_target,'/'); if(slash) { link_target.truncate(slash-link_target); info.is_directory=true; } FileInfo *fi=new FileInfo(link_target); if(info.sym_link) fi->SetSymlink(info.sym_link); else fi->SetType(info.is_directory ? fi->DIRECTORY : fi->NORMAL); if(info.nlink>0) fi->SetNlink(info.nlink); if(info.user[0]) fi->SetUser(info.user); if(info.group[0]) fi->SetGroup(info.group); if(info.size!=-1) fi->SetSize(info.size); if(info.perms[0]) { int m=parse_perms(info.perms+1); if(m>=0) fi->SetMode(m); } if(info.date_prec!=-1 && info.date!=NO_DATE) fi->SetDate(info.date,info.date_prec); set->Add(fi); } return skip_len; } // HttpDirList implementation #define super DirList int HttpDirList::Do() { if(done) return STALL; if(buf->Eof()) { done=true; return MOVED; } if(!ubuf) { curr=args->getnext(); if(!curr) { buf->PutEOF(); done=true; return MOVED; } if(args->count()>2) { if(args->getindex()>1) buf->Put("\n"); buf->Put(curr); buf->Put(":\n"); } curr_url=new ParsedURL(session->GetFileURL(curr)); if(mode==FA::RETRIEVE) { // strip file name, directory remains. const char *slash=strrchr(curr_url->path,'/'); if(slash && slash>curr_url->path) curr_url->path.truncate(slash-curr_url->path); } retry: const char *cache_buffer=0; int cache_buffer_size=0; int err; if(use_cache && FileAccess::cache->Find(session,curr,mode,&err, &cache_buffer,&cache_buffer_size)) { if(err) { if(mode==FA::MP_LIST) { mode=FA::LONG_LIST; goto retry; } SetErrorCached(cache_buffer); } ubuf=new IOBuffer(IOBuffer::GET); ubuf->Put(cache_buffer,cache_buffer_size); ubuf->PutEOF(); } else { if(mode==FA::MP_LIST && !*curr && session->GetCwd().is_file) { mode=FA::LONG_LIST; goto retry; } session->Open(curr,mode); session->UseCache(use_cache); ubuf=new IOBufferFileAccess(session); if(FileAccess::cache->IsEnabled(session->GetHostName())) ubuf->Save(FileAccess::cache->SizeLimit()); } } const char *b; int len; ubuf->Get(&b,&len); if(b==0) // eof { FileAccess::cache->Add(session,curr,mode,FA::OK,ubuf); ubuf=0; return MOVED; } int m=STALL; reparse: if(mode!=FA::MP_LIST || parse_as_html) { int n=parse_html(b,len,ubuf->Eof(),buf,0,&all_links,curr_url,&base_href,&ls_options, color); if(n>0) { ubuf->Skip(n); m=MOVED; } } else { ParsePropsFormat(b,len,ubuf->Eof()); if(parse_as_html) goto reparse; ubuf->Skip(len); } if(ubuf->Error()) { FileAccess::cache->Add(session,curr,mode,session->GetErrorCode(),ubuf); if(mode==FA::MP_LIST) { mode=FA::LONG_LIST; ubuf=0; goto retry; } SetError(ubuf->ErrorText()); m=MOVED; } return m; } HttpDirList::HttpDirList(FileAccess *s,ArgV *a) : DirList(s,a) { mode=FA::MP_LIST; parse_as_html=false; #if USE_EXPAT xml_p=0; xml_ctx=0; #endif args->rewind(); int opt; while((opt=args->getopt("faCFl"))!=EOF) { switch(opt) { case('f'): mode=FA::RETRIEVE; break; case('a'): ls_options.show_all=true; break; case('C'): ls_options.multi_column=true; break; case('F'): ls_options.append_type=true; break; } } while(args->getindex()>1) args->delarg(1); // remove options. if(args->count()<2) args->Append(""); args->rewind(); curr=0; curr_url=0; } HttpDirList::~HttpDirList() { ParsePropsFormat(0,0,true); } const char *HttpDirList::Status() { if(ubuf && !ubuf->Eof() && session->IsOpen()) return xstring::format(_("Getting file list (%lld) [%s]"), (long long)session->GetPos(),session->CurrentStatus()); return ""; } void HttpDirList::SuspendInternal() { super::SuspendInternal(); if(ubuf) ubuf->SuspendSlave(); } void HttpDirList::ResumeInternal() { if(ubuf) ubuf->ResumeSlave(); super::ResumeInternal(); } #undef super // HttpListInfo implementation FileSet *HttpListInfo::Parse(const char *b,int len) { if(mode==FA::MP_LIST) { FileSet *fs=ParseProps(b,len,session->GetCwd()); if(!fs) mode=FA::LONG_LIST; return fs; } return session->ParseLongList(b,len); } FileSet *Http::ParseLongList(const char *b,int len,int *err) const { if(err) *err=0; FileSet *set=0; if(len>5 && !strncmp(b,"count()>0) return set; ParsedURL prefix(GetConnectURL()); xstring_c base_href; for(;;) { int n=parse_html(b,len,true,Ref::null,set,0,&prefix,&base_href); if(n==0) break; b+=n; len-=n; } return set; } lftp-4.6.3a/src/StatusLine.cc0000644000015000007670000001454512535304711012756 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #ifdef HAVE_TERMIOS_H #include #endif #include #include #include "trio.h" #include #include #include #include "xstring.h" #include "ResMgr.h" #include "misc.h" #include "StatusLine.h" #include "lftp_tinfo.h" ResDecl res_status_interval ("cmd:status-interval", "0.8s", ResMgr::TimeIntervalValidate,ResMgr::NoClosure); int StatusLine::GetWidth() { #ifdef TIOCGWINSZ struct winsize sz; sz.ws_col=sz.ws_row=0; ioctl(fd,TIOCGWINSZ,&sz); if(sz.ws_col==0) sz.ws_col=80; if(sz.ws_row==0) sz.ws_row=24; LastHeight=sz.ws_row; return(LastWidth=sz.ws_col); #else /* !TIOCGWINSZ */ return 80; #endif } StatusLine::StatusLine(int new_fd) { to_status_line = get_string_term_cap("tsl", "ts"); from_status_line = get_string_term_cap("fsl", "fs"); prev_line = get_string_term_cap("cuu1","up"); fd=new_fd; update_delayed=false; next_update_title_only=false; strcpy(def_title,""); not_term=!isatty(fd); GetWidth(); } StatusLine::~StatusLine() { /* Don't leave a title behind. */ WriteTitle("", fd); } void StatusLine::Clear(bool title_also) { const char *empty=""; update_timer.Stop(); ShowN(&empty,1); update_delayed=false; update_timer.SetMilliSeconds(20); if(title_also) WriteTitle(def_title, fd); } void StatusLine::DefaultTitle(const char *s) { strncpy(def_title, s, sizeof(def_title)); def_title[sizeof(def_title)-1] = 0; } void StatusLine::Show(const char *f,...) { if(f==0 || f[0]==0) { Clear(); return; } char newstr[0x800]; va_list v; va_start(v,f); vsnprintf(newstr,sizeof(newstr),f,v); va_end(v); newstr[sizeof(newstr)-1]=0; const char *s=newstr; ShowN(&s,1); } void StatusLine::ShowN(const char *const* newstr,int n) { if(!update_delayed && shown.IsEqual(newstr,n)) return; if(update_delayed && to_be_shown.IsEqual(newstr,n)) return; if(!update_timer.Stopped()) { /* not yet */ to_be_shown.Assign(newstr,n); update_delayed=true; } else { update(newstr,n); update_delayed=false; } } const char *StatusLine::to_status_line; const char *StatusLine::from_status_line; const char *StatusLine::prev_line; void StatusLine::WriteTitle(const char *s, int fd) const { if(!ResMgr::QueryBool("cmd:set-term-status", getenv("TERM"))) return; subst_t subst[] = { { 'a', "\007" }, { 'e', "\033" }, { 'n', "\n" }, { 's', "lftp" }, { 'v', VERSION }, { 'T', s }, { 0, "" } }; const char *status_format = ResMgr::Query("cmd:term-status", getenv("TERM")); xstring &disp=xstring::get_tmp(); if(status_format && *status_format) disp.set_allocated(Subst(status_format, subst)); else if(to_status_line && from_status_line) /* If we have no format, and we have both tsl and fsl, use them: */ disp.vset(to_status_line, s, from_status_line, NULL); else return; write(fd, disp, disp.length()); } void StatusLine::update(const char *const *newstr,int newstr_height) { if(not_term) return; if(!in_foreground_pgrp()) return; /* Don't write blank titles into the title; let Clear() do that. */ if(newstr_height>0 && newstr[0][0]) WriteTitle(newstr[0], fd); if(next_update_title_only) { next_update_title_only=false; return; } int w=GetWidth(); int mbflags=0; if(newstr_height>LastHeight) newstr_height=LastHeight; // clear old extra lines. Assume we are at beginning of last shown line. int j=shown.Count(); if(!prev_line) // if there is no way to go up, show a single line only. j=newstr_height=1; int i=j-newstr_height; char *spaces=string_alloca(w+1); memset(spaces,' ',w); spaces[w]=0; while(i-->0) { int tw=mbswidth(shown[--j],mbflags); write(fd,"\r",1); write(fd,spaces,tw); write(fd,"\r",1); write(fd,prev_line,strlen(prev_line)); } // move to top of shown lines. while(--j>0) write(fd,prev_line,strlen(prev_line)); int curr_line=0; while(curr_line0) { int ch_len=mblen(end,len); if(ch_len<1) ch_len=1; int ch_width=mbsnwidth(end,ch_len,mbflags); if(wpos+ch_width>w-1) break; end+=ch_len; len-=ch_len; wpos+=ch_width; if(wpos>=w-1) break; } // FIXME: this assumes that multibyte chars cannot include ' '. while(end>newstr[curr_line] && end[-1]==' ') { end--; wpos--; // FIXME: assumption - space width is 1 } if(end-newstr[curr_line]>0) write(fd,newstr[curr_line],end-newstr[curr_line]); const char *shown_curr=(curr_line>=shown.Count()?"":shown[curr_line]); int dif=strlen(shown_curr)-(end-newstr[curr_line])+2; if(dif>(w-1)-wpos) dif=(w-1)-wpos; if(dif>0) write(fd,spaces,dif); write(fd,"\r",1); if(++curr_line # This file is covered by GNU GPL. See file COPYING for details. if [ $# -eq 0 ]; then echo "Usage: $0 [-c] [-d] [-v] URL [URL...]" echo " -c continue, reget" echo " -d debug output" echo " -v verbose messages" exit 1 fi INTRO="set cmd:at-exit;set xfer:max-redirections 16;" SCRIPT="" verbose=false while : do case "$1" in -*v*) verbose=true INTRO="$INTRO set cmd:verbose y;" ;; esac case "$1" in -*d*) INTRO="$INTRO debug 8;";; esac case "$1" in -*c*) CONT=-c;; -*[dv]*) ;; *) break;; esac shift done for f do need_pass=false case "$f" in "*[\"'\\]*") # need to quote f="`echo "$f" | sed 's/\([\\\"'\'']\)/\\\1/g'`" ;; esac case "$f" in "*://*:*@*") ;; "*://*@*") need_pass=true;; esac if $verbose; then SCRIPT="$SCRIPT echo Retrieving \`\"$f\"\'...;" fi if $need_pass; then SCRIPT="$SCRIPT echo \"$f\" needs password;" fi SCRIPT="$SCRIPT get1 $CONT \"$f\";" if $verbose; then SCRIPT="$SCRIPT && echo Got \`\"$f\"\'.;" fi done if [ "$SCRIPT" = "" ]; then echo "Usage: $0 URL [URL...]" >&2 exit 1 fi exec lftp -c "$INTRO $SCRIPT" lftp-4.6.3a/src/buffer_zlib.h0000644000015000007670000000217012407767075013023 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef BUFFER_ZLIB_H #define BUFFER_ZLIB_H #include #include #include #include #include "buffer.h" class DataInflator : public DataTranslator { z_stream z; int z_err; public: DataInflator(); ~DataInflator(); void PutTranslated(Buffer *dst,const char *buf,int size); void ResetTranslation(); }; #endif //BUFFER_ZLIB_H lftp-4.6.3a/src/Makefile.am0000644000015000007670000001400012536241502012371 00000000000000pkgverlibdir = $(pkglibdir)/$(VERSION) bin_PROGRAMS = lftp bin_SCRIPTS = lftpget pkgdata_SCRIPTS = import-ncftp import-netscape verify-file convert-mozilla-cookies xdg-move noinst_SCRIPTS = ftpget EXTRA_DIST = $(pkgdata_SCRIPTS) $(bin_SCRIPTS) $(noinst_SCRIPTS) lftp_SOURCES = lftp.cc complete.h complete.cc lftp_rl.c lftp_rl.h attach.cc attach.h noinst_PROGRAMS = example1 example2 example1-cmd noinst_LTLIBRARIES = example-module1.la example1_SOURCES = example1.cc example1_cmd_SOURCES = example1-cmd.cc example2_SOURCES = example2.cc example_module1_la_SOURCES = example-module1.cc example_module1_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir) TASK_MODULES = liblftp-pty.la liblftp-network.la proto-ftp.la proto-http.la proto-file.la proto-fish.la proto-sftp.la JOB_MODULES = cmd-mirror.la cmd-sleep.la cmd-torrent.la if WITH_MODULES pkgverlib_LTLIBRARIES = $(TASK_MODULES) $(JOB_MODULES) else TASK_MODULES_STATIC = $(TASK_MODULES) JOB_MODULES_STATIC = $(JOB_MODULES) endif lib_LTLIBRARIES = liblftp-tasks.la liblftp-jobs.la proto_ftp_la_SOURCES = ftpclass.cc ftpclass.h FtpListInfo.cc FtpListInfo.h\ FtpDirList.cc FtpDirList.h ftp-opie.c netkey.c FileCopyFtp.cc FileCopyFtp.h proto_http_la_SOURCES = Http.cc Http.h HttpDir.cc HttpDir.h HttpDirXML.cc buffer_zlib.cc buffer_zlib.h proto_file_la_SOURCES = LocalAccess.cc LocalAccess.h proto_fish_la_SOURCES = Fish.cc Fish.h proto_sftp_la_SOURCES = SFtp.cc SFtp.h cmd_mirror_la_SOURCES = MirrorJob.cc MirrorJob.h cmd_sleep_la_SOURCES = SleepJob.cc SleepJob.h cmd_torrent_la_SOURCES= Torrent.cc Torrent.h TorrentTracker.cc TorrentTracker.h\ DHT.cc DHT.h Bencode.cc Bencode.h liblftp_pty_la_SOURCES = PtyShell.cc PtyShell.h lftp_pty.c lftp_pty.h liblftp_network_la_SOURCES = NetAccess.cc NetAccess.h Resolver.cc Resolver.h\ lftp_ssl.cc lftp_ssl.h buffer_ssl.cc buffer_ssl.h RateLimit.cc RateLimit.h\ network.cc network.h SSH_Access.cc SSH_Access.h if NEED_TRIO TRIO = $(top_builddir)/trio/libtrio.la endif GNULIB = $(top_builddir)/lib/libgnu.la proto_ftp_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir) proto_http_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir) proto_file_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir) proto_fish_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir) proto_sftp_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir) cmd_mirror_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir) cmd_sleep_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir) cmd_torrent_la_LDFLAGS= -module -avoid-version -rpath $(pkgverlibdir) liblftp_pty_la_LDFLAGS = -avoid-version -rpath $(pkgverlibdir) liblftp_network_la_LDFLAGS = -avoid-version -rpath $(pkgverlibdir) $(OPENSSL_LDFLAGS) liblftp_network_la_LIBADD = $(SOCKSLIBS) $(OPENSSL_LIBS) $(LIBGNUTLS_LIBS) $(GNULIB) proto_ftp_la_LIBADD = liblftp-network.la proto_http_la_LIBADD = liblftp-network.la $(EXPAT_LIBS) $(ZLIB_LDFLAGS) $(ZLIB) proto_fish_la_LIBADD = liblftp-network.la liblftp-pty.la proto_sftp_la_LIBADD = liblftp-network.la liblftp-pty.la cmd_torrent_la_LIBADD = liblftp-network.la liblftp_tasks_la_SOURCES = PollVec.cc PollVec.h SMTask.cc SMTask.h ProcWait.cc\ ProcWait.h GetPass.cc GetPass.h ConnectionSlot.cc ConnectionSlot.h\ CharReader.cc CharReader.h Cache.cc Cache.h LsCache.cc LsCache.h\ FileAccess.h FileAccess.cc ResMgr.h ResMgr.cc Ref.h ProtoLog.cc ProtoLog.h\ Filter.cc Filter.h SignalHook.cc SignalHook.h FileCopy.cc FileCopy.h\ xmalloc.cc xmalloc.h xstring.cc xstring.h FileSet.cc FileSet.h\ log.h log.cc StringSet.cc StringSet.h xarray.cc xarray.h xmap.cc xmap.h\ buffer.cc buffer.h url.cc url.h StatusLine.cc StatusLine.h plural.c plural.h\ misc.h misc.cc fg.cc fg.h module.cc module.h modconfig.h\ resource.cc DummyProto.cc DummyProto.h Error.cc Error.h\ ArgV.cc ArgV.h ascii_ctype.h keyvalue.cc keyvalue.h bookmark.cc bookmark.h\ Speedometer.cc FileGlob.cc FileGlob.h xlist.h xheap.h\ Speedometer.h netrc.cc netrc.h lftp_tinfo.cc lftp_tinfo.h\ TimeDate.cc TimeDate.h Timer.cc Timer.h GetFileInfo.cc GetFileInfo.h\ StringPool.cc StringPool.h DirColors.cc DirColors.h IdNameCache.cc\ IdNameCache.h PatternSet.cc PatternSet.h LocalDir.cc LocalDir.h liblftp_tasks_la_LIBADD = $(TASK_MODULES_STATIC) $(TRIO) $(GNULIB)\ $(LIB_CRYPTO) $(INET_PTON_LIB) $(LIB_CLOCK_GETTIME) $(SOCKSLIBS)\ $(LIBSOCKET) $(LIB_POLL) $(LIB_SELECT) $(LTLIBINTL) $(LTLIBICONV) liblftp_jobs_la_SOURCES = Job.cc Job.h CmdExec.cc CmdExec.h\ commands.cc mgetJob.h mgetJob.cc SysCmdJob.cc SysCmdJob.h rmJob.cc rmJob.h\ parsecmd.cc mvJob.cc mvJob.h alias.cc alias.h\ CatJob.cc CatJob.h EditJob.cc EditJob.h GetJob.cc GetJob.h\ ColumnOutput.h ColumnOutput.cc FileSetOutput.h FileSetOutput.cc\ mkdirJob.cc mkdirJob.h pgetJob.cc pgetJob.h FileFeeder.cc FileFeeder.h\ QueueFeeder.cc QueueFeeder.h history.cc history.h\ FindJob.cc FindJob.h FindJobDu.cc FindJobDu.h ChmodJob.cc ChmodJob.h\ TreatFileJob.cc TreatFileJob.h CopyJob.cc CopyJob.h echoJob.cc echoJob.h\ OutputJob.cc OutputJob.h FileCopyOutputJob.cc FileCopyOutputJob.h\ buffer_std.cc buffer_std.h liblftp_jobs_la_LIBADD = $(JOB_MODULES_STATIC) liblftp-tasks.la lftp_LDFLAGS = -export-dynamic lftp_LDADD = liblftp-jobs.la $(READLINE) lftp_DEPENDENCIES = liblftp-jobs.la $(READLINE_DEPEND) example1_LDADD = liblftp-tasks.la example1_cmd_LDADD = liblftp-jobs.la example2_LDADD = liblftp-tasks.la CLEANFILES = *.la AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/trio $(ZLIB_CPPFLAGS) $(OPENSSL_CPPFLAGS) $(LIBGNUTLS_CFLAGS) # libtool does not strip modules, do it here. install-data-hook: if WITH_MODULES rm -f $(DESTDIR)$(pkgverlibdir)/*.la; \ case " $(LDFLAGS) " in *" -s "*) \ $(STRIP) $(DESTDIR)$(pkgverlibdir)/*.so;; \ esac else -rmdir $(DESTDIR)$(pkgverlibdir) 2>/dev/null || : endif # without *.la files libtool does not remove the *.so files. uninstall-hook: -rmdir "$(DESTDIR)$(pkgdatadir)" 2>/dev/null || : if WITH_MODULES for m in $(pkgverlib_LTLIBRARIES); do rm -f "$(DESTDIR)$(pkgverlibdir)/$${m%.la}.so"; done -rmdir "$(DESTDIR)$(pkgverlibdir)" 2>/dev/null || : -rmdir "$(DESTDIR)$(pkglibdir)" 2>/dev/null || : endif lftp-4.6.3a/src/lftp.cc0000644000015000007670000003314512405754467011642 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "modconfig.h" #include "trio.h" #include #include // for mkdir() #include #include #include #include #include #include #include "xstring.h" #include "xmalloc.h" #include "alias.h" #include "CmdExec.h" #include "SignalHook.h" #include "GetPass.h" #include "history.h" #include "log.h" #include "DummyProto.h" #include "ResMgr.h" #include "LsCache.h" #include "IdNameCache.h" #include "LocalDir.h" #include "ConnectionSlot.h" #include "misc.h" #include "ArgV.h" #include "attach.h" #include "configmake.h" #include "lftp_rl.h" #include "complete.h" CDECL_BEGIN #include CDECL_END #define top_exec CmdExec::top void hook_signals() { SignalHook::DoCount(SIGHUP); SignalHook::Ignore(SIGTTOU); ProcWait::Signal(true); } ResDecl res_save_cwd_history ("cmd:save-cwd-history","yes",ResMgr::BoolValidate,ResMgr::NoClosure); ResDecl res_save_rl_history ("cmd:save-rl-history","yes",ResMgr::BoolValidate,ResMgr::NoClosure); ResDecl res_stifle_rl_history ("cmd:stifle-rl-history","500",ResMgr::UNumberValidate,ResMgr::NoClosure); class ReadlineFeeder : public CmdFeeder, private ResClient { bool tty:1; bool ctty:1; bool add_newline:1; int eof_count; xstring_c cmd_buf; xstring_c for_history; static bool readline_inited; void readline_init() { if(readline_inited) return; readline_inited=true; lftp_readline_init(); lftp_rl_read_history(); if(for_history) { lftp_add_history_nodups(for_history); for_history.set(0); } Reconfig(0); } public: ReadlineFeeder(const ArgV *args) { tty=isatty(0); ctty=(tcgetpgrp(0)!=(pid_t)-1); add_newline=false; eof_count=0; if(args && args->count()>1) for_history.set_allocated(args->CombineQuoted()); } virtual ~ReadlineFeeder() { if(readline_inited) { if(res_save_cwd_history.QueryBool(0)) cwd_history.Save(); if(res_save_rl_history.QueryBool(0)) lftp_rl_write_history(); } } bool IsInteractive() const { return tty; } bool RealEOF() { return !tty || eof_count>3; } const char *NextCmd(class CmdExec *exec,const char *prompt) { if(add_newline) { add_newline=false; return "\n"; } ::completion_shell=exec; ::remote_completion=exec->remote_completion; if(tty) { readline_init(); if(ctty) // controlling terminal { if(!in_foreground_pgrp()) { // looks like we are in background. Can't read from tty exec->Timeout(500); return ""; } } SignalHook::ResetCount(SIGINT); cmd_buf.set_allocated(lftp_readline(prompt)); xmalloc_register_block(cmd_buf.get_non_const()); if(cmd_buf && *cmd_buf) { if(exec->csh_history) { char *history_value0=0; int expanded = lftp_history_expand (cmd_buf, &history_value0); if (expanded) { if(history_value0) xmalloc_register_block(history_value0); xstring_ca history_value(history_value0); if (expanded < 0) fprintf (stderr, "%s\n", history_value.get()); /* If there was an error, return nothing. */ if (expanded < 0 || expanded == 2) /* 2 == print only */ { exec->Timeout(0); // and retry immediately return ""; } cmd_buf.set_allocated(history_value.borrow()); } } lftp_add_history_nodups(cmd_buf); } else if(cmd_buf==0 && exec->interactive) puts("exit"); if(cmd_buf==0) eof_count++; else eof_count=0; } else // not a tty { if(exec->interactive) { while(*prompt) { char ch=*prompt++; if(ch!=1 && ch!=2) putchar(ch); } fflush(stdout); } cmd_buf.set_allocated(readline_from_file(0)); } ::completion_shell=0; if(cmd_buf && last_char(cmd_buf)!='\n') { exec->Timeout(0); add_newline=true; } return cmd_buf; } void clear() { if(!tty) return; lftp_rl_clear(); } void Reconfig(const char *) { lftp_rl_history_stifle(res_stifle_rl_history.Query(0)); } }; bool ReadlineFeeder::readline_inited; #define args (parent->args) #define exit_code (parent->exit_code) #define output (parent->output) #define session (parent->session) #define eprintf parent->eprintf CMD(history) { enum { READ, WRITE, CLEAR, LIST } mode = LIST; const char *fn = NULL; static struct option history_options[]= { {"read",required_argument,0,'r'}, {"write",required_argument,0,'w'}, {"clear",no_argument,0,'c'}, {"list",required_argument,0,'l'}, {0,0,0,0} }; exit_code=0; int opt; while((opt=args->getopt_long("+r:w:cl",history_options,0))!=EOF) { switch(opt) { case 'r': mode = READ; fn = optarg; break; case 'w': mode = WRITE; fn = optarg; break; case 'c': mode = CLEAR; break; case 'l': mode = LIST; break; case '?': eprintf(_("Try `help %s' for more information.\n"),args->a0()); return 0; } } int cnt = 16; if(const char *arg = args->getcurr()) { if(!strcasecmp(arg, "all")) cnt = -1; else if(isdigit((unsigned char)arg[0])) cnt = atoi(arg); else { eprintf(_("%s: %s - not a number\n"), args->a0(), args->getcurr()); exit_code=1; return 0; } } switch(mode) { case READ: if(int err = lftp_history_read(fn)) { eprintf("%s: %s: %s\n", args->a0(), fn, strerror(err)); exit_code=1; } break; case WRITE: if(int err = lftp_history_write(fn)) { eprintf("%s: %s: %s\n", args->a0(), fn, strerror(err)); exit_code=1; } break; case LIST: lftp_history_list(cnt); break; case CLEAR: lftp_history_clear(); break; } return 0; } CMD(attach) { const char *pid_s=args->getarg(1); if(!pid_s) { xstring& path=AcceptTermFD::get_sock_path(1); path.rtrim('1'); path.append('*'); glob_t g; glob(path, 0, NULL, &g); for(size_t i=0; ia0(),sock_path); if(unlink(sock_path)==-1) eprintf("%s: unlink(%s): %s\n",args->a0(),sock_path,strerror(errno)); } pid_s=0; continue; } pid_s=alloca_strdup(pid_s); break; } globfree(&g); if(!pid_s) { eprintf("%s: no backgrounded lftp processes found.\n",args->a0()); return 0; } } int pid=atoi(pid_s); SMTaskRef term_sender(new SendTermFD(pid)); while(!term_sender->Done()) { SMTask::Schedule(); SMTask::Block(); } exit_code=0; if(term_sender->Failed()) { eprintf("%s\n",term_sender->ErrorText()); exit_code=1; } return 0; } #undef args #undef exit_code #undef output #undef session #undef eprintf static void sig_term(int sig) { printf(_("[%u] Terminated by signal %d. %s\n"),(unsigned)getpid(),sig,SMTask::now.IsoDateTime()); if(top_exec) { top_exec->KillAll(); alarm(30); while(Job::NumberOfJobs()>0) { SMTask::Schedule(); SMTask::Block(); } } exit(1); } static void detach() { SignalHook::Ignore(SIGINT); SignalHook::Ignore(SIGHUP); SignalHook::Ignore(SIGTSTP); const char *home=get_lftp_data_dir(); if(home) { xstring& log=xstring::get_tmp(home); if(access(log,F_OK)==-1) log.append("_log"); else log.append("/log"); int fd=open(log,O_WRONLY|O_APPEND|O_CREAT,0600); if(fd>=0) { dup2(fd,1); // stdout dup2(fd,2); // stderr if(fd!=1 && fd!=2) close(fd); } Log::global->ShowPID(); Log::global->ShowTime(); Log::global->ShowContext(); } close(0); // close stdin. open("/dev/null",O_RDONLY); // reopen it, just in case. #ifdef HAVE_SETSID setsid(); // start a new session. #endif SignalHook::Handle(SIGTERM,sig_term); } static void move_to_background() { // notify jobs Job::lftpMovesToBackground_ToAll(); // wait they do something, but no more than 1 sec. SMTask::RollAll(TimeInterval(1,0)); // if all jobs terminated, don't really move to bg. if(Job::NumberOfJobs()==0) return; top_exec->AtBackground(); top_exec->WaitDone(); if(Job::NumberOfJobs()==0) return; fflush(stdout); fflush(stderr); pid_t pid=fork(); switch(pid) { case(0): // child { pid=getpid(); detach(); printf(_("[%u] Started. %s\n"),(unsigned)pid,SMTask::now.IsoDateTime()); SMTaskRef term_acceptor(new AcceptTermFD()); for(;;) { SMTask::Schedule(); if(Job::NumberOfJobs()==0) break; SMTask::Block(); if(term_acceptor->Accepted()) { hook_signals(); top_exec->SetInteractive(); top_exec->SetStatusLine(new StatusLine(1)); top_exec->SetCmdFeeder(new ReadlineFeeder(0)); for(;;) { SMTask::Schedule(); if(top_exec->Done() || term_acceptor->Detached()) { if(Job::NumberOfJobs()>0) { printf(_("[%u] Detaching from the terminal to complete transfers...\n"),(unsigned)pid); } else if(top_exec->Done()) { printf(_("[%u] Exiting and detaching from the terminal.\n"),(unsigned)pid); } fflush(stdout); term_acceptor->Detach(); detach(); printf(_("[%u] Detached from terminal. %s\n"),(unsigned)pid,SMTask::now.IsoDateTime()); break; } SMTask::Block(); } } } top_exec->AtExitBg(); top_exec->AtTerminate(); top_exec->WaitDone(); printf(_("[%u] Finished. %s\n"),(unsigned)pid,SMTask::now.IsoDateTime()); break; } default: // parent printf(_("[%u] Moving to background to complete transfers...\n"), (unsigned)pid); fflush(stdout); _exit(0); case(-1): perror("fork()"); } } int lftp_slot(int count,int key) { if(!top_exec) return 0; char slot[2]; slot[0]=key; slot[1]=0; top_exec->ChangeSlot(slot); lftp_rl_set_prompt(top_exec->MakePrompt()); return 0; } void source_if_exist(const char *rc) { if(access(rc,R_OK)!=-1) { top_exec->FeedCmd("source "); top_exec->FeedCmd(rc); top_exec->FeedCmd("\n"); } } static void tty_clear() { if(top_exec) top_exec->pre_stdout(); } // look for the option, remove it and return true if found static bool pick_option(int& argc,char **argv,const char *option) { for(int i=1; i Write history to file.\n" " -r Read history from file; appends to current history.\n" " -c Clear the history.\n" " -l List the history (default).\n" "Optional argument cnt specifies the number of history lines to list,\n" "or \"all\" to list all entries.\n")); CmdExec::RegisterCommand("attach",cmd_attach,"attach [PID]", N_("Attach the terminal to specified backgrounded lftp process.\n")); top_exec=new CmdExec(0,0); hook_signals(); top_exec->SetStatusLine(new StatusLine(1)); Log::global=new Log; Log::global->SetCB(tty_clear); source_if_exist(SYSCONFDIR"/lftp.conf"); if(!pick_option(argc,argv,"--norc")) { const char *home=getenv("HOME"); if(home) source_if_exist(dir_file(home,".lftprc")); home=get_lftp_config_dir(); if(home) source_if_exist(dir_file(home,"rc")); } top_exec->WaitDone(); top_exec->SetTopLevel(); top_exec->Fg(); Ref args(new ArgV(argc,argv)); args->setarg(0,"lftp"); lftp_feeder=new ReadlineFeeder(args); top_exec->ExecParsed(args.borrow()); top_exec->WaitDone(); int exit_code=top_exec->ExitCode(); top_exec->AtExit(); top_exec->WaitDone(); if(Job::NumberOfJobs()>0) { top_exec->SetInteractive(false); move_to_background(); } else { top_exec->AtExitFg(); top_exec->AtTerminate(); top_exec->WaitDone(); } top_exec->KillAll(); top_exec=0; Job::Cleanup(); ConnectionSlot::Cleanup(); SessionPool::ClearAll(); FileAccess::ClassCleanup(); ProcWait::DeleteAll(); IdNameCacheCleanup(); SignalHook::Cleanup(); Log::Cleanup(); SMTask::Cleanup(); return exit_code; } lftp-4.6.3a/src/mvJob.h0000644000015000007670000000272712122060322011566 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef MVJOB_H #define MVJOB_H #include "Job.h" #include "StatusLine.h" #include "ArgV.h" #include "trio.h" class mvJob : public SessionJob { xstring_c from; xstring to; FA::open_mode m; bool remove_target; bool failed; bool done; public: int Do(); int Done() { return done; } int ExitCode() { return failed; } xstring& FormatStatus(xstring&,int,const char *); void ShowRunStatus(const SMTaskRef&); void SayFinal(); void doOpen() const; const char *cmd() const { return m==FA::RENAME ? "mv" : "ln"; } mvJob(FileAccess *session,const char *f,const char *t,FA::open_mode m=FA::RENAME); void RemoveTargetFirst() { remove_target=true; } }; #endif // MVJOB_H lftp-4.6.3a/src/pgetJob.cc0000644000015000007670000002744212513710676012264 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include "pgetJob.h" #include "url.h" #include "misc.h" #include "log.h" ResType pget_vars[] = { {"pget:save-status", "10s", ResMgr::TimeIntervalValidate,ResMgr::NoClosure}, {"pget:default-n", "5", ResMgr::UNumberValidate,ResMgr::NoClosure}, {"pget:min-chunk-size", "1M", ResMgr::UNumberValidate,ResMgr::NoClosure}, {0} }; ResDecls pget_vars_register(pget_vars); #undef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #define super CopyJob int pgetJob::Do() { int m=STALL; if(Done()) return m; if(status_timer.Stopped()) { SaveStatus(); status_timer.Reset(); } if(c->Done()) { if(status_file) { remove(status_file); status_file.set(0); } } if(no_parallel || max_chunks<2) { c->Resume(); return super::Do(); } if(chunks_done && chunks && c->GetPos()>=limit0) { c->SetRangeLimit(limit0); // make it stop. c->Resume(); c->Do(); free_chunks(); m=MOVED; } if(chunks==0 || c->GetPos()Resume(); m|=super::Do(); } else if(chunks.count()>0) { if(chunks[0]->Error()) { Log::global->Format(0,"pget: chunk[%d] error: %s\n",0,chunks[0]->ErrorText()); no_parallel=true; c->Resume(); } else if(!chunks[0]->Done() && chunks[0]->GetBytesCount()Resume(); if(chunks.count()==1) { free_chunks(); no_parallel=true; } else { limit0=chunks[0]->c->GetRangeLimit(); chunks.remove(0); } m=MOVED; } else c->Suspend(); } if(Done()) return m; off_t offset=c->GetPos(); off_t size=c->GetSize(); if(chunks==0 && !chunks_done) { if(size==NO_SIZE_YET) return m; if(size==NO_SIZE || (c->put && c->put->GetLocal()==0)) { Log::global->Write(0,_("pget: falling back to plain get")); Log::global->Write(0," ("); if(c->put && c->put->GetLocal()==0) { Log::global->Write(0,_("the target file is remote")); if(size==NO_SIZE) Log::global->Write(0,", "); } if(size==NO_SIZE) Log::global->Write(0,_("the source file size is unknown")); Log::global->Write(0,")\n"); no_parallel=true; return m; } // Make sure the destination file is open before starting chunks, // it disables temp-name creation in the chunk's Init. if(c->put->GetLocal()->getfd()==-1) return m; c->put->NeedSeek(); // seek before writing if(pget_cont) LoadStatus(); else if(status_file) remove(status_file); if(!chunks) InitChunks(offset,size); m=MOVED; if(!chunks) { no_parallel=true; return m; } if(!pget_cont) { SaveStatus(); status_timer.Reset(); } } /* cycle through the chunks */ chunks_done=true; total_xferred=MIN(offset,limit0); off_t got_already=c->GetSize()-limit0; total_xfer_rate=c->GetRate(); off_t rem=limit0-c->GetPos(); if(rem<=0) total_eta=0; else total_eta=c->GetETA(rem); for(int i=0; iError()) { Log::global->Format(0,"pget: chunk[%d] error: %s\n",i,chunks[i]->ErrorText()); no_parallel=true; break; } if(!chunks[i]->Done()) { if(chunks[i]->GetPos()>=chunks[i]->start) total_xferred+=MIN(chunks[i]->GetPos(),chunks[i]->limit) -chunks[i]->start; if(total_eta>=0) { long eta=chunks[i]->GetETA(); if(eta<0) total_eta=-1; else if(eta>total_eta) total_eta=eta; // total eta is the maximum. } total_xfer_rate+=chunks[i]->GetRate(); chunks_done=false; } else // done { total_xferred+=chunks[i]->limit-chunks[i]->start; } got_already-=chunks[i]->limit-chunks[i]->start; } total_xferred+=got_already; if(no_parallel) { free_chunks(); return MOVED; } return m; } // xgettext:c-format static const char pget_status_format[]=N_("`%s', got %lld of %lld (%d%%) %s%s"); #define PGET_STATUS _(pget_status_format),name, \ (long long)total_xferred,(long long)size, \ percent(total_xferred,size),Speedometer::GetStrS(total_xfer_rate), \ c->GetETAStrSFromTime(total_eta) void pgetJob::ShowRunStatus(const SMTaskRef& s) { if(Done() || no_parallel || max_chunks<2 || !chunks) { super::ShowRunStatus(s); return; } const char *name=SqueezeName(s->GetWidthDelayed()-58); off_t size=GetSize(); StringSet status; status.AppendFormat(PGET_STATUS); int w=s->GetWidthDelayed(); char *bar=string_alloca(w--); memset(bar,'+',w); bar[w]=0; int i; int p=c->GetPos()*w/size; for(i=start0*w/size; iDone()?chunks[chunk]->limit:chunks[chunk]->GetPos())*w/size; for(i=chunks[chunk]->start*w/size; ilimit*w/size; for( ; iShow(status); } // list subjobs (chunk xfers) only when verbose xstring& pgetJob::FormatJobs(xstring& s,int verbose,int indent) { indent--; if(!chunks) return Job::FormatJobs(s,verbose,indent); if(verbose>1) { if(c->GetPos()SetRangeLimit(limit0); // to see right ETA. CopyJob::FormatStatus(s,verbose,"\t"); c->SetRangeLimit(FILE_END); } Job::FormatJobs(s,verbose,indent); } return s; } xstring& pgetJob::FormatStatus(xstring& s,int verbose,const char *prefix) { if(Done() || no_parallel || max_chunks<2 || !chunks) return super::FormatStatus(s,verbose,prefix); s.append(prefix); const char *name=GetDispName(); off_t size=GetSize(); s.appendf(PGET_STATUS); return s.append('\n'); } void pgetJob::free_chunks() { if(chunks) { for(int i=0; iGetBytesCount(); chunks.unset(); } } pgetJob::pgetJob(FileCopy *c1,const char *n,int m) : CopyJob(c1,n,"pget") { chunks_bytes=0; start0=limit0=0; total_xferred=0; total_xfer_rate=0; no_parallel=false; chunks_done=false; pget_cont=c->SetContinue(false); max_chunks=m?m:ResMgr::Query("pget:default-n",0); total_eta=-1; status_timer.SetResource("pget:save-status",0); const Ref& local=c->put->GetLocal(); if(local && local->full_name) { status_file.vset(local->full_name.get(),".lftp-pget-status",NULL); if(pget_cont) LoadStatus0(); } } void pgetJob::PrepareToDie() { free_chunks(); super::PrepareToDie(); } pgetJob::~pgetJob() { } pgetJob::ChunkXfer *pgetJob::NewChunk(const char *remote,off_t start,off_t limit) { const Ref& local=c->put->GetLocal(); FileCopyPeerFDStream *dst_peer=new FileCopyPeerFDStream(local,FileCopyPeer::PUT); dst_peer->NeedSeek(); // seek before writing dst_peer->SetBase(0); FileCopy *c1=FileCopy::New(c->get->Clone(),dst_peer,false); c1->SetRange(start,limit); c1->SetSize(GetSize()); c1->DontCopyDate(); c1->DontVerify(); c1->FailIfCannotSeek(); ChunkXfer *chunk=new ChunkXfer(c1,remote,start,limit); chunk->cmdline.setf("\\chunk %lld-%lld",(long long)start,(long long)(limit-1)); return chunk; } pgetJob::ChunkXfer::ChunkXfer(FileCopy *c1,const char *name, off_t s,off_t lim) : CopyJob(c1,name,"pget-chunk") { start=s; limit=lim; } void pgetJob::SaveStatus() { if(!status_file) return; FILE *f=fopen(status_file,"w"); if(!f) return; off_t size=GetSize(); fprintf(f,"size=%lld\n",(long long)size); int i=0; fprintf(f,"%d.pos=%lld\n",i,(long long)GetPos()); if(!chunks) goto out_close; fprintf(f,"%d.limit=%lld\n",i,(long long)limit0); for(int chunk=0; chunkDone()) continue; i++; fprintf(f,"%d.pos=%lld\n",i,(long long)chunks[chunk]->GetPos()); fprintf(f,"%d.limit=%lld\n",i,(long long)chunks[chunk]->limit); } out_close: fclose(f); } void pgetJob::LoadStatus0() { if(!status_file) return; FILE *f=fopen(status_file,"r"); if(!f) { int saved_errno=errno; // Probably the file is already complete // or it was previously downloaded by plain get. struct stat st; if(stat(c->put->GetLocal()->full_name,&st)==-1) return; Log::global->Format(0,"pget: %s: cannot open (%s), resuming at the file end\n", status_file.get(),strerror(saved_errno)); c->SetRange(st.st_size,FILE_END); return; } long long size; if(fscanf(f,"size=%lld\n",&size)<1) goto out_close; long long pos; int j; if(fscanf(f,"%d.pos=%lld\n",&j,&pos)<2 || j!=0) goto out_close; Log::global->Format(10,"pget: got chunk[%d] pos=%lld\n",j,pos); c->SetRange(pos,FILE_END); out_close: fclose(f); } void pgetJob::LoadStatus() { if(!status_file) return; FILE *f=fopen(status_file,"r"); if(!f) return; struct stat st; if(fstat(fileno(f),&st)<0) { out_close: fclose(f); return; } long long size; if(fscanf(f,"size=%lld\n",&size)<1) goto out_close; int i=0; int max_chunks=st.st_size/20; // highest estimate - min 20 bytes per chunk in status file. long long *pos=(long long *)alloca(2*max_chunks*sizeof(*pos)); long long *limit=pos+max_chunks; for(;;) { int j; if(fscanf(f,"%d.pos=%lld\n",&j,pos+i)<2 || j!=i) break; if(fscanf(f,"%d.limit=%lld\n",&j,limit+i)<2 || j!=i) goto out_close; if(i>0 && pos[i]>=limit[i]) continue; Log::global->Format(10,"pget: got chunk[%d] pos=%lld\n",j,pos[i]); Log::global->Format(10,"pget: got chunk[%d] limit=%lld\n",j,limit[i]); i++; } if(i<1) goto out_close; if(sizeGetSize()) // file grew? { if(limit[i-1]==size) limit[i-1]=c->GetSize(); else { pos[i]=size; limit[i]=c->GetSize(); i++; } } int num_of_chunks=i-1; start0=pos[0]; limit0=limit[0]; c->SetRange(pos[0],FILE_END); if(num_of_chunks<1) goto out_close; for(i=0; iSetParentFg(this,false); chunks.append(c); } goto out_close; } void pgetJob::InitChunks(off_t offset,off_t size) { /* initialize chunks */ off_t chunk_size=(size-offset)/max_chunks; int min_chunk_size=ResMgr::Query("pget:min-chunk-size",0); if(chunk_sizeSetParentFg(this,false); chunks.append(c); curr_offs+=chunk_size; } assert(curr_offs==size); } lftp-4.6.3a/src/SleepJob.h0000644000015000007670000000336012122060634012214 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef SLEEPJOB_H #define SLEEPJOB_H #include "Job.h" #include "ResMgr.h" #include "LocalDir.h" #include "CmdExec.h" class SleepJob : public SessionJob, public Timer { xstring cmd; int exit_code; bool done; Ref saved_cwd; JobRef exec; bool repeat; bool weak; // terminate on `exit bg'. int repeat_count; int max_repeat_count; int continue_code; int break_code; public: int Do(); int Done() { return done; } int ExitCode() { return exit_code; } SleepJob(const TimeInterval &when,FileAccess *s=0,LocalDirectory *cwd=0,char *what=0); ~SleepJob(); const char *Status(); xstring& FormatStatus(xstring&,int v,const char *); void ShowRunStatus(const SMTaskRef& s); void Repeat(int m) { repeat=true; max_repeat_count=m; Stop(); } void SetWeak(bool w) { weak=w; } void ContinueCode(int c) { continue_code=c; } void BreakCode(int c) { break_code=c; } void lftpMovesToBackground(); }; #endif//SLEEPJOB_H lftp-4.6.3a/src/Ref.h0000644000015000007670000000413312364474052011237 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef REF_H #define REF_H template class Ref { Ref(const Ref&); // disable cloning void operator=(const Ref&); // and assignment protected: T *ptr; public: Ref() { ptr=0; } Ref(T *p) { ptr=p; } ~Ref() { delete ptr; } void operator=(T *p) { delete ptr; ptr=p; } operator const T*() const { return ptr; } T *operator->() const { return ptr; } T *borrow() { return replace_value(ptr,(T*)0); } const T *get() const { return ptr; } T *get_non_const() const { return ptr; } template const Ref& Cast() const { void(static_cast(ptr)); return *(const Ref*)this; } static const Ref null; void _set(T *p) { ptr=p; } void _clear() { ptr=0; } void unset() { *this=0; } }; template const Ref Ref::null; template class RefToArray : public Ref { RefToArray(const RefToArray&); // disable cloning void operator=(const RefToArray&); // and assignment public: RefToArray() {} RefToArray(T *p) : Ref(p) {} ~RefToArray() { delete[] Ref::ptr; Ref::ptr=0; } void operator=(T *p) { delete[] Ref::ptr; Ref::ptr=p; } T& operator[](unsigned i) const { return Ref::ptr[i]; } static const RefToArray null; }; template const RefToArray RefToArray::null; #endif lftp-4.6.3a/src/attach.cc0000644000015000007670000000161512122057014012112 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "attach.h" // this limits SendTermFD to a single instance, but we don't need more yet. pid_t SendTermFD::pass_pid; lftp-4.6.3a/src/lftp_rl.c0000644000015000007670000001332712122060126012146 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include "lftp_rl.h" /* complete.cc */ void lftp_line_complete(); void lftp_add_history_nodups(const char *cmd_buf) { HIST_ENTRY *temp; char ts[24]; if(cmd_buf[0]==' ') return; using_history(); temp=previous_history(); if(temp==0 || strcmp(temp->line,cmd_buf)) add_history(cmd_buf); sprintf(ts," %lld",(long long)time(0)); add_history_time(ts); using_history(); } char *lftp_readline(const char *prompt) { char *ret = readline(prompt); /* Tell completion that we don't need completion data anymore; * it might be taking a good chunk of memory. */ lftp_line_complete(); return ret; } int lftp_history_expand(const char *what, char **where) { return history_expand((char*)what,where); } int lftp_history_read(const char *fn) { using_history(); return read_history(fn); } int lftp_history_write(const char *fn) { using_history(); return write_history(fn); } void lftp_history_list(int cnt) { HISTORY_STATE *st = history_get_history_state(); HIST_ENTRY *hist; int i; using_history(); i = history_base + st->length - cnt; if(cnt == -1 || i < history_base) i = history_base; char ts_str[24]; while((hist = history_get(i))) { ts_str[0]=0; if(hist->timestamp[0]) { time_t ts=atol(hist->timestamp+1); strftime(ts_str,sizeof(ts_str),"%Y-%m-%d %H:%M:%S",localtime(&ts)); } printf("%5d%c %s %s\n", i++, hist->data?'*':' ', ts_str, hist->line); } } void lftp_history_clear() { clear_history(); } static int is_clear=0; void lftp_rl_clear() { extern char *rl_display_prompt; extern int _rl_mark_modified_lines; int old_end=rl_end; char *old_prompt=rl_display_prompt; int old_mark=_rl_mark_modified_lines; rl_end=0; rl_display_prompt=""; rl_expand_prompt(0); _rl_mark_modified_lines=0; rl_redisplay(); rl_end=old_end; rl_display_prompt=old_prompt; _rl_mark_modified_lines=old_mark; if(rl_display_prompt==rl_prompt) rl_expand_prompt(rl_prompt); is_clear=1; } void lftp_rl_redisplay_maybe() { if(is_clear) rl_redisplay(); is_clear=0; } /* prototype hell differences in various readline versions make it impossible * to use certain functions/variables in C++ */ void lftp_rl_set_ignore_some_completions_function(int (*func)(char**)) { rl_ignore_some_completions_function=func; } char **lftp_rl_completion_matches(const char *text,char *(*compentry)(const char *,int)) { return rl_completion_matches(text,compentry); } void completion_display_list (char **matches, int len); void lftp_rl_display_match_list (char **matches, int len, int max) { printf("\n"); /* get off the input line */ completion_display_list(matches, len); rl_forced_update_display(); /* redraw input line */ } void lftp_rl_init( const char *readline_name, char **(*attempted_completion_function)(const char *,int,int), int (*getc_function)(FILE*), const char *completer_quote_characters, const char *completer_word_break_characters, const char *filename_quote_characters, char *(*filename_quoting_function)(char *,int,char *), char *(*filename_dequoting_function)(const char *,int), int (*char_is_quoted_p)(const char *,int)) { rl_readline_name =readline_name; rl_attempted_completion_function =attempted_completion_function; rl_getc_function =getc_function; rl_completer_quote_characters =completer_quote_characters; rl_completer_word_break_characters=(char*)completer_word_break_characters; rl_filename_quote_characters =filename_quote_characters; rl_filename_quoting_function =filename_quoting_function; rl_filename_dequoting_function =(rl_dequote_func_t*)filename_dequoting_function; rl_char_is_quoted_p =(rl_linebuf_func_t*)char_is_quoted_p; rl_completion_display_matches_hook = lftp_rl_display_match_list; history_write_timestamps=1; history_comment_char=' '; } void lftp_rl_add_defun(const char *name,int (*func)(int,int),int key) { rl_add_defun(name,func,key); } void lftp_rl_bind(const char *key,const char *func) { char *line=alloca(strlen(key)+2+strlen(func)+1); sprintf(line,"%s: %s",key,func); rl_parse_and_bind(line); } void lftp_rl_set_prompt(const char *p) { rl_set_prompt(p); } extern char *get_lftp_data_dir(); static char *lftp_history_file; void lftp_rl_read_history() { if(!lftp_history_file) { const char *add="/rl_history"; const char *home=get_lftp_data_dir(); if(!home) return; lftp_history_file=(char*)malloc(strlen(home)+strlen(add)+1); strcat(strcpy(lftp_history_file,home),add); } read_history(lftp_history_file); } void lftp_rl_write_history() { if(!lftp_history_file) return; write_history(lftp_history_file); } void lftp_rl_history_stifle(int s) { if(s==0) unstifle_history(); else stifle_history(s); } lftp-4.6.3a/src/LocalDir.cc0000644000015000007670000000366412203374241012351 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include "LocalDir.h" #include "misc.h" #ifndef O_DIRECTORY # define O_DIRECTORY 0 #endif void LocalDirectory::SetFromCWD() { Unset(); fd=open(".",O_RDONLY|O_DIRECTORY); fcntl(fd,F_SETFD,FD_CLOEXEC); name.set_allocated(xgetcwd()); } const char *LocalDirectory::Chdir() { #ifdef HAVE_FCHDIR if(fd!=-1) { int res=fchdir(fd); if(res==-1) return strerror(errno); return 0; } #endif if(name) { int res=chdir(name); if(res==-1) return strerror(errno); return 0; } return "Directory location is undefined"; } const char *LocalDirectory::GetName() { return name; } void LocalDirectory::Unset() { if(fd!=-1) close(fd); fd=-1; name.set(0); } LocalDirectory::LocalDirectory() { fd=-1; } LocalDirectory::LocalDirectory(const LocalDirectory *o) { fd=-1; if(o->fd!=-1) { fd=dup(o->fd); fcntl(fd,F_SETFD,FD_CLOEXEC); } name.set(o->name); } LocalDirectory *LocalDirectory::Clone() const { return new LocalDirectory(this); } LocalDirectory::~LocalDirectory() { Unset(); } lftp-4.6.3a/src/OutputJob.cc0000644000015000007670000003347612413500301012606 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ /* Usage notes: * * Call PreFilter() to add a filter to the beginning of the chain; these * filters are initialized only once for all data. For example, * PreFilter("wc -l") * */ /* * Implementation notes: * * Background things we can't get around: * We must buffer (via FileCopy) output to a filter, since it might block. * * We must buffer the output from the filter to an output FileCopyPeer (ie. * a URL), for the same reason. * * So, we're stuck with having up to two FileCopy's. (One to send, one to filter.) * * In some cases, we only need one: if the output is an FD, the filter can * hook up directly and we can forget about that stage. * * In the case where we're outputting to a URL, we set up a FileCopy from a * pipe to the URL, and then pretend we're just outputting to an FD (the * pipe.) This means in the simple case of having no filters at all, writing * to a URL or file, we send the data an extra time through a FileCopy and a * pipe. That's a bit inefficient, but that's "cat file1 > file2"; that's * normally done with "get file1 -o file2", so this shouldn't happen often. * * It's very important that if the output is stdout, any filters point directly * at it, not through an extra copy: a pager, for example, will expect the output * to be a TTY. * */ #include #include "OutputJob.h" #include "ArgV.h" #include "FileCopy.h" #include "CopyJob.h" #include "url.h" #include "misc.h" #include "StatusLine.h" #include "DummyProto.h" #include #include #include #include #include #include #define super Job void OutputJob::InitCopy() { if(error) return; if(initialized) return; if(fa) { /* Set up a pipe sending data at the peer, so we can act like the FDStream * constructor. */ int filter_pipe[2]; if(pipe(filter_pipe) == -1) { // retry later current->TimeoutS(1); return; } FileCopyPeerFA *dst_peer = FileCopyPeerFA::New(fa.borrow(), fa_path, FA::STORE); /* Status only for remote outputs. */ if(!strcmp(dst_peer->GetProto(), "file")) no_status=true; fcntl(filter_pipe[0],F_SETFL,O_NONBLOCK); fcntl(filter_pipe[1],F_SETFL,O_NONBLOCK); /* The output of the pipe (0) goes to the output FileCopy. */ FDStream *pipe_output = new FDStream(filter_pipe[0],""); FileCopy *output_fc=FileCopy::New(new FileCopyPeerFDStream(pipe_output, FileCopyPeer::GET), dst_peer,false); output=new CopyJob(output_fc, fa_path, a0); output->NoStatus(no_status); output_fd=new FDStream(filter_pipe[1],""); pipe_output->CloseWhenDone(); output_fd->CloseWhenDone(); fa_path.set(0); } initialized=true; if(Error()) return; /* Clear the statusline, since we might change the pgrp if we create filters. */ ClearStatus(); /* Some legitimate uses produce broken pipe condition (cat|head). * We still want to produce broken pipe if we're not piping, eg * cat > pipe. */ if(IsFiltered()) fail_if_broken=false; if(filter) { /* Create the global filter: */ OutputFilter *global = new OutputFilter(filter, output_fd.borrow()); output_fd=global; } /* Use a FileCopy to buffer our output to the filter: */ FileCopyPeerFDStream *out = new FileCopyPeerFDStream(output_fd.borrow(), FileCopyPeer::PUT); FileCopy *input_fc = FileCopy::New(new FileCopyPeer(FileCopyPeer::GET), out, false); if(!fail_if_broken) input_fc->DontFailIfBroken(); input=new CopyJob(input_fc, xstring::format(_("%s (filter)"),a0.get()), filter?filter:a0); if(!output) output=input; input->SetParentFg(this); InputPeer()->SetDate(NO_DATE); InputPeer()->SetSize(NO_SIZE); input->GetCopy()->DontCopyDate(); input->NoStatus(); if(input != output) { output->SetParentFg(this); OutputPeer()->SetDate(NO_DATE); OutputPeer()->SetSize(NO_SIZE); output->GetCopy()->DontCopyDate(); output->NoStatus(); } if(is_stdout) { output->ClearStatusOnWrite(); output->GetCopy()->LineBuffered(); } Timeout(0); } void OutputJob::Init(const char *_a0) { input=output=0; initialized=false; error=false; no_status=false; a0.set(_a0); is_stdout=false; fail_if_broken=true; is_a_tty=false; width=-1; statusbar_redisplay=true; } /* Local (fd) output. */ OutputJob::OutputJob(FDStream *output_, const char *a0) : output_fd(output_ ? output_ : new FDStream(1,"")) { Init(a0); if(output_) { /* We don't want to produce broken pipe when we're actually * piping, since some legitimate uses produce broken pipe, eg * cat|head. However, that's actually handled in InitCopy(). * User pipes aren't handled by us yet: instead of being set with * SetFilter, they're being set up ahead of time and passed to * us as an FDStream, so we don't really know if we're being filtered. * * So, until we handle pipes directly, disable broken pipe whenever * we're being sent anywhere but stdout. */ fail_if_broken=false; } is_stdout=output_fd->usesfd(1); is_a_tty=isatty(output_fd->fd); width=fd_width(output_fd->fd); /* We don't output status when outputting locally. */ no_status=true; /* Make sure that if the output is going to fail, it fails early, so * the parent doesn't start anything expensive (like begin downloading * a file.) */ if(output_fd->getfd()==-1 && output_fd->error()) { eprintf("%s: %s\n", a0, output_fd->error_text.get()); error=true; } } OutputJob::OutputJob(const char *path, const char *a0, FileAccess *fa0) : fa(fa0 ? fa0->Clone() : FileAccess::New("file")), fa_path(path) { Init(a0); } void OutputJob::PrepareToDie() { Bg(); AcceptSig(SIGTERM); Delete(input); if(input != output) Delete(output); input=0; output=0; super::PrepareToDie(); } /* This is called to ask us "permission" to display a status line. */ bool OutputJob::ShowStatusLine(const SMTaskRef& s) { /* If our output file is gone, or isn't stdout, we don't care. */ if(!output || !is_stdout) return true; /* If we're filtered, we never display at all. (We don't know anything about * the filter's output; the only time we do is when we're outputting to a URL * or a file, and that doesn't apply here.) */ if(IsFiltered()) return false; /* If we're not line buffered, display only if the output CopyJob says to. */ if(!output->GetCopy()->IsLineBuffered()) return output->HasStatus(); /* We're line buffered, so we can output a status line without stomping * on a partially output line. * * If we've output something recently, only send the output to the title, * to avoid flickering status for no reason. */ if(!update_timer.Stopped()) { s->NextUpdateTitleOnly(); return true; } /* If we're not reenabling the status bar, and the statusbar has * been turned off (due to output being reenabled), only send to * the title. */ if(!statusbar_redisplay && output->GetCopy()->WriteAllowed()) { s->NextUpdateTitleOnly(); return true; } /* Don't disable write if there are data to be written in buffer */ if(output->GetCopy()->WriteAllowed() && output->GetCopy()->WritePending()) return false; /* There hasn't been output in a while. Stop the output again, * so the FileCopy will clear the StatusLine when there's more data. */ output->GetCopy()->AllowWrite(false); return true; } /* Get our contribution to the status line, which is just the output * status, if any. Input status is the job of the user object. */ const char *OutputJob::Status(const StatusLine *s) { if(no_status) return ""; /* Never show anything if we havn't even received any data yet; it won't * start connecting until then, so it's not interesting. */ if(!initialized) return ""; /* Use the status from the output CopyJob. It'll be the one that's connecting * to a host, if applicable. */ return output->Status(s,true); } void OutputJob::PutEOF() { if(Error()) return; /* Make sure we've sent at least one (empty) block. This ensures * that we always start the input->output code path. */ Put("", 0); /* Send an EOF to the input peer; it'll send an EOF to the output peer * when all of its data is actually sent. */ if(InputPeer()) InputPeer()->PutEOF(); else if(tmp_buf) tmp_buf->PutEOF(); else abort(); } /* add a filter to the beginning of the list */ void OutputJob::PreFilter(const char *newfilter) { if(!filter) filter.set(newfilter); else { char *old_filter=alloca_strdup(filter); filter.vset(newfilter," | ",old_filter,NULL); } } /* Return the width of the output. If there's a filter, we can either * return -1 (we might be piping through "sed", changing the width), * or the width we know (which is sane for most pagers.) I'm not sure * which is better. */ int OutputJob::GetWidth() const { if(IsFiltered()) return -1; return width; } /* Return true if the output is going directly to a TTY. */ bool OutputJob::IsTTY() const { if(IsFiltered()) return false; return is_a_tty; } static const SMTaskRef null_peer; /* Get the input FileCopyPeer; this is the buffer we write to. */ const SMTaskRef& OutputJob::InputPeer() const { if(input) return input->GetGet(); return null_peer; } /* Get the output FileCopyPeer (the FileCopyPeer that's doing the final output). */ const SMTaskRef& OutputJob::OutputPeer() const { if(output) return output->GetPut(); return null_peer; } /* We're done if the output is finished, or on error. */ int OutputJob::Done() { if(Error()) return true; if(!initialized) return false; if(input && !input->Done()) return false; if(output && !output->Done()) return false; return true; } int OutputJob::Do() { if(!initialized && tmp_buf) InitCopy(); return STALL; } /* Don't register errors until they're actually printed by * the sub-job (ie. it's also Done()). */ bool OutputJob::Error() { if(error) return true; if(input && input->Error() && input->Done()) error=true; if(output && input != output && output->Error() && output->Done()) error=true; return error; } void OutputJob::Fg() { super::Fg(); if(input) input->Fg(); if(output && input != output) output->Fg(); } void OutputJob::Bg() { if(output && input != output) output->Bg(); if(input) input->Bg(); super::Bg(); } void OutputJob::SuspendInternal() { super::SuspendInternal(); if(input) input->SuspendSlave(); if(output && input != output) output->SuspendSlave(); } void OutputJob::ResumeInternal() { if(input) input->ResumeSlave(); if(output && input != output) output->ResumeSlave(); super::ResumeInternal(); } bool OutputJob::Full() { /* It'd be nicer to just check copy->GetGet()->IsSuspended(), since * the FileCopy will suspend the Get end if the Put end gets filled. * However, it won't do that until it actually tries to send something. */ int size = 0; if(input) { if(input->GetPut()) size += input->GetPut()->Buffered(); if(input->GetGet()) size += input->GetGet()->Buffered(); if(input != output) { if(output->GetPut()) size += output->GetPut()->Buffered(); if(output->GetGet()) size += output->GetGet()->Buffered(); } } if(tmp_buf) size += tmp_buf->Size(); return size >= 0x10000; } /* We'll actually go over the buffer limit here; that's OK; it's not a * strict value. (It's not convenient to prevent that completely with * Format(), either.) */ void OutputJob::Put(const char *buf,int size) { InitCopy(); if(Error()) return; if(!InputPeer()) { if(!tmp_buf) tmp_buf=new Buffer; tmp_buf->Put(buf,size); return; } // InputPeer was inited, flush tmp_buf. if(InputPeer() && tmp_buf) { Ref saved_buf(tmp_buf.borrow()); const char *b=0; int s=0; saved_buf->Get(&b,&s); if(b && s>0) Put(b,s); if(saved_buf->Eof()) PutEOF(); } update_timer.SetResource("cmd:status-interval",0); off_t oldpos = InputPeer()->GetPos(); InputPeer()->Put(buf, size); InputPeer()->SetPos(oldpos); } void OutputJob::Format(const char *f,...) { va_list v; va_start(v,f); const xstring& str=xstring::vformat(f,v); va_end(v); Put(str); } /* Propagate signals down to our child processes. */ int OutputJob::AcceptSig(int sig) { int m=MOVED; if(sig == SIGTERM || sig == SIGINT) m=WANTDIE; /* If we have an input copier right now, it'll contain the top filter * (which is linked to all other filters), so send it the signal. */ if(input) input->AcceptSig(sig); /* Otherwise, the only filters we have running are in output_fd. */ else if(output_fd) output_fd->Kill(sig); if(sig!=SIGCONT) AcceptSig(SIGCONT); return m; } lftp-4.6.3a/src/mkdirJob.cc0000644000015000007670000000630012344365561012422 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "mkdirJob.h" #include "plural.h" #include "url.h" #include "misc.h" #define super SessionJob #define orig_session super::session mkdirJob::mkdirJob(FileAccess *s,ArgV *a) : super(s), args(a), session(orig_session) { quiet=false; failed=file_count=0; args->rewind(); const char *op=args->getarg(0); curr=first=0; opt_p=false; int opt; while((opt=args->getopt("pf"))!=EOF) { switch(opt) { case 'p': opt_p=true; break; case 'f': quiet=true; break; default: return; } } args->back(); first=curr=args->getnext(); if(curr==0) { fprintf(stderr,"Usage: %s [-p] [-f] paths...\n",op); return; } } int mkdirJob::Do() { if(Done()) return STALL; if(session->IsClosed()) { ParsedURL u(curr,true); if(u.proto) { session=my_session=FileAccess::New(&u); session->SetPriority(fg?1:0); session->Mkdir(u.path,opt_p); } else { session=orig_session; session->Mkdir(curr,opt_p); } } int res=session->Done(); if(res==FA::DO_AGAIN || res==FA::IN_PROGRESS) return STALL; if(res<0) { failed++; if(!quiet) fprintf(stderr,"%s: %s\n",args->getarg(0),session->StrError(res)); } file_count++; session->Close(); curr=args->getnext(); return MOVED; } xstring& mkdirJob::FormatStatus(xstring& s,int v,const char *prefix) { SessionJob::FormatStatus(s,v,prefix); if(Done()) return s; return s.appendf("%s`%s' [%s]\n",prefix,curr,session->CurrentStatus()); } void mkdirJob::ShowRunStatus(const SMTaskRef& s) { if(Done()) return; s->Show("%s `%s' [%s]",args->getarg(0), squeeze_file_name(curr,s->GetWidthDelayed()-40), session->CurrentStatus()); } void mkdirJob::SayFinal() { if(failed==file_count) return; const char *op=args->getarg(0); if(file_count==1) // A directory has just been created printf(_("%s ok, `%s' created\n"),op,first); else if(failed) printf(plural("%s failed for %d of %d director$y|ies$\n",file_count), op,failed,file_count); else printf(plural("%s ok, %d director$y|ies$ created\n",file_count), op,file_count); } void mkdirJob::Fg() { super::Fg(); if(orig_session!=session) orig_session->SetPriority(1); } void mkdirJob::Bg() { if(orig_session!=session) orig_session->SetPriority(0); super::Bg(); } lftp-4.6.3a/src/LocalAccess.cc0000644000015000007670000003416212500302115013020 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include #include #include "LocalAccess.h" #include "xstring.h" #include "misc.h" #include "log.h" #include "LocalDir.h" CDECL_BEGIN #include CDECL_END #define FILES_AT_ONCE_STAT 64 #define FILES_AT_ONCE_READDIR 256 FileAccess *LocalAccess::New() { return new LocalAccess(); } void LocalAccess::ClassInit() { // register the class Register("file",LocalAccess::New); } void LocalAccess::Init() { done=false; error_code=OK; home.Set(getenv("HOME")); hostname.set("localhost"); } LocalAccess::LocalAccess() : FileAccess() { Init(); xstring_ca c(xgetcwd()); cwd.Set(c?c.get():"."); LogNote(10,"local cwd is `%s'",cwd.path.get()); } LocalAccess::LocalAccess(const LocalAccess *o) : FileAccess(o) { Init(); } void LocalAccess::errno_handle() { saved_errno=errno; const char *err=strerror(saved_errno); if(mode==RENAME) error.vset("rename(",file.get(),", ",file1.get(),"): ",err,NULL); else error.vset(file.get(),": ",err,NULL); if(saved_errno!=EEXIST) LogError(0,"%s",error.get()); } int LocalAccess::Done() { if(error_code<0) return error_code; if(done) return OK; switch((open_mode)mode) { case(CLOSED): case(CONNECT_VERIFY): return OK; default: return IN_PROGRESS; } } int LocalAccess::Do() { if(Error() || done) return STALL; int m=STALL; if(mode!=CLOSED) ExpandTildeInCWD(); switch((open_mode)mode) { case(CLOSED): return m; case(LIST): case(LONG_LIST): case(QUOTE_CMD): if(stream==0) { const char *cmd=0; // FIXME: shell-quote file name if(mode==LIST) { if(file && file[0]) cmd=xstring::cat("ls ",shell_encode(file).get(),NULL); else cmd="ls"; } else if(mode==LONG_LIST) { if(file && file[0]) cmd=xstring::cat("ls -l",shell_encode(file).get(),NULL); else cmd="ls -la"; } else// if(mode==QUOTE_CMD) cmd=file; LogNote(5,"running `%s'",cmd); InputFilter *f_stream=new InputFilter(cmd); f_stream->SetCwd(cwd); stream=f_stream; real_pos=0; m=MOVED; } if(stream->getfd()==-1) { if(stream->error()) { Fatal(stream->error_text); return MOVED; } TimeoutS(1); return m; } stream->Kill(SIGCONT); return m; case(CHANGE_DIR): { LocalDirectory old_cwd; old_cwd.SetFromCWD(); const char *err=old_cwd.Chdir(); if(err) { SetError(NO_FILE,err); return MOVED; } if(chdir(file)==-1) { errno_handle(); error_code=NO_FILE; } else { cwd.Set(file); old_cwd.Chdir(); } done=true; return MOVED; } case(REMOVE): { const char *f=dir_file(cwd,file); LogNote(5,"remove(%s)",f); if(remove(f)==-1) { errno_handle(); error_code=NO_FILE; } done=true; return MOVED; } case(REMOVE_DIR): if(rmdir(dir_file(cwd,file))==-1) { errno_handle(); error_code=NO_FILE; } done=true; return MOVED; case(RENAME): case(LINK): case(SYMLINK): { const char *cwd_file1=dir_file(cwd,file1); int (*fn)(const char *f1,const char *f2)=( mode==RENAME ? rename : mode==LINK ? link : /*mode==SYMLINK?*/ symlink ); if(fn(mode==SYMLINK?file.get():dir_file(cwd,file),cwd_file1)==-1) { errno_handle(); error_code=NO_FILE; } done=true; return MOVED; } case(MAKE_DIR): if(mkdir_p) { const char *sl=strchr(file,'/'); while(sl) { if(sl>file) mkdir(dir_file(cwd,xstring::get_tmp(file,sl-file)),0775); sl=strchr(sl+1,'/'); } } if(mkdir(dir_file(cwd,file),0775)==-1) { errno_handle(); error_code=NO_FILE; } done=true; return MOVED; case(CHANGE_MODE): if(chmod(dir_file(cwd,file),chmod_mode)==-1) { errno_handle(); error_code=NO_FILE; } done=true; return MOVED; case(RETRIEVE): case(STORE): if(stream==0) { int o_mode=O_RDONLY; if(mode==STORE) { o_mode=O_WRONLY|O_CREAT; if(pos==0) o_mode|=O_TRUNC; } stream=new FileStream(dir_file(cwd,file),o_mode); real_pos=-1; m=MOVED; } if(stream->getfd()==-1) { if(stream->error()) { SetError(NO_FILE,stream->error_text); return MOVED; } TimeoutS(1); return m; } stream->Kill(SIGCONT); if(opt_size || opt_date) { struct stat st; if(fstat(stream->getfd(),&st)==-1) { if(opt_size) *opt_size=NO_SIZE; if(opt_date) *opt_date=NO_DATE; } else { if(opt_size) *opt_size=(S_ISREG(st.st_mode)?st.st_size:NO_SIZE); if(opt_date) *opt_date=st.st_mtime; } opt_size=0; opt_date=0; } return m; case(CONNECT_VERIFY): done=true; return MOVED; case(ARRAY_INFO): fill_array_info(); done=true; return MOVED; case MP_LIST: SetError(NOT_SUPP); return MOVED; } return m; } void LocalAccess::fill_array_info() { for(FileInfo *fi=fileset_for_info->curr(); fi; fi=fileset_for_info->next()) fi->LocalFile(fi->name,(fi->filetype!=fi->SYMLINK)); } int LocalAccess::Read(Buffer *buf0,int size) { if(error_code<0) return error_code; if(stream==0) return DO_AGAIN; int fd=stream->getfd(); if(fd==-1) return DO_AGAIN; if(real_pos==-1) { if(ascii || lseek(fd,pos,SEEK_SET)==-1) real_pos=0; else real_pos=pos; } stream->Kill(SIGCONT); read_again: int res; char *buf=buf0->GetSpace(size); #ifndef NATIVE_CRLF if(ascii) res=read(fd,buf,size/2); else #endif res=read(fd,buf,size); if(res<0) { saved_errno=errno; if(E_RETRY(saved_errno)) { Block(stream->getfd(),POLLIN); return DO_AGAIN; } if(stream->NonFatalError(saved_errno)) return DO_AGAIN; return SEE_ERRNO; } stream->clear_status(); if(res==0) return res; // eof #ifndef NATIVE_CRLF if(ascii) { char *p=buf; for(int i=res; i>0; i--) { if(*p=='\n') { memmove(p+1,p,i); *p++='\r'; res++; } p++; } } #endif real_pos+=res; if(real_pos<=pos) goto read_again; off_t shift=pos+res-real_pos; if(shift>0) { memmove(buf,buf+shift,size-shift); res-=shift; } pos+=res; return(res); } int LocalAccess::Write(const void *vbuf,int len) { const char *buf=(const char *)vbuf; if(error_code<0) return error_code; if(stream==0) return DO_AGAIN; int fd=stream->getfd(); if(fd==-1) return DO_AGAIN; if(real_pos==-1) { if(ascii || lseek(fd,pos,SEEK_SET)==-1) real_pos=0; else real_pos=pos; if(real_posKill(SIGCONT); int skip_cr=0; #ifndef NATIVE_CRLF if(ascii) { // find where line ends. const char *cr=buf; for(;;) { cr=(const char *)memchr(cr,'\r',len-(cr-buf)); if(!cr) break; if(cr-bufgetfd(),POLLOUT); return DO_AGAIN; } if(stream->NonFatalError(saved_errno)) { // in case of full disk, check file correctness. if(saved_errno==ENOSPC) { struct stat st; if(fstat(fd,&st)!=-1) { if(st.st_sizeclear_status(); if(res==len) res+=skip_cr; pos=(real_pos+=res); return res; } int LocalAccess::StoreStatus() { if(mode!=STORE) return OK; if(!stream) return IN_PROGRESS; if(stream->getfd()==-1) { if(stream->error()) SetError(NO_FILE,stream->error_text); } stream=0; if(error_code==OK && entity_date!=NO_DATE) { static struct utimbuf ut; ut.actime=ut.modtime=entity_date; utime(dir_file(cwd,file),&ut); } if(error_code<0) return error_code; return OK; } void LocalAccess::Close() { done=false; error_code=OK; stream=0; FileAccess::Close(); } const char *LocalAccess::CurrentStatus() { if(stream && stream->status) return stream->status; return ""; } bool LocalAccess::SameLocationAs(const FileAccess *fa) const { if(!SameProtoAs(fa)) return false; LocalAccess *o=(LocalAccess*)fa; if(xstrcmp(home,o->home)) return false; return !xstrcmp(cwd,o->cwd); } class LocalListInfo : public ListInfo { DIR *dir; public: LocalListInfo(FileAccess *s,const char *d) : ListInfo(s,d), dir(0) {} ~LocalListInfo() { if(dir) closedir(dir); } const char *Status(); int Do(); }; ListInfo *LocalAccess::MakeListInfo(const char *path) { return new LocalListInfo(this,path); } int LocalListInfo::Do() { int m=STALL; if(done) return STALL; if(!dir && !result) { const char *path=session->GetCwd(); dir=opendir(path); if(!dir) { SetError(xstring::format("%s: %s",path,strerror(errno))); return MOVED; } m=MOVED; } if(dir) { if(!result) result=new FileSet; int count=FILES_AT_ONCE_READDIR; for(;;) { struct dirent *f=readdir(dir); if(f==0) break; const char *name=f->d_name; if(name[0]=='~') name=dir_file(".",name); result->Add(new FileInfo(name)); if(!--count) return MOVED; // let other tasks run } closedir(dir); dir=0; result->rewind(); m=MOVED; } if(!dir && result) { int count=FILES_AT_ONCE_STAT; const char *path=session->GetCwd(); for(FileInfo *file=result->curr(); file!=0; file=result->next()) { const char *name=dir_file(path,file->name); file->LocalFile(name, follow_symlinks); if(!(file->defined&file->TYPE)) result->SubtractCurr(); if(!--count) return MOVED; // let other tasks run } result->Exclude(exclude_prefix,exclude); done=true; m=MOVED; } return m; } const char *LocalListInfo::Status() { if(done) return ""; if(dir && result) return xstring::format("%s (%d)",_("Getting directory contents"),result->count()); if(result && result->count()) return xstring::format("%s (%d%%)",_("Getting files information"),result->curr_pct()); return ""; } #include "FileGlob.h" class LocalGlob : public Glob { const char *cwd; public: LocalGlob(const char *cwd,const char *pattern); const char *Status() { return "Reading directory"; } int Do(); }; Glob *LocalAccess::MakeGlob(const char *pattern) { file.set(pattern); ExpandTildeInCWD(); return new LocalGlob(cwd,file); } LocalGlob::LocalGlob(const char *c,const char *pattern) : Glob(0,pattern) { cwd=c; } int LocalGlob::Do() { if(done) return STALL; glob_t g; LocalDirectory oldcwd; oldcwd.SetFromCWD(); // check if we can return. if(oldcwd.Chdir()) { SetError(_("cannot get current directory")); return MOVED; } if(chdir(cwd)==-1) { SetError(xstring::format("chdir(%s): %s",cwd,strerror(errno))); return MOVED; } glob(pattern, 0, NULL, &g); for(unsigned i=0; i ubuf; Ref fg_data; public: LocalDirList(ArgV *a,const char *cwd); const char *Status() { return ""; } int Do(); }; DirList *LocalAccess::MakeDirList(ArgV *a) { return new LocalDirList(a,cwd); } #include "ArgV.h" LocalDirList::LocalDirList(ArgV *a,const char *cwd) : DirList(0,0) { a->setarg(0,"ls"); a->insarg(1,"-l"); InputFilter *f=new InputFilter(a); // a is consumed. f->SetCwd(cwd); ubuf=new IOBufferFDStream(f,IOBuffer::GET); } int LocalDirList::Do() { if(done) return STALL; if(buf->Eof()) { done=true; return MOVED; } if(ubuf->Error()) { SetError(ubuf->ErrorText()); return MOVED; } if(!fg_data) fg_data=ubuf->GetFgData(false); const char *b; int len; ubuf->Get(&b,&len); if(b==0) // eof { buf->PutEOF(); return MOVED; } if(len==0) return STALL; buf->Put(b,len); ubuf->Skip(len); return MOVED; } #include "modconfig.h" #ifdef MODULE_PROTO_FILE CDECL void module_init() { LocalAccess::ClassInit(); } #endif lftp-4.6.3a/src/buffer_ssl.h0000644000015000007670000000246212122057104012643 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef BUFFER_SSL_H #define BUFFER_SSL_H #include "buffer.h" #if USE_SSL #include "lftp_ssl.h" class IOBufferSSL : public IOBuffer { Ref my_ssl; const Ref& ssl; int Get_LL(int size); int Put_LL(const char *buf,int size); int PutEOF_LL(); public: IOBufferSSL(lftp_ssl *s,dir_t m) : IOBuffer(m), my_ssl(s), ssl(my_ssl) {} IOBufferSSL(const Ref& s,dir_t m) : IOBuffer(m), ssl(s) {} ~IOBufferSSL(); int Do(); bool Done() { return IOBuffer::Done() && ssl->handshake_done; } }; #endif #endif//BUFFER_SSL_H lftp-4.6.3a/src/xmalloc.cc0000644000015000007670000000664212122061007012307 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "trio.h" #include "xmalloc.h" static int memory_count=0; static void memory_error_and_abort(const char *fname,size_t size) { fprintf(stderr,"%s: out of virtual memory when trying to get %lu bytes\n", fname,(long)size); exit(2); } void *xmalloc (size_t bytes) { if(bytes==0) return 0; void *temp=(void*)malloc(bytes); if(temp==0) memory_error_and_abort("xmalloc",bytes); memory_count++; #ifdef MEM_DEBUG printf("xmalloc %p %lu (count=%d)\n",temp,(long)bytes,memory_count); #endif return(temp); } void *xrealloc(void *pointer,size_t bytes) { void *temp; if(pointer==0 && bytes==0) return 0; if(bytes==0) { memory_count--; free(pointer); temp=0; goto leave; } if(pointer==0) { temp=(void*)malloc(bytes); memory_count++; } else temp=(void*)realloc(pointer,bytes); if(temp==0) memory_error_and_abort ("xrealloc",bytes); leave: #ifdef MEM_DEBUG printf("xrealloc %p %p %lu (count=%d)\n",pointer,temp,(long)bytes,memory_count); #endif return(temp); } void xfree(void *p) { if(!p) return; #ifdef MEM_DEBUG printf("xfree %p (count=%d)\n",p,memory_count); #endif memory_count--; free(p); } char *xstrdup(const char *s,int spare) { if(!s) return (char*)xmalloc(spare); #ifdef MEM_DEBUG printf("xstrdup \"%s\"\n",s); #endif size_t len=strlen(s)+1; char *mem=(char*)xmalloc(len+spare); memcpy(mem,s,len); return mem; } char *xstrset(char *&mem,const char *s,size_t len) { if(!s) { xfree(mem); return mem=0; } #ifdef MEM_DEBUG printf("xstrset \"%.*s\"\n",len,s); #endif if(s==mem) { mem[len]=0; return mem; } size_t old_len=(mem?strlen(mem)+1:0); if(mem && s>mem && smem && s. */ #include #include "trio.h" #include #include #include "xstring.h" #include "netrc.h" #include "log.h" static bool comment(const char *s, FILE *f) { if(s[0]!='#') return false; // skip entire line for(;;) { int ch=getc(f); if(ch==EOF || ch=='\n') break; } return true; } NetRC::Entry *NetRC::LookupHost(const char *h,const char *u) { char str[256]; char chost[256]=""; char cuser[256]=""; char cpass[256]=""; char cacct[256]=""; const char *const home=getenv("HOME"); if(!home) return 0; const char *const netrc=xstring::cat(home,"/.netrc",NULL); FILE *f=fopen(netrc,"r"); if(f==NULL) { Log::global->Format(10,"notice: cannot open %s: %s\n",netrc,strerror(errno)); return NULL; } bool host_found=false; bool user_found=false; while(fscanf(f,"%255s",str)==1) { if(comment(str,f)) continue; if(!strcmp(str,"macdef")) { // currently macdef is ignored if(fgets(str,255,f)==0) break; for(;;) { if(fgets(str,255,f)==0) break; if(str[strspn(str," \t\n")]==0) // macdef ends with empty line break; } continue; } if(!strcmp(str,"default")) { strcpy(chost,""); // ignore the default continue; } if(!strcmp(str,"machine")) { if(host_found && user_found) break; if(fscanf(f,"%255s",str)!=1) break; strcpy(chost,str); // reset data for new machine. cuser[0]=0; cpass[0]=0; cacct[0]=0; host_found=!strcasecmp(chost,h); user_found=false; continue; } if(!strcmp(str,"login")) { if(fscanf(f,"%255s",str)!=1) break; if(strcasecmp(chost,h)) continue; strcpy(cuser,str); cpass[0]=0; cacct[0]=0; user_found=(!u || !strcasecmp(cuser,u)); continue; } if(!strcmp(str,"password")) { if(fscanf(f,"%255s",str)!=1) break; if(strcasecmp(chost,h) || (u && strcasecmp(cuser,u)) || cpass[0]) continue; strcpy(cpass,str); for(char *s=cpass; *s; s++) { if(*s=='\\' && s[1]>='0' && s[1]<'8') { int ch=0; int n=0; if(sscanf(s+1,"%3o%n",&ch,&n)!=1) continue; if(ch==0) continue; *s=ch; memmove(s+1,s+1+n,strlen(s+1+n)+1); } } continue; } if(!strcmp(str,"account")) { if(fscanf(f,"%255s",str)!=1) break; if(strcasecmp(chost,h) || (u && strcasecmp(cuser,u)) || cacct[0]) continue; strcpy(cacct,str); continue; } } fclose(f); if(host_found && user_found) { Log::global->Format(10,"found netrc entry: host=%s, user=%s, pass=%s, acct=%s\n",h,cuser,cpass,cacct); return new Entry(h,cuser[0]?cuser:0,cpass[0]?cpass:0,cacct[0]?cacct:0); } return 0; } lftp-4.6.3a/src/PtyShell.cc0000644000015000007670000001177512247332727012441 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "trio.h" #include #include #include #include #include #include #include #include #ifdef HAVE_SYS_IOCTL_H # include #endif #include #include #include "PtyShell.h" #include "lftp_pty.h" #include "SignalHook.h" #include "ArgV.h" #include "misc.h" int PtyShell::getfd() { if(fd!=-1 || error() || closed) return fd; int ptyfd,ttyfd; pid_t pid; int pipe0[2]; int pipe1[2]; if(use_pipes) { if(pipe(pipe0)<0) return -1; if(pipe(pipe1)<0) { close(pipe0[0]); close(pipe0[1]); return -1; } } const char *tty_name=open_pty(&ptyfd,&ttyfd); if(!tty_name) { if(!NonFatalError(errno)) error_text.vset(_("pseudo-tty allocation failed: "),strerror(errno),NULL); if(use_pipes) { close(pipe0[0]); close(pipe0[1]); close(pipe1[0]); close(pipe1[1]); } return -1; } struct termios tc; tcgetattr(ttyfd,&tc); tc.c_lflag=0; tc.c_oflag=0; tc.c_iflag=0; tc.c_cc[VMIN]=1; tc.c_cc[VTIME]=0; tcsetattr(ttyfd,TCSANOW,&tc); ProcWait::Signal(false); fflush(stderr); switch(pid=fork()) { case(0): /* child */ close(ptyfd); if(use_pipes) { close(pipe0[1]); close(pipe1[0]); dup2(pipe0[0],0); dup2(pipe1[1],1); if(pipe0[0]>2) close(pipe0[0]); if(pipe1[1]>2) close(pipe1[1]); } else { dup2(ttyfd,0); dup2(ttyfd,1); } dup2(ttyfd,2); if(ttyfd>2) close(ttyfd); /* start new session */ setsid(); /* make the pseudo-tty our controlling tty */ #ifdef TIOCSCTTY /* use ioctl if available. FD 2 is tty even if use_pipes==true */ ioctl(2, TIOCSCTTY, NULL); #else /* otherwise open the tty without O_NOCTTY flag */ ttyfd=open(tty_name, O_RDWR); if(ttyfd>=0) close(ttyfd); #endif SignalHook::RestoreAll(); kill(getpid(),SIGSTOP); if(oldcwd) { if(chdir(oldcwd)==-1) { fprintf(stderr,_("chdir(%s) failed: %s\n"),oldcwd.get(),strerror(errno)); fflush(stderr); _exit(1); } } /* force the messages to be in english */ putenv((char*)"LC_ALL=C"); putenv((char*)"LANG=C"); putenv((char*)"LANGUAGE=C"); if(a) execvp(a->a0(),a->GetVNonConst()); execl("/bin/sh","sh","-c",name.get(),NULL); fprintf(stderr,_("execl(/bin/sh) failed: %s\n"),strerror(errno)); fflush(stderr); _exit(1); case(-1): /* error */ close(ttyfd); close(ptyfd); if(use_pipes) { close(pipe0[0]); close(pipe0[1]); close(pipe1[0]); close(pipe1[1]); } goto out; } /* parent */ if(pg==0) pg=pid; close(ttyfd); fd=ptyfd; fcntl(fd,F_SETFD,FD_CLOEXEC); fcntl(fd,F_SETFL,O_NONBLOCK); if(use_pipes) { close(pipe0[0]); pipe_out=pipe0[1]; close(pipe1[1]); pipe_in=pipe1[0]; fcntl(pipe_in,F_SETFD,FD_CLOEXEC); fcntl(pipe_in,F_SETFL,O_NONBLOCK); fcntl(pipe_out,F_SETFD,FD_CLOEXEC); fcntl(pipe_out,F_SETFL,O_NONBLOCK); } oldcwd.set(0); int info; waitpid(pid,&info,WUNTRACED); w=new ProcWait(pid); out: ProcWait::Signal(true); return fd; } void PtyShell::Init() { oldcwd.set_allocated(xgetcwd()); pg=0; closed=false; use_pipes=false; pipe_in=-1; pipe_out=-1; } void PtyShell::SetCwd(const char *cwd) { oldcwd.set(cwd); } PtyShell::PtyShell(const char *filter) : FDStream(-1,filter) { Init(); } PtyShell::PtyShell(ArgV *a1) : FDStream(-1,0), a(a1) { Init(); name.set_allocated(a->Combine()); } PtyShell::~PtyShell() { if(fd!=-1) close(fd); if(pipe_in!=-1) close(pipe_in); if(pipe_out!=-1) close(pipe_out); if(w) { w->Kill(); w.borrow()->Auto(); } } bool PtyShell::Done() { if(w==0) return true; if(fd!=-1) { close(fd); fd=-1; closed=true; } if(w->GetState()!=w->RUNNING) return true; return false; } bool PtyShell::broken() { if(w==0) return false; if(fd==-1) return false; if(w->GetState()!=w->RUNNING) return true; // filter process terminated - pipe is broken return false; } lftp-4.6.3a/src/StringSet.cc0000644000015000007670000000423612122060713012572 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "StringSet.h" #include "misc.h" #define set_size set.count() StringSet::StringSet() {} StringSet::StringSet(const char *const *s,int n) { Assign(s,n); } StringSet::StringSet(const StringSet &o) { Assign(o.set.get(),o.set.count()); } StringSet::StringSet(const char *s) { Assign(&s,1); } bool StringSet::IsEqual(const char *const *set1,int n1) const { if(set_size!=n1) return false; int i=0; while(i0) set.append(xstrdup(*set1++)); } void StringSet::Append(const char *s) { if(!s) return; set.append(xstrdup(s)); } void StringSet::Replace(int i,const char *s) { if(i==set_size) Append(s); else if(i>=0 && i=set_size) return 0; char *s=set[i]; set[i]=0; set.remove(i); return s; } lftp-4.6.3a/src/ftpclass.cc0000644000015000007670000034754112460162352012507 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include #include #include #include "ftpclass.h" #include "xstring.h" #include "url.h" #include "FtpListInfo.h" #include "FileGlob.h" #include "FtpDirList.h" #include "log.h" #include "FileCopyFtp.h" #include "LsCache.h" #include "buffer_ssl.h" #include "ascii_ctype.h" #include "misc.h" #include "strftime.h" #define TELNET_IAC '\377' //255 /* interpret as command: */ #define TELNET_IP '\364' //244 /* interrupt process--permanently */ #define TELNET_DM '\362' //242 /* for telfunc calls */ #define TELNET_WILL '\373' //251 #define TELNET_WONT '\374' //252 #define TELNET_DO '\375' //253 #define TELNET_DONT '\376' //254 #include #include #ifdef TM_IN_SYS_TIME # include #endif #ifdef HAVE_FCNTL_H # include #endif CDECL_BEGIN #include "regex.h" CDECL_END #if USE_SSL # include "lftp_ssl.h" #else # define control_ssl 0 const bool Ftp::ftps=false; #endif #define FTP_DEFAULT_PORT "21" #define FTPS_DEFAULT_PORT "990" #define FTP_DATA_PORT 20 #define FTPS_DATA_PORT 989 #define HTTP_DEFAULT_PROXY_PORT "3128" #define super NetAccess #define is5XX(code) ((code)>=500 && (code)<600) #define is4XX(code) ((code)>=400 && (code)<500) #define is3XX(code) ((code)>=300 && (code)<400) #define is2XX(code) ((code)>=200 && (code)<300) #define is1XX(code) ((code)>=100 && (code)<200) #define cmd_unsupported(code) ((code)==500 || (code)==502) #define site_cmd_unsupported(code) (cmd_unsupported((code)) || (code)==501) #define debug(a) Log::global->Format a #ifndef EINPROGRESS #define EINPROGRESS -1 #endif FileAccess *Ftp::New() { return new Ftp(); } void Ftp::ClassInit() { // register the class Register("ftp",Ftp::New); FileCopy::fxp_create=FileCopyFtp::New; #if USE_SSL Register("ftps",FtpS::New); #endif } #if INET6 struct eprt_proto_match { int proto; int eprt_proto; }; static const eprt_proto_match eprt_proto[]= { { AF_INET, 1 }, { AF_INET6, 2 }, { -1, -1 } }; const char *Ftp::encode_eprt(const sockaddr_u *a) { int proto; if(a->sa.sa_family==AF_INET) proto=1; else if(a->sa.sa_family==AF_INET6) proto=2; else return 0; return xstring::format("|%d|%s|%d|",proto,a->address(),a->port()); } #endif bool Ftp::Connection::data_address_ok(const sockaddr_u *dp,bool verify_address,bool verify_port) { sockaddr_u d; sockaddr_u c; socklen_t len; len=sizeof(d); if(dp) d=*dp; else if(getpeername(data_sock,&d.sa,&len)==-1) { LogError(0,"getpeername(data_sock): %s\n",strerror(errno)); return !verify_address && !verify_port; } len=sizeof(c); if(getpeername(control_sock,&c.sa,&len)==-1) { LogError(0,"getpeername(control_sock): %s\n",strerror(errno)); return !verify_address; } #if INET6 if(d.sa.sa_family==AF_INET && c.sa.sa_family==AF_INET6 && IN6_IS_ADDR_V4MAPPED(&c.in6.sin6_addr)) { if(memcmp(&d.in.sin_addr,&c.in6.sin6_addr.s6_addr[12],4)) goto address_mismatch; if(d.in.sin_port!=htons(FTP_DATA_PORT) && d.in.sin_port!=htons(FTPS_DATA_PORT)) goto wrong_port; } #endif if(d.sa.sa_family!=c.sa.sa_family) return false; if(d.sa.sa_family==AF_INET) { if(memcmp(&d.in.sin_addr,&c.in.sin_addr,sizeof(d.in.sin_addr))) goto address_mismatch; if(d.in.sin_port!=htons(FTP_DATA_PORT) && d.in.sin_port!=htons(FTPS_DATA_PORT)) goto wrong_port; return true; } #if INET6 # ifndef IN6_ARE_ADDR_EQUAL # define IN6_ARE_ADDR_EQUAL(a,b) (!memcmp((a),(b),16)) # endif if(d.sa.sa_family==AF_INET6) { if(!IN6_ARE_ADDR_EQUAL(&d.in6.sin6_addr,&c.in6.sin6_addr)) goto address_mismatch; if(d.in6.sin6_port!=htons(FTP_DATA_PORT) && d.in6.sin6_port!=htons(FTPS_DATA_PORT)) goto wrong_port; return true; } #endif return true; wrong_port: if(!verify_port) return true; LogError(0,_("Data connection peer has wrong port number")); return false; address_mismatch: if(!verify_address) return true; LogError(0,_("Data connection peer has mismatching address")); return false; } /* Procedures for checking for a special answers */ /* General rule: check for valid replies first, errors second. */ void Ftp::RestCheck(int act) { if(is2XX(act) || is3XX(act)) { real_pos=conn->rest_pos; // REST successful conn->last_rest=conn->rest_pos; return; } real_pos=0; if(pos==0) return; if(is5XX(act)) { if(cmd_unsupported(act)) conn->rest_supported=false; LogNote(2,_("Switching to NOREST mode")); flags|=NOREST_MODE; if(mode==STORE) pos=0; if(copy_mode!=COPY_NONE) copy_failed=true; return; } Disconnect(line); } void Ftp::NoFileCheck(int act) { if(is2XX(act)) return; if(cmd_unsupported(act)) { SetError(FATAL,all_lines); return; } if(real_pos>0 && !GetFlag(IO_FLAG) && copy_mode==COPY_NONE && ((is4XX(act) && strstr(line,"Append/Restart not permitted")) || (is5XX(act) && !Transient5XX(act)))) { DataClose(); LogNote(2,_("Switching to NOREST mode")); flags|=NOREST_MODE; real_pos=0; if(mode==STORE) pos=0; state=EOF_STATE; // retry return; } if(is5XX(act) && !Transient5XX(act)) { SetError(NO_FILE,all_lines); return; } if(copy_mode!=COPY_NONE) { copy_failed=true; return; } DataClose(); state=EOF_STATE; eof=false; if(mode==STORE && GetFlag(IO_FLAG)) SetError(STORE_FAILED,0); else if(NextTry()) retry_timer.Set(2); // retry after 2 seconds } /* 5xx that aren't errors at all */ bool Ftp::NonError5XX(int act) const { return (mode==LIST && act==550 && (!file || !file[0])) // ...and proftpd workaround. || (mode==LIST && act==450 && strstr(line,"No files found")); } bool Ftp::ServerSaid(const char *s) const { return strstr(line,s) && (!file || !strstr(file,s)); } /* 5xx that are really transient like 4xx */ bool Ftp::Transient5XX(int act) const { if(!is5XX(act)) return false; if(act==530 && expect->FirstIs(Expect::PASS) && Retry530()) return true; // retry on these errors (ftp server ought to send 4xx code instead) if(ServerSaid("Broken pipe") || ServerSaid("Too many") || ServerSaid("timed out") || ServerSaid("closed by the remote host")) return true; // if there were some data received, assume it is temporary error. if(mode!=STORE && GetFlag(IO_FLAG)) return true; return false; } #if USE_SSL const char *Ftp::get_protect_res() { if(mode==LIST || mode==MP_LIST || (mode==LONG_LIST && !use_stat_for_list)) return "ftp:ssl-protect-list"; else if(mode==RETRIEVE || mode==STORE) return "ftp:ssl-protect-data"; return 0; } #endif // 226 Transfer complete. void Ftp::TransferCheck(int act) { if(act==225 || act==226) // data connection is still open or ABOR worked. { copy_done=true; conn->CloseAbortedDataConnection(); if(!conn->received_150 && state!=DATA_OPEN_STATE) goto simulate_eof; } if(act==211) { // permature STAT? conn->stat_timer.ResetDelayed(3); return; } if(act==213) // this must be a STAT reply. { conn->stat_timer.Reset(); long long p; // first try Serv-U format: // Status for user UUU from X.X.X.X // Stored 1 files, 0 Kbytes // Retrieved 0 files, 0 Kbytes // Receiving file XXX (YYY bytes) const char *r=strstr(all_lines,"Receiving file"); if(r) { r=strrchr(r,'('); char c=0; if(r && sscanf(r,"(%lld bytes%c",&p,&c)==2 && c==')') goto found_offset; } // wu-ftpd format: // Status: XXX of YYY bytes transferred // or // Status: XXX bytes transferred // // find the first number. for(const char *b=line+4; ; b++) { if(*b==0) return; if(!is_ascii_digit(*b)) continue; if(sscanf(b,"%lld",&p)==1) break; } found_offset: if(copy_mode==COPY_DEST) real_pos=pos=p; return; } if(copy_mode!=COPY_NONE && is4XX(act)) { copy_passive=!copy_passive; copy_failed=true; return; } if(NonError5XX(act)) goto simulate_eof; if(act==426 && copy_mode==COPY_NONE) { if(conn->data_sock==-1 && strstr(line,"Broken pipe")) return; } if(act==426 && mode==STORE) { DataClose(); state=EOF_STATE; SetError(FATAL,all_lines); } if(is2XX(act) && conn->data_sock==-1) eof=true; #if USE_SSL if(conn->auth_supported && act==522 && conn->prot=='C') { const char *res=get_protect_res(); if(res) { // try again with PROT P DataClose(); ResMgr::Set(res,hostname,"yes"); state=EOF_STATE; return; } } #endif NoFileCheck(act); return; simulate_eof: DataClose(); state=EOF_STATE; eof=true; return; } bool Ftp::Retry530() const { const char *rexp=Query("retry-530",hostname); if(re_match(all_lines,rexp,REG_ICASE)) { LogNote(9,_("Server reply matched ftp:retry-530, retrying")); return true; } if(!user) { rexp=Query("retry-530-anonymous",hostname); if(re_match(all_lines,rexp,REG_ICASE)) { LogNote(9,_("Server reply matched ftp:retry-530-anonymous, retrying")); return true; } } return false; } void Ftp::LoginCheck(int act) { if(conn->ignore_pass) return; if(act==530 && Retry530()) // overloaded server? goto retry; if(is5XX(act)) { SetError(LOGIN_FAILED,all_lines); return; } if(!is2XX(act) && !is3XX(act)) { retry: Disconnect(line); NextPeer(); if(peer_curr==0) reconnect_timer.Reset(); // count the reconnect-interval from this moment last_connection_failed=true; } if(is3XX(act) && !expect->Has(Expect::ACCT_PROXY)) { if(!QueryStringWithUserAtHost("acct")) { Disconnect(line); SetError(LOGIN_FAILED,_("Account is required, set ftp:acct variable")); } } } void Ftp::NoPassReqCheck(int act) // for USER command { if(is2XX(act)) // in some cases, ftpd does not ask for pass. { conn->ignore_pass=true; return; } if(act==331 && allow_skey && user && pass) { skey_pass.set(make_skey_reply()); if(force_skey && skey_pass==0) { SetError(LOGIN_FAILED,_("ftp:skey-force is set and server does not support OPIE nor S/KEY")); return; } } if(act==331 && allow_netkey && user && pass) { netkey_pass.set(make_netkey_reply()); } if(is3XX(act)) return; if(act==530 && Retry530()) // overloaded server? goto retry; if(is5XX(act)) { // proxy interprets USER as user@host, so we check for host name validity if(proxy && (strstr(line,"host") || strstr(line,"resolve"))) { LogNote(9,_("assuming failed host name lookup")); SetError(LOOKUP_ERROR,all_lines); return; } SetError(LOGIN_FAILED,all_lines); return; } retry: Disconnect(line); reconnect_timer.Reset(); // count the reconnect-interval from this moment last_connection_failed=true; } // login to proxy. void Ftp::proxy_LoginCheck(int act) { if(is2XX(act)) return; if(is5XX(act)) { SetError(LOGIN_FAILED,all_lines); return; } Disconnect(line); reconnect_timer.Reset(); // count the reconnect-interval from this moment } void Ftp::proxy_NoPassReqCheck(int act) { if(is3XX(act) || is2XX(act)) return; if(is5XX(act)) { SetError(LOGIN_FAILED,all_lines); return; } Disconnect(line); reconnect_timer.Reset(); // count the reconnect-interval from this moment } static void normalize_path_vms(char *path) { for(char *s=path; *s; s++) *s=to_ascii_lower(*s); char *colon=strchr(path,':'); if(colon) { memmove(path+1,path,strlen(path)+1); path[0]='/'; path=colon+1; if(path[1]=='[') memmove(path,path+1,strlen(path)); } else { path=strchr(path,'['); if(!*path) return; } *path++='/'; while(*path && *path!=']') { if(*path=='.') *path='/'; path++; } if(!*path) return; if(path[1]) *path='/'; else *path=0; } char *Ftp::ExtractPWD() { char *pwd=string_alloca(line.length()+1); const char *scan=strchr(line,'"'); if(scan==0) return 0; scan++; const char *right_quote=strrchr(scan,'"'); if(!right_quote) return 0; char *store=pwd; while(scanvms_path=true; normalize_path_vms(pwd); } else if(dev_len==2 || dev_len==3) { conn->dos_path=true; } if(!strchr(pwd,'/') || conn->dos_path) { // for safety -- against dosish ftpd for(char *s=pwd; *s; s++) if(*s=='\\') *s='/'; } return xstrdup(pwd); } int Ftp::SendCWD(const char *path,const char *path_url,Expect::expect_t c) { int cwd_count=0; if(QueryTriBool("ftp:use-tvfs",0,conn->tvfs_supported)) { conn->SendCmd2("CWD",path); expect->Push(new Expect(Expect::CWD_CURR,path)); cwd_count++; } else if(path_url) { path_url=url::path_ptr(path_url); if(path_url[0]=='/') path_url++; if(path_url[0]=='~') { if(path_url[1]==0) path_url++; else if(path_url[1]=='/') path_url+=2; } LogNote(9,"using URL path `%s'",path_url); char *path_url1=alloca_strdup(path_url); // to split it xstring path2("~"); for(char *dir_url=strtok(path_url1,"/"); dir_url; dir_url=strtok(NULL,"/")) { const char *dir=url::decode(dir_url); if(dir[0]=='/') path2.truncate(); if(path2.length()>0 && path2.last_char()!='/') path2.append('/'); path2.append(dir); conn->SendCmd2("CWD",dir); expect->Push(new Expect(Expect::CWD_CURR,path2)); cwd_count++; } } else { char *path1=alloca_strdup(path); // to split it char *path2=alloca_strdup(path); // to re-assemble if(AbsolutePath(path)) { if(real_cwd && !strncmp(real_cwd,path,real_cwd.length()) && path[real_cwd.length()]=='/') { path1+=real_cwd.length()+1; path2[real_cwd.length()]=0; } else { int dev_len=device_prefix_len(path); dev_len+=(path2[dev_len]=='/'); if(dev_len==1 && path[0]=='/' && real_cwd.ne("/")) { // just a root directory, append first path component const char *slash=strchr(path+1,'/'); if(slash) dev_len=slash-path; else dev_len=strlen(path); } path2[dev_len]=0; path1+=dev_len; if(!path2[0]) { if(real_cwd && strcmp(real_cwd,"~") && (!home.path || strcmp(real_cwd,home.path))) { conn->SendCmd("CWD"); expect->Push(new Expect(Expect::CWD_CURR,"~")); cwd_count++; } } else if(!real_cwd || strcmp(real_cwd,path2)) { conn->SendCmd2("CWD",path2); expect->Push(new Expect(Expect::CWD_CURR,path2)); cwd_count++; } } } else { strcpy(path2,"~"); if(path1[0]=='~') { if(path1[1]==0) path1++; else if(path1[1]=='/') path1+=2; } if(real_cwd && strcmp(real_cwd,"~") && (!home.path || strcmp(real_cwd,home.path))) { conn->SendCmd("CWD"); expect->Push(new Expect(Expect::CWD_CURR,"~")); cwd_count++; } } int path2_len=strlen(path2); for(char *dir=strtok(path1,"/"); dir; dir=strtok(NULL,"/")) { if(path2_len>0 && path2[path2_len-1]!='/') { strcpy(path2+path2_len,"/"); path2_len++; } strcpy(path2+path2_len,dir); path2_len+=strlen(dir); conn->SendCmd2("CWD",dir); expect->Push(new Expect(Expect::CWD_CURR,path2)); cwd_count++; } } Expect *last_cwd=expect->FindLastCWD(); if(last_cwd) { LogNote(9,"CWD path to be sent is `%s'",last_cwd->arg.get()); last_cwd->check_case=c; } return cwd_count; } Ftp::pasv_state_t Ftp::Handle_PASV() { unsigned a0,a1,a2,a3,p0,p1; /* * Extract address. RFC1123 says: * "...must scan the reply for the first digit..." */ for(const char *b=line+4; ; b++) { if(*b==0) { Disconnect(line); return PASV_NO_ADDRESS_YET; } if(!is_ascii_digit(*b)) continue; if(sscanf(b,"%u,%u,%u,%u,%u,%u",&a0,&a1,&a2,&a3,&p0,&p1)==6) break; } unsigned char *a,*p; conn->data_sa.sa.sa_family=conn->peer_sa.sa.sa_family; if(conn->data_sa.sa.sa_family==AF_INET) { a=(unsigned char*)&conn->data_sa.in.sin_addr; p=(unsigned char*)&conn->data_sa.in.sin_port; } #if INET6 else if(conn->data_sa.sa.sa_family==AF_INET6) { a=((unsigned char*)&conn->data_sa.in6.sin6_addr)+12; a[-1]=a[-2]=0xff; // V4MAPPED p=(unsigned char*)&conn->data_sa.in6.sin6_port; } #endif else { Disconnect("unsupported address family"); return PASV_NO_ADDRESS_YET; } a[0]=a0; a[1]=a1; a[2]=a2; a[3]=a3; p[0]=p0; p[1]=p1; bool ignore_pasv_address = QueryBool("ignore-pasv-address",hostname); if(ignore_pasv_address) LogNote(2,"Address returned by PASV is ignored according to ftp:ignore-pasv-address setting"); else if(conn->data_sa.is_reserved() || conn->data_sa.is_multicast() || (QueryBool("fix-pasv-address",hostname) && !conn->proxy_is_http && (conn->data_sa.is_private() != conn->peer_sa.is_private() || conn->data_sa.is_loopback() != conn->peer_sa.is_loopback()))) { // broken server, try to fix up ignore_pasv_address=true; conn->fixed_pasv=true; LogNote(2,"Address returned by PASV seemed to be incorrect and has been fixed"); } if(ignore_pasv_address) { if(conn->data_sa.sa.sa_family==AF_INET) memcpy(a,&conn->peer_sa.in.sin_addr,sizeof(conn->peer_sa.in.sin_addr)); #if INET6 else if(conn->data_sa.in.sin_family==AF_INET6) // peer_sa should be V4MAPPED memcpy(a,&conn->peer_sa.in6.sin6_addr.s6_addr[12],4); #endif } return PASV_HAVE_ADDRESS; } Ftp::pasv_state_t Ftp::Handle_EPSV() { char delim; char *format=alloca_strdup("|||%u|"); unsigned port; const char *c=strchr(line,'('); c=c?c+1:line+4; delim=*c; for(char *p=format; *p; p++) if(*p=='|') *p=delim; if(sscanf(c,format,&port)!=1) { LogError(0,_("cannot parse EPSV response")); Disconnect(_("cannot parse EPSV response")); return PASV_NO_ADDRESS_YET; } socklen_t len=sizeof(conn->data_sa); getpeername(conn->control_sock,&conn->data_sa.sa,&len); if(conn->data_sa.sa.sa_family==AF_INET) conn->data_sa.in.sin_port=htons(port); #if INET6 else if(conn->data_sa.sa.sa_family==AF_INET6) conn->data_sa.in6.sin6_port=htons(port); #endif else { Disconnect("unsupported address family"); return PASV_NO_ADDRESS_YET; } return PASV_HAVE_ADDRESS; } void Ftp::CatchDATE(int act) { if(!fileset_for_info) return; FileInfo *fi=fileset_for_info->curr(); if(!fi) return; if(is2XX(act)) { if(line.length()>4 && is_ascii_digit(line[4])) fi->SetDate(ConvertFtpDate(line+4),0); } else if(is5XX(act)) { if(cmd_unsupported(act)) conn->mdtm_supported=false; } else { Disconnect(line); return; } fi->NoNeed(fi->DATE); if(!(fi->need&fi->SIZE)) fileset_for_info->next(); TrySuccess(); } void Ftp::CatchDATE_opt(int act) { if(!opt_date) return; if(is2XX(act) && line.length()>4 && is_ascii_digit(line[4])) { *opt_date=ConvertFtpDate(line+4); opt_date=0; } else { if(cmd_unsupported(act)) conn->mdtm_supported=false; *opt_date=NO_DATE; } } void Ftp::CatchSIZE(int act) { if(!fileset_for_info) return; FileInfo *fi=fileset_for_info->curr(); if(!fi) return; long long size=NO_SIZE; if(is2XX(act)) { if(line.length()>4) { if(sscanf(line+4,"%lld",&size)!=1) size=NO_SIZE; } } else if(is5XX(act)) { if(cmd_unsupported(act)) conn->size_supported=false; } else { Disconnect(line); return; } if(size>=1) fi->SetSize(size); fi->NoNeed(fi->SIZE); if(!(fi->need&fi->DATE)) fileset_for_info->next(); TrySuccess(); } void Ftp::CatchSIZE_opt(int act) { long long size=NO_SIZE; if(is2XX(act)) { if(line.length()>4) { if(sscanf(line+4,"%lld",&size)!=1) size=NO_SIZE; } } else { if(cmd_unsupported(act)) conn->size_supported=false; } // SIZE 0 is ignored (for some buggy servers). if(size<1) return; if(mode==RETRIEVE) entity_size=size; if(opt_size) { *opt_size=size; opt_size=0; } } Ftp::Connection::Connection(const char *c) : closure(c), send_cmd_buffer(DirectedBuffer::PUT) { control_sock=-1; telnet_layer_send=0; data_sock=-1; aborted_data_sock=-1; #if USE_SSL prot='C'; // current protection scheme 'C'lear or 'P'rivate auth_sent=false; auth_supported=true; cpsv_supported=false; sscn_supported=true; sscn_on=false; #endif type='A'; last_rest=0; rest_pos=0; quit_sent=false; fixed_pasv=false; translation_activated=false; sync_wait=1; // expect server greetings multiline_code=0; ignore_pass=false; try_feat_after_login=false; tune_after_login=false; utf8_activated=false; dos_path=false; vms_path=false; have_feat_info=false; mdtm_supported=true; size_supported=true; rest_supported=true; site_chmod_supported=true; site_utime_supported=true; site_utime2_supported=true; pret_supported=false; utf8_supported=false; lang_supported=false; mlst_supported=false; clnt_supported=false; host_supported=false; mfmt_supported=false; epsv_supported=false; tvfs_supported=false; proxy_is_http=false; may_show_password=false; can_do_pasv=true; nop_time=0; nop_count=0; nop_offset=0; abor_close_timer.SetResource("ftp:abor-max-wait",closure); stat_timer.SetResource("ftp:stat-interval",closure); waiting_150_timer.SetResource("ftp:waiting-150-timeout",closure); #if USE_SSL waiting_ssl_shutdown.SetResource("ftp:ssl-shutdown-timeout",closure); #endif } void Ftp::InitFtp() { #if USE_SSL ftps=false; // ssl and prot='P' by default (port 990) #endif eof=false; state=INITIAL_STATE; flags=SYNC_MODE; allow_skey=true; allow_netkey=true; force_skey=false; verify_data_address=true; use_stat=true; use_stat_for_list=true; use_mdtm=true; use_size=true; use_telnet_iac=true; use_pret=true; use_mlsd=false; max_buf=0x10000; copy_mode=COPY_NONE; copy_addr_valid=false; copy_passive=false; copy_protect=false; copy_ssl_connect=false; copy_done=false; copy_connection_open=false; copy_allow_store=false; copy_failed=false; disconnect_on_close=false; last_connection_failed=false; Reconfig(); } Ftp::Ftp() : super() { InitFtp(); } Ftp::Ftp(const Ftp *f) : super(f) { InitFtp(); state=INITIAL_STATE; flags=f->flags&MODES_MASK; Reconfig(); } Ftp::Connection::~Connection() { CloseAbortedDataConnection(); CloseDataConnection(); control_send=0; control_recv=0; #if USE_SSL control_ssl=0; // ssl should be freed after send/recv #endif if(control_sock!=-1) { LogNote(7,_("Closing control socket")); close(control_sock); } } void Ftp::PrepareToDie() { Enter(); Disconnect(); if(conn) { FlushSendQueue(); ReceiveResp(); } Disconnect(); Leave(); } bool Ftp::AbsolutePath(const char *s) const { if(!s || !*s) return false; int dev_len=device_prefix_len(s); return(s[0]=='/' || (s[0]=='~' && s[1]!=0 && s[1]!='/') || (((conn->dos_path && dev_len==3) || (conn->vms_path && dev_len>2)) && s[dev_len-1]=='/')); } // returns true if we need to sleep instead of moving to higher level. bool Ftp::GetBetterConnection(int level,bool limit_reached) { bool need_sleep=false; // if(level==0 && cwd==0) // return need_sleep; for(FA *fo=FirstSameSite(); fo!=0; fo=NextSameSite(fo)) { Ftp *o=(Ftp*)fo; // we are sure it is Ftp. if(o->GetConnectLevel()!=CL_LOGGED_IN) continue; if(!SameConnection(o)) continue; if(level==0 && xstrcmp(real_cwd,o->real_cwd)) continue; if(o->conn->data_sock!=-1 || o->state!=EOF_STATE || o->mode!=CLOSED) { /* session is in use; last resort is to takeover an active connection */ if(level<2) continue; /* only take over lower priority or suspended jobs */ if(!connection_takeover || (o->priority>=priority && !o->IsSuspended())) continue; if(o->conn->data_sock!=-1 && o->expect->Count()<=1) { /* don't take over active connections if they won't be able to resume */ if((o->flags&NOREST_MODE) && o->real_pos>0x1000) continue; if(o->QueryBool("web-mode",o->hostname)) continue; o->DataAbort(); o->DataClose(); if(!o->conn) return need_sleep; // oops... } else { if(!o->expect->IsEmpty() || o->disconnect_on_close) continue; } } else { if(limit_reached) { /* wait until job is diff seconds idle before taking it over */ int diff=o->last_priority-priority; if(diff>0) { /* number of seconds the task has been idle */ if(o->idle_timer.TimePassed()quit_sent=true; super::HandleTimeout(); DisconnectNow(); } // Create buffers after control socket had been connected. void Ftp::Connection::MakeBuffers() { #if USE_SSL control_ssl=0; #endif control_send=new IOBufferFDStream( new FDStream(control_sock,"control-socket"),IOBuffer::PUT); control_recv=new IOBufferFDStream( new FDStream(control_sock,"control-socket"),IOBuffer::GET); } void Ftp::Connection::InitTelnetLayer() { if(telnet_layer_send) return; control_send=telnet_layer_send=new IOBufferTelnet(control_send.borrow()); control_recv=new IOBufferTelnet(control_recv.borrow()); } bool Ftp::ProxyIsHttp() { if(!proxy_proto) return false; return !strcmp(proxy_proto,"http") || !strcmp(proxy_proto,"https"); } int Ftp::Do() { const char *command=0; bool append_file=false; int res; socklen_t addr_len; const unsigned char *a; const unsigned char *p; automate_state oldstate; int m=STALL; const char *error; // check if idle time exceeded if(mode==CLOSED && conn && idle_timer.Stopped()) { LogNote(1,_("Closing idle connection")); Disconnect(); if(conn) idle_timer.Reset(); return m; } if(conn && conn->quit_sent) { m|=FlushSendQueue(); m|=ReceiveResp(); if(expect && expect->IsEmpty()) { DisconnectNow(); return MOVED; } goto usual_return; } /* Some servers cannot detect ABOR, help them by reading remaining data and closing data connection in few seconds */ if(conn && conn->aborted_data_sock!=-1) { char discard[0x2000]; int res=read(conn->aborted_data_sock,discard,sizeof(discard)); if(res==0 || conn->abor_close_timer.Stopped()) conn->CloseAbortedDataConnection(); else Block(conn->aborted_data_sock,POLLIN); } if(Error() || eof || mode==CLOSED) { // inactive behavior if(conn) { m|=FlushSendQueue(); m|=ReceiveResp(); } if(eof || mode==CLOSED) goto notimeout_return; goto usual_return; } if(!hostname) return m; if(mode==CHANGE_MODE && !QueryBool("use-site-chmod")) { SetError(NOT_SUPP,_("SITE CHMOD is disabled by ftp:use-site-chmod")); return MOVED; } if(mode==MP_LIST && !use_mlsd) { SetError(NOT_SUPP,_("MLSD is disabled by ftp:use-mlsd")); return MOVED; } switch(state) { case(INITIAL_STATE): { // walk through ftp classes and try to find identical idle ftp session // first try "easy" cases of session take-over. for(int i=0; i<3; i++) { bool limit_reached=last_connection_failed || (connection_limit>0 && connection_limit<=CountConnections()); if(i>=2 && !limit_reached) break; bool need_sleep=GetBetterConnection(i,limit_reached); if(state!=INITIAL_STATE) return MOVED; if(need_sleep) return m; } if(!resolver && mode!=CONNECT_VERIFY && !ReconnectAllowed()) return m; if(ftps) m|=Resolve(FTPS_DEFAULT_PORT,"ftps","tcp"); else m|=Resolve(FTP_DEFAULT_PORT,"ftp","tcp"); if(!peer) return m; if(mode==CONNECT_VERIFY) return m; if(!ReconnectAllowed()) return m; if(!NextTry()) return MOVED; last_connection_failed=false; assert(!conn); assert(!expect); conn=new Connection(hostname); expect=new ExpectQueue(); conn->proxy_is_http=ProxyIsHttp(); if(conn->proxy_is_http) SetFlag(PASSIVE_MODE,1); conn->peer_sa=peer[peer_curr]; conn->control_sock=SocketCreateTCP(conn->peer_sa.sa.sa_family); if(conn->control_sock==-1) { conn=0; expect=0; if(peer_curr+1peer_sa.sa.sa_family); SetError(SEE_ERRNO,str); return MOVED; } if(QueryBool("use-ip-tos",hostname)) MinimizeLatency(conn->control_sock); SayConnectingTo(); res=SocketConnect(conn->control_sock,&conn->peer_sa); state=CONNECTING_STATE; if(res==-1 && errno!=EINPROGRESS) { saved_errno=errno; LogError(0,"connect(control_sock): %s",strerror(saved_errno)); if(NotSerious(saved_errno)) { Disconnect(strerror(saved_errno)); return MOVED; } goto system_error; } m=MOVED; timeout_timer.Reset(); } /* fallthrough */ case(CONNECTING_STATE): assert(conn && conn->control_sock!=-1); res=Poll(conn->control_sock,POLLOUT,&error); if(res==-1) { LogError(0,_("Socket error (%s) - reconnecting"),error); Disconnect(error); return MOVED; } if(!(res&POLLOUT)) goto usual_return; #if USE_SSL if(proxy && (!xstrcmp(proxy_proto,"ftps") || !xstrcmp(proxy_proto,"https"))) { conn->MakeSSLBuffers(hostname); } else // note the following block #endif { conn->MakeBuffers(); } if(!proxy || !conn->proxy_is_http) goto pre_CONNECTED_STATE; state=HTTP_PROXY_CONNECTED; m=MOVED; HttpProxySendConnect(); /* fallthrough */ case HTTP_PROXY_CONNECTED: if(!HttpProxyReplyCheck(conn->control_recv)) goto usual_return; pre_CONNECTED_STATE: #if USE_SSL if(ftps && (!proxy || conn->proxy_is_http)) { conn->MakeSSLBuffers(hostname); const char *initial_prot=ResMgr::Query("ftps:initial-prot",hostname); conn->prot=initial_prot[0]; } #endif if(use_telnet_iac) conn->InitTelnetLayer(); state=CONNECTED_STATE; m=MOVED; expect->Push(Expect::READY); if(use_feat) { if(!proxy || conn->proxy_is_http) { conn->SendCmd("FEAT"); expect->Push(Expect::FEAT); } else { conn->try_feat_after_login=true; } } /* fallthrough */ case CONNECTED_STATE: { m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=CONNECTED_STATE || Error()) return MOVED; if(expect->Has(Expect::FEAT) || conn->quit_sent) goto usual_return; #if USE_SSL if(QueryBool((user && pass)?"ssl-allow":"ssl-allow-anonymous",hostname) && !ftps && (!proxy || conn->proxy_is_http)) SendAuth(Query("ssl-auth",hostname)); if(state!=CONNECTED_STATE) return MOVED; if(conn->auth_sent && !expect->IsEmpty()) goto usual_return; #endif // Do connection tuning after AUTH TLS. if(conn->have_feat_info) TuneConnectionAfterFEAT(); const char *user_to_use=(user?user.get():anon_user.get()); const char *proxy_auth_type=Query("proxy-auth-type",proxy); if(proxy && !conn->proxy_is_http) { if(!strcmp(proxy_auth_type,"joined") && proxy_user && proxy_pass) { user_to_use=xstring::cat(user_to_use,"@",proxy_user.get(),"@", hostname.get(),portname?":":NULL,portname.get(),NULL); } else if(!strcmp(proxy_auth_type,"joined-acct") && proxy_user && proxy_pass) { user_to_use=xstring::cat(user_to_use,"@",hostname.get(), portname?":":"",portname?portname.get():"", " ",proxy_user.get(),NULL); // proxy_pass is sent later with ACCT command } else if(!strcmp(proxy_auth_type,"proxy-user@host") && proxy_user && proxy_pass) { expect->Push(Expect::USER_PROXY); conn->SendCmd2("USER",xstring::cat(proxy_user.get(),"@",hostname.get(), portname?":":"",portname?portname.get():"",NULL)); expect->Push(Expect::PASS_PROXY); conn->SendCmd2("PASS",proxy_pass); } else // no proxy auth, or type is `open' or `user'. { bool use_open=!strcmp(proxy_auth_type,"open"); if(!use_open) { user_to_use=xstring::cat(user_to_use,"@",hostname.get(), portname?":":NULL,portname.get(),NULL); } if(proxy_user && proxy_pass) { expect->Push(Expect::USER_PROXY); conn->SendCmd2("USER",proxy_user); expect->Push(Expect::PASS_PROXY); conn->SendCmd2("PASS",proxy_pass); } if(use_open) { expect->Push(Expect::OPEN_PROXY); conn->SendCmd2("OPEN",xstring::cat(hostname.get(), portname?":":NULL,portname.get(),NULL)); } } } skey_pass.set(0); netkey_pass.set(0); expect->Push(Expect::USER); conn->SendCmd2("USER",user_to_use); state=USER_RESP_WAITING_STATE; m=MOVED; } /* fallthrough */ case(USER_RESP_WAITING_STATE): { if((GetFlag(SYNC_MODE) || (user && pass && allow_skey)) && !expect->IsEmpty()) { m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=USER_RESP_WAITING_STATE || Error()) return MOVED; if(!expect->IsEmpty()) goto usual_return; } const char *proxy_auth_type=Query("proxy-auth-type",proxy); if(!conn->ignore_pass) { conn->may_show_password = (skey_pass!=0) || (netkey_pass!=0) || (user==0) || pass_open; const char *pass_to_use=(pass?pass:anon_pass); if(allow_skey && skey_pass) pass_to_use=skey_pass; else if(allow_netkey && netkey_pass) pass_to_use=netkey_pass; else if(proxy && !conn->proxy_is_http && proxy_user && proxy_pass && !strcmp(proxy_auth_type,"joined")) pass_to_use=xstring::cat(pass_to_use,"@",proxy_pass.get(),NULL); expect->Push(Expect::PASS); conn->SendCmd2("PASS",pass_to_use); } if(proxy && !conn->proxy_is_http && proxy_user && proxy_pass && !strcmp(proxy_auth_type,"joined-acct")) { expect->Push(Expect::ACCT_PROXY); conn->SendCmd2("ACCT",proxy_pass); } SendAcct(); if(conn->try_feat_after_login) { conn->SendCmd("FEAT"); expect->Push(Expect::FEAT); } else if(conn->tune_after_login) TuneConnectionAfterFEAT(); SendSiteGroup(); SendSiteIdle(); SendSiteCommands(); if(!home_auto) { // if we don't yet know the home location, try to get it conn->SendCmd("PWD"); expect->Push(Expect::PWD); } #if USE_SSL if(conn->ssl_is_activated()) { conn->SendCmd("PBSZ 0"); expect->Push(Expect::IGNORE); // select PROT mode before CCC if there is no need to change it later bool prot_data=QueryBool("ssl-protect-data"); bool prot_list=QueryBool("ssl-protect-list"); if(prot_data==prot_list) SendPROT(prot_data?'P':'C'); if(QueryBool("ssl-use-ccc")) { conn->SendCmd("CCC"); expect->Push(Expect::CCC); } } #endif // USE_SSL set_real_cwd(0); } /* fallthrough */ pre_EOF_STATE: state=EOF_STATE; m=MOVED; case(EOF_STATE): m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=EOF_STATE || Error()) return MOVED; if(expect->Has(Expect::FEAT) || expect->Has(Expect::OPTS_UTF8) || expect->Has(Expect::LANG)) goto usual_return; #if USE_SSL if(expect->Has(Expect::CCC) || expect->Has(Expect::PROT)) goto usual_return; #endif // USE_SSL if(!conn->utf8_activated && charset && *charset) conn->SetControlConnectionTranslation(charset); if(mode==CONNECT_VERIFY) goto notimeout_return; if(mode==CHANGE_MODE && !conn->site_chmod_supported) { SetError(NOT_SUPP,_("SITE CHMOD is not supported by this site")); return MOVED; } if(mode==MP_LIST && !conn->mlst_supported) { SetError(NOT_SUPP,_("MLST and MLSD are not supported by this site")); return MOVED; } if(home.path==0 && !expect->IsEmpty()) goto usual_return; if(!retry_timer.Stopped()) goto usual_return; if(real_cwd==0) set_real_cwd(home_auto); ExpandTildeInCWD(); if(!CheckRetries()) return MOVED; if(mode!=CHANGE_DIR) { Expect *last_cwd=expect->FindLastCWD(); // Send CWD if we have a CWD in flight and it differs from wanted cwd // or we don't have a CWD and read_cwd differs from wanted cwd if((!last_cwd && xstrcmp(cwd,real_cwd) && !(real_cwd==0 && !xstrcmp(cwd,"~"))) || (last_cwd && xstrcmp(last_cwd->arg,cwd))) { SendCWD(cwd,cwd.url,Expect::CWD_CURR); } else if(last_cwd && !xstrcmp(last_cwd->arg,cwd)) { // no need for extra CWD, one's already sent. last_cwd->check_case=Expect::CWD_CURR; } } #if USE_SSL if(conn->ssl_is_activated() || (conn->auth_supported && conn->auth_sent)) { char want_prot=conn->prot; const char *protect_res=get_protect_res(); if(protect_res) want_prot=QueryBool(protect_res,hostname)?'P':'C'; if(copy_mode!=COPY_NONE) want_prot=copy_protect?'P':'C'; bool want_sscn=conn->sscn_on; if(copy_mode!=COPY_NONE) want_sscn=copy_protect && copy_ssl_connect && !(copy_passive && conn->cpsv_supported); else if(mode==RETRIEVE || mode==STORE || mode==LIST || mode==MP_LIST || (mode==LONG_LIST && !use_stat_for_list)) want_sscn=false; if(conn->sscn_supported && want_sscn!=conn->sscn_on) { conn->SendCmd2("SSCN",want_sscn?"ON":"OFF"); expect->Push(new Expect(Expect::SSCN,want_sscn?'Y':'N')); } SendPROT(want_prot); } #endif state=CWD_CWD_WAITING_STATE; m=MOVED; /* fallthrough */ case CWD_CWD_WAITING_STATE: { m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=CWD_CWD_WAITING_STATE || Error()) return MOVED; // wait for all CWD to finish if(mode!=CHANGE_DIR && expect->FindLastCWD()) goto usual_return; #if USE_SSL // PROT and SSCN are critical for data transfers if(expect->Has(Expect::PROT) || expect->Has(Expect::SSCN)) goto usual_return; #endif // address of peer is not known yet if(copy_mode!=COPY_NONE && !copy_passive && !copy_addr_valid) goto usual_return; if(entity_size>=0 && entity_size<=pos && (mode==RETRIEVE || (mode==STORE && entity_size>0))) { if(mode==STORE) SendUTimeRequest(); if(mode==RETRIEVE) LogNote(9,"received all data but no EOF\n"); eof=true; goto pre_WAITING_STATE; // simulate eof. } if(!conn->rest_supported) flags|=NOREST_MODE; if(mode==STORE && GetFlag(NOREST_MODE) && pos>0) pos=0; if(copy_mode==COPY_NONE && (mode==RETRIEVE || mode==STORE || mode==LIST || mode==MP_LIST || (mode==LONG_LIST && !use_stat_for_list))) { assert(conn->data_sock==-1); conn->data_sock=SocketCreateUnboundTCP(conn->peer_sa.sa.sa_family,hostname); if(conn->data_sock==-1) { saved_errno=errno; LogError(0,"socket(data): %s",strerror(saved_errno)); goto system_error; } if(QueryBool("use-ip-tos",hostname)) MaximizeThroughput(conn->data_sock); addr_len=sizeof(conn->data_sa); getsockname(conn->control_sock,&conn->data_sa.sa,&addr_len); // Try to assign a port from given range Range range(Query("port-range")); for(int t=0; ; t++) { if(t>=10) { close(conn->data_sock); conn->data_sock=-1; TimeoutS(1); // retry later. return m; } if(t==9) ReuseAddress(conn->data_sock); // try to reuse address. int port=0; if(!range.IsFull()) port=range.Random(); bool do_addr_bind=QueryBool("bind-data-socket") && !conn->peer_sa.is_loopback(); if(!do_addr_bind && !port) break; // nothing to bind if(conn->data_sa.sa.sa_family==AF_INET) { conn->data_sa.in.sin_port=htons(port); if(!do_addr_bind) memset(&conn->data_sa.in.sin_addr,0,sizeof(conn->data_sa.in.sin_addr)); } #if INET6 else if(conn->data_sa.sa.sa_family==AF_INET6) { conn->data_sa.in6.sin6_port=htons(port); if(!do_addr_bind) memset(&conn->data_sa.in6.sin6_addr,0,sizeof(conn->data_sa.in6.sin6_addr)); } #endif else { Fatal("unsupported network protocol"); return MOVED; } if(bind(conn->data_sock,&conn->data_sa.sa,addr_len)==0) break; saved_errno=errno; // Fail unless socket was already taken if(saved_errno!=EINVAL && saved_errno!=EADDRINUSE) { LogError(0,"bind(data_sock,[%s]:%d): %s", SocketNumericAddress(&conn->data_sa),port,strerror(saved_errno)); close(conn->data_sock); conn->data_sock=-1; if(NonFatalError(saved_errno)) { TimeoutS(1); return m; } SetError(SEE_ERRNO,"Cannot bind data socket for ftp:port-range"); return MOVED; } LogError(10,"bind(data_sock,[%s]:%d): %s", SocketNumericAddress(&conn->data_sa),port,strerror(saved_errno)); } if(!GetFlag(PASSIVE_MODE)) listen(conn->data_sock,1); // get the allocated port addr_len=sizeof(conn->data_sa); getsockname(conn->data_sock,&conn->data_sa.sa,&addr_len); } char want_type=(ascii?'A':'I'); if(GetFlag(NOREST_MODE) || pos==0) real_pos=0; else real_pos=-1; // we don't yet know if REST will succeed flags&=~IO_FLAG; last_priority=priority; conn->received_150=false; switch((enum open_mode)mode) { case(RETRIEVE): if(file[0]==0) goto long_list; command="RETR"; append_file=true; break; case(STORE): if(!QueryBool("rest-stor",hostname)) { real_pos=0; // some old servers don't handle REST/STOR properly. pos=0; } command="STOR"; append_file=true; break; long_list: case(LONG_LIST): if(use_stat_for_list) { real_pos=0; command="STAT"; conn->data_iobuf=new IOBuffer(IOBuffer::GET); rate_limit=new RateLimit(hostname); want_type=conn->type; } else { want_type='A'; if(!rest_list) real_pos=0; // some ftp servers do not do REST/LIST. command="LIST"; } if(list_options && list_options[0]) command=xstring::cat(command," ",list_options.get(),NULL); if(file && file[0]) append_file=true; if(use_stat_for_list && !append_file && !strchr(command,' ')) command="STAT ."; break; case(MP_LIST): want_type='A'; real_pos=0; // REST doesn't work for MLSD command="MLSD"; if(file && file[0]) append_file=true; break; case(LIST): want_type='A'; real_pos=0; // REST doesn't work for NLST command="NLST"; if(file && file[0]) append_file=true; break; case(CHANGE_DIR): if((real_cwd && !xstrcmp(real_cwd,file)) || SendCWD(file,file_url,Expect::CWD)==0) cwd.Set(file,false,file_url,device_prefix_len(file)); goto pre_WAITING_STATE; case(MAKE_DIR): command="MKD"; append_file=true; want_type=conn->type; break; case(REMOVE_DIR): command="RMD"; append_file=true; want_type=conn->type; break; case(REMOVE): command="DELE"; append_file=true; want_type=conn->type; break; case(QUOTE_CMD): real_pos=0; command=""; append_file=true; conn->data_iobuf=new IOBuffer(IOBuffer::GET); rate_limit=new RateLimit(hostname); break; case(RENAME): command="RNFR"; append_file=true; want_type=conn->type; break; case(LINK): command="SITE LINK"; append_file=true; want_type=conn->type; break; case(SYMLINK): command="SITE SYMLINK"; append_file=true; want_type=conn->type; break; case(ARRAY_INFO): break; case(CHANGE_MODE): { command=xstring::format("SITE CHMOD %03o",chmod_mode); append_file=true; want_type=conn->type; break; } case(CONNECT_VERIFY): case(CLOSED): state=EOF_STATE; return MOVED; } if(want_type!=conn->type) { conn->SendCmdF("TYPE %c",want_type); expect->Push(new Expect(Expect::TYPE,want_type)); } if(opt_size && conn->size_supported && file[0] && use_size) { conn->SendCmd2("SIZE",file,url::path_ptr(file_url),home); expect->Push(Expect::SIZE_OPT); } if(opt_date && conn->mdtm_supported && file[0] && use_mdtm) { conn->SendCmd2("MDTM",file,url::path_ptr(file_url),home); expect->Push(Expect::MDTM_OPT); } if(mode==ARRAY_INFO) { SendArrayInfoRequests(); goto pre_WAITING_STATE; } if(mode==QUOTE_CMD || mode==CHANGE_MODE || (mode==LONG_LIST && use_stat_for_list) || mode==REMOVE || mode==REMOVE_DIR || mode==MAKE_DIR || mode==RENAME) { if(mode==MAKE_DIR && mkdir_p) { Ref dirs(MkdirMakeSet()); for(int i=0; iCount(); i++) { conn->SendCmd2("MKD",dirs->String(i)); expect->Push(Expect::IGNORE); } } if(append_file) conn->SendCmd2(command,file,url::path_ptr(file_url),home); else conn->SendCmd(command); if(mode==QUOTE_CMD) { expect->Push(Expect::QUOTED); if(!strncasecmp(file,"CWD",3) || !strncasecmp(file,"CDUP",4) || !strncasecmp(file,"XCWD",4) || !strncasecmp(file,"XCUP",4)) { LogNote(9,"Resetting cwd"); set_real_cwd(0); // we do not know the path now. } } else if(mode==LONG_LIST) expect->Push(Expect::QUOTED); else if(mode==RENAME) expect->Push(Expect::RNFR); else expect->Push(Expect::FILE_ACCESS); goto pre_WAITING_STATE; } if(mode==LINK || mode==SYMLINK) { conn->SendCmdF("%s %s %s",command,file.get(),file1.get()); expect->Push(Expect::FILE_ACCESS); goto pre_WAITING_STATE; } if((copy_mode==COPY_NONE && GetFlag(PASSIVE_MODE)) || (copy_mode!=COPY_NONE && copy_passive)) { if(use_pret && conn->pret_supported) { conn->SendCmd(xstring::cat("PRET ",command," ",file.get(),NULL)); expect->Push(Expect::PRET); } conn->can_do_pasv=(conn->peer_sa.sa.sa_family==AF_INET); #if INET6 conn->can_do_pasv|=(conn->peer_sa.sa.sa_family==AF_INET6 && IN6_IS_ADDR_V4MAPPED(&conn->peer_sa.in6.sin6_addr)); #endif if(conn->can_do_pasv && !(conn->epsv_supported && QueryBool("prefer-epsv",hostname))) { #if USE_SSL if(copy_mode!=COPY_NONE && conn->prot=='P' && !conn->sscn_on && copy_ssl_connect) conn->SendCmd("CPSV"); // same as PASV, but server does SSL_connect else #endif // note the following statement conn->SendCmd("PASV"); expect->Push(Expect::PASV); pasv_state=PASV_NO_ADDRESS_YET; } else { conn->SendCmd("EPSV"); expect->Push(Expect::EPSV); pasv_state=PASV_NO_ADDRESS_YET; } } else // !PASSIVE { sockaddr_u control_sa; if(copy_mode!=COPY_NONE) conn->data_sa=copy_addr; if(conn->data_sa.sa.sa_family==AF_INET) { a=(const unsigned char*)&conn->data_sa.in.sin_addr; p=(const unsigned char*)&conn->data_sa.in.sin_port; // check if data socket address is unbound if((a[0]|a[1]|a[2]|a[3])==0) { socklen_t addr_len=sizeof(control_sa); getsockname(conn->control_sock,&control_sa.sa,&addr_len); a=(const unsigned char*)&control_sa.in.sin_addr; } #if INET6 ipv4_port: #endif if(copy_mode==COPY_NONE) { const char *port_ipv4=Query("port-ipv4",hostname); struct in_addr fake_ip; if(port_ipv4 && port_ipv4[0]) { if(inet_pton(AF_INET,port_ipv4,&fake_ip)) a=(const unsigned char*)&fake_ip; } } conn->SendCmdF("PORT %d,%d,%d,%d,%d,%d",a[0],a[1],a[2],a[3],p[0],p[1]); expect->Push(Expect::PORT); } else { #if INET6 if(conn->data_sa.sa.sa_family==AF_INET6 && IN6_IS_ADDR_V4MAPPED(&conn->data_sa.in6.sin6_addr)) { a=((unsigned char*)&conn->data_sa.in6.sin6_addr)+12; p=(unsigned char*)&conn->data_sa.in6.sin6_port; goto ipv4_port; } conn->SendCmd2("EPRT",encode_eprt(&conn->data_sa)); expect->Push(Expect::PORT); #else Fatal(_("unsupported network protocol")); return MOVED; #endif } } if(mode==STORE && entity_size!=NO_SIZE && QueryBool("use-allo",hostname)) { // ALLO is usually ignored by servers, but send it anyway. conn->SendCmdF("ALLO %lld",(long long)entity_size); expect->Push(Expect::ALLO); } // some broken servers don't reset REST after a transfer, // so check if last_rest was different. if(real_pos==-1 || conn->last_rest!=real_pos) { conn->rest_pos=(real_pos!=-1?real_pos:pos); conn->SendCmdF("REST %lld",(long long)conn->rest_pos); expect->Push(Expect::REST); real_pos=-1; } if(copy_mode!=COPY_DEST || copy_allow_store) { if(append_file) conn->SendCmd2(command,file,url::path_ptr(file_url),home); else conn->SendCmd(command); expect->Push(Expect::TRANSFER); } m=MOVED; if(copy_mode!=COPY_NONE && !copy_passive) goto pre_WAITING_STATE; if((copy_mode==COPY_NONE && GetFlag(PASSIVE_MODE)) || (copy_mode!=COPY_NONE && copy_passive)) { state=DATASOCKET_CONNECTING_STATE; goto datasocket_connecting_state; } state=ACCEPTING_STATE; } /* fallthrough */ case(ACCEPTING_STATE): m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=ACCEPTING_STATE || Error()) return MOVED; res=Poll(conn->data_sock,POLLIN,&error); if(res==-1) { LogError(0,_("Data socket error (%s) - reconnecting"),error); Disconnect(error); return MOVED; } if(!(res&POLLIN)) goto usual_return; res=SocketAccept(conn->data_sock,&conn->data_sa,hostname); if(res==-1) { saved_errno=errno; if(saved_errno==EWOULDBLOCK) goto usual_return; if(NotSerious(saved_errno)) { LogError(0,"%s",strerror(saved_errno)); Disconnect(strerror(saved_errno)); return MOVED; } goto system_error; } close(conn->data_sock); conn->data_sock=res; if(QueryBool("use-ip-tos",hostname)) MaximizeThroughput(conn->data_sock); LogNote(5,_("Accepted data connection from (%s) port %u"), SocketNumericAddress(&conn->data_sa),SocketPort(&conn->data_sa)); if(!conn->data_address_ok(0,verify_data_address,verify_data_port)) { Disconnect("invalid data connection address"); return MOVED; } goto pre_waiting_150; case(DATASOCKET_CONNECTING_STATE): datasocket_connecting_state: if(pasv_state!=PASV_DATASOCKET_CONNECTING) m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=DATASOCKET_CONNECTING_STATE || Error()) return MOVED; switch(pasv_state) { case PASV_NO_ADDRESS_YET: goto usual_return; case PASV_HAVE_ADDRESS: if(copy_mode==COPY_NONE && !conn->data_address_ok(&conn->data_sa,verify_data_address,/*port_verify*/false)) { Disconnect("invalid data connection address"); return MOVED; } pasv_state=PASV_DATASOCKET_CONNECTING; if(copy_mode!=COPY_NONE) { memcpy(©_addr,&conn->data_sa,sizeof(conn->data_sa)); copy_addr_valid=true; goto pre_WAITING_STATE; } if(!conn->proxy_is_http) { LogNote(5,_("Connecting data socket to (%s) port %u"), SocketNumericAddress(&conn->data_sa),SocketPort(&conn->data_sa)); res=SocketConnect(conn->data_sock,&conn->data_sa); } else // proxy_is_http { LogNote(5,_("Connecting data socket to proxy %s (%s) port %u"), proxy.get(),SocketNumericAddress(&conn->peer_sa),SocketPort(&conn->peer_sa)); res=SocketConnect(conn->data_sock,&conn->peer_sa); } if(res==-1 && errno!=EINPROGRESS) { saved_errno=errno; LogError(0,"connect: %s",strerror(saved_errno)); Disconnect(strerror(saved_errno)); if(NotSerious(saved_errno)) return MOVED; goto system_error; } m=MOVED; /* fallthrough */ case PASV_DATASOCKET_CONNECTING: res=Poll(conn->data_sock,POLLOUT,&error); if(res==-1) { LogError(0,_("Data socket error (%s) - reconnecting"),error); if(conn->fixed_pasv && QueryBool("auto-passive-mode",hostname)) { LogNote(2,_("Switching passive mode off")); SetFlag(PASSIVE_MODE,0); } Disconnect(error); return MOVED; } if(!(res&POLLOUT)) goto usual_return; LogNote(9,_("Data connection established")); if(!conn->proxy_is_http) goto pre_waiting_150; pasv_state=PASV_HTTP_PROXY_CONNECTED; m=MOVED; conn->data_iobuf=new IOBufferFDStream(new FDStream(conn->data_sock,"data-socket"),IOBuffer::PUT); HttpProxySendConnectData(); conn->data_iobuf->Roll(); // FIXME, data_iobuf could be not done yet conn->data_iobuf=new IOBufferFDStream(new FDStream(conn->data_sock,"data-socket"),IOBuffer::GET); /* fallthrough */ case PASV_HTTP_PROXY_CONNECTED: if(HttpProxyReplyCheck(conn->data_iobuf)) goto pre_waiting_150; goto usual_return; } /* fallthrough */ pre_waiting_150: state=WAITING_150_STATE; conn->waiting_150_timer.Reset(); rate_limit=new RateLimit(hostname); m=MOVED; case WAITING_150_STATE: m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=WAITING_150_STATE || Error()) return MOVED; if(!conn->received_150 && !expect->IsEmpty() && !conn->waiting_150_timer.Stopped()) goto usual_return; // now init data connection properly and start data exchange state=DATA_OPEN_STATE; m=MOVED; #if USE_SSL if(conn->prot=='P') { Ref ssl(new lftp_ssl(conn->data_sock,lftp_ssl::CLIENT,hostname)); if(QueryBool("ssl-data-use-keys",hostname) || !conn->control_ssl) ssl->load_keys(); // share session id between control and data connections. if(conn->control_ssl && QueryBool("ssl-copy-sid",hostname)) ssl->copy_sid(conn->control_ssl); IOBuffer::dir_t dir=(mode==STORE?IOBuffer::PUT:IOBuffer::GET); IOBufferSSL *ssl_buf=new IOBufferSSL(ssl.borrow(),dir); conn->data_iobuf=ssl_buf; } else // note the following block #endif { IOBuffer::dir_t dir=(mode==STORE?IOBuffer::PUT:IOBuffer::GET); if(!conn->data_iobuf || conn->data_iobuf->GetDirection()!=dir) conn->data_iobuf=new IOBufferFDStream(new FDStream(conn->data_sock,"data-socket"),dir); } if(mode==LIST || mode==LONG_LIST || mode==MP_LIST) { if(conn->utf8_activated) conn->data_iobuf->SetTranslation("UTF-8",true); else if(charset && *charset) conn->data_iobuf->SetTranslation(charset,true); } rate_limit->SetBufferSize(conn->data_iobuf,max_buf); /* fallthrough */ case(DATA_OPEN_STATE): { if(expect->IsEmpty() && conn->data_sock!=-1) { // When ftp server has sent "Transfer complete" it is idle, // but the data can be still unsent in server side kernel buffer. // So the ftp server can decide the connection is idle for too long // time and disconnect. This hack is to prevent the above. if(now.UnixTime() >= conn->nop_time+nop_interval) { // prevent infinite NOOP's if(conn->nop_offset==pos && timeout_timer.GetLastSetting()nop_count*nop_interval) { LogError(1,"NOOP timeout"); HandleTimeout(); return MOVED; } if(conn->nop_time!=0) { conn->nop_count++; conn->SendCmd("NOOP"); expect->Push(Expect::IGNORE); } conn->nop_time=now; if(conn->nop_offset!=pos) conn->nop_count=0; conn->nop_offset=pos; } TimeoutS(nop_interval-(time_t(now)-conn->nop_time)); } oldstate=state; m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=oldstate || Error()) return MOVED; timeout_timer.Reset(conn->data_iobuf->EventTime()); if(conn->data_iobuf->Error() && conn->data_sock!=-1) { LogError(0,"%s",conn->data_iobuf->ErrorText()); conn->CloseDataSocket(); // workaround for proftpd bug - it resets data connection when no files found. if(mode==LIST && expect->IsEmpty() && !conn->received_150 && conn->data_iobuf->GetPos()==0) { DataClose(); state=EOF_STATE; eof=true; return MOVED; } } // handle errors on data connection only when storing or got all replies // and read all data. if(conn->data_iobuf->Error() && (mode==STORE || (expect->IsEmpty() && conn->data_iobuf->Size()==0))) { if(conn->data_iobuf->ErrorFatal()) SetError(FATAL,conn->data_iobuf->ErrorText()); if(!expect->IsEmpty()) DisconnectNow(); else { DataClose(); state=EOF_STATE; if(mode==STORE && GetFlag(IO_FLAG)) SetError(STORE_FAILED,0); else if(NextTry()) retry_timer.Set(2); // retry after 2 seconds } return MOVED; } if(mode!=STORE) { if(conn->data_iobuf->Size()>=rate_limit->BytesAllowedToGet()) { conn->data_iobuf->Suspend(); TimeoutS(1); } else if(conn->data_iobuf->Size()>=max_buf) { conn->data_iobuf->Suspend(); m=MOVED; } else if(conn->data_iobuf->IsSuspended() && !IsSuspended()) { conn->data_iobuf->Resume(); if(conn->data_iobuf->Size()>0) m=MOVED; } if(conn->data_iobuf->Size()==0 && conn->data_iobuf->Eof()) { LogNote(9,"Got EOF on data connection"); conn->data_iobuf->PutEOF(); // for ssl shutdown DataClose(); if(expect->IsEmpty()) { eof=true; m=MOVED; } state=WAITING_STATE; } } if(state!=oldstate || Error()) return MOVED; CheckTimeout(); if(state!=oldstate) return MOVED; goto usual_return; } pre_WAITING_STATE: if(copy_mode!=COPY_NONE) TrySuccess(); // it is enough to get here in copying. state=WAITING_STATE; m=MOVED; case(WAITING_STATE): { oldstate=state; m|=FlushSendQueue(); m|=ReceiveResp(); if(state!=oldstate || Error()) return MOVED; // more work to do? if(expect->IsEmpty() && mode==ARRAY_INFO && fileset_for_info->curr()) { SendArrayInfoRequests(); return MOVED; } if(conn->data_iobuf) { if(expect->IsEmpty() && conn->data_sock==-1 && !conn->data_iobuf->Eof()) { conn->data_iobuf->PutEOF(); m=MOVED; } timeout_timer.Reset(conn->data_iobuf->EventTime()); if(conn->data_iobuf->Eof() && conn->data_iobuf->Size()==0) { state=EOF_STATE; DataAbort(); DataClose(); idle_timer.Reset(); eof=true; return MOVED; } } if(copy_mode==COPY_DEST && !copy_allow_store) goto notimeout_return; if(copy_mode==COPY_DEST && !copy_done && copy_connection_open && expect->Count()==1 && use_stat && !conn->ssl_is_activated() && !conn->proxy_is_http) { if(conn->stat_timer.Stopped()) { // send STAT to know current position. SendUrgentCmd("STAT"); expect->Push(Expect::TRANSFER); FlushSendQueue(true); m=MOVED; } } // FXP is special - no data connection at all. if(copy_mode!=COPY_NONE) goto notimeout_return; goto usual_return; } case WAITING_CCC_SHUTDOWN: if(conn->control_recv->Error()) { if(conn->control_recv->ErrorFatal()) SetError(FATAL,conn->control_recv->ErrorText()); Disconnect(conn->control_recv->ErrorText()); return MOVED; } if(conn->control_recv->Eof() || conn->waiting_ssl_timer.Stopped()) { conn->MakeBuffers(); goto pre_EOF_STATE; } break; } /* end of switch */ usual_return: if(m==MOVED) return MOVED; if(CheckTimeout()) return MOVED; notimeout_return: if(m==MOVED) return MOVED; if(conn && conn->data_sock!=-1) { if(state==ACCEPTING_STATE) Block(conn->data_sock,POLLIN); else if(state==DATASOCKET_CONNECTING_STATE) { if(pasv_state==PASV_DATASOCKET_CONNECTING) Block(conn->data_sock,POLLOUT); } } if(conn && conn->control_sock!=-1) { if(state==CONNECTING_STATE) Block(conn->control_sock,POLLOUT); } return m; system_error: assert(saved_errno!=0); if(NonFatalError(saved_errno)) { TimeoutS(1); return m; } DisconnectNow(); SetError(SEE_ERRNO,0); return MOVED; } #if USE_SSL void Ftp::SendAuth(const char *auth) { if(conn->auth_sent || conn->ssl_is_activated()) return; if(!conn->auth_supported) { if(QueryBool("ssl-force",hostname)) SetError(LOGIN_FAILED,_("ftp:ssl-force is set and server does not support or allow SSL")); return; } if(conn->auth_args_supported) { char *a=alloca_strdup(conn->auth_args_supported); bool saw_ssl=false; bool saw_tls=false; for(a=strtok(a,";"); a; a=strtok(0,";")) { if(!strcasecmp(a,auth)) break; if(!strcasecmp(a,"SSL")) saw_ssl=true; else if(!strcasecmp(a,"TLS")) saw_tls=true; } if(!a) { const char *old_auth=auth; if(saw_tls) auth="TLS"; else if(saw_ssl) auth="SSL"; LogError(1,"AUTH %s is not supported, using AUTH %s instead",old_auth,auth); } } conn->SendCmd2("AUTH",auth); expect->Push(Expect::AUTH_TLS); conn->auth_sent=true; conn->prot='\0'; // send PROT command always, for non-conforming servers } void Ftp::SendPROT(char want_prot) { if(want_prot==conn->prot || !conn->auth_supported) return; conn->SendCmdF("PROT %c",want_prot); expect->Push(new Expect(Expect::PROT,want_prot)); } #endif // USE_SSL void Ftp::SendSiteIdle() { if(!QueryBool("use-site-idle")) return; conn->SendCmd2("SITE IDLE",idle_timer.GetLastSetting().Seconds()); expect->Push(Expect::IGNORE); } void Ftp::SendUTimeRequest() { if(entity_date==NO_DATE || !file) return; char d[15]; time_t n=entity_date; strftime(d,sizeof(d),"%Y%m%d%H%M%S",gmtime(&n)); d[sizeof(d)-1]=0; if(conn->mfmt_supported) { conn->SendCmd2(xstring::format("MFMT %s",d),file,url::path_ptr(file_url),home); expect->Push(Expect::IGNORE); } else if(QueryBool("use-site-utime2") && conn->site_utime2_supported) { conn->SendCmd2(xstring::format("SITE UTIME %s",d),file,url::path_ptr(file_url),home); expect->Push(Expect::SITE_UTIME2); } else if(QueryBool("use-site-utime") && conn->site_utime_supported) { conn->SendCmd(xstring::format("SITE UTIME %s %s %s %s UTC",file.get(),d,d,d)); expect->Push(Expect::SITE_UTIME); } else if(QueryBool("use-mdtm-overloaded")) { conn->SendCmd2(xstring::format("MDTM %s",d),file,url::path_ptr(file_url),home); expect->Push(Expect::IGNORE); } } const char *Ftp::QueryStringWithUserAtHost(const char *var) { const char *u=user?user.get():"anonymous"; const char *h=hostname?hostname.get():""; const char *closure=xstring::cat(u,"@",h,NULL); const char *val=Query(var,closure); if(!val || !val[0]) val=Query(var,hostname); if(!val || !val[0]) return 0; return val; } void Ftp::SendAcct() { const char *acct=QueryStringWithUserAtHost("acct"); if(!acct) return; conn->SendCmd2("ACCT",acct); expect->Push(Expect::IGNORE); } void Ftp::SendSiteGroup() { const char *group=QueryStringWithUserAtHost("site-group"); if(!group) return; conn->SendCmd2("SITE GROUP",group); expect->Push(Expect::IGNORE); } void Ftp::SendSiteCommands() { const char *site_commands=QueryStringWithUserAtHost("site"); if(!site_commands) return; char *cmd=alloca_strdup(site_commands); for(;;) { char *sep=strstr(cmd," "); if(sep) *sep=0; conn->SendCmd2("SITE",cmd); expect->Push(Expect::IGNORE); if(!sep) break; cmd=sep+2; } } void Ftp::SendArrayInfoRequests() { for(int i=fileset_for_info->curr_index(); icount(); i++) { FileInfo *fi=(*fileset_for_info)[i]; bool sent=false; if((fi->need&fi->DATE) && conn->mdtm_supported && use_mdtm) { conn->SendCmd2("MDTM",ExpandTildeStatic(fi->name)); expect->Push(Expect::MDTM); sent=true; } if((fi->need&fi->SIZE) && conn->size_supported && use_size) { conn->SendCmd2("SIZE",ExpandTildeStatic(fi->name)); expect->Push(Expect::SIZE); sent=true; } if(!sent) { if(i==fileset_for_info->curr_index()) fileset_for_info->next(); // if it is the first one, just skip it. else break; // otherwise, wait until it is the first. } else { if(GetFlag(SYNC_MODE)) break; // don't flood the queues. } } } int Ftp::ReplyLogPriority(int code) const { // Greeting messages if(code==220 || code==230) return 3; if(code==250 && mode==CHANGE_DIR) return 3; if(code==451 && mode==CLOSED) return 4; /* Most 5XXs go to level 4, as it's the job's responsibility to * print fatal errors. Some 5XXs are treated as 4XX's; send those * to level 0. (Maybe they should go to 1; we're going to retry them, * after all. */ if(is5XX(code)) return Transient5XX(code)? 0:4; if(is4XX(code)) return 0; // 221 is the reply to QUIT, but we don't expect it. if(code==221 && !conn->quit_sent) return 0; return 4; } int Ftp::ReceiveOneLine() { const char *resp; int resp_size; conn->control_recv->Get(&resp,&resp_size); if(resp==0) // eof { if(!conn->quit_sent) LogError(0,_("Peer closed connection")); DisconnectNow(); return -1; } if(resp_size==0) return 0; int line_len=0; int skip_len=0; // find pair const char *nl=find_char(resp,resp_size,'\n'); for(;;) { if(!nl) { if(conn->control_recv->Eof()) { skip_len=line_len=resp_size; break; } return 0; } if(nl>resp && nl[-1]=='\r') { line_len=nl-resp-1; skip_len=nl-resp+1; break; } if(nl==resp+resp_size-1 && now-conn->control_recv->EventTime()>5) { LogError(1,"server bug: single "); nl=find_char(resp,resp_size,'\n'); line_len=nl-resp; skip_len=nl-resp+1; break; } nl=find_char(nl+1,resp_size-(nl+1-resp),'\n'); } line.nset(resp,line_len); conn->control_recv->Skip(skip_len); // Change to according to RFC2640. // Other occurencies of are changed to '!'. char *w=line.get_non_const(); const char *r=w; for(int i=line.length(); i>0; i--,r++) { if(*r) *w++=*r; else if(r==line || r[-1]!='\r') *w++='!'; } line.truncate(line.length()-(r-w)); return line.length(); } int Ftp::ReceiveResp() { int m=STALL; if(!conn || !conn->control_recv) return m; timeout_timer.Reset(conn->control_recv->EventTime()); if(conn->control_recv->Error()) { LogError(0,"%s",conn->control_recv->ErrorText()); if(conn->control_recv->ErrorFatal()) SetError(FATAL,conn->control_recv->ErrorText()); DisconnectNow(); return MOVED; } for(;;) // handle all lines in buffer, one line per loop { if(!conn || !conn->control_recv) return m; int res=ReceiveOneLine(); if(res==-1) return MOVED; if(res==0) return m; int code=0; if(line.length()>=3 && is_ascii_digit(line[0]) && is_ascii_digit(line[1]) && is_ascii_digit(line[2])) sscanf(line,"%3d",&code); if(conn->multiline_code && conn->multiline_code!=code && QueryBool("ftp:strict-multiline",closure)) code=0; // reply can only terminate with the same code int log_prio=ReplyLogPriority(conn->multiline_code?conn->multiline_code:code); bool is_first_line=(line[3]=='-' && conn->multiline_code==0); bool is_last_line=(line[3]!='-' && code!=0); bool is_data=(!expect->IsEmpty() && expect->FirstIs(Expect::QUOTED) && conn->data_iobuf); int data_offset=0; if(is_data && mode==LONG_LIST) { if(code && !is2XX(code)) is_data=false; if(code && line.length()>4) { data_offset=4; if(is_first_line && strstr(line+data_offset,"FTP server status")) { TurnOffStatForList(); is_data=false; } if((is_first_line && !strncasecmp(line+data_offset,"Stat",4)) || (is_last_line && !strncasecmp(line+data_offset,"End",3))) is_data=false; } } if(is_data && conn->data_iobuf) { if(line[data_offset]==' ') data_offset++; conn->data_iobuf->Put(line+data_offset,line.length()-data_offset); conn->data_iobuf->Put("\n"); log_prio=10; } LogRecv(log_prio,line); if(conn->multiline_code==0 || all_lines.length()==0) all_lines.set(line); // not continuation else if(all_lines.length()<0x4000) all_lines.vappend("\n",line.get(),NULL); if(code==0) continue; if(line[3]=='-') { if(conn->multiline_code==0) conn->multiline_code=code; continue; } if(conn->multiline_code && line[3]!=' ') continue; // The space is required to terminate multiline reply conn->multiline_code=0; if(!is1XX(code)) { if(conn->sync_wait>0) conn->sync_wait--; // clear the flag to send next command else { if(code!=421) { LogError(3,_("extra server response")); return m; } } } CheckResp(code); m=MOVED; if(error_code==NO_FILE || error_code==LOGIN_FAILED) { if(error_code==LOGIN_FAILED) reconnect_timer.Reset(); // count the reconnect-interval from this moment if(persist_retries++& buf) { if(!proxy_user || !proxy_pass) return; xstring& auth=xstring::cat(proxy_user.get(),":",proxy_pass.get(),NULL); int auth_len=auth.length(); char *buf64=string_alloca(base64_length(auth_len)+1); base64_encode(auth,buf64,auth_len); buf->Format("Proxy-Authorization: Basic %s\r\n",buf64); Log::global->Format(4,"+--> Proxy-Authorization: Basic %s\r\n",buf64); } void Ftp::HttpProxySendConnect() { const char *the_port=portname?portname.get():ftps?FTPS_DEFAULT_PORT:FTP_DEFAULT_PORT; conn->control_send->Format("CONNECT %s:%s HTTP/1.0\r\n",hostname.get(),the_port); Log::global->Format(4,"+--> CONNECT %s:%s HTTP/1.0\n",hostname.get(),the_port); HttpProxySendAuth(conn->control_send); conn->control_send->Put("\r\n"); http_proxy_status_code=0; } void Ftp::HttpProxySendConnectData() { const char *the_host=SocketNumericAddress(&conn->data_sa); int the_port=SocketPort(&conn->data_sa); conn->data_iobuf->Format("CONNECT %s:%d HTTP/1.0\r\n",the_host,the_port); Log::global->Format(4,"+--> CONNECT %s:%d HTTP/1.0\n",the_host,the_port); HttpProxySendAuth(conn->data_iobuf); conn->data_iobuf->Put("\r\n"); http_proxy_status_code=0; } // Check reply and return true when the reply is received and is ok. bool Ftp::HttpProxyReplyCheck(const SMTaskRef& buf) { const char *b; int s; buf->Get(&b,&s); const char *nl=b?(const char*)memchr(b,'\n',s):0; if(!nl) { if(buf->Error()) { LogError(0,"%s",buf->ErrorText()); if(buf->ErrorFatal()) SetError(FATAL,buf->ErrorText()); } else if(buf->Eof()) LogError(0,_("Peer closed connection")); if(conn && (buf->Eof() || buf->Error())) DisconnectNow(); return false; } char *line=string_alloca(nl-b); memcpy(line,b,nl-b-1); // don't copy \r line[nl-b-1]=0; buf->Skip(nl-b+1); // skip \r\n too. Log::global->Format(4,"<--+ %s\n",line); if(!http_proxy_status_code) { if(1!=sscanf(line,"HTTP/%*d.%*d %d",&http_proxy_status_code) || !is2XX(http_proxy_status_code)) { // check for retriable codes if(http_proxy_status_code==408 // Request Timeout || http_proxy_status_code==502 // Bad Gateway || http_proxy_status_code==503 // Service Unavailable || http_proxy_status_code==504)// Gateway Timeout { DisconnectNow(); return false; } SetError(FATAL,line); return false; } } if(!*line) return true; return false; } void Ftp::SendUrgentCmd(const char *cmd) { if(!use_telnet_iac || !conn->telnet_layer_send) { conn->SendCmd(cmd); return; } static const char pre_cmd[]={TELNET_IAC,TELNET_IP,TELNET_IAC,TELNET_DM}; #if USE_SSL if(conn->ssl_is_activated()) { // no way to send urgent data over ssl, send normally. conn->telnet_layer_send->Buffer::Put(pre_cmd,4); } else // note the following block #endif { int fl=fcntl(conn->control_sock,F_GETFL); fcntl(conn->control_sock,F_SETFL,fl&~O_NONBLOCK); FlushSendQueue(/*all=*/true); if(!conn || !conn->control_send) return; if(conn->control_send->Size()>0) conn->control_send->Roll(); // only DM byte is to be sent in urgent mode send(conn->control_sock,pre_cmd,3,0); send(conn->control_sock,pre_cmd+3,1,MSG_OOB); fcntl(conn->control_sock,F_SETFL,fl); } conn->SendCmd(cmd); } void Ftp::DataAbort() { if(!conn || state==CONNECTING_STATE || conn->quit_sent) return; if(conn->data_sock==-1 && copy_mode==COPY_NONE) return; // nothing to abort if(copy_mode!=COPY_NONE) { if(expect->IsEmpty()) return; // the transfer seems to be finished if(!copy_addr_valid) return; // data connection cannot be established at this time if(!copy_connection_open && expect->FirstIs(Expect::TRANSFER)) { // wu-ftpd-2.6.0 cannot interrupt accept() or connect(). DisconnectNow(); return; } } copy_connection_open=false; // if transfer has been completed then ABOR is not needed if(conn->data_sock!=-1 && expect->IsEmpty()) return; expect->Close(); if(!QueryBool("use-abor",hostname) || expect->Count()>1 || conn->proxy_is_http) { // check that we have a data socket to close, and the server is not // in uninterruptible accept() state. if(copy_mode==COPY_NONE && !(GetFlag(PASSIVE_MODE) && state==DATASOCKET_CONNECTING_STATE && (pasv_state==PASV_NO_ADDRESS_YET || pasv_state==PASV_HAVE_ADDRESS))) DataClose(); // just close data connection else { // otherwise, just close control connection. DisconnectNow(); } return; } if(conn->aborted_data_sock!=-1) // don't allow double ABOR. { DisconnectNow(); return; } SendUrgentCmd("ABOR"); expect->Push(Expect::ABOR); FlushSendQueue(true); conn->abor_close_timer.Reset(); // don't close it now, wait for ABOR result conn->AbortDataConnection(); // ABOR over SSL connection does not always work, // closing data socket should help it. if(conn->ssl_is_activated()) conn->CloseAbortedDataConnection(); if(QueryBool("web-mode")) Disconnect(); } void Ftp::ControlClose() { if(conn && conn->control_send) conn->control_send->PutEOF(); conn=0; expect=0; } void Ftp::DisconnectNow() { DataClose(); ControlClose(); state=INITIAL_STATE; http_proxy_status_code=0; if(copy_mode!=COPY_NONE) { if(copy_addr_valid) copy_failed=true; } else { if(mode==STORE && GetFlag(IO_FLAG)) SetError(STORE_FAILED,0); } copy_addr_valid=false; } void Ftp::DisconnectLL() { if(!conn) return; if(conn->quit_sent) return; /* protect against re-entering from FlushSendQueue */ static bool disconnect_in_progress=false; if(disconnect_in_progress) return; disconnect_in_progress=true; bool no_greeting=(!expect->IsEmpty() && expect->FirstIs(Expect::READY)); expect->Close(); DataAbort(); DataClose(); if(conn && state!=CONNECTING_STATE && state!=HTTP_PROXY_CONNECTED && expect->Count()<2 && QueryBool("use-quit",hostname)) { conn->SendCmd("QUIT"); expect->Push(Expect::IGNORE); conn->quit_sent=true; goto out; } ControlClose(); if(state==CONNECTING_STATE || no_greeting) NextPeer(); DisconnectNow(); out: disconnect_on_close=false; Timeout(0); disconnect_in_progress=false; } void Ftp::Connection::CloseDataSocket() { if(data_sock==-1) return; LogNote(7,_("Closing data socket")); close(data_sock); data_sock=-1; } void Ftp::Connection::CloseDataConnection() { data_iobuf=0; fixed_pasv=false; CloseDataSocket(); } void Ftp::Connection::AbortDataConnection() { CloseAbortedDataConnection(); aborted_data_sock=data_sock; data_sock=-1; CloseDataConnection(); // clean up all other members. } void Ftp::Connection::CloseAbortedDataConnection() { if(aborted_data_sock!=-1) { LogNote(9,_("Closing aborted data socket")); close(aborted_data_sock); aborted_data_sock=-1; } } void Ftp::DataClose() { rate_limit=0; if(!conn) return; conn->nop_time=0; conn->nop_offset=0; conn->nop_count=0; if(conn->data_sock!=-1 && QueryBool("web-mode")) disconnect_on_close=true; conn->CloseDataConnection(); if(state==DATA_OPEN_STATE || state==DATASOCKET_CONNECTING_STATE) state=WAITING_STATE; } int Ftp::Connection::FlushSendQueueOneCmd() { const char *send_cmd_ptr; int send_cmd_count; send_cmd_buffer.Get(&send_cmd_ptr,&send_cmd_count); if(send_cmd_count==0) return 0; const char *cmd_begin=send_cmd_ptr; const char *line_end=(const char*)memchr(send_cmd_ptr,'\n',send_cmd_count); if(!line_end) return 0; int to_write=line_end+1-send_cmd_ptr; control_send->Put(send_cmd_ptr,to_write); send_cmd_buffer.Skip(to_write); sync_wait++; int log_level=5; if(!may_show_password && !strncasecmp(cmd_begin,"PASS ",5)) LogSend(log_level,"PASS XXXX"); else { xstring log; for(const char *s=cmd_begin; s<=line_end; s++) { if(*s==0) log.append(""); else if(*s==TELNET_IAC && telnet_layer_send) { s++; if(*s==TELNET_IAC) log.append('\377'); else if(*s==TELNET_IP) log.append(""); else if(*s==TELNET_DM) log.append(""); } else log.append(*s?*s:'!'); } LogSend(log_level,log); } return 1; } int Ftp::FlushSendQueue(bool all) { int m=STALL; if(!conn || !conn->control_send) return m; if(conn->control_send->Error()) { LogError(0,"%s",conn->control_send->ErrorText()); if(conn->control_send->ErrorFatal()) { #if USE_SSL if(conn->ssl_is_activated() && !ftps && !QueryBool("ssl-force",hostname) && !conn->control_ssl->cert_error) { // retry without ssl ResMgr::Set("ftp:ssl-allow",hostname,"no"); DontSleep(); } else #endif SetError(FATAL,conn->control_send->ErrorText()); } DisconnectNow(); return MOVED; } if(conn->send_cmd_buffer.Size()==0) return m; while(conn->sync_wait<=0 || all || !GetFlag(SYNC_MODE)) { int res=conn->FlushSendQueueOneCmd(); if(!res) break; m|=MOVED; } if(m==MOVED) conn->control_send->Roll(); timeout_timer.Reset(conn->control_send->EventTime()); return m; } void Ftp::Connection::Send(const char *buf) { while(*buf) { char ch=*buf++; send_cmd_buffer.Put(&ch,1); if(ch=='\r') send_cmd_buffer.PutRaw("",1); // RFC2640 } } void Ftp::Connection::SendEncoded(const char *buf) { while(*buf) { char ch=*buf++; if(ch=='%' && isxdigit((unsigned char)buf[0]) && isxdigit((unsigned char)buf[1])) { int n=0; if(sscanf(buf,"%2x",&n)==1) { buf+=2; ch=n; // don't translate encoded bytes send_cmd_buffer.PutRaw(&ch,1); send_cmd_buffer.ResetTranslation(); goto next; } } send_cmd_buffer.Put(&ch,1); next: if(ch=='\r') send_cmd_buffer.PutRaw("",1); // RFC2640 } } void Ftp::Connection::SendCRNL() { send_cmd_buffer.PutRaw("\r\n",2); send_cmd_buffer.ResetTranslation(); } void Ftp::Connection::SendCmd(const char *cmd) { Send(cmd); SendCRNL(); } void Ftp::Connection::SendURI(const char *u,const char *home) { if(u[0]=='/' && u[1]=='~') u++; else if(!strncasecmp(u,"/%2F",4)) { Send("/"); u+=4; } else if(home && strcmp(home,"/")) Send(home); SendEncoded(u); } void Ftp::Connection::SendCmd2(const char *cmd,const char *f,const char *u,const char *home) { if(cmd && cmd[0]) { Send(cmd); send_cmd_buffer.Put(" ",1); } if(u) SendURI(u,home); else Send(f); SendCRNL(); } void Ftp::Connection::SendCmd2(const char *cmd,int v) { char buf[32]; snprintf(buf,sizeof(buf),"%d",v); SendCmd2(cmd,buf); } void Ftp::Connection::SendCmdF(const char *f,...) { va_list v; va_start(v,f); xstring& s=xstring::vformat(f,v); va_end(v); SendCmd(s); } int Ftp::SendEOT() { if(mode!=STORE) return(OK); /* nothing to do */ if(state!=DATA_OPEN_STATE) return(DO_AGAIN); if(!conn->data_iobuf->Eof()) conn->data_iobuf->PutEOF(); if(!conn->data_iobuf->Done()) return(DO_AGAIN); DataClose(); state=WAITING_STATE; return(OK); } void Ftp::Close() { if(mode!=CLOSED) idle_timer.Reset(); flags&=~NOREST_MODE; // can depend on a particular file eof=false; Resume(); ExpandTildeInCWD(); DataAbort(); DataClose(); if(conn) { expect->Close(); switch(state) { case(CONNECTING_STATE): case(HTTP_PROXY_CONNECTED): case(CONNECTED_STATE): case(USER_RESP_WAITING_STATE): Disconnect(); break; case(ACCEPTING_STATE): case(DATASOCKET_CONNECTING_STATE): case(CWD_CWD_WAITING_STATE): case(WAITING_STATE): case(DATA_OPEN_STATE): case(WAITING_150_STATE): state=EOF_STATE; break; case(INITIAL_STATE): case(EOF_STATE): case(WAITING_CCC_SHUTDOWN): break; } } else { state=INITIAL_STATE; } copy_mode=COPY_NONE; copy_protect=false; copy_ssl_connect=false; copy_addr_valid=false; copy_done=false; copy_connection_open=false; copy_allow_store=false; copy_failed=false; super::Close(); if(disconnect_on_close) Disconnect(); } Ftp::ExpectQueue::ExpectQueue() { first=0; last=&first; count=0; } Ftp::ExpectQueue::~ExpectQueue() { while(first) delete Pop(); } void Ftp::ExpectQueue::Push(Expect *e) { *last=e; last=&e->next; e->next=0; count++; } void Ftp::ExpectQueue::Push(Expect::expect_t e) { Push(new Expect(e)); } Ftp::Expect *Ftp::ExpectQueue::Pop() { if(!first) return 0; Expect *res=first; first=first->next; if(last==&res->next) last=&first; res->next=0; count--; return res; } bool Ftp::ExpectQueue::Has(Expect::expect_t cc) const { for(const Expect *scan=first; scan; scan=scan->next) if(cc==scan->check_case) return true; return false; } bool Ftp::ExpectQueue::FirstIs(Expect::expect_t cc) const { if(first && first->check_case==cc) return true; return false; } void Ftp::ExpectQueue::Close() { for(Expect *scan=first; scan; scan=scan->next) { switch(scan->check_case) { case(Expect::IGNORE): case(Expect::PWD): case(Expect::USER): case(Expect::USER_PROXY): case(Expect::PASS): case(Expect::PASS_PROXY): case(Expect::OPEN_PROXY): case(Expect::ACCT_PROXY): case(Expect::READY): case(Expect::ABOR): case(Expect::CWD_STALE): case(Expect::PRET): case(Expect::PASV): case(Expect::EPSV): case(Expect::TRANSFER_CLOSED): case(Expect::FEAT): case(Expect::SITE_UTIME): case(Expect::SITE_UTIME2): case(Expect::TYPE): case(Expect::LANG): case(Expect::OPTS_UTF8): case(Expect::ALLO): #if USE_SSL case(Expect::AUTH_TLS): case(Expect::PROT): case(Expect::SSCN): case(Expect::CCC): #endif break; case(Expect::CWD_CURR): case(Expect::CWD): scan->check_case=Expect::CWD_STALE; break; case(Expect::NONE): case(Expect::REST): case(Expect::SIZE): case(Expect::SIZE_OPT): case(Expect::MDTM): case(Expect::MDTM_OPT): case(Expect::PORT): case(Expect::FILE_ACCESS): case(Expect::RNFR): case(Expect::QUOTED): scan->check_case=Expect::IGNORE; break; case(Expect::TRANSFER): scan->check_case=Expect::TRANSFER_CLOSED; break; } } } Ftp::Expect *Ftp::ExpectQueue::FindLastCWD() const { Expect *last_cwd=0; for(Expect *scan=first; scan; scan=scan->next) { switch(scan->check_case) { case(Expect::CWD_CURR): case(Expect::CWD_STALE): case(Expect::CWD): last_cwd=scan; default: ; } } return last_cwd; } bool Ftp::IOReady() { if(copy_mode!=COPY_NONE && !copy_passive && !copy_addr_valid) return true; // simulate to be ready as other fxp peer has to go return (state==DATA_OPEN_STATE || state==WAITING_STATE) && real_pos!=-1 && IsOpen(); } void Ftp::SuspendInternal() { super::SuspendInternal(); if(conn) conn->SuspendInternal(); } void Ftp::ResumeInternal() { if(conn) conn->ResumeInternal(); super::ResumeInternal(); } int Ftp::CanRead() { if(Error()) return(error_code); if(mode==CLOSED || eof) return(0); if(!conn || !conn->data_iobuf) return DO_AGAIN; if(expect->Has(Expect::REST) && real_pos==-1) return DO_AGAIN; if(state==DATASOCKET_CONNECTING_STATE) return DO_AGAIN; int size=conn->data_iobuf->Size(); if(state==DATA_OPEN_STATE) { assert(rate_limit!=0); int allowed=rate_limit->BytesAllowedToGet(); if(allowed==0) return DO_AGAIN; if(size>allowed) size=allowed; } if(norest_manual && real_pos==0 && pos>0) return DO_AGAIN; if(size==0) return DO_AGAIN; return size; } int Ftp::Read(Buffer *buf,int size) { int size1=CanRead(); if(size1<=0) return size1; if(size>size1) size=size1; int skip=0; if(real_pos+size0) { conn->data_iobuf->Skip(skip); rate_limit->BytesGot(skip); real_pos+=skip; size-=skip; if(size<=0) return DO_AGAIN; } assert(real_pos==pos); size=buf->MoveDataHere(conn->data_iobuf,size); if(size<=0) return DO_AGAIN; rate_limit->BytesGot(size); real_pos+=size; pos+=size; TrySuccess(); flags|=IO_FLAG; return(size); } /* Write - send data to ftp server * Uploading is not reliable in this realization * Well, not less reliable than in any usual ftp client. The reason for this is uncheckable receiving of data on the remote end. Since that, we have to leave re-putting up to caller. Fortunately, class FileCopy does it. */ int Ftp::Write(const void *buf,int size) { if(mode!=STORE) return(0); if(Error()) return(error_code); if(!conn || state!=DATA_OPEN_STATE || (expect->Has(Expect::REST) && real_pos==-1)) return DO_AGAIN; if(!conn->data_iobuf) return DO_AGAIN; { assert(rate_limit!=0); int allowed=rate_limit->BytesAllowedToPut(); if(allowed==0) return DO_AGAIN; if(size>allowed) size=allowed; } if(size+conn->data_iobuf->Size()>=max_buf) size=max_buf-conn->data_iobuf->Size(); if(size<=0) return 0; conn->data_iobuf->Put((const char*)buf,size); if(retries+persist_retries>0 && conn->data_iobuf->GetPos()>Buffered()+0x20000) { // reset retry count if some data were actually written to server. LogNote(10,"resetting retry count"); TrySuccess(); } assert(rate_limit!=0); rate_limit->BytesPut(size); pos+=size; real_pos+=size; flags|=IO_FLAG; return(size); } int Ftp::StoreStatus() { if(Error()) return(error_code); if(mode!=STORE) return(OK); if(state==DATA_OPEN_STATE) { // have not send EOT by SendEOT, do it now SendEOT(); } if(state==WAITING_STATE && expect->IsEmpty()) { eof=true; return(OK); } return(IN_PROGRESS); } void Ftp::MoveConnectionHere(Ftp *o) { expect=o->expect.borrow(); expect->Close(); // we need not handle other session's replies. assert(o->conn->data_iobuf==0); conn=o->conn.borrow(); conn->ResumeInternal(); o->state=INITIAL_STATE; line.move_here(o->line); all_lines.move_here(o->all_lines); if(peer_curr>=peer.count()) peer_curr=0; timeout_timer.Reset(o->timeout_timer); if(!home) set_home(home_auto); set_real_cwd(o->real_cwd); o->Disconnect(); state=EOF_STATE; } void Ftp::SendOPTS_MLST() { char *facts=alloca_strdup(conn->mlst_attr_supported); char *store=facts; bool differs=false; for(char *tok=strtok(facts,";"); tok; tok=strtok(0,";")) { bool was_enabled=false; bool want_enable=false; int len=strlen(tok); if(len>0 && tok[len-1]=='*') { was_enabled=true; tok[--len]=0; } // "unique" not needed yet. static const char *const needed[]={ "type","size","modify","perm", "UNIX.mode","UNIX.owner","UNIX.uid","UNIX.group","UNIX.gid", 0}; for(const char *const *scan=needed; *scan; scan++) { if(!strcasecmp(tok,*scan)) { memmove(store,tok,len); store+=len; *store++=';'; want_enable=true; break; } } differs|=(was_enabled^want_enable); } if(store>facts && store[-1]==';') --store; if(!differs || store==facts) return; *store=0; conn->SendCmd2("OPTS MLST",facts); expect->Push(Expect::IGNORE); } void Ftp::TuneConnectionAfterFEAT() { if(conn->clnt_supported) { const char *client=Query("client",hostname); if(client && client[0]) { conn->SendCmd2("CLNT",client); expect->Push(Expect::IGNORE); } } if(conn->lang_supported) { const char *lang_to_use=Query("lang",hostname); if(lang_to_use && lang_to_use[0]) conn->SendCmd2("LANG",lang_to_use); else conn->SendCmd("LANG"); expect->Push(Expect::LANG); } if(conn->utf8_supported && QueryBool("use-utf8",hostname)) { // some non-RFC2640 servers require this command. conn->SendCmd("OPTS UTF8 ON"); expect->Push(Expect::OPTS_UTF8); } if(conn->host_supported) { conn->SendCmd2("HOST",hostname); expect->Push(Expect::IGNORE); } if(conn->mlst_attr_supported) SendOPTS_MLST(); } void Ftp::CheckFEAT(char *reply) { if(QueryBool("trust-feat",hostname)) { // turn off these pre-FEAT extensions only when trusting FEAT reply, // as some servers forget to advertise them. conn->mdtm_supported=false; conn->size_supported=false; conn->rest_supported=false; conn->tvfs_supported=false; } #if USE_SSL conn->auth_supported=false; conn->auth_args_supported.set(0); conn->cpsv_supported=false; conn->sscn_supported=false; #endif conn->pret_supported=false; conn->epsv_supported=false; char *scan=strchr(reply,'\n'); if(scan) scan++; if(!scan || !*scan) return; for(char *f=strtok(scan,"\r\n"); f; f=strtok(0,"\r\n")) { if(!strncmp(f,line,3)) { if(f[3]==' ') break; // last line if(f[3]=='-') f+=4; // workaround for broken servers, RFC2389 does not allow it. } while(*f==' ') f++; if(!strcasecmp(f,"UTF8")) conn->utf8_supported=true; else if(!strncasecmp(f,"LANG ",5)) conn->lang_supported=true; else if(!strcasecmp(f,"PRET")) conn->pret_supported=true; else if(!strcasecmp(f,"MDTM")) conn->mdtm_supported=true; else if(!strcasecmp(f,"SIZE")) conn->size_supported=true; else if(!strcasecmp(f,"CLNT") || !strncasecmp(f,"CLNT ",5)) conn->clnt_supported=true; else if(!strcasecmp(f,"HOST")) conn->host_supported=true; else if(!strcasecmp(f,"MFMT")) conn->mfmt_supported=true; else if(!strncasecmp(f,"REST ",5)) // FIXME: actually REST STREAM conn->rest_supported=true; else if(!strcasecmp(f,"REST")) conn->rest_supported=true; else if(!strncasecmp(f,"MLST ",5)) { conn->mlst_supported=true; conn->mlst_attr_supported.set(f+5); } else if(!strcasecmp(f,"EPSV")) conn->epsv_supported=true; else if(!strcasecmp(f,"TVFS")) conn->tvfs_supported=true; #if USE_SSL else if(!strncasecmp(f,"AUTH ",5)) { conn->auth_supported=true; if(conn->auth_args_supported) conn->auth_args_supported.vappend(";",f+5,NULL); else conn->auth_args_supported.append(f+5); } else if(!strcasecmp(f,"AUTH")) conn->auth_supported=true; else if(!strcasecmp(f,"CPSV")) conn->cpsv_supported=true; else if(!strcasecmp(f,"SSCN")) conn->sscn_supported=true; #endif // USE_SSL } conn->have_feat_info=true; } void Ftp::TurnOffStatForList() { DataClose(); expect->Close(); state=EOF_STATE; LogNote(2,"Setting ftp:use-stat-for-list to off"); ResMgr::Set("ftp:use-stat-for-list",hostname,"off"); use_stat_for_list=false; } void Ftp::CheckResp(int act) { // close aborted accepting data socket when the connection is established if(is1XX(act) && GetFlag(PASSIVE_MODE) && conn->aborted_data_sock!=-1) conn->CloseAbortedDataConnection(); if(is1XX(act) && expect->FirstIs(Expect::TRANSFER)) { // allow data transfer conn->received_150=true; if(state==WAITING_STATE) { // set the FXP flag copy_connection_open=true; conn->stat_timer.ResetDelayed(2); } if(mode==RETRIEVE && entity_size<0 && QueryBool("catch-size",hostname)) { // try to catch size const char *s=strrchr(line,'('); if(s && is_ascii_digit(s[1])) { long long size_ll; int n; if(1<=sscanf(s+1,"%lld%n",&size_ll,&n) && !strncmp(s+1+n," bytes",6)) { entity_size=size_ll; if(opt_size) *opt_size=entity_size; LogNote(7,_("saw file size in response")); } } } } if(is1XX(act)) // intermediate responses are ignored return; if(act==421) // server is going to disconnect, don't try sending QUIT. conn->quit_sent=true; Expect *exp=expect->Pop(); if(!exp) { if(act!=421) LogError(3,_("extra server response")); if(is2XX(act)) // some buggy servers send several 226 replies return; Disconnect(line); return; } Expect::expect_t cc=exp->check_case; const char *arg=exp->arg; // some servers mess all up if(act==331 && cc==Expect::READY && !GetFlag(SYNC_MODE) && expect->Count()>1) { delete expect->Pop(); LogNote(2,_("Turning on sync-mode")); ResMgr::Set("ftp:sync-mode",hostname,"on"); Disconnect(); DontSleep(); // retry immediately goto leave; } switch(cc) { case Expect::NONE: if(is2XX(act)) // default rule. break; Disconnect(line); break; case Expect::QUOTED: if(mode==LONG_LIST && !is2XX(act) && use_stat_for_list) TurnOffStatForList(); break; case Expect::IGNORE: ignore: break; case Expect::READY: case Expect::OPEN_PROXY: if(!GetFlag(SYNC_MODE) && re_match(all_lines,Query("auto-sync-mode",hostname))) { LogNote(2,_("Turning on sync-mode")); ResMgr::Set("ftp:sync-mode",hostname,"on"); assert(GetFlag(SYNC_MODE)); Disconnect(); DontSleep(); // retry immediately } if(!is2XX(act)) { Disconnect(line); if(cc==Expect::OPEN_PROXY && act==403) { SetError(LOGIN_FAILED,all_lines); break; } NextPeer(); if(peer_curr==0) reconnect_timer.Reset(); // count the reconnect-interval from this moment last_connection_failed=true; } break; case Expect::REST: RestCheck(act); break; case Expect::CWD: case Expect::CWD_CURR: if(is2XX(act)) { if(cc==Expect::CWD) cwd.Set(file,false,file_url,device_prefix_len(file)); set_real_cwd(arg); cache->SetDirectory(this, arg, true); break; } if(is5XX(act)) { if(!strcmp(arg,"~")) { // reconnect will change CWD to home directory Disconnect(); DontSleep(); break; } SetError(NO_FILE,all_lines); cache->SetDirectory(this, arg, false); break; } Disconnect(line); break; case Expect::CWD_STALE: if(is2XX(act)) set_real_cwd(arg); goto ignore; case Expect::ABOR: conn->CloseAbortedDataConnection(); goto ignore; case Expect::SIZE: CatchSIZE(act); break; case Expect::SIZE_OPT: CatchSIZE_opt(act); break; case Expect::MDTM: CatchDATE(act); break; case Expect::MDTM_OPT: CatchDATE_opt(act); break; case Expect::FILE_ACCESS: file_access: if(mode==CHANGE_MODE && site_cmd_unsupported(act)) { conn->site_chmod_supported=false; SetError(NO_FILE,all_lines); break; } NoFileCheck(act); break; case Expect::PRET: if(cmd_unsupported(act)) { conn->pret_supported=false; break; } if(is5XX(act)) SetError(NO_FILE,all_lines); break; case Expect::ALLO: if(cmd_unsupported(act) || act==202) ResMgr::Set("ftp:use-allo",hostname,"no"); else if(is5XX(act)) SetError(NO_FILE,all_lines); break; case Expect::PASV: case Expect::EPSV: if(is2XX(act)) { if(line.length()<=4) goto passive_off; memset(&conn->data_sa,0,sizeof(conn->data_sa)); if(cc==Expect::PASV) pasv_state=Handle_PASV(); else // cc==Expect::EPSV pasv_state=Handle_EPSV(); if(pasv_state==PASV_NO_ADDRESS_YET) goto passive_off; if(conn->aborted_data_sock!=-1) SocketConnect(conn->aborted_data_sock,&conn->data_sa); break; } if(cmd_unsupported(act) && cc==Expect::EPSV && conn->can_do_pasv && QueryBool("prefer-epsv",hostname)) { ResMgr::Set("ftp:prefer-epsv",hostname,"no"); Disconnect("EPSV failed, will try PASV"); break; } if(copy_mode!=COPY_NONE) { copy_passive=!copy_passive; copy_failed=true; break; } if(is5XX(act)) { passive_off: if(QueryBool("auto-passive-mode",hostname)) { LogNote(2,_("Switching passive mode off")); SetFlag(PASSIVE_MODE,0); } } Disconnect(line); break; case Expect::PORT: if(is2XX(act)) break; if(copy_mode!=COPY_NONE) { copy_passive=!copy_passive; copy_failed=true; break; } if(is5XX(act)) { if(QueryBool("auto-passive-mode",hostname)) { LogNote(2,_("Switching passive mode on")); SetFlag(PASSIVE_MODE,1); } } Disconnect(line); break; case Expect::PWD: if(is2XX(act)) { if(!home_auto) { home_auto.set_allocated(ExtractPWD()); PropagateHomeAuto(); } if(!home) set_home(home_auto); cache->SetDirectory(this, home, true); break; } break; case Expect::RNFR: if(is3XX(act)) { conn->SendCmd2("RNTO",file1); expect->Push(Expect::FILE_ACCESS); break; } goto file_access; case Expect::USER_PROXY: proxy_NoPassReqCheck(act); break; case Expect::USER: NoPassReqCheck(act); break; case Expect::PASS_PROXY: case Expect::ACCT_PROXY: proxy_LoginCheck(act); break; case Expect::PASS: LoginCheck(act); break; case Expect::TRANSFER: TransferCheck(act); if(mode==STORE && is2XX(act) && entity_size==real_pos) SendUTimeRequest(); break; case Expect::TRANSFER_CLOSED: if(strstr(line,"ABOR") && expect->Count()>=2 && expect->FirstIs(Expect::ABOR)) { LogError(1,"server bug: 426 reply missed"); delete expect->Pop(); conn->CloseAbortedDataConnection(); } break; case Expect::FEAT: if(is2XX(act)) { CheckFEAT(all_lines.get_non_const()); if(conn->try_feat_after_login && conn->have_feat_info) TuneConnectionAfterFEAT(); } else if(is5XX(act) && !cmd_unsupported(act)) conn->try_feat_after_login=true; break; case Expect::SITE_UTIME: if(site_cmd_unsupported(act)) { conn->site_utime_supported=false; SendUTimeRequest(); // try another method. } break; case Expect::SITE_UTIME2: if(site_cmd_unsupported(act)) { conn->site_utime2_supported=false; SendUTimeRequest(); // try another method. } break; case Expect::TYPE: if(is2XX(act)) conn->type=arg[0]; break; case Expect::OPTS_UTF8: case Expect::LANG: if(is2XX(act) && conn->utf8_supported) { conn->utf8_activated=true; conn->SetControlConnectionTranslation("UTF-8"); } else if(is5XX(act) && !cmd_unsupported(act)) conn->tune_after_login=true; break; #if USE_SSL case Expect::AUTH_TLS: if(is2XX(act) || is3XX(act)) { conn->MakeSSLBuffers(hostname); } else { if(QueryBool("ssl-force",hostname)) SetError(LOGIN_FAILED,_("ftp:ssl-force is set and server does not support or allow SSL")); conn->prot='C'; conn->auth_supported=false; } break; case Expect::PROT: if(is2XX(act)) conn->prot=arg[0]; else if(!conn->prot) conn->prot=(ftps?'P':'C'); break; case Expect::SSCN: if(is2XX(act)) conn->sscn_on=(arg[0]=='Y'); else if(cmd_unsupported(act)) conn->sscn_supported=false; break; case Expect::CCC: if(is2XX(act)) { conn->control_send->PutEOF(); state=WAITING_CCC_SHUTDOWN; conn->waiting_ssl_timer.Reset(); } break; #endif // USE_SSL } /* end switch */ leave: delete exp; } const char *Ftp::CurrentStatus() { if(Error()) return StrError(error_code); if(expect && expect->Has(Expect::FEAT)) return _("FEAT negotiation..."); switch(state) { case(EOF_STATE): if(conn && conn->control_sock!=-1) { if(conn->send_cmd_buffer.Size()>0) return(_("Sending commands...")); if(!expect->IsEmpty()) return(_("Waiting for response...")); if(!retry_timer.Stopped()) return _("Delaying before retry"); return(_("Connection idle")); } return(_("Not connected")); case(INITIAL_STATE): if(hostname) { if(resolver) return(_("Resolving host address...")); if(!ReconnectAllowed()) return DelayingMessage(); } return(_("Not connected")); case(CONNECTING_STATE): case(HTTP_PROXY_CONNECTED): return(_("Connecting...")); case(CONNECTED_STATE): #if USE_SSL if(conn->auth_sent) return _("TLS negotiation..."); #endif return _("Connected"); case(USER_RESP_WAITING_STATE): return(_("Logging in...")); case(DATASOCKET_CONNECTING_STATE): if(pasv_state==PASV_NO_ADDRESS_YET) return(_("Waiting for response...")); return(_("Making data connection...")); case(CWD_CWD_WAITING_STATE): if(expect->FindLastCWD()) return(_("Changing remote directory...")); /*fallthrough*/ case(WAITING_STATE): if(copy_mode==COPY_SOURCE) return ""; if(copy_mode==COPY_DEST && expect->IsEmpty()) return _("Waiting for other copy peer..."); if(mode==STORE) return(_("Waiting for transfer to complete")); case(WAITING_150_STATE): return(_("Waiting for response...")); case(WAITING_CCC_SHUTDOWN): return(_("Waiting for TLS shutdown...")); case(ACCEPTING_STATE): return(_("Waiting for data connection...")); case(DATA_OPEN_STATE): #if USE_SSL if(conn->prot=='P') { if(mode==STORE) return(_("Sending data/TLS")); else return(_("Receiving data/TLS")); } #endif if(conn->data_sock!=-1) { if(mode==STORE) return(_("Sending data")); else return(_("Receiving data")); } return(_("Waiting for transfer to complete")); } abort(); } time_t Ftp::ConvertFtpDate(const char *s) { struct tm tm; memset(&tm,0,sizeof(tm)); int year,month,day,hour,minute,second; int skip=0; int n=sscanf(s,"%4d%n",&year,&skip); // try to workaround server's y2k bug // I hope in the next 300 years the y2k bug will be finally fixed :) if(n==1 && year>=1910 && year<=1930) { n=sscanf(s,"%5d%n",&year,&skip); year=year-19100+2000; } if(n!=1) return NO_DATE; n=sscanf(s+skip,"%2d%2d%2d%2d%2d",&month,&day,&hour,&minute,&second); if(n!=5) return NO_DATE; tm.tm_year=year-1900; tm.tm_mon=month-1; tm.tm_mday=day; tm.tm_hour=hour; tm.tm_min=minute; tm.tm_sec=second; return mktime_from_utc(&tm); } void Ftp::SetFlag(int flag,bool val) { flag&=MODES_MASK; // only certain flags can be changed if(val) flags|=flag; else flags&=~flag; } bool Ftp::SameSiteAs(const FileAccess *fa) const { if(!SameProtoAs(fa)) return false; Ftp *o=(Ftp*)fa; return(!xstrcasecmp(hostname,o->hostname) && !xstrcmp(portname,o->portname) && !xstrcmp(user,o->user) && !xstrcmp(pass,o->pass) && ftps==o->ftps); } bool Ftp::SameConnection(const Ftp *o) const { if(!strcasecmp(hostname,o->hostname) && !xstrcmp(portname,o->portname) && !xstrcmp(user,o->user) && !xstrcmp(pass,o->pass) && (user || !xstrcmp(anon_user,o->anon_user)) && (pass || !xstrcmp(anon_pass,o->anon_pass)) && ftps==o->ftps) return true; return false; } bool Ftp::SameLocationAs(const FileAccess *fa) const { if(!SameProtoAs(fa)) return false; Ftp *o=(Ftp*)fa; if(!hostname || !o->hostname) return false; if(SameConnection(o)) { if(home && o->home && strcmp(home,o->home)) return false; return !xstrcmp(cwd,o->cwd); } return false; } int Ftp::Done() { if(Error()) return(error_code); if(mode==CLOSED) return OK; if(mode==ARRAY_INFO) { if(state==WAITING_STATE && expect->IsEmpty() && !fileset_for_info->curr()) return(OK); return(IN_PROGRESS); } if(copy_mode==COPY_DEST && !copy_allow_store) return(IN_PROGRESS); if(mode==CHANGE_DIR || mode==RENAME || mode==MAKE_DIR || mode==REMOVE_DIR || mode==REMOVE || mode==CHANGE_MODE || mode==LINK || mode==SYMLINK || copy_mode!=COPY_NONE) { if(state==WAITING_STATE && expect->IsEmpty()) return(OK); return(IN_PROGRESS); } if(mode==CONNECT_VERIFY) { if(state!=INITIAL_STATE) return OK; return(peer?OK:IN_PROGRESS); } abort(); } void Ftp::ResetLocationData() { super::ResetLocationData(); flags=0; home_auto.set(FindHomeAuto()); Reconfig(); state=INITIAL_STATE; } bool Ftp::AnonymousQuietMode() { if(user && user.ne("anonymous") && user.ne("ftp")) return false; const char *pass_to_use=(pass?pass:anon_pass); return pass_to_use && *pass_to_use=='-'; // minus sign in password means quiet mode } void Ftp::Reconfig(const char *name) { closure.set(hostname); super::Reconfig(name); if(!xstrcmp(name,"net:idle") || !xstrcmp(name,"ftp:use-site-idle")) { if(conn && conn->data_sock==-1 && state==EOF_STATE && !conn->quit_sent) SendSiteIdle(); return; } SetFlag(SYNC_MODE, QueryBool("sync-mode")); if(!conn || !conn->proxy_is_http) SetFlag(PASSIVE_MODE,QueryBool("passive-mode")); rest_list = QueryBool("rest-list"); nop_interval = Query("nop-interval").to_number(1,30); allow_skey = QueryBool("skey-allow"); force_skey = QueryBool("skey-force"); allow_netkey = QueryBool("netkey-allow"); verify_data_address = QueryBool("verify-address"); verify_data_port = QueryBool("verify-port"); use_stat = QueryBool("use-stat"); use_stat_for_list=QueryBool("use-stat-for-list") && !AnonymousQuietMode(); use_mdtm = QueryBool("use-mdtm"); use_size = QueryBool("use-size"); use_pret = QueryBool("use-pret"); use_feat = QueryBool("use-feat"); use_mlsd = QueryBool("use-mlsd"); use_telnet_iac = QueryBool("use-telnet-iac"); max_buf = Query("xfer:buffer-size"); anon_user.set(Query("anon-user")); anon_pass.set(Query("anon-pass")); if(!name || !xstrcmp(name,"ftp:list-options")) { if(name && !IsSuspended()) cache->TreeChanged(this,"/"); list_options.set(Query("list-options")); } if(!name || !xstrcmp(name,"ftp:charset")) { if(name && !IsSuspended()) cache->TreeChanged(this,"/"); charset.set(Query("charset")); if(conn && conn->have_feat_info && !conn->utf8_activated && !(expect->Has(Expect::LANG) || expect->Has(Expect::OPTS_UTF8)) && charset && *charset) conn->SetControlConnectionTranslation(charset); } const char *h=QueryStringWithUserAtHost("home"); if(h && h[0] && AbsolutePath(h)) set_home(h); else set_home(home_auto); if(NoProxy(hostname)) SetProxy(0); else SetProxy(Query("proxy")); if(proxy && proxy_port==0) { if(ProxyIsHttp()) proxy_port.set(HTTP_DEFAULT_PROXY_PORT); else proxy_port.set(FTP_DEFAULT_PORT); } if(conn && conn->control_sock!=-1) SetSocketBuffer(conn->control_sock); if(conn && conn->data_sock!=-1) SetSocketBuffer(conn->data_sock); if(conn && conn->data_iobuf && rate_limit) rate_limit->SetBufferSize(conn->data_iobuf,max_buf); } void Ftp::Cleanup() { if(hostname==0) return; for(FA *fo=FirstSameSite(); fo!=0; fo=NextSameSite(fo)) fo->CleanupThis(); CleanupThis(); } void Ftp::CleanupThis() { if(!conn || mode!=CLOSED) return; Disconnect(); } void Ftp::SetError(int ec,const char *e) { // join multiline error message into single line, removing `550-' prefix. if(e && strchr(e,'\n')) { char *joined=string_alloca(strlen(e)+1); const char *prefix=e; char *store=joined; while(*e) { if(*e=='\n') { if(e[1]) *store++=' '; e++; if(!strncmp(e,prefix,3) && (e[3]=='-' || e[3]==' ')) e+=4; } else { *store++=*e++; } } *store=0; e=joined; } super::SetError(ec,e); switch((status)ec) { case(SEE_ERRNO): case(LOOKUP_ERROR): case(NO_HOST): case(FATAL): case(LOGIN_FAILED): Disconnect(); break; case(IN_PROGRESS): case(OK): case(NOT_OPEN): case(NO_FILE): case(FILE_MOVED): case(STORE_FAILED): case(DO_AGAIN): case(NOT_SUPP): break; } } Ftp::ConnectLevel Ftp::GetConnectLevel() const { if(!conn) return CL_NOT_CONNECTED; if(state==CONNECTING_STATE || state==HTTP_PROXY_CONNECTED) return CL_CONNECTING; if(state==CONNECTED_STATE) return CL_JUST_CONNECTED; if(state==USER_RESP_WAITING_STATE) return CL_NOT_LOGGED_IN; if(conn->quit_sent) return CL_JUST_BEFORE_DISCONNECT; return CL_LOGGED_IN; } ListInfo *Ftp::MakeListInfo(const char *path) { return new FtpListInfo(this,path); } Glob *Ftp::MakeGlob(const char *pattern) { return new GenericGlob(this,pattern); } DirList *Ftp::MakeDirList(ArgV *args) { return new FtpDirList(this,args); } extern "C" const char *calculate_skey_response (int, const char *, const char *); const char *Ftp::make_skey_reply() { static const char * const skey_head[] = { "S/Key MD5 ", "s/key ", "opiekey ", "otp-md5 ", 0 }; const char *cp; for(int i=0; ; i++) { if(skey_head[i]==0) return 0; cp=strstr(all_lines,skey_head[i]); if(cp) { cp+=strlen(skey_head[i]); break; } } LogNote(9,"found s/key substring"); int skey_sequence=0; char *buf=string_alloca(strlen(cp)); if(sscanf(cp,"%d %s",&skey_sequence,buf)!=2 || skey_sequence<1) return 0; return calculate_skey_response(skey_sequence,buf,pass); } extern "C" const char *calculate_netkey_response (const char *, const char *); const char *Ftp::make_netkey_reply() { static const char * const netkey_head[] = { "encrypt challenge, ", 0 }; const char *cp; for(int i=0; ; i++) { if(netkey_head[i]==0) return 0; cp=strstr(all_lines,netkey_head[i]); if(cp) { cp+=strlen(netkey_head[i]); break; } } if(cp) { xstring &buf=xstring::get_tmp(cp); buf.truncate_at(' '); buf.truncate_at(','); LogNote(9,"found netkey challenge %s",buf.get()); return calculate_netkey_response(pass,buf); } return 0; } int Ftp::Buffered() { if(!conn || !conn->data_iobuf) return 0; if(state!=DATA_OPEN_STATE || conn->data_sock==-1 || mode!=STORE) return 0; return conn->data_iobuf->Size()+SocketBuffered(conn->data_sock); } const char *Ftp::ProtocolSubstitution(const char *host) { if(NoProxy(host)) return 0; const char *proxy=ResMgr::Query("ftp:proxy",host); if(proxy && QueryBool("use-hftp",host) && (!strncmp(proxy,"http://",7) || !strncmp(proxy,"https://",8))) return "hftp"; return 0; } #if USE_SSL #undef super #define super Ftp FtpS::FtpS() { ftps=true; res_prefix="ftp"; } FtpS::~FtpS() { } FtpS::FtpS(const FtpS *o) : super(o) { ftps=true; res_prefix="ftp"; Reconfig(); } FileAccess *FtpS::New() { return new FtpS(); } void Ftp::Connection::MakeSSLBuffers(const char *hostname) { control_ssl=new lftp_ssl(control_sock,lftp_ssl::CLIENT,hostname); control_ssl->load_keys(); IOBufferSSL *send_ssl=new IOBufferSSL(control_ssl,IOBufferSSL::PUT); IOBufferSSL *recv_ssl=new IOBufferSSL(control_ssl,IOBufferSSL::GET); control_send=send_ssl; control_recv=recv_ssl; telnet_layer_send=0; } #endif void TelnetEncode::PutTranslated(Buffer *target,const char *put_buf,int size) { size_t put_size=size; const char *iac; while(put_size>0) { iac=(const char*)memchr(put_buf,TELNET_IAC,put_size); if(!iac) { target->Put(put_buf,put_size); break; } target->Put(put_buf,iac+1-put_buf); put_size-=iac+1-put_buf; put_buf=iac+1; // double the IAC to send it literally. target->Put(iac,1); } } void TelnetDecode::PutTranslated(Buffer *target,const char *put_buf,int size) { if(Size()>0) { Put(put_buf,size); Get(&put_buf,&size); } if(size<=0) return; size_t put_size=size; const char *iac; while(put_size>0) { iac=(const char*)memchr(put_buf,TELNET_IAC,put_size); if(!iac) break; target->Put(put_buf,iac-put_buf); Skip(iac-put_buf); put_size-=iac-put_buf; put_buf=iac; if(put_size<2) { if(Size()==0) Put(put_buf,put_size); // remember incomplete sequence return; } switch(iac[1]) { // 3-byte commands case TELNET_WILL: case TELNET_WONT: case TELNET_DO: case TELNET_DONT: if(put_size<3) { if(Size()==0) Put(put_buf,put_size); // remember incomplete sequence return; } Skip(3); put_buf+=3; put_size-=3; break; // 2-byte commands case TELNET_IAC: target->Put(iac,1); /*fallthrough*/ default: Skip(2); put_buf+=2; put_size-=2; } } if(put_size>0) { target->Put(put_buf,put_size); Skip(put_size); } } void Ftp::Connection::SetControlConnectionTranslation(const char *cs) { if(translation_activated) return; if(telnet_layer_send) { // cannot do two conversions in one DirectedBuffer, stack it. control_recv=new IOBufferStacked(control_recv.borrow()); } send_cmd_buffer.SetTranslation(cs,false); control_recv->SetTranslation(cs,true); translation_activated=true; } #include "modconfig.h" #ifdef MODULE_PROTO_FTP void module_init() { Ftp::ClassInit(); } #endif lftp-4.6.3a/src/xarray.cc0000644000015000007670000000464212311550526012165 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "xarray.h" void xarray0::get_space_do(size_t s,size_t g) { if(!buf) buf=xmalloc(element_size*(size=s+keep_extra)); else if(size=g*8 && s+keep_extra<=size/2) buf=xrealloc(buf,element_size*(size/=2)); } void xarray0::_nset(const void *s,int len) { if(!s) { xfree(buf); init(); return; } this->len=len; if(s==buf) return; if(s>buf && s<(char*)buf+size*element_size) { memmove(buf,s,len*element_size); return; } get_space(len); memcpy(buf,s,len*element_size); } void *xarray0::_insert(int before) { assert(before>=0 && before<=len); grow_space(len+1); if(before=0 && j<=len); if(j0) lo=m+1; else { *pos=m; return true; } } *pos=lo; return false; } void *xarray0::_insert_ordered(const void *n,qsort_cmp_t cmp) { int pos; (void)_bsearch(n,cmp,&pos); return _insert(pos); } lftp-4.6.3a/src/Timer.h0000644000015000007670000000463012274155266011610 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef TIMER_H #define TIMER_H #include "SMTask.h" #include "ResMgr.h" #include "xlist.h" #include "xheap.h" class Timer { Time start; Time stop; TimeInterval last_setting; double random_max; const char *resource; const char *closure; static int infty_count; static xlist_head all_timers; xlist all_timers_node; static xheap running_timers; xheap::node running_timers_node; void re_sort(); void re_set(); void add_random(); void set_last_setting(const TimeInterval &); void init(); void reconfig(const char *); public: Timer(); ~Timer(); Timer(int s,int ms=0); Timer(const TimeInterval &); Timer(const char *,const char *); bool Stopped() const; void Stop() { stop=SMTask::now; re_sort(); } void Set(const TimeInterval&); void Set(time_t s,int ms=0) { Set(TimeInterval(s,ms)); } void SetMilliSeconds(int ms) { Set(TimeInterval(0,ms)); } void SetMicroSeconds(int us) { Set(TimeInterval(0,0,us)); } void SetResource(const char *,const char *); void AddRandom(double r); void Reset(const Time &t); void Reset() { Reset(SMTask::now); } void Reset(const Timer &t) { Reset(t.GetStartTime()); } void ResetDelayed(int s); void StopDelayed(int s); const TimeInterval& GetLastSetting() const { return last_setting; } TimeDiff TimePassed() const { return SMTask::now-start; } TimeInterval TimeLeft() const; bool IsInfty() const { return last_setting.IsInfty(); } const Time &GetStartTime() const { return start; } static timeval GetTimeoutTV(); static void ReconfigAll(const char *); }; bool operator<(const Timer& a,const Timer& b); #endif lftp-4.6.3a/src/Timer.cc0000644000015000007670000000741512274155275011752 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "SMTask.h" #include "Timer.h" #include "xstring.h" #include "misc.h" #define now SMTask::now xlist_head Timer::all_timers; xheap Timer::running_timers; int Timer::infty_count; timeval Timer::GetTimeoutTV() { Timer *t; while((t=running_timers.get_min())!=0 && t->Stopped()) running_timers.pop_min(); if(!t) { timeval tv={infty_count?HOUR:-1, 0}; return tv; } TimeDiff remains(t->stop,now); return remains.toTimeval(); } TimeInterval Timer::TimeLeft() const { if(IsInfty()) return TimeInterval(); if(now>=stop) return TimeInterval(0,0); return TimeInterval(stop-now); } void Timer::set_last_setting(const TimeInterval &i) { infty_count-=IsInfty(); last_setting=i; infty_count+=IsInfty(); re_set(); } void Timer::add_random() { if(random_max>0.0001) { stop+=TimeDiff::valueOf(random_max*random01()); } } void Timer::re_set() { stop=start; stop+=last_setting; add_random(); re_sort(); } void Timer::AddRandom(double r) { random_max=r; add_random(); re_sort(); } void Timer::Set(const TimeInterval &i) { resource=closure=0; start=SMTask::now; set_last_setting(i); } void Timer::Reset(const Time &t) { if(start>=t && stop>t) return; start=t; re_set(); } void Timer::ResetDelayed(int s) { Reset(SMTask::now+TimeDiff(s,0)); } void Timer::StopDelayed(int s) { stop=SMTask::now+TimeDiff(s,0); re_sort(); } void Timer::SetResource(const char *r,const char *c) { if(resource!=r || closure!=c) { resource=r; closure=c; start=now; reconfig(r); } else { Reset(); } } bool Timer::Stopped() const { if(IsInfty()) return false; return now>=stop; } void Timer::reconfig(const char *r) { if(resource && (!r || !strcmp(r,resource))) set_last_setting(TimeIntervalR(ResMgr::Query(resource,closure))); } void Timer::init() { resource=0; closure=0; random_max=0; all_timers.add(all_timers_node); } Timer::~Timer() { running_timers.remove(running_timers_node); all_timers_node.remove(); infty_count-=IsInfty(); } Timer::Timer() : last_setting(1,0), all_timers_node(this), running_timers_node(this) { init(); } Timer::Timer(const TimeInterval &d) : last_setting(d), all_timers_node(this), running_timers_node(this) { init(); infty_count+=IsInfty(); re_set(); } Timer::Timer(const char *r,const char *c) : last_setting(0,0), all_timers_node(this), running_timers_node(this) { init(); resource=r; closure=c; start=now; reconfig(r); } Timer::Timer(int s,int ms) : all_timers_node(this), running_timers_node(this) { init(); Set(TimeInterval(s,ms)); } void Timer::re_sort() { running_timers.remove(running_timers_node); if(nowreconfig(r); } bool operator<(const Timer& a,const Timer& b) { return a.TimeLeft(). */ #ifndef JOB_H #define JOB_H #include #include "trio.h" #undef printf #include "SMTask.h" #include "StatusLine.h" #include "fg.h" #include "FileAccess.h" #define JobRef SMTaskRef // it is basically the same class Job : public SMTask { static void SortJobs(); xlist all_jobs_node; static xlist_head all_jobs; xlist_head children_jobs; xlist children_jobs_node; protected: bool fg; Ref fg_data; void PrepareToDie(); virtual ~Job(); public: int jobno; Job *parent; xarray waiting; void AddWaiting(Job *); template void AddWaiting(const JobRef& r) { AddWaiting(r.get_non_const()); } void RemoveWaiting(const Job *); void ReplaceWaiting(Job *from,Job *to); void SetParent(Job *j); void SetParentFg(Job *j, bool f=true) { SetParent(j); if(f && j->fg) Fg(); // else if(f && !j->fg) // Bg(); } void AllocJobno(); void PrintStatus(int,const char *prefix="\t"); virtual xstring& FormatStatus(xstring& s,int v,const char *prefix="\t") { return s; } virtual xstring& FormatShortStatus(xstring& s); virtual void ShowRunStatus(const SMTaskRef&); void ClearStatus() { eprintf("%s",""); /* just "" causes a -Wformat-zero-length" warning */ } virtual void SayFinal() {}; // final phrase of fg job virtual int Done()=0; virtual int ExitCode() { return 0; } virtual int Do()=0; virtual int AcceptSig(int); virtual void Bg(); virtual void Fg(); xstring cmdline; virtual const xstring& GetCmdLine() { return cmdline?cmdline:xstring::get_tmp("?",1); } xstring& FormatJobTitle(xstring& s,int indent=0,const char *suffix=0); xstring& FormatOneJob(xstring& s,int verbose,int indent=0,const char *suffix=0); xstring& FormatOneJobRecursively(xstring& s,int verbose,int indent=0); virtual xstring& FormatJobs(xstring& s,int verbose,int indent=0); void PrintJobTitle(int indent=0,const char *suffix=0); void ListOneJob(int verbose,int indent=0,const char *suffix=0); void ListOneJobRecursively(int verbose,int indent); void ListDoneJobs(); void BuryDoneJobs(); Job *FindAnyChild(); bool WaitsFor(Job *); static Job *FindWhoWaitsFor(Job *); bool CheckForWaitLoop(Job *parent); int NumAwaitedJobs() { return waiting.count(); } Job *FindDoneAwaitedJob(); void WaitForAllChildren(); void AllWaitingFg(); static int NumberOfJobs(); int NumberOfChildrenJobs(); static Job *FindJob(int n); static bool Running(int n) { Job *j=FindJob(n); return j && !j->Done(); } void Kill(int n); static void Kill(Job*); void SendSig(int n,int sig); static void KillAll(); static void Cleanup(); void vfprintf(FILE *file,const char *fmt,va_list v); // CmdExec redefines this, and traps all messages of its children. virtual void top_vfprintf(FILE *file,const char *fmt,va_list v); // C-like functions calling vfprintf void eprintf(const char *fmt,...) PRINTF_LIKE(2,3); void fprintf(FILE *file,const char *fmt,...) PRINTF_LIKE(3,4); void printf(const char *fmt,...) PRINTF_LIKE(2,3); void perror(const char *); void puts(const char *); Job(); virtual const char *GetConnectURL() { return 0; } virtual void lftpMovesToBackground() { Resume(); } static void lftpMovesToBackground_ToAll(); virtual off_t GetBytesCount(); virtual double GetTimeSpent(); virtual double GetTransferRate(); void WaitDone(); }; class SessionJob : public Job { protected: SessionJob(FileAccess *s) : session(s) {} FileAccess *Clone() const { return session->Clone(); } public: FileAccessRef session; xstring& FormatStatus(xstring&,int,const char *); const char *GetConnectURL() { if(!session) return 0; return session->GetConnectURL(); } void Fg(); void Bg(); }; #endif /* JOB_H */ lftp-4.6.3a/src/Error.h0000644000015000007670000000222612410755452011613 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef ERROR_H #define ERROR_H #include "xstring.h" class Error { xstring text; int code; bool fatal; public: Error(); Error(int,const char *,bool); ~Error(); void Set(int,const char *,bool); const char *Text() const { return text; } int Code() const { return code; } bool IsFatal() const { return fatal; } static Error *Fatal(const char *s,int c=-1); }; #endif//ERROR_H lftp-4.6.3a/src/LsCache.cc0000644000015000007670000001746312210060476012164 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "FileAccess.h" #include "LsCache.h" #include "plural.h" #include "misc.h" int LsCacheEntry::EstimateSize() const { int size=sizeof(*this); size+=LsCacheEntryLoc::EstimateSize(); size+=LsCacheEntryData::EstimateSize(); return size; } LsCacheEntryLoc::LsCacheEntryLoc(const FileAccess *p_loc,const char *a,int m) : arg(a), mode(m) { loc=p_loc->Clone(); loc->Suspend(); } const char *LsCacheEntryLoc::GetClosure() const { return loc->GetHostName(); } LsCacheEntryData::LsCacheEntryData(int e,const char *d,int l,const FileSet *fs) { SetData(e,d,l,fs); } LsCacheEntry::LsCacheEntry(const FileAccess *p_loc,const char *a,int m,int e,const char *d,int l,const FileSet *fs) : LsCacheEntryLoc(p_loc,a,m), LsCacheEntryData(e,d,l,fs) { SetResource(e==FA::OK?"cache:expire":"cache:expire-negative",GetClosure()); } void LsCacheEntryData::SetData(int e,const char *d,int l,const FileSet *fs) { afset=fs?new FileSet(fs):0; data.nset(d,l); err_code=e; } void LsCacheEntryData::GetData(int *e,const char **d,int *l,const FileSet **fs) { if(d && l) { *d=data; *l=data.length(); } if(fs) *fs=afset; *e=err_code; } bool LsCacheEntryLoc::Matches(const FileAccess *p_loc,const char *a,int m) { return (m==-1 || mode==m) && arg.eq(a) && p_loc->SameLocationAs(loc); } ResDecl res_cache_empty_listings("cache:cache-empty-listings","no",ResMgr::BoolValidate,0); ResDecl res_cache_enable("cache:enable","yes",ResMgr::BoolValidate,0); ResDecl res_cache_expire("cache:expire","60m",ResMgr::TimeIntervalValidate,0); ResDecl res_cache_expire_neg("cache:expire-negative","1m",ResMgr::TimeIntervalValidate,0); ResDecl res_cache_size ("cache:size","16M",ResMgr::UNumberValidate,ResMgr::NoClosure); LsCache::LsCache() : Cache(&res_cache_size,&res_cache_enable) {} void LsCache::Add(const FileAccess *p_loc,const char *a,int m,int e,const char *d,int l,const FileSet *fs) { if(!strcmp(p_loc->GetProto(),"file")) return; // don't cache local objects if(l == 0 && !res_cache_empty_listings.QueryBool(p_loc->GetHostName())) return; if(e!=FA::OK && e!=FA::NO_FILE && e!=FA::NOT_SUPP) return; Trim(); LsCacheEntry *c=Find(p_loc,a,m); if(!c) { if(!IsEnabled(p_loc->GetHostName())) return; AddCacheEntry(new LsCacheEntry(p_loc,a,m,e,d,l,fs)); } else { c->SetData(e,d,l,fs); } } void LsCache::Add(const FileAccess *p_loc,const char *a,int m,int e,const Buffer *ubuf,const FileSet *fs) { if(!ubuf->IsSaving()) return; const char *cache_buffer; int cache_buffer_size; if(e) { cache_buffer=ubuf->ErrorText(); cache_buffer_size=strlen(cache_buffer)+1; } else ubuf->GetSaved(&cache_buffer,&cache_buffer_size); LsCache::Add(p_loc,a,m,e,cache_buffer,cache_buffer_size,fs); } LsCacheEntry *LsCache::Find(const FileAccess *p_loc,const char *a,int m) { if(!IsEnabled(p_loc->GetHostName())) return 0; LsCacheEntry *c; for(c=IterateFirst(); c; c=IterateNext()) { if(c->Matches(p_loc,a,m)) break; } if(c && c->Stopped()) { Trim(); return 0; } return c; } bool LsCache::Find(const FileAccess *p_loc,const char *a,int m,int *e,const char **d,int *l,const FileSet **fs) { LsCacheEntry *c=Find(p_loc,a,m); if(!c) return false; c->GetData(e,d,l,fs); return true; } const FileSet *LsCache::FindFileSet(const FileAccess *p_loc,const char *a,int m) { LsCacheEntry *c=Find(p_loc,a,m); if(!c) return 0; return c->GetFileSet(c->loc); } const FileSet *LsCacheEntryData::GetFileSet(const FileAccess *parser) { if(afset) return afset; if(err_code!=FA::OK) return 0; afset=parser->ParseLongList(data, data.length()); return afset; } void LsCache::UpdateFileSet(const FileAccess *p_loc,const char *a,int m,const FileSet *fs) { if(!fs) return; LsCacheEntry *c=Find(p_loc,a,m); if(!c) return; c->UpdateFileSet(fs); } void LsCache::List() { Trim(); long vol=0; for(LsCacheEntry *c=IterateFirst(); c; c=IterateNext()) vol+=c->EstimateSize(); printf(plural("%ld $#l#byte|bytes$ cached",vol),vol); long sizelimit=res_cache_size.Query(0); if(sizelimit<0) puts(_(", no size limit")); else printf(_(", maximum size %ld\n"),sizelimit); } void LsCache::Changed(change_mode m,const FileAccess *f,const char *dir) { xstring fdir(dir_file(f->GetCwd(),dir)); if(m==FILE_CHANGED) dirname_modify(fdir); LsCacheEntry *c=IterateFirst(); while(c) { const FileAccess *sloc=c->loc; if(f->SameLocationAs(sloc) || (f->SameSiteAs(sloc) && (m==TREE_CHANGED? !strncmp(fdir,dir_file(sloc->GetCwd(),c->arg),fdir.length()) : !strcmp (fdir,dir_file(sloc->GetCwd(),c->arg))))) c=IterateDelete(); else c=IterateNext(); } } /* Mark a path as a directory or file. (We have other ways of knowing this; * this is the most explicit and least expensive.) */ void LsCache::SetDirectory(const FileAccess *p_loc, const char *path, bool dir) { if(!path) return; FileAccess::Path new_cwd = p_loc->GetCwd(); new_cwd.Change(path,!dir); SMTaskRef new_p_loc(p_loc->Clone()); new_p_loc->SetCwd(new_cwd); const char *entry = dir? "1":"0"; LsCache::Add(new_p_loc,"",FileAccess::CHANGE_DIR, dir?FA::OK:FA::NO_FILE, entry, strlen(entry)); } /* This is a hint function. If file type is really needed, use GetFileInfo * with showdir set to true. (GetFileInfo uses this function.) * Returns -1 if type is not known, 1 if a directory, 0 if a file. */ int LsCache::IsDirectory(const FileAccess *p_loc,const char *dir_c) { FileAccess::Path new_cwd(p_loc->GetCwd()); new_cwd.Change(dir_c); FileAccessRef new_p_loc(p_loc->Clone()); new_p_loc->SetCwd(new_cwd); int ret = -1; /* Cheap tests first: * * First, we know the path is a directory or not if we have an expicit * CHANGE_DIR entry for it. */ const char *buf_c; int bufsiz; int e; if(Find(new_p_loc, "", FileAccess::CHANGE_DIR, &e, &buf_c,&bufsiz)) { assert(bufsiz==1); return (e==FA::OK); } /* We know the path is a directory if we have a cache entry for it. This is * true regardless of the list type. (Unless it's a CHANGE_DIR entry; do this * test after the CHANGE_DIR check.) */ if(Find(new_p_loc, "", FA::LONG_LIST, &e, 0,0)) return(e==FA::OK); if(Find(new_p_loc, "", FA::MP_LIST, &e, 0,0)) return(e==FA::OK); if(Find(new_p_loc, "", FA::LIST, &e, 0,0)) return(e==FA::OK); /* We know this is a file or a directory if the dirname is cached and * contains the basename. */ { const char *bn=basename_ptr(new_cwd.path); bn=alloca_strdup(bn); // save basename new_cwd.Change(".."); new_p_loc->SetCwd(new_cwd); const FileSet *fs=FindFileSet(new_p_loc, "", FA::MP_LIST); if(!fs) fs=FindFileSet(new_p_loc, "", FA::LONG_LIST); if(fs) { FileInfo *fi=fs->FindByName(bn); if(fi && (fi->defined&fi->TYPE)) return(fi->filetype == fi->DIRECTORY); } } return ret; } lftp-4.6.3a/src/FileGlob.cc0000644000015000007670000001463212311765732012351 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "trio.h" #include "xstring.h" #include #include #include #include #include #include "FileGlob.h" #include "misc.h" #include "url.h" // Glob implementation Glob::Glob(FileAccess *s,const char *p) : FileAccessOperation(s), pattern(p) { dirs_only=false; files_only=false; match_period=true; inhibit_tilde=true; casefold=false; if(pattern[0]=='~') { const char *slash=strchr(pattern,'/'); if(slash) inhibit_tilde=HasWildcards(xstring::get_tmp(pattern,slash-pattern)); else inhibit_tilde=HasWildcards(pattern); } if(pattern[0] && !HasWildcards(pattern)) { // no need to glob, just unquote char *u=alloca_strdup(pattern); UnquoteWildcards(u); add(new FileInfo(u)); done=true; } } Glob::~Glob() { } void Glob::add_force(const FileInfo *info) { // insert new file name into list list.Add(new FileInfo(*info)); } void Glob::add(const FileInfo *info) { if(info->defined&info->TYPE) { if(dirs_only && info->filetype==info->NORMAL) return; // note that symlinks can point to directories, // so skip normal files only. if(files_only && info->filetype==info->DIRECTORY) return; } const char *s=info->name; if(s==0) return; int flags=FNM_PATHNAME; if(match_period) flags|=FNM_PERIOD; if(casefold) flags|=FNM_CASEFOLD; if(pattern[0]!=0 && fnmatch(pattern, s, flags)!=0) return; // unmatched if(s[0]=='~' && inhibit_tilde) { char *new_name=alloca_strdup2(s,2); strcpy(new_name,"./"); strcat(new_name,s); FileInfo new_info(*info); new_info.SetName(new_name); add_force(&new_info); } else { add_force(info); } } bool Glob::HasWildcards(const char *s) { while(*s) { switch(*s) { case '\\': if(s[1]) s++; break; case '*': case '[': case ']': case '?': return true; } s++; } return false; } void Glob::UnquoteWildcards(char *s) { char *store=s; for(;;) { if(*s=='\\') { if(s[1]=='*' || s[1]=='[' || s[1]==']' || s[1]=='?' || s[1]=='\\') s++; } *store=*s; if(*s==0) break; s++; store++; } } int NoGlob::Do() { if(!done) { if(!HasWildcards(pattern)) { char *p=alloca_strdup(pattern); UnquoteWildcards(p); add(new FileInfo(p)); } done=true; return MOVED; } return STALL; } NoGlob::NoGlob(const char *p) : Glob(0,p) { } void GlobURL::NewGlob(const char *p) { glob=0; session=orig_session; url_prefix.set(p); url_prefix.truncate(url::path_index(p)); ParsedURL p_url(p,true); if(p_url.proto && p_url.path) { session=my_session=FA::New(&p_url); if(session) glob=session->MakeGlob(p_url.path); } else { glob=session->MakeGlob(p); } if(!glob) glob=new NoGlob(p); if(type==FILES_ONLY) glob->FilesOnly(); else if(type==DIRS_ONLY) glob->DirectoriesOnly(); } GlobURL::GlobURL(const FileAccessRef& s,const char *p,type_select t) : orig_session(s), session(orig_session), type(t) { NewGlob(p); } GlobURL::~GlobURL() {} FileSet *GlobURL::GetResult() { FileSet &list=*glob->GetResult(); if(session==orig_session) return &list; for(int i=0; list[i]; i++) list[i]->SetName(url_file(url_prefix,list[i]->name)); return &list; } // GenericGlob implementation GenericGlob::GenericGlob(FileAccess *s,const char *n_pattern) : Glob(s,n_pattern) { dir_list=0; curr_dir=0; if(done) return; char *dir=alloca_strdup(pattern); char *slash=strrchr(dir,'/'); if(!slash) dir=0; else if(slash>dir) *slash=0; // non-root directory else dir[1]=0; // root directory if(dir) { updir_glob=new GenericGlob(s,dir); updir_glob->DirectoriesOnly(); } } int GenericGlob::Do() { int m=STALL; if(done) return m; if(!dir_list && updir_glob) { if(updir_glob->Error()) { SetError(updir_glob->ErrorText()); updir_glob=0; done=true; return MOVED; } if(!updir_glob->Done()) return m; dir_list=updir_glob->GetResult(); dir_list->rewind(); m=MOVED; if(dir_list==0 || dir_list->curr()==0) { done=true; return m; } curr_dir=dir_list->curr()->name; } if(li) { if(!li->Done() && !li->Error()) return m; if(li->Done() && !li->Error()) { FileSet *set=li->GetResult(); set->rewind(); for(FileInfo *info=set->curr(); info!=NULL; info=set->next()) { const char *name=info->name; if(name[0]=='.' && name[1]=='/') name+=2; if(curr_dir && curr_dir[0]) name=dir_file(curr_dir,name); info->SetName(name); add(info); } delete set; } if(dir_list) dir_list->next(); if(!dir_list || dir_list->curr()==0) { if(li && li->Error()) SetError(li->ErrorText()); li=0; done=true; return MOVED; } li=0; curr_dir=dir_list->curr()->name; } li=session->MakeListInfo(curr_dir); if(!li) { // Cannot glob. Just unquote wildcards. char *p=alloca_strdup(pattern); UnquoteWildcards(p); add(new FileInfo(p)); done=true; return MOVED; } li->UseCache(use_cache); return MOVED; } const char *GenericGlob::Status() { if(updir_glob && !dir_list) return updir_glob->Status(); if(!li) return ""; const char *st = li->Status(); if(!*st) return ""; if(!curr_dir) return st; static xstring buf; buf.vset(curr_dir,": ",st,NULL); return buf; } lftp-4.6.3a/src/CopyJob.h0000644000015000007670000001065412313770700012066 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef COPYJOB_H #define COPYJOB_H #include "Job.h" #include "StatusLine.h" #include "FileCopy.h" class CopyJob : public Job { protected: SMTaskRef c; bool done; xstring_c name; // file name xstring_c dispname; // displayed file name xstring_c op; // command name bool no_status; bool no_status_on_write; bool clear_status_on_write; void SetDispName(); void PrepareToDie(); public: CopyJob(FileCopy *c1,const char *n,const char *op1); ~CopyJob(); void NoStatus(bool t=true) { no_status=t; } void NoStatusOnWrite() { no_status_on_write=true; } void ClearStatusOnWrite() { clear_status_on_write=true; } bool HasStatus() const { return !no_status; } int Do(); int Done() { return done; } int ExitCode(); void SuspendInternal() { c->SuspendSlave(); } void ResumeInternal() { c->ResumeSlave(); } void Fg() { if(c) c->Fg(); Job::Fg(); } void Bg() { Job::Bg(); if(c) c->Bg(); } int AcceptSig(int sig); pid_t GetProcGroup() { return c?c->GetProcGroup():0; } bool Error() { return c->Error(); } const char *ErrorText() { return c->ErrorText(); } double GetTimeSpent() { return c->GetTimeSpent(); } off_t GetBytesCount() { return c->GetBytesCount(); } double GetTransferRate() { return c->GetTransferRate(); } off_t GetSize() { return c->GetSize(); } off_t GetPos() { return c->GetPos(); } float GetRate() { return c->GetRate(); } long GetETA() { return c->GetETA(); } long GetETA(off_t rem) { return c->GetETA(rem); } const char *GetETAStrSFromTime(time_t t) { return c->GetETAStrSFromTime(t); } void SetRange(off_t s,off_t lim) { c->SetRange(s,lim); } void SetRangeLimit(off_t lim) { return c->SetRangeLimit(lim); } void SetDate(const FileTimestamp& d) { c->SetDate(d); } void SetSize(off_t s) { c->SetSize(s); } const SMTaskRef& GetCopy() { return c; } const SMTaskRef& GetPut() { return c->put; } const SMTaskRef& GetGet() { return c->get; } const char *Status(const StatusLine *s,bool base=false); void ShowRunStatus(const SMTaskRef&); xstring& FormatStatus(xstring&,int,const char *); const char *GetName() const { return name; } const char *GetDispName() const { return dispname; } const char *SqueezeName(int w, bool base=false); static CopyJob *NewGet(FileAccess *f,const char *src,const char *dst); static CopyJob *NewPut(FileAccess *f,const char *src,const char *dst); static const char *FormatBytesTimeRate(off_t bytes,double time); }; class CopyJobCreator { public: virtual CopyJob *New(FileCopy *c,const char *n,const char *o) const = 0; virtual ~CopyJobCreator() {} }; class ArgV; class CopyJobEnv : public SessionJob { protected: CopyJob *cp; bool done; int errors; int count; off_t bytes; TimeDate transfer_start_ts; double time_spent; const char *op; bool no_status; xstring_c cwd; bool cont; bool ascii; Ref args; virtual void NextFile() = 0; void SetCopier(FileCopy *c,const char *n); void AddCopier(FileCopy *c,const char *n); Ref cj_new; public: int Do(); int Done(); virtual int ExitCode() { return errors!=0; } int AcceptSig(int sig); CopyJobEnv(FileAccess *s,ArgV *a,bool c=false); ~CopyJobEnv(); void SetCopyJobCreator(CopyJobCreator *c) { cj_new=c; } void SayFinal(); xstring& FormatFinalWithPrefix(xstring&,const char *); xstring& FormatStatus(xstring&,int,const char *); void Ascii() { ascii=true; } double GetTimeSpent() { return time_spent+(waiting.count()>0?now-transfer_start_ts:0.); } off_t GetBytesCount() { return bytes+Job::GetBytesCount(); } }; #endif // COPYJOB_H lftp-4.6.3a/src/bookmark.h0000644000015000007670000000306412461654262012333 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef BOOKMARK_H #define BOOKMARK_H #include #include "keyvalue.h" class Bookmark : public KeyValueDB { xstring bm_file; int bm_fd; time_t stamp; void Save(); void Load(); void Refresh(); int Lock(int type) { return KeyValueDB::Lock(bm_fd,type); } void PreModify(); void PostModify(); void Close(); void AutoSync(); public: void Add(const char *id,const char *value); void Remove(const char *id); const char *Lookup(const char *id); char *Format(); char *FormatHidePasswords(); void UserLoad() { Load(); Close(); } void UserSave(); Bookmark(); ~Bookmark(); void Rewind() { Refresh(); KeyValueDB::Rewind(); } const xstring& GetFilePath() const { return bm_file; } }; extern Bookmark lftp_bookmarks; #endif //BOOKMARK_H lftp-4.6.3a/src/CharReader.h0000644000015000007670000000217212122057173012515 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef CHARREADER_H #define CHARREADER_H #include "SMTask.h" // CharReader fetches a single character from given file descriptor. class CharReader : public SMTask { int fd; int ch; int Do(); public: enum { NOCHAR=-2, EOFCHAR=-1 }; int GetChar() { return ch; }; CharReader(int new_fd) { fd=new_fd; ch=NOCHAR; } }; #endif//CHARREADER_H lftp-4.6.3a/src/FileCopyFtp.cc0000644000015000007670000001560112375656531013055 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "FileCopyFtp.h" #include "log.h" #define super FileCopy #if !USE_SSL #define protect false #define passive_ssl_connect true #endif #define ftp_src get->GetSession().Cast() #define ftp_dst put->GetSession().Cast() void FileCopyFtp::Close() { ftp_src->Close(); ftp_dst->Close(); } int FileCopyFtp::Do() { int src_res,dst_res; int m=super::Do(); if(disable_fxp || Error() || !put || !get) return m; if(state==PUT_WAIT && put->GetSeekPos()!=FILE_END) { if(get->GetSize()>=0 && put->GetSeekPos()>=get->GetSize()) return m; if(ftp_dst->IsClosed()) { put->OpenSession(); ftp_dst->SetCopyMode(Ftp::COPY_DEST,!passive_source,protect, passive_source^passive_ssl_connect,dst_retries,dst_try_time); m=MOVED; } } if(state!=DO_COPY || put->GetSeekPos()==FILE_END || get->Eof()) return m; // FileCopy can suspend peers. get->Resume(); put->Resume(); if(ftp_src->IsClosed()) { get->OpenSession(); ftp_src->SetCopyMode(Ftp::COPY_SOURCE,passive_source,protect, !(passive_source^passive_ssl_connect),src_retries,src_try_time); m=MOVED; } if(ftp_dst->IsClosed()) { put->OpenSession(); ftp_dst->SetCopyMode(Ftp::COPY_DEST,!passive_source,protect, passive_source^passive_ssl_connect,dst_retries,dst_try_time); m=MOVED; } // check for errors if(ftp_src->CopyFailed() || ftp_dst->CopyFailed()) { if(ftp_src->RestartFailed() || ftp_dst->RestartFailed()) { get->CannotSeek(put->GetSize()); put->CannotSeek(put->GetSize()); } else if(passive_source==orig_passive_source) { passive_source=!passive_source; Log::global->Write(0,_("**** FXP: trying to reverse ftp:fxp-passive-source\n")); } #if USE_SSL else if(passive_ssl_connect==orig_passive_ssl_connect) { passive_ssl_connect=!passive_ssl_connect; passive_source=orig_passive_source; Log::global->Write(0,_("**** FXP: trying to reverse ftp:fxp-passive-sscn\n")); } else if(protect && !ResMgr::QueryBool("ftp:ssl-force",ftp_src->GetHostName()) && !ResMgr::QueryBool("ftp:ssl-force",ftp_dst->GetHostName())) { passive_source=orig_passive_source; protect=false; Log::global->Write(0,_("**** FXP: trying to reverse ftp:ssl-protect-fxp\n")); } #endif // USE_SSL else { // both ways failed. Fall back to normal copying. Log::global->Write(0,_("**** FXP: giving up, reverting to plain copy\n")); Close(); disable_fxp=true; get->SetFXP(false); put->SetFXP(false); if(ResMgr::QueryBool("ftp:fxp-force",ftp_src->GetHostName()) || ResMgr::QueryBool("ftp:fxp-force",ftp_dst->GetHostName())) { SetError(_("ftp:fxp-force is set but FXP is not available")); return MOVED; } off_t pos=put->GetRealPos(); if(!get->CanSeek(pos) || !put->CanSeek(pos)) pos=0; get->Seek(pos); put->Seek(pos); RateReset(); return MOVED; } RateReset(); src_retries=ftp_src->GetRetries(); dst_retries=ftp_dst->GetRetries(); src_try_time=ftp_src->GetTryTime(); dst_try_time=ftp_dst->GetTryTime(); Close(); if(put->CanSeek()) { put->Seek(FILE_END); get->Suspend(); put->Resume(); state=PUT_WAIT; } else put->Seek(0); return MOVED; } src_res=ftp_src->Done(); dst_res=ftp_dst->Done(); if(src_res==FA::OK && dst_res==FA::OK) { Close(); const long long size=GetSize(); if(size>=0) { get->SetPos(size); put->SetPos(size); } get->PutEOF(); return MOVED; } if(src_res!=FA::IN_PROGRESS && src_res!=FA::OK) { SetError(ftp_src->StrError(src_res)); return MOVED; } if(dst_res!=FA::IN_PROGRESS && dst_res!=FA::OK) { SetError(ftp_dst->StrError(dst_res)); return MOVED; } // exchange copy address if(ftp_dst->SetCopyAddress(ftp_src) || ftp_src->SetCopyAddress(ftp_dst)) m=MOVED; if(!ftp_dst->CopyStoreAllowed() && ftp_src->CopyIsReadyForStore() && ftp_dst->CopyIsReadyForStore()) { ftp_dst->CopyAllowStore(); m=MOVED; RateReset(); } // check for timeout when one session is done, and the other is stuck if(dst_res==FA::OK && src_res==FA::IN_PROGRESS) ftp_src->CopyCheckTimeout(ftp_dst); if(src_res==FA::OK && dst_res==FA::IN_PROGRESS) ftp_dst->CopyCheckTimeout(ftp_src); off_t add=ftp_dst->GetPos()-put->GetRealPos(); if(add>0) { RateAdd(add); bytes_count+=add; } off_t pos=ftp_dst->GetPos(); get->SetPos(pos); put->SetPos(pos); return m; } void FileCopyFtp::Init() { no_rest=false; orig_passive_source=passive_source=false; src_retries=dst_retries=0; src_try_time=dst_try_time=0; disable_fxp=false; #if USE_SSL protect=false; orig_passive_ssl_connect=passive_ssl_connect=true; #endif } // s,d must be FileCopyPeerFA, s->GetSession(),d->GetSession() must be Ftp. FileCopyFtp::FileCopyFtp(FileCopyPeer *s,FileCopyPeer *d,bool c,bool rp) : super(s,d,c) { Init(); passive_source=rp; get->SetFXP(true); put->SetFXP(true); if(ftp_src->IsPassive() && !ftp_dst->IsPassive()) passive_source=true; else if(!ftp_src->IsPassive() && ftp_dst->IsPassive()) passive_source=false; orig_passive_source=passive_source; #if USE_SSL if(ResMgr::QueryBool("ftp:ssl-protect-fxp",ftp_src->GetHostName()) || ResMgr::QueryBool("ftp:ssl-protect-fxp",ftp_dst->GetHostName())) protect=true; passive_ssl_connect=ResMgr::QueryBool("ftp:fxp-passive-sscn",0); orig_passive_ssl_connect=passive_ssl_connect; #endif } FileCopy *FileCopyFtp::New(FileCopyPeer *s,FileCopyPeer *d,bool c) { const FileAccessRef& s_s=s->GetSession(); const FileAccessRef& d_s=d->GetSession(); if(!s_s || !d_s) return 0; if((strcmp(s_s->GetProto(),"ftp") && strcmp(s_s->GetProto(),"ftps")) || (strcmp(d_s->GetProto(),"ftp") && strcmp(d_s->GetProto(),"ftps"))) return 0; if(!ResMgr::QueryBool("ftp:use-fxp",s_s->GetHostName()) || !ResMgr::QueryBool("ftp:use-fxp",d_s->GetHostName())) return 0; return new FileCopyFtp(s,d,c,ResMgr::QueryBool("ftp:fxp-passive-source",0)); } lftp-4.6.3a/src/module.cc0000644000015000007670000001253512536251533012151 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "trio.h" #include #ifdef HAVE_DLFCN_H # include #endif #include #include #include "module.h" #include "ResMgr.h" #include "configmake.h" #include "xstring.h" #ifndef RTLD_GLOBAL # define RTLD_GLOBAL 0 #endif #ifdef RTLD_NOW # define DLOPEN_FLAGS RTLD_NOW|RTLD_GLOBAL #else /* SunOS4 manual says it is reserved and must be 1 */ # define DLOPEN_FLAGS 1 #endif #ifdef RTLD_LAZY # define DLOPEN_FLAGS_LAZY RTLD_LAZY|RTLD_GLOBAL #else # define DLOPEN_FLAGS_LAZY DLOPEN_FLAGS #endif typedef void (*init_t)(int,const char*const*); /* TODO: this can go to a config file. */ static const char * const module_aliases[]= { "proto-hftp", "proto-http", #if USE_SSL "proto-https", "proto-http", "proto-ftps", "proto-ftp", #endif "cmd-at", "cmd-sleep", "cmd-repeat", "cmd-sleep", NULL }; class lftp_module_info { lftp_module_info *next; static lftp_module_info *base; char *path; void *addr; public: lftp_module_info(const char *p,void *a) { path=xstrdup(p); addr=a; next=base; base=this; } ~lftp_module_info() { xfree(path); for(lftp_module_info **scan=&base; *scan; scan=&scan[0]->next) { if(*scan==this) { *scan=scan[0]->next; break; } } } static lftp_module_info *find_module(const char *name) { int name_len=strlen(name); for(lftp_module_info *scan=base; scan; scan=scan->next) { char *slash=strrchr(scan->path,'/'); char *scan_name=(slash?slash+1:scan->path); if(!strncmp(scan_name,name,name_len) && (scan_name[name_len]==0 || !strcmp(&scan_name[name_len],".so"))) { return scan; } } return 0; } static void delete_by_name(const char *name) { lftp_module_info *m=find_module(name); if(m) delete m; } }; lftp_module_info *lftp_module_info::base; static ResDecl res_mod_path("module:path", PKGLIBDIR "/" VERSION ":" PKGLIBDIR, 0,0); /* dlopen can take a file without extension and automatically do the * right thing, however that doesn't fit with this code that tries to * stat before the dlopen call, hence need some help here */ #if defined(__MACH__) && defined(__APPLE__) static const char ext[] = ".bundle"; #else static const char ext[] = ".so"; #endif static int access_so(xstring &fullpath) { int res=access(fullpath,F_OK); if(res==-1) { if(!fullpath.ends_with(ext)) fullpath.append(ext); res=access(fullpath,F_OK); } return res; } static const char *find_module_alias(const char *path) { const char *const *scan; for(scan=module_aliases; *scan; scan+=2) if(!strcmp(path,*scan)) return scan[1]; return path; } void *module_load(const char *path,int argc,const char *const *argv) { #ifdef HAVE_DLOPEN void *map; const char *modules_path=res_mod_path.Query(path); xstring fullpath; init_t init; if(strchr(path,'/')) { fullpath.set(path); access_so(fullpath); } else { path=find_module_alias(path); char *p=alloca_strdup(modules_path); for(p=strtok(p,":"); p; p=strtok(0,":")) { fullpath.vset(p,"/",path,NULL); if(access_so(fullpath)==0) break; } if(p==0) { fullpath.vset(PKGLIBDIR,"/",VERSION,"/",path,NULL); // fallback access_so(fullpath); } } map=dlopen(fullpath,DLOPEN_FLAGS); // LAZY? if(map==0) return 0; (void)new lftp_module_info(fullpath,map); #if 0 // for some reason this does not work even with LAZY (because of _init?). const char*const*depend=(const char*const*)dlsym(map,"module_depend"); if(depend) { while(*depend) { if(lftp_module_info::find_module(*depend)==0) { void *dep=module_load(*depend,0,0); if(!dep) fprintf(stderr,_("depend module `%s': %s\n"),*depend,module_error_message()); } depend++; } } #endif //0 init=(init_t)dlsym(map,"module_init"); if(init) (*init)(argc,argv); return map; #else // !HAVE_DLOPEN return 0; #endif } const char *module_error_message() { #ifdef HAVE_DLOPEN return dlerror(); #else return _("modules are not supported on this system"); #endif } bool module_init_preloaded(const char *module) { #if defined(HAVE_DLOPEN) && defined(RTLD_DEFAULT) module=find_module_alias(module); char *init_fn=alloca_strdup2(module,12); // change dashes to underscores in the function name for(char *scan=init_fn; *scan; scan++) if(*scan=='-') *scan='_'; strcat(init_fn,"_module_init"); init_t init=(init_t)dlsym(RTLD_DEFAULT,init_fn); if(init) { (*init)(0,0); return true; } #endif return false; } lftp-4.6.3a/src/FileCopyFtp.h0000644000015000007670000000256712122057424012710 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FILECOPYFTP_H #define FILECOPYFTP_H #include "FileCopy.h" #include "ftpclass.h" class FileCopyFtp : public FileCopy { bool no_rest; bool passive_source; bool orig_passive_source; bool disable_fxp; #if USE_SSL bool protect; bool passive_ssl_connect; bool orig_passive_ssl_connect; #endif int src_retries; int dst_retries; time_t src_try_time; time_t dst_try_time; void Close(); public: void Init(); FileCopyFtp(FileCopyPeer *src,FileCopyPeer *dst,bool cont,bool rp); int Do(); static FileCopy *New(FileCopyPeer *src,FileCopyPeer *dst,bool cont); }; #endif // FILECOPYFTP_H lftp-4.6.3a/src/NetAccess.h0000644000015000007670000000632612345607454012404 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef NETACCESS_H #define NETACCESS_H #include "FileAccess.h" #include "Resolver.h" #include "LsCache.h" #include "RateLimit.h" class NetAccess : public FileAccess, public Networker { protected: SMTaskRef resolver; xarray peer; int peer_curr; void ClearPeer(); void NextPeer(); int max_persist_retries; int persist_retries; Timer idle_timer; Timer timeout_timer; bool CheckTimeout(); int reconnect_interval; float reconnect_interval_current; float reconnect_interval_multiplier; int reconnect_interval_max; int connection_limit; bool connection_takeover; Ref rate_limit; int socket_buffer; int socket_maxseg; void SetSocketBuffer(int sock) { Networker::SetSocketBuffer(sock,socket_buffer); } void SetSocketMaxseg(int sock) { Networker::SetSocketMaxseg(sock,socket_maxseg); } int SocketCreate(int af,int type,int proto) { return Networker::SocketCreate(af,type,proto,hostname); } int SocketCreateTCP(int af) { return Networker::SocketCreateTCP(af,hostname); } int Poll(int fd,int ev,const char **err); const char *CheckHangup(const struct pollfd *pfd,int num); xstring_c proxy; xstring_c proxy_port; xstring_c proxy_user; xstring_c proxy_pass; xstring_c proxy_proto; xstring_c home_auto; void PropagateHomeAuto(); const char *FindHomeAuto(); void SayConnectingTo(); void SetProxy(const char *); static bool NoProxy(const char *); int Resolve(const char *defp,const char *ser,const char *pr); const char *DelayingMessage(); bool ReconnectAllowed(); bool CheckRetries(); // returns false if max-retries exceeded. bool NextTry(); // increments retries; does CheckRetries(). void TrySuccess(); // reset retry counters. virtual void HandleTimeout(); public: void Init(); NetAccess(); NetAccess(const NetAccess *); ~NetAccess(); void Reconfig(const char *name=0); void Open(const char *fn,int mode,off_t offs); void ResetLocationData(); void Close(); int CountConnections(); static void ClassInit(); }; class GenericParseListInfo : public ListInfo { protected: int mode; SMTaskRef ubuf; bool get_time_for_dirs; bool can_get_prec_time; virtual FileSet *Parse(const char *buf,int len) { return session->ParseLongList(buf,len); } public: GenericParseListInfo(FileAccess *session,const char *path); int Do(); const char *Status(); }; #endif//NETACCESS_H lftp-4.6.3a/src/url.cc0000644000015000007670000002250212466357651011473 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "trio.h" #include "xstring.h" #include #include #include "url.h" #include "ascii_ctype.h" #include "ConnectionSlot.h" #include "bookmark.h" #include "misc.h" #include "log.h" #include "network.h" /* URL -> [PROTO://]CONNECT[[:]/PATH] CONNECT -> [USER[:PASS]@]HOST[:PORT] exceptions: file:/PATH bm:BOOKMARK[/PATH] slot:SLOT[/PATH] */ static bool valid_slot(const char *s); static bool valid_bm(const char *s); ParsedURL::ParsedURL(const char *url,bool proto_required,bool use_rfc1738) { parse(url,proto_required,use_rfc1738); } ParsedURL::~ParsedURL() { } void ParsedURL::parse(const char *url,bool proto_required,bool use_rfc1738) { orig_url.set(url); xstring_c connect; const char *base=url; const char *scan=base; while(is_ascii_alpha(*scan)) scan++; if(scan[0]==':' && scan[1]=='/' && scan[2]=='/') { // found protocol proto.nset(base,scan-base); base=scan+=3; if(!strcmp(proto,"file") && scan[0]=='/') goto file_with_no_host; } else if(scan[0]==':' && !strncmp(base,"file:",5)) { // special form for file protocol proto.nset(base,scan-base); scan++; file_with_no_host: path.set(scan); host.set("localhost"); goto decode; } else if(scan[0]==':' && ((!strncmp(base,"slot:",5) && valid_slot(scan+1)) || (!strncmp(base,"bm:",3) && valid_bm(scan+1)))) { // special form for selecting a connection slot or a bookmark proto.nset(base,scan-base); scan++; base=scan; scan=strchr(scan,'/'); if(scan) { host.nset(base,scan-base); path.set(scan); } else host.set(base); goto decode; } else if(proto_required) { // all the rest is path, if protocol is required. path.set(base); goto decode; } scan=base; while(*scan && *scan!='/') scan++; // skip host name, port and user:pass connect.nset(base,scan-base-(scan>base && scan[-1]==':')); if(*scan=='/') // directory { if(scan[1]=='~') path.set(scan+1); else { if((!xstrcmp(proto,"ftp") || !xstrcmp(proto,"hftp")) && use_rfc1738) { // special handling for ftp protocol. if(!strncasecmp(scan+1,"%2F",3)) path.set(scan+1); else if(!(is_ascii_alpha(scan[1]) && scan[2]==':' && scan[3]=='/')) path.vset("~",scan,NULL); } else path.set(scan); } } else if(proto) { if(!strcmp(proto,"http") || !strcmp(proto,"https")) path.set("/"); } // try to extract user name/password base=connect; scan=strrchr(base,'@'); if(scan) { user.nset(base,scan-base); base=scan+1; scan=user; while(*scan && *scan!=':') scan++; if(*scan==':') { pass.set(scan+1); user.truncate(scan-user); } } // extract host name scan=base; if(*scan=='[') // RFC2732 [ipv6] { while(*scan && *scan!=']') scan++; if(*scan==']') { scan++; host.nset(base+1,scan-base-2); } else scan=base; } if(scan==base) { while(*scan && *scan!=':') scan++; host.nset(base,scan-base); } if(*scan==':') // port found { if(strchr(scan+1,':')==0) { port.set(scan+1); } else { /* more than one colon - maybe it is ipv6 digital address */ host.set(base); } } decode: user.url_decode(); pass.url_decode(); host.url_decode(); path.url_decode(); if(!xstrcmp(proto,"slot")) { const FileAccess *fa=ConnectionSlot::FindSession(host); if(!fa) return; orig_url.set(0); char *orig_path=alloca_strdup(path); proto.set(fa->GetProto()); user.set(fa->GetUser()); pass.set(fa->GetPassword()); host.set(fa->GetHostName()); port.set(fa->GetPort()); path.set(fa->GetCwd()); orig_path+=(orig_path!=0 && orig_path[0]=='/'); path.set(dir_file(fa->GetCwd(),path)); if(!orig_path || orig_path[0]==0) path.append('/'); } else if(!xstrcmp(proto,"bm")) { const char *bm=lftp_bookmarks.Lookup(host); if(!bm || !bm[0]) return; const char *new_url=0; xstring u(bm); if(orig_url) { const char *new_path=orig_url+url::path_index(orig_url); if(new_path[0]=='/') new_path++; if(new_path[0]=='/' || new_path[0]=='~') u.truncate(url::path_index(u)); assert(u[0]); if(u.last_char()!='/' && new_path[0]!='/') u.append('/'); else if(u.last_char()=='/' && new_path[0]=='/') new_path++; u.append(new_path); new_url=u; } else new_url=url_file(bm,path+(path && path[0]=='/')); parse(new_url,proto_required,use_rfc1738); } } static bool valid_slot(const char *cs) { xstring& s=xstring::get_tmp(cs); s.truncate_at('/'); s.url_decode(); return 0!=ConnectionSlot::Find(s); } static bool valid_bm(const char *bm) { xstring& s=xstring::get_tmp(bm); s.truncate_at('/'); s.url_decode(); const char *url=lftp_bookmarks.Lookup(s); return(url && !strchr(url,' ') && !strchr(url,'\t')); } int url::path_index(const char *base) { const char *scan=base; while(is_ascii_alpha(*scan)) scan++; if(scan[0]!=':') return 0; if(scan[1]=='/' && scan[2]=='/') { // found protocol const char *slash=strchr(scan+3,'/'); if(slash) return slash-base; return strlen(base); } else if(!strncmp(base,"file:",5)) { // special form for file protocol return scan+1-base; } else if((!strncmp(base,"slot:",5) && valid_slot(base+5)) || (!strncmp(base,"bm:",3) && valid_bm(base+3))) { const char *slash=strchr(scan+1,'/'); if(slash) return slash-base; return strlen(base); } return 0; } const char *url::path_ptr(const char *base) { if(!base) return 0; return base+path_index(base); } char *ParsedURL::Combine(const char *home,bool use_rfc1738) { xstring u(""); bool is_file=!xstrcmp(proto,"file"); bool is_ftp=(!xstrcmp(proto,"ftp") || !xstrcmp(proto,"hftp")); if(proto) { u.append(proto); u.append(is_file?":":"://"); } if(user && !is_file) { u.append(url::encode(user,URL_USER_UNSAFE)); if(pass) { u.append(':'); u.append(url::encode(pass,URL_PASS_UNSAFE)); } u.append('@'); } if(host && !is_file) { unsigned encode_flags=0; if(xtld_name_ok(host)) encode_flags|=URL_ALLOW_8BIT; if(is_ipv6_address(host)) u.append('[').append(host).append(']'); else u.append_url_encoded(host,URL_HOST_UNSAFE,encode_flags); } if(port && !is_file) { u.append(':'); u.append(url::encode(port,URL_PORT_UNSAFE)); } if(path && strcmp(path,"~")) { if(path[0]!='/' && !is_file) // e.g. ~/path u.append('/'); int p_offset=0; if(is_ftp && use_rfc1738) { // some cruft for ftp urls... if(path[0]=='/' && xstrcmp(home,"/")) { u.append("/%2F"); p_offset=1; } else if(path[0]=='~' && path[1]=='/') p_offset=2; } u.append(url::encode(path+p_offset,URL_PATH_UNSAFE)); } return u.borrow(); } xstring& url::decode(const char *p) { if(!p) return xstring::null; return xstring::get_tmp(p).url_decode(); } xstring& url::encode(const char *s,int len,const char *unsafe,unsigned flags) { if(!s) return xstring::null; return xstring::get_tmp("").append_url_encoded(s,len,unsafe,flags); } bool url::dir_needs_trailing_slash(const char *proto_c) { if(!proto_c) return false; char *proto=alloca_strdup(proto_c); char *colon=strchr(proto,':'); if(colon) *colon=0; return !strcasecmp(proto,"http") || !strcasecmp(proto,"https"); } bool url::find_password_pos(const char *url,int *start,int *len) { *start=*len=0; const char *scan=strstr(url,"://"); if(!scan) return false; scan+=3; const char *at=strchr(scan,'@'); if(!at) return false; const char *colon=strchr(scan,':'); if(!colon || colon>at) return false; const char *slash=strchr(scan,'/'); if(slash && slash. */ #ifndef PTYSHELL_H #define PTYSHELL_H #include "Filter.h" class PtyShell : public FDStream { Ref a; SMTaskRef w; pid_t pg; xstring_c oldcwd; bool closed; bool use_pipes; int pipe_in; int pipe_out; void Init(); public: PtyShell(const char *filter); PtyShell(ArgV *a); ~PtyShell(); void SetCwd(const char *); void UsePipes() { use_pipes=true; } int getfd(); int getfd_pipe_in() { return pipe_in; } int getfd_pipe_out() { return pipe_out; } bool Done(); void Kill(int sig=SIGTERM) { if(w) w->Kill(sig); } pid_t GetProcGroup() const { return pg; } bool broken(); }; #endif // PTYSHELL_H lftp-4.6.3a/src/FindJob.h0000644000015000007670000000673312433662336012047 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FINDJOB_H #define FINDJOB_H #include "Job.h" #include "buffer.h" #include "ArgV.h" #include "GetFileInfo.h" #include "PatternSet.h" class FinderJob : public SessionJob { FileAccessRef my_session; FileAccess::Path orig_init_dir; xstring_c dir; int errors; SMTaskRef li; class place { friend class FinderJob; xstring_c path; Ref fset; place(const char *p,FileSet *f) : path(p), fset(f) {} }; RefArray stack; void Up(); void Down(const char *d); void Push(FileSet *f); virtual void Enter(const char *d) { } virtual void Exit() { } bool depth_done; unsigned file_info_need; /* In certain circumstances, we can skip a LIST altogether and just * pass argument names on: we don't need anything other than the name * (no other file_info_needs) and we're not recursing (which would imply * needing the type.) This means arguments that don't actually exist * get passed on; if this is inappropriate (ie for a simple Find), * call ValidateArgs(). */ bool validate_args; Ref exclude; protected: enum state_t { START_INFO, INFO, LOOP, PROCESSING, WAIT, DONE }; state_t state; const char *op; FileAccessRefC session; FileAccess::Path init_dir; enum prf_res { PRF_FATAL, PRF_ERR, PRF_OK, PRF_WAIT, PRF_LATER }; virtual prf_res ProcessFile(const char *d,const FileInfo *fi); virtual void ProcessList(FileSet *f) { } virtual void Finish() {}; bool show_sl; bool depth_first; bool use_cache; bool quiet; int maxdepth; void NextDir(const char *d); const char *GetCur() const { return dir; } void Need(unsigned need) { file_info_need=need; } void ValidateArgs() { validate_args=true; } bool ProcessingURL() { return session!=SessionJob::session; } public: int Do(); int Done() { return state==DONE; } int ExitCode() { return state!=DONE || errors; } void Init(); FinderJob(FileAccess *s); void PrepareToDie() { session->Close(); SessionJob::PrepareToDie(); } ~FinderJob(); void ShowRunStatus(const SMTaskRef&); xstring& FormatStatus(xstring&,int,const char *); void BeQuiet() { quiet=true; } void SetExclude(PatternSet *p) { exclude = p; } void set_maxdepth(int _maxdepth) { maxdepth = _maxdepth; } void Fg(); void Bg(); }; class FinderJob_List : public FinderJob { SMTaskRef buf; Ref args; bool long_listing; protected: prf_res ProcessFile(const char *d,const FileInfo *fi); void Finish(); public: FinderJob_List(FileAccess *s,ArgV *a,FDStream *o); void DoLongListing(bool yes=true) { long_listing=yes; } int Done() { return FinderJob::Done() && buf->Done(); } }; #endif //FINDJOB_H lftp-4.6.3a/src/example-module1.cc0000644000015000007670000000056212122054516013651 00000000000000#include #include "CmdExec.h" Job *cmd_test1(CmdExec *parent) { parent->printf("test1 called with %d arguments\n",parent->args->count()); parent->exit_code=0; return 0; } CDECL void module_init(int argc,const char *const *argv) { CmdExec::RegisterCommand("test1",cmd_test1,"test1 [args]","This test command prints the number of arguments\n"); } lftp-4.6.3a/src/network.cc0000644000015000007670000002501212513706743012352 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H # include #endif #ifdef HAVE_NETINET_IP_H # include #endif #ifdef HAVE_NETINET_TCP_H # include #endif #ifdef HAVE_SYS_IOCTL_H # include #endif #ifdef HAVE_TERMIOS_H # include #endif #include "SMTask.h" #include "network.h" #include "ResMgr.h" #include "ProtoLog.h" #include "xstring.h" const char *sockaddr_u::address() const { #ifdef HAVE_GETNAMEINFO char *buf=xstring::tmp_buf(NI_MAXHOST); if(getnameinfo(&sa,addr_len(),buf,NI_MAXHOST,0,0,NI_NUMERICHOST)<0) return "????"; return buf; #else static char buf[16]; if(sa.sa_family!=AF_INET) return "????"; unsigned char *a=(unsigned char *)&in.sin_addr; snprintf(buf,16,"%u.%u.%u.%u",a[0],a[1],a[2],a[3]); return buf; #endif } int sockaddr_u::port() const { if(sa.sa_family==AF_INET) return ntohs(in.sin_port); #if INET6 if(sa.sa_family==AF_INET6) return ntohs(in6.sin6_port); #endif return 0; } void sockaddr_u::set_port(int port) { if(sa.sa_family==AF_INET) in.sin_port=htons(port); #if INET6 if(sa.sa_family==AF_INET6) in6.sin6_port=htons(port); #endif } const xstring& sockaddr_u::to_xstring() const { return xstring::format("[%s]:%d",address(),port()); } bool sockaddr_u::is_reserved() const { if(sa.sa_family==AF_INET) { unsigned char *a=(unsigned char *)&in.sin_addr; return (a[0]==0) || (a[0]==127 && !is_loopback()) || (a[0]>=240); } #if INET6 if(family()==AF_INET6) { return IN6_IS_ADDR_UNSPECIFIED(&in6.sin6_addr) || IN6_IS_ADDR_V4MAPPED(&in6.sin6_addr) || IN6_IS_ADDR_V4COMPAT(&in6.sin6_addr); } #endif return false; } bool sockaddr_u::is_multicast() const { if(sa.sa_family==AF_INET) { unsigned char *a=(unsigned char *)&in.sin_addr; return (a[0]>=224 && a[0]<240); } #if INET6 if(family()==AF_INET6) return IN6_IS_ADDR_MULTICAST(&in6.sin6_addr); #endif return false; } bool sockaddr_u::is_private() const { if(sa.sa_family==AF_INET) { unsigned char *a=(unsigned char *)&in.sin_addr; return (a[0]==10) || (a[0]==172 && a[1]>=16 && a[1]<32) || (a[0]==192 && a[1]==168) || (a[0]==169 && a[1]==254); // self-assigned } #if INET6 if(family()==AF_INET6) { return IN6_IS_ADDR_SITELOCAL(&in6.sin6_addr) || IN6_IS_ADDR_LINKLOCAL(&in6.sin6_addr); } #endif return false; } bool sockaddr_u::is_loopback() const { if(sa.sa_family==AF_INET) { unsigned char *a=(unsigned char *)&in.sin_addr; return (a[0]==127 && a[1]==0 && a[2]==0 && a[3]==1); } #if INET6 if(sa.sa_family==AF_INET6) return IN6_IS_ADDR_LOOPBACK(&in6.sin6_addr); #endif return false; } bool sockaddr_u::is_compatible(const sockaddr_u& o) const { return family()==o.family() && !is_multicast() && !o.is_multicast() && !is_reserved() && !o.is_reserved() && is_private()==o.is_private() && is_loopback()==o.is_loopback(); } bool sockaddr_u::set_compact(const char *c,size_t len) { if(len==4) { sa.sa_family=AF_INET; memcpy(&in.sin_addr,c,4); in.sin_port=0; return true; #if INET6 } else if(len==16) { sa.sa_family=AF_INET6; memcpy(&in6.sin6_addr,c,16); return true; #endif } else if(len==6) { sa.sa_family=AF_INET; memcpy(&in.sin_addr,c,4); in.sin_port=htons((c[5]&255)|((c[4]&255)<<8)); return true; #if INET6 } else if(len==18) { sa.sa_family=AF_INET6; memcpy(&in6.sin6_addr,c,16); in6.sin6_port=htons((c[17]&255)|((c[16]&255)<<8)); return true; #endif } return false; } const sockaddr_compact& sockaddr_u::compact() const { sockaddr_compact& c=compact_addr(); int p=port(); if(c.length() && p) { c.append(char(p>>8)); c.append(char(p&255)); } return c; } sockaddr_compact& sockaddr_u::compact_addr() const { sockaddr_compact& c=sockaddr_compact::get_tmp(); if(family()==AF_INET) c.append((const char*)&in.sin_addr,4); #if INET6 else if(family()==AF_INET6) c.append((const char*)&in6.sin6_addr,16); #endif return c; } void Networker::NonBlock(int fd) { int fl=fcntl(fd,F_GETFL); fcntl(fd,F_SETFL,fl|O_NONBLOCK); } void Networker::CloseOnExec(int fd) { fcntl(fd,F_SETFD,FD_CLOEXEC); } static int one=1; void Networker::KeepAlive(int sock) { setsockopt(sock,SOL_SOCKET,SO_KEEPALIVE,(char*)&one,sizeof(one)); } void Networker::MinimizeLatency(int sock) { #ifdef IP_TOS int tos = IPTOS_LOWDELAY; setsockopt(sock, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)); #endif } void Networker::MaximizeThroughput(int sock) { #ifdef IP_TOS int tos = IPTOS_THROUGHPUT; setsockopt(sock, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)); #endif } void Networker::ReuseAddress(int sock) { setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char*)&one,sizeof(one)); } void Networker::SetSocketBuffer(int sock,int socket_buffer) { if(socket_buffer==0) return; if(-1==setsockopt(sock,SOL_SOCKET,SO_SNDBUF,(char*)&socket_buffer,sizeof(socket_buffer))) ProtoLog::LogError(1,"setsockopt(SO_SNDBUF,%d): %s",socket_buffer,strerror(errno)); if(-1==setsockopt(sock,SOL_SOCKET,SO_RCVBUF,(char*)&socket_buffer,sizeof(socket_buffer))) ProtoLog::LogError(1,"setsockopt(SO_RCVBUF,%d): %s",socket_buffer,strerror(errno)); } void Networker::SetSocketMaxseg(int sock,int socket_maxseg) { #ifndef SOL_TCP # define SOL_TCP IPPROTO_TCP #endif #ifdef TCP_MAXSEG if(socket_maxseg==0) return; if(-1==setsockopt(sock,SOL_TCP,TCP_MAXSEG,(char*)&socket_maxseg,sizeof(socket_maxseg))) ProtoLog::LogError(1,"setsockopt(TCP_MAXSEG,%d): %s",socket_maxseg,strerror(errno)); #endif } int Networker::SocketCreateUnbound(int af,int type,int proto,const char *hostname) { int s=socket(af,type,proto); if(s<0) return s; NonBlock(s); CloseOnExec(s); SetSocketBuffer(s,ResMgr::Query("net:socket-buffer",hostname)); return s; } bool sockaddr_u::set_defaults(int af,const char *hostname,int port) { memset(this,0,sizeof(*this)); sa.sa_family=af; const char *b=0; if(af==AF_INET) { b=ResMgr::Query("net:socket-bind-ipv4",hostname); if(!(b && b[0] && inet_pton(af,b,&in.sin_addr))) b=0; in.sin_port=htons(port); } #if INET6 else if(af==AF_INET6) { b=ResMgr::Query("net:socket-bind-ipv6",hostname); if(!(b && b[0] && inet_pton(af,b,&in6.sin6_addr))) b=0; in6.sin6_port=htons(port); } #endif return b || port; } void Networker::SocketBindStd(int s,int af,const char *hostname,int port) { sockaddr_u bind_addr; if(bind_addr.set_defaults(af,hostname,port)) { if(bind_addr.bind_to(s)==-1) ProtoLog::LogError(0,"bind(%s): %s",bind_addr.to_string(),strerror(errno)); } } int Networker::SocketCreate(int af,int type,int proto,const char *hostname) { int s=SocketCreateUnbound(af,type,proto,hostname); if(s<0) return s; SocketBindStd(s,af,hostname); return s; } void Networker::SocketTuneTCP(int s,const char *hostname) { KeepAlive(s); SetSocketMaxseg(s,ResMgr::Query("net:socket-maxseg",hostname)); } int Networker::SocketCreateTCP(int af,const char *hostname) { int s=SocketCreate(af,SOCK_STREAM,IPPROTO_TCP,hostname); if(s<0) return s; SocketTuneTCP(s,hostname); return s; } int Networker::SocketCreateUnboundTCP(int af,const char *hostname) { int s=SocketCreateUnbound(af,SOCK_STREAM,IPPROTO_TCP,hostname); if(s<0) return s; SocketTuneTCP(s,hostname); return s; } int Networker::SocketConnect(int fd,const sockaddr_u *u) { // some systems have wrong connect() prototype, so we have to cast off const. // in any case, connect does not alter the address. int res=connect(fd,(sockaddr*)&u->sa,SocketAddrLen(u)); if(res!=-1) SMTask::UpdateNow(); // if non-blocking doesn't work return res; } int Networker::SocketAccept(int fd,sockaddr_u *u,const char *hostname) { socklen_t len=sizeof(*u); int a=accept(fd,&u->sa,&len); if(a<0) return a; NonBlock(a); CloseOnExec(a); KeepAlive(a); SetSocketBuffer(a,ResMgr::Query("net:socket-buffer",hostname)); SetSocketMaxseg(a,ResMgr::Query("net:socket-maxseg",hostname)); return a; } void Networker::SocketSinglePF(int s,int pf) { #if INET6 && defined(IPV6_V6ONLY) if(pf==PF_INET6) { int on = 1; if(-1==setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&on, sizeof(on))) ProtoLog::LogError(1,"setsockopt(IPV6_V6ONLY): %s",strerror(errno)); } #endif } #ifdef TIOCOUTQ static bool TIOCOUTQ_returns_free_space; static bool TIOCOUTQ_works; static bool TIOCOUTQ_tested; static void test_TIOCOUTQ() { int sock=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP); if(sock==-1) return; TIOCOUTQ_tested=true; int avail=-1; socklen_t len=sizeof(avail); if(getsockopt(sock,SOL_SOCKET,SO_SNDBUF,(char*)&avail,&len)==-1) avail=-1; int buf=-1; if(ioctl(sock,TIOCOUTQ,&buf)==-1) buf=-1; if(buf>=0 && avail>0 && (buf==0 || buf==avail)) { TIOCOUTQ_works=true; TIOCOUTQ_returns_free_space=(buf==avail); } close(sock); } #endif int Networker::SocketBuffered(int sock) { #ifdef TIOCOUTQ if(!TIOCOUTQ_tested) test_TIOCOUTQ(); if(!TIOCOUTQ_works) return 0; int buffer=0; if(TIOCOUTQ_returns_free_space) { socklen_t len=sizeof(buffer); if(getsockopt(sock,SOL_SOCKET,SO_SNDBUF,(char*)&buffer,&len)==-1) return 0; int avail=buffer; if(ioctl(sock,TIOCOUTQ,&avail)==-1) return 0; if(avail>buffer) return 0; // something wrong buffer-=avail; buffer=buffer*3/4; // approx... } else { if(ioctl(sock,TIOCOUTQ,&buffer)==-1) return 0; } return buffer; #else return 0; #endif } lftp-4.6.3a/src/history.cc0000644000015000007670000001002112270241230012335 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include "trio.h" #include "history.h" #include "url.h" #include "misc.h" #define super KeyValueDB History::History() { full=0; stamp=0; fd=-1; modified=false; const char *home=get_lftp_data_dir(); if(home) file.vset(home,"/cwd_history",NULL); } History::~History() { Close(); if(full) delete full; } const char *History::extract_url(const char *res) { const char *url=strchr(res,':'); if(url) url++; else url=res; if(url::is_url(url)) return url; return url::decode(url); } time_t History::extract_stamp(const char *res) { return atol(res); } const char *History::Lookup(const FileAccess *s) { const char *url=s->GetConnectURL(s->NO_PATH|s->NO_PASSWORD); if(!url) return 0; const char *res=super::Lookup(url); if(res) return extract_url(res); Refresh(); Close(); if(!full) return 0; res=full->Lookup(url); if(res) return extract_url(res); return 0; } void History::Refresh() { if(!file) return; struct stat st; if((fd==-1 ? stat(file,&st) : fstat(fd,&st)) == -1) return; if(st.st_mtime==stamp) return; Load(); } void History::Load() { if(full) full->Empty(); if(!file) return; if(fd==-1) { fd=open(file,O_RDONLY); if(fd==-1) return; fcntl(fd,F_SETFD,FD_CLOEXEC); if(Lock(fd,F_RDLCK)==-1) fprintf(stderr,"%s: lock for reading failed, trying to read anyway\n",file.get()); } if(!full) full=new KeyValueDB; struct stat st; fstat(fd,&st); stamp=st.st_mtime; lseek(fd,0,SEEK_SET); full->Read(dup(fd)); // Read closes fd } void History::Close() { if(fd!=-1) { close(fd); fd=-1; } } void History::Set(const FileAccess *s,const FileAccess::Path &cwd) { if(cwd.path==0 || !strcmp(cwd.path,"~") || s->GetHostName()==0) return; xstring res; res.setf("%lu:",(unsigned long)time(0)); if(!cwd.url) { res.append_url_encoded(cwd,URL_PATH_UNSAFE); if(!cwd.is_file && url::dir_needs_trailing_slash(s->GetProto()) && res.last_char()!='/') res.append('/'); } else res.append(cwd.url); super::Add(s->GetConnectURL(s->NO_PATH|s->NO_PASSWORD),res); modified=true; } void History::Save() { Close(); if(!file) return; if(!modified) return; fd=open(file,O_RDWR|O_CREAT,0600); if(fd==-1) return; fcntl(fd,F_SETFD,FD_CLOEXEC); if(Lock(fd,F_WRLCK)==-1) { fprintf(stderr,"%s: lock for writing failed\n",file.get()); Close(); return; } Refresh(); // merge int count=0; for(Pair *p=chain; p; p=p->next) { time_t new_stamp=extract_stamp(p->value); time_t old_stamp=0; const char *old_value=full->Lookup(p->key); if(old_value) old_stamp=extract_stamp(old_value); if(old_stampAdd(p->key,p->value); count++; } } if(count==0) { Close(); return; } lseek(fd,0,SEEK_SET); #ifdef HAVE_FTRUNCATE if(ftruncate(fd,0)==-1) // note the following statement #endif close(open(file,O_WRONLY|O_TRUNC)); full->Write(fd); fd=-1; // Write closes file } lftp-4.6.3a/src/buffer_std.h0000644000015000007670000000201412122057121012624 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef BUFFER_STD_H #define BUFFER_STD_H #include "Job.h" #include "buffer.h" class IOBuffer_STDOUT : public IOBuffer { Job *master; int Put_LL(const char *buf,int size); public: IOBuffer_STDOUT(Job *m) : IOBuffer(PUT) { master=m; } }; #endif //BUFFER_STD_H lftp-4.6.3a/src/lftp_pty.h0000644000015000007670000000166012122060121012342 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef LFTP_PTY_H #define LFTP_PTY_H CDECL_BEGIN /* opens a pseudo-tty, returns slave tty name if successful */ const char *open_pty(int *ptyfd, int *ttyfd); CDECL_END #endif lftp-4.6.3a/src/module.h0000644000015000007670000000170112536034353012003 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef MODULE_H #define MODULE_H void *module_load(const char *name,int argc,const char *const *argv); const char *module_error_message(); bool module_init_preloaded(const char *prefix); #endif lftp-4.6.3a/src/CharReader.cc0000644000015000007670000000305312252010506012643 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include "trio.h" #include "CharReader.h" int CharReader::Do() { int m=STALL; if(ch!=NOCHAR) return m; if(!Ready(fd,POLLIN)) { Block(fd,POLLIN); return m; } int oldfl=fcntl(fd,F_GETFL); if(!(oldfl&O_NONBLOCK)) fcntl(fd,F_SETFL,oldfl|O_NONBLOCK); unsigned char c; int res=read(fd,&c,1); if(res==-1 && errno==EAGAIN) Block(fd,POLLIN); else if(res==-1 && errno==EINTR) m=MOVED; else if(res>0) { ch=c; m=MOVED; } else // eof or error. { ch=EOFCHAR; m=MOVED; } if(!(oldfl&O_NONBLOCK)) fcntl(fd,F_SETFL,oldfl); if(res==-1 && ch==EOFCHAR) fprintf(stderr,"read(%d): %s\n",fd,strerror(errno)); return m; } lftp-4.6.3a/src/FileSet.h0000644000015000007670000001523112537466517012070 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FILESET_H #define FILESET_H #include #include "xarray.h" #undef TYPE class TimeInterval; class Range; #define NO_SIZE ((off_t)-1L) #define NO_SIZE_YET ((off_t)-2L) #define NO_DATE ((time_t)-1L) #define NO_DATE_YET ((time_t)-2L) struct FileTimestamp { time_t ts; int ts_prec; FileTimestamp() : ts(NO_DATE_YET), ts_prec(0) {} void set(time_t ts1,int ts1_prec) { ts=ts1; ts_prec=ts1_prec; } bool is_set() { return ts!=NO_DATE && ts!=NO_DATE_YET; } operator time_t() const { return ts; } time_t operator=(time_t t) { set(t,0); return t; } }; class FileInfo { void def(unsigned m) { defined|=m; need&=~m; } public: xstring name; xstring longname; xstring_c symlink; mode_t mode; FileTimestamp date; off_t size; xstring data; const char *user, *group; int nlinks; enum type { UNKNOWN=0, DIRECTORY, SYMLINK, NORMAL }; type filetype; enum defined_bits { NAME=001,MODE=002,DATE=004,TYPE=010,SYMLINK_DEF=020, SIZE=0100,USER=0200,GROUP=0400,NLINKS=01000, IGNORE_SIZE_IF_OLDER=02000, // for ignore mask IGNORE_DATE_IF_OLDER=04000, // for ignore mask ALL_INFO=NAME|MODE|DATE|TYPE|SYMLINK_DEF|SIZE|USER|GROUP|NLINKS }; unsigned defined; unsigned need; int rank; void Init(); FileInfo() { Init(); } FileInfo(const FileInfo &fi); FileInfo(const char *n); ~FileInfo(); void SetName(const char *n) { name.set(n); def(NAME); } void SetName(const xstring& n) { name.set(n); def(NAME); } void SetUser(const char *n); void SetGroup(const char *n); void LocalFile(const char *name, bool follow_symlinks); static FileInfo *parse_ls_line(const char *line,int line_len,const char *tz); static FileInfo *parse_ls_line(const char *line,const char *tz) { return parse_ls_line(line,strlen(line),tz); } void SetMode(mode_t m) { mode=m; def(MODE); } void SetDate(time_t t,int prec) { date.set(t,prec); def(DATE); } void SetType(type t) { filetype=t; def(TYPE); } void SetSymlink(const char *s) { symlink.set(s); filetype=SYMLINK; def(TYPE|SYMLINK_DEF); } void SetSize(off_t s) { size=s; def(SIZE); } void SetNlink(int n) { nlinks=n; def(NLINKS); } void Merge(const FileInfo&); bool SameAs(const FileInfo *,int ignore) const; bool OlderThan(time_t t) const; bool NewerThan(time_t t) const; bool NotOlderThan(time_t t) const; bool NotNewerThan(time_t t) const; bool SizeOutside(const Range *r) const; bool TypeIs(type t) const { return (defined&TYPE) && filetype==t; } void SetAssociatedData(const void *d,int len) { data.nset((const char*)d,len); } const void *GetAssociatedData() const { return data; } void SetRank(int r) { rank=r; } int GetRank() const { return rank; } void MakeLongName(); void SetLongName(const char *s) { longname.set(s); } const char *GetLongName() { if(!longname) MakeLongName(); return longname; } operator const char *() const { return name; } bool Has(unsigned m) const { return defined&m; } bool HasAny(unsigned m) const { return defined&m; } bool HasAll(unsigned m) const { return (defined&m)==m; } void Need(unsigned m) { need|=m; } void NoNeed(unsigned m) { need&=~m; } }; class PatternSet; class FileSet { public: enum sort_e { BYNAME, BYSIZE, DIRSFIRST, BYRANK, BYDATE }; private: RefArray files; /* indexes when sort != NAME: */ xarray sorted; int ind; void Sub(int); void add_before(int pos,FileInfo *fi); public: FileSet(); FileSet(const FileSet *s); ~FileSet(); void Empty(); int get_fnum() const { return files.count(); } int count() const { return files.count(); } int curr_index() const { return ind; } int curr_pct() const { return count()==0 ? 100 : ind*100/count(); } void Add(FileInfo *); void Merge(const FileSet *); void SubtractSame(const FileSet *,int ignore); void SubtractAny(const FileSet *); void SubtractTimeCmp(bool (FileInfo::*cmp)(time_t) const,time_t); void SubtractOlderThan(time_t t) { SubtractTimeCmp(&FileInfo::OlderThan,t); } void SubtractNewerThan(time_t t) { SubtractTimeCmp(&FileInfo::NewerThan,t); } void SubtractNotOlderThan(time_t t) { SubtractTimeCmp(&FileInfo::NotOlderThan,t); } void SubtractNotNewerThan(time_t t) { SubtractTimeCmp(&FileInfo::NotNewerThan,t); } void SubtractSizeOutside(const Range *r); void SubtractDirs(); void SubtractNotDirs(); void SubtractNotIn(const FileSet *); void SubtractSameType(const FileSet *); void SubtractDirs(const FileSet *); void SubtractNotOlderDirs(const FileSet *); void SubtractCurr(); void Sort(sort_e newsort, bool casefold=false, bool reverse=false); void Unsort(); void SortByPatternList(const char *list_c); void ReverseSort(); void Exclude(const char *prefix,const PatternSet *x); void ExcludeDots(); void ExcludeCompound(); void ExcludeUnaccessible(); void rewind() { ind=0; } FileInfo *curr(); FileInfo *next(); void LocalRemove(const char *dir); void LocalUtime(const char *dir,bool only_dirs=false); void LocalChmod(const char *dir,mode_t mask=0); void LocalChown(const char *dir); void Count(int *d,int *f,int *s,int *o) const; void CountBytes(long long *b) const; int FindGEIndByName(const char *name) const; FileInfo *FindByName(const char *name) const; void SetSize(const char *name,off_t size) { FileInfo *f=FindByName(name); if(f) f->SetSize(size); } void SetDate(const char *name,time_t date,int prec) { FileInfo *f=FindByName(name); if(f) f->SetDate(date,prec); } /* add a path to all files */ void PrependPath(const char *path); /* get all defined_bits used by this fileset */ int Have() const; FileInfo * operator[](int i) const; size_t EstimateMemory() const; void Dump(const char *tag) const; }; #endif // FILESET_H lftp-4.6.3a/src/QueueFeeder.h0000644000015000007670000000534612122060513012712 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef QUEUEFEEDER_H #define QUEUEFEEDER_H #include "CmdExec.h" class QueueFeeder : public CmdFeeder { struct QueueJob { xstring_c cmd; xstring_c pwd; xstring_c lpwd; QueueJob *next, *prev; QueueJob(): next(0), prev(0) {} } *jobs, *lastjob; xstring_c cur_pwd; xstring_c cur_lpwd; xstring buffer; /* remove the given job from the list */ void unlink_job(QueueJob *job); /* get the n'th job */ QueueJob *get_job(int n); /* get the n'th job, removed from the list: */ QueueJob *grab_job(int n); /* get all jobs (linked and removed from the list) * that match the cmd: */ QueueJob *grab_job(const char *cmd); /* get the next job in j that matches cmd (including j) */ static QueueJob *get_next_match(const char *cmd, QueueJob *j); void PrintJobs(const QueueJob *job, int v, const char *plur) const; xstring& FormatJobs(xstring& s,const QueueJob *job, int v, const char *plur) const; void insert_jobs(QueueJob *job, QueueJob *&lst_head, QueueJob *&lst_tail, QueueJob *before); void FreeList(QueueJob *j); public: const char *NextCmd(CmdExec *exec,const char *prompt); /* Add a command to the queue at a given position; a 0 position inserts at the end. */ void QueueCmd(const char *cmd, const char *pwd, const char *lpwd, int pos = 0, int verbose = 0); /* delete jobs (by index or wildcard expr) */ bool DelJob(int from, int v = 0); bool DelJob(const char *cmd, int v = 0); /* move one or more jobs (by index or wildcard expr). */ bool MoveJob(int from, int to, int v = 0); bool MoveJob(const char *cmd, int to, int v = 0); static int JobCount(const QueueJob *); int JobCount() const { return JobCount(jobs); } enum { PrintRequeue = 9999 }; xstring& FormatStatus(xstring&,int v,const char *prefix="\t") const; QueueFeeder(const char *pwd, const char *lpwd): jobs(0), lastjob(0), cur_pwd(pwd), cur_lpwd(lpwd) {} virtual ~QueueFeeder(); }; #endif//QUEUEFEEDER_H lftp-4.6.3a/src/plural.c0000644000015000007670000000734512122060426012011 00000000000000/* * plural word form chooser for i18n * * Copyright (c) 1998 by Alexander V. Lukyanov (lav@yars.free.net) * * This file is in public domain. */ /* * This file provides a function to transform a string with all plural forms * of a word to a string with concrete form depending on a number. * It uses a rule encoded in special string. */ /* TODO: * allow to select number of argument */ #include #include #include #include #include #include "plural.h" static int choose_plural_form(const char *rule,int num) { int res=0; int match=1; int n=num; char c; int arg,arg_len; for(;;) { switch(c=*rule) { case '=': case '!': case '>': case '<': case '%': if(sscanf(rule+1,"%d%n",&arg,&arg_len)<1) return -1; rule+=arg_len; if(c=='%') n%=arg; if((c=='=' && !(n==arg)) || (c=='!' && !(n!=arg)) || (c=='>' && !(n> arg)) || (c=='<' && !(n< arg))) match=0; break; case '|': case ' ': case '\0': if(match) return res; if(c=='\0') return res+1; if(c=='|') match=1; if(c==' ') /* next rule */ { n=num; res++; match=1; } break; } rule++; } /* return res;*/ } /* * The function takes _untranslated_ string with $form1|form2|form3...$ * inserts, and a list of integer numbers. It uses gettext on the string. * Using "translated" rule and the list of numbers it choose appropriate * plural forms. * * If the string or the rule cannot be translated, it uses untranslated * string and default (english) rule. * * Returns pointer to static storage, copy if needed. */ const char *plural(const char *format,...) { static char *res=0; static size_t res_size=0; /* This is the rule for plural form choice (last condition can be omitted) */ /* Operators: = > < ! | % */ const char *rule=N_("=1 =0|>1"); const char *s; char *store; int index,plural_index; const char *new_format=gettext(format); const char *new_rule=gettext(rule); va_list va; long arg; va_start(va,format); if(new_format!=format && new_rule!=rule) /* there is translation */ { rule=new_rule; /* use "translated" rule */ format=new_format; /* and translated format */ } if(res==0) res=malloc(res_size=256); if(res==0) return 0; store=res; for(s=format; *s; s++) { #define ALLOCATE \ if(store-res+1>=res_size) \ { \ int dif=store-res; \ res=realloc(res,res_size*=2); \ if(res==0) \ return 0; \ store=res+dif; \ } /* end ALLOCATE */ if(*s=='$' && s[1]) { s++; if(*s=='$') goto plain; /* check options */ if(*s=='#') { s++; if(*s=='l') /* long */ { s++; if(*s=='l') /* long long */ { s++; arg=va_arg(va,long long)%1000000; } else arg=va_arg(va,long); } else { arg=va_arg(va,int); } if(*s=='#') /* end of options */ s++; } else { arg=va_arg(va,int); } if(arg<0) arg=-arg; plural_index=choose_plural_form(rule,arg); index=0; while(index!=plural_index) { /* skip plural form */ while(*s!='$' && *s!='|' && *s) s++; if(*s==0) goto out; if(*s=='$') break; s++; index++; } if(index==plural_index) { /* insert the form */ while(*s!='$' && *s!='|' && *s) { ALLOCATE; *store++=*s++; } while(*s!='$' && *s) s++; if(*s==0) goto out; } } else { plain: ALLOCATE; *store++=*s; } } out: ALLOCATE; *store=0; va_end(va); return res; } lftp-4.6.3a/src/DHT.cc0000644000015000007670000007625412351742537011317 00000000000000/* * lftp - file transfer program * * Copyright (c) 2012-2014 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include "Torrent.h" #include "DHT.h" #include "log.h" #include "url.h" #include "misc.h" #include "plural.h" DHT::DHT(int af,const xstring& id) : af(af), rate_limit("DHT"), sent_req_expire_scan(5), search_cleanup_timer(5), refresh_timer(1), nodes_cleanup_timer(30), save_timer(300), node_id(id.copy()), t(random()) { LogNote(10,"creating DHT with id=%s",node_id.hexdump()); Reconfig(0); } DHT::~DHT() { } void DHT::Bootstrap() { // run bootstrap search LogNote(9,"bootstrapping"); Search *s=new Search(node_id); s->Bootstrap(); StartSearch(s); } int DHT::Do() { int m=STALL; if(state_io) { if(state_io->GetDirection()==IOBuffer::GET) { if(state_io->Error()) { LogError(1,"loading state: %s",state_io->ErrorText()); state_io=0; m=MOVED; } else if(state_io->Eof()) { Load(state_io); state_io=0; m=MOVED; } } else { if(state_io->Error()) LogError(1,"saving state: %s",state_io->ErrorText()); if(state_io->Done()) { state_io=0; m=MOVED; } } } if(sent_req_expire_scan.Stopped()) { for(const Request *r=sent_req.each_begin(); r; r=sent_req.each_next()) { if(r->Expired()) { LogError(4,"DHT request %s to %s timed out",r->data->lookup_str("q").get(),r->addr.to_string()); Node *n=nodes.lookup(r->GetNodeId()); const xstring& target=r->GetSearchTarget(); if(target) { Search *s=search.lookup(target); // if we have lost a search request and have not received any // reply yet - try to restart the search with good nodes. if(s && !s->best_node_id) RestartSearch(s); } sent_req.remove(sent_req.each_key()); if(n) { n->LostPing(); LogNote(4,"DHT node %s has lost %d packets",n->GetName(),n->ping_lost_count); } } } sent_req_expire_scan.Reset(); } if(search_cleanup_timer.Stopped()) { for(Search *s=search.each_begin(); s; s=search.each_next()) { if(s->search_timer.Stopped()) search.remove(search.each_key()); } search_cleanup_timer.Reset(); } if(nodes_cleanup_timer.Stopped()) { for(Node *n=nodes.each_begin(); n; n=nodes.each_next()) { if(n->IsBad()) { LogNote(9,"removing bad node %s",n->GetName()); RemoveNode(n); } } if(nodes.count()>MAX_NODES) { // remove some nodes. int to_remove=nodes.count()-MAX_NODES; for(Node *n=nodes.each_begin(); n && to_remove>0; n=nodes.each_next()) { if(!n->IsGood() && !n->in_routes) { LogNote(9,"removing node %s (not good)",n->GetName()); RemoveNode(n); to_remove--; } } for(Node *n=nodes.each_begin(); n && to_remove>0; n=nodes.each_next()) { if(!n->in_routes && !n->responded) { LogNote(9,"removing node %s (never responded)",n->GetName()); RemoveNode(n); to_remove--; } } LogNote(9,"node count=%d",nodes.count()); } for(int i=1; inodes.count()>K) { xarray& nodes=routes[i]->nodes; int q_num=PingQuestionable(nodes,nodes.count()-K); if(nodes.count()>K+q_num) routes[i]->RemoveNode(K); // too may candidates, trim one } } // remove bad peers for(KnownTorrent *t=torrents.each_begin(); t; t=torrents.each_next()) { xarray_p& p=t->peers; int seeds=0; for(int i=0; iIsGood()) p.remove(i--); else seeds+=p[i]->seed; } LogNote(9,"torrent %s has %d known peers (%d seeds)", torrents.each_key().hexdump(),p.count(),seeds); if(p.count()==0) torrents.remove(torrents.each_key()); } nodes_cleanup_timer.Reset(); if(save_timer.Stopped()) { Save(); save_timer.Reset(); } if(nodes.count()>0 && routes[0]->nodes.count()<2 && search.count()==0) Bootstrap(); // lost almost all nodes, try to bootstrap again } if(refresh_timer.Stopped()) { for(int i=0; iIsFresh()) { LogNote(9,"refreshing route bucket %d",i); // make random id in the range int bytes=routes[i]->prefix_bits/8; int bits=routes[i]->prefix_bits%8; xstring random_id(routes[i]->prefix.get(),bytes+(bits>0)); unsigned mask=(1<<(8-bits))-1; if(bits>0) random_id.get_non_const()[bytes]|=(random()/13)&mask; while(random_id.length()<20) random_id.append(char(random()/13)); StartSearch(new Search(random_id)); routes[i]->fresh_timer.Reset(); } } refresh_timer.Reset(); } // manual bootstrapping if(resolver) { if(resolver->Error()) { LogError(1,"%s",resolver->ErrorMsg()); resolver=0; m=MOVED; } else if(resolver->Done()) { const xarray& r=resolver->Result(); for(int i=0; iSendPing(r[i]); resolver=0; m=MOVED; } } if(!state_io && !resolver && bootstrap_nodes.count()>0) { xstring &b=*bootstrap_nodes.next(); ParsedURL u(b); if(u.proto==0 && u.host) resolver=new Resolver(u.host,u.port,"6881"); m=MOVED; } if(send_queue.count()>0 && MaySendMessage()) { SendMessage(send_queue.next().borrow()); m=MOVED; } return m; } BeNode *DHT::NewQuery(const char *q,xmap_p& a) { xmap_p m; BeNode *n=new BeNode((const char*)&t,sizeof(t)); m.add("t",n); t++; m.add("y",new BeNode("q",1)); m.add("q",new BeNode(q)); a.add("id",new BeNode(node_id)); m.add("a",new BeNode(&a)); return new BeNode(&m); } BeNode *DHT::NewReply(const xstring& t0,xmap_p& r) { xmap_p m; m.add("t",new BeNode(t0)); m.add("y",new BeNode("r",1)); r.add("id",new BeNode(node_id)); m.add("r",new BeNode(&r)); return new BeNode(&m); } BeNode *DHT::NewError(const xstring& t0,int code,const char *msg) { xmap_p m; m.add("t",new BeNode(t0)); m.add("y",new BeNode("e",1)); xarray_p e; e.append(new BeNode(code)); e.append(new BeNode(msg)); m.add("e",new BeNode(&e)); return new BeNode(&m); } const char *DHT::MessageType(BeNode *q) { const xstring& y=q->lookup_str("y"); const char *msg_type="message"; if(y.eq("q")) msg_type=q->lookup_str("q"); else if(y.eq("r")) msg_type="response"; else if(y.eq("e")) msg_type="error"; return msg_type; } void DHT::SendMessage(BeNode *q,const sockaddr_u& a,const xstring& id) { if(send_queue.count()>MAX_SEND_QUEUE) { LogError(9,"tail dropping output message"); delete q; return; } send_queue.push(new Request(q,a,id)); } void DHT::SendMessage(Request *req) { req->expire_timer.Reset(); BeNode *q=req->data.get_non_const(); const sockaddr_u& a=req->addr; LogSend(4,xstring::format("sending DHT %s to %s %s",MessageType(q), a.to_string(),q->Format1())); int res=-1; res=Torrent::GetUDPSocket(af)->SendUDP(a,q->Pack()); if(res!=-1 && q->lookup_str("y").eq("q")) { sent_req.add(q->lookup_str("t"),req); rate_limit.BytesPut(res); } else { delete req; } } bool DHT::MaySendMessage() { return rate_limit.BytesAllowedToPut()>=256 && Torrent::GetUDPSocket(af)->MaySendUDP(); } void DHT::SendPing(const sockaddr_u& a,const xstring& id) { if(a.port()==0 || a.is_private() || a.is_reserved() || a.is_multicast()) return; Enter(); xmap_p arg; SendMessage(NewQuery("ping",arg),a,id); Leave(); } void DHT::SendPing(Node *n) { SendPing(n->addr,n->id); n->ping_timer.Reset(); } void DHT::AnnouncePeer(const Torrent *t) { const xstring& info_hash=t->GetInfoHash(); // check for duplicated announce if(search.exists(info_hash)) return; Enter(); Search *s=new Search(info_hash); s->WantPeers(t->Complete()); #if INET6 // try to find nodes in the other AF if needed if(Torrent::GetDHT(af==AF_INET?AF_INET6:AF_INET)->nodes.count()<1) s->Bootstrap(); #endif StartSearch(s); Leave(); } void DHT::DenouncePeer(const Torrent *t) { // remove any search for this torrent search.remove(t->GetInfoHash()); } int DHT::AddNodesToReply(xmap_p &r,const xstring& target,int max_count) { xarray n; FindNodes(target,n,max_count,true); xstring compact_nodes; for(int i=0; iid); compact_nodes.append(n[i]->addr.compact()); } r.add(af==AF_INET?"nodes":"nodes6",new BeNode(compact_nodes)); return n.count(); } int DHT::AddNodesToReply(xmap_p &r,const xstring& target,bool want_n4,bool want_n6) { int nodes_count=0; if(want_n4) nodes_count+=Torrent::GetDHT(AF_INET)->AddNodesToReply(r,target,K); if(want_n6) nodes_count+=Torrent::GetDHT(AF_INET6)->AddNodesToReply(r,target,K); return nodes_count; } const xstring& DHT::Node::GetToken() { if(!my_token || token_timer.Stopped()) { // make new token my_last_token.set(my_token); my_token.truncate(); for(int i=0; i<16; i++) my_token.append(char(random()/13)); token_timer.Reset(); } return my_token; } bool DHT::Node::TokenIsValid(const xstring& token) const { if(!token || !my_token || token_timer.Stopped()) return false; return token.eq(my_token) || token.eq(my_last_token); } const xstring& DHT::Request::GetSearchTarget() const { const BeNode *a=data->lookup("a",BeNode::BE_DICT); if(!a) return xstring::null; const xstring& q=data->lookup_str("q"); const char *target=q.eq("find_node")?"target":"info_hash"; return a->lookup_str(target); } void DHT::HandlePacket(BeNode *p,const sockaddr_u& src) { LogRecv(4,xstring::format("received DHT %s from %s %s",MessageType(p), src.to_string(),p->Format1())); int pkt_len=p->str.length(); if(rate_limit.BytesAllowedToGet()lookup_str("t"); if(!t) return; const xstring& y=p->lookup_str("y"); if(!y) return; if(y.eq("q")) { const xstring& q=p->lookup_str("q"); if(!q) return; BeNode *a=p->lookup("a",BeNode::BE_DICT); if(!a) return; const xstring& id=a->lookup_str("id"); if(id.length()!=20) return; Node *node=FoundNode(id,src,false); if(!node) return; xmap_p r; if(src.family()==AF_INET) r.add("ip",new BeNode(src.compact_addr())); bool want_n4=false; bool want_n6=false; BeNode *want=a->lookup("want",BeNode::BE_LIST); if(want) { for(int i=0; ilist.count(); i++) { BeNode *w=want->list[i]; if(w->type!=BeNode::BE_STR) continue; if(w->str.eq("n4")) want_n4=true; if(w->str.eq("n6")) want_n6=true; } } if(!want_n4 && !want_n6) { want_n4=(src.family()==AF_INET); want_n6=(src.family()==AF_INET6); } if(q.eq("ping")) { LogSend(5,xstring::format("DHT ping reply to %s",src.to_string())); SendMessage(NewReply(t,r),src); } else if(q.eq("find_node")) { const xstring& target=a->lookup_str("target"); if(!target) return; int nodes_count=AddNodesToReply(r,target,want_n4,want_n6); LogSend(5,xstring::format("DHT find_node reply with %d nodes to %s",nodes_count,src.to_string())); SendMessage(NewReply(t,r),src); } else if(q.eq("get_peers")) { const xstring& info_hash=a->lookup_str("info_hash"); if(info_hash.length()!=20) return; bool noseed=a->lookup_int("noseed"); KnownTorrent *torrent=torrents.lookup(info_hash); int nodes_count=0; int values_count=0; if(!torrent || torrent->peers.count()==0) { nodes_count=AddNodesToReply(r,info_hash,want_n4,want_n6); } else { xarray_p& p=torrent->peers; xarray_p values; for(int i=0; iseed) continue; if(!peer->IsGood()) continue; if(peer->compact_addr.family()==AF_INET && !want_n4) continue; #if INET6 if(peer->compact_addr.family()==AF_INET6 && !want_n6) continue; #endif values.append(new BeNode(peer->compact_addr)); values_count++; } if(values_count>0) r.add("values",new BeNode(&values)); else nodes_count=AddNodesToReply(r,info_hash,want_n4,want_n6); } r.add("token",new BeNode(node->GetToken())); LogSend(5,xstring::format("DHT get_peers reply with %d values and %d nodes to %s", values_count,nodes_count,src.to_string())); SendMessage(NewReply(t,r),src); } else if(q.eq("announce_peer")) { // need a valid token if(!node->TokenIsValid(a->lookup_str("token"))) { SendMessage(NewError(t,ERR_PROTOCOL,"invalid token"),src); return; } // ok, token is valid. Now add the peer. const xstring& info_hash=a->lookup_str("info_hash"); if(info_hash.length()!=20) return; int port=a->lookup_int("port"); if(!port) return; bool seed=a->lookup_int("seed"); sockaddr_u peer_addr(src); peer_addr.set_port(port); AddPeer(info_hash,peer_addr.compact(),seed); SendMessage(NewReply(t,r),src); } else if(q.eq("vote")) { #if 0 // need a valid token if(!node->TokenIsValid(a->lookup_str("token"))) { SendMessage(NewError(t,ERR_PROTOCOL,"invalid token"),src); return; } // target is sha1(info_hash+"rating") const xstring& target=a->lookup_str("target"); if(target.length()!=20) return; unsigned vote=a->lookup_int("vote"); // store the vote // return what? SendMessage(NewReply(t,r),src); #endif } else { SendMessage(NewError(t,ERR_UNKNOWN_METHOD,"method unknown"),src); } return; } Ref req(sent_req.borrow(t)); if(!req) { LogError(2,"got DHT reply with unknown `t' from %s",src.to_string()); return; } if(req->addr!=src) { LogError(2,"got DHT reply from %s instead of %s",src.to_string(),req->addr.to_string()); return; } const xstring& q=req->data->lookup_str("q"); if(y.eq("r")) { BeNode *r=p->lookup("r",BeNode::BE_DICT); if(!r) return; const xstring& id=r->lookup_str("id"); if(id.length()!=20) return; const sockaddr_compact& ip=sockaddr_compact::cast(r->lookup_str("ip")); if(ip && !ValidNodeId(node_id,ip)) { if(!ip_voted.lookup(src.compact_addr())) { sockaddr_u reported_ip(ip); LogNote(2,"%s reported our IP as %s",src.to_string(),reported_ip.address()); unsigned& votes=ip_votes.lookup_Lv(ip); votes++; if(votes>=4) { // we have incorrect node_id, restart with correct one. MakeNodeId(node_id,ip); LogNote(0,"restarting DHT with new id %s",node_id.hexdump()); Restart(); } } } FoundNode(id,src,true); if(q.eq("get_peers")) { const xstring& info_hash=req->GetSearchTarget(); Torrent *torrent=Torrent::FindTorrent(info_hash); BeNode *values=r->lookup("values",BeNode::BE_LIST); if(values) { // some peers found. for(int i=0; ilist.count(); i++) { if(values->list[i]->type!=BeNode::BE_STR) continue; const sockaddr_compact &c=sockaddr_compact::cast(values->list[i]->str); sockaddr_u a(c); if(!a.port()) continue; LogNote(9,"found peer %s for info_hash=%s",a.to_string(),info_hash.hexdump()); if(torrent) torrent->AddPeer(new TorrentPeer(torrent,&a,TorrentPeer::TR_DHT)); } } const xstring& token=r->lookup_str("token"); if(token && torrent) { if(!ValidNodeId(id,src.compact_addr())) LogError(2,"warning: node id %s is invalid for %s",id.hexdump(),src.address()); // announce the torrent int port=torrent->GetPortIPv4(); #if INET6 if(src.family()==AF_INET6) port=torrent->GetPortIPv6(); #endif xmap_p a; a.add("info_hash",new BeNode(info_hash)); a.add("port",new BeNode(port)); a.add("token",new BeNode(token)); if(torrent->Complete()) a.add("seed",new BeNode(1)); SendMessage(NewQuery("announce_peer",a),src,id); torrent->DHT_Announced(src.family()); } } if(q.eq("find_node") || q.eq("get_peers")) { const xstring& target=req->GetSearchTarget(); const xstring &node_id=req->GetNodeId(); LogNote(9,"got reply for %s with target %s from node %s",q.get(),target.hexdump(),node_id.hexdump()); Search *s=search.lookup(target); if(s && s->IsFeasible(node_id)) { s->best_node_id.set(node_id); s->depth++; LogNote(9,"search for %s goes to depth=%d with best_node_id=%s", s->target_id.hexdump(),s->depth,node_id.hexdump()); } const xstring& nodes=r->lookup_str("nodes"); if(nodes) { LogNote(9,"adding %d nodes",(int)nodes.length()/26); const char *data=nodes; int len=nodes.length(); while(len>=26) { xstring id(data,20); sockaddr_u a; a.set_compact(data+20,6); data+=26; len-=26; FoundNode(id,a,false,s); } } #if INET6 const xstring& nodes6=r->lookup_str("nodes6"); if(nodes6) { LogNote(9,"adding %d nodes6",(int)nodes6.length()/38); const char *data=nodes6; int len=nodes6.length(); while(len>=38) { xstring id(data,20); sockaddr_u a; a.set_compact(data+20,18); data+=38; len-=38; FoundNode(id,a,false,s); } } #endif //INET6 } } else if(y.eq("e")) { int code=0; const char *msg="unknown"; BeNode *e=p->lookup("e",BeNode::BE_LIST); if(e) { if(e->list.count()>=1 && e->list[0]->type==BeNode::BE_INT) code=e->list[0]->num; if(e->list.count()>=2 && e->list[1]->type==BeNode::BE_STR) msg=e->list[1]->str; } LogError(2,"got DHT error for %s (%d: %s) from %s",q.get(),code,msg,src.to_string()); } } bool DHT::Search::IsFeasible(const xstring &id) const { if(!best_node_id) return true; for(int i=0; i<20; i++) { unsigned char a=id[i]^target_id[i]; unsigned char b=best_node_id[i]^target_id[i]; if(ab) return false; } return false; } void DHT::Search::ContinueOn(DHT *d,const Node *n) { if(searched.exists(n->id)) { LogNote(9,"skipping search on %s, already searched",n->GetName()); return; } LogNote(3,"search for %s continues on %s (%s) depth=%d", target_id.hexdump(),n->id.hexdump(),n->GetName(),depth); xmap_p a; #if INET6 if(bootstrap) { xarray_p want; want.append(new BeNode("n4")); want.append(new BeNode("n6")); a.add("want",new BeNode(&want)); } #endif if(!want_peers) { a.add("target",new BeNode(target_id)); d->SendMessage(d->NewQuery("find_node",a),n->addr,n->id); } else { a.add("info_hash",new BeNode(target_id)); if(noseed) a.add("noseed",new BeNode(1)); d->SendMessage(d->NewQuery("get_peers",a),n->addr,n->id); } searched.add(n->id,true); search_timer.Reset(); } void DHT::StartSearch(Search *s) { LogNote(9,"starting search for %s",s->target_id.hexdump()); xarray n; FindNodes(s->target_id,n,K,true); if(n.count()==0) { LogError(2,"no good nodes found in the routing table"); FindNodes(s->target_id,n,K,false); } for(int i=0; iContinueOn(this,n[i]); search.add(s->target_id,s); } void DHT::RestartSearch(Search *s) { xarray n; FindNodes(s->target_id,n,K,true); for(int i=0; iContinueOn(this,n[i]); } DHT::Node *DHT::FoundNode(const xstring& id,const sockaddr_u& a,bool responded,Search *s) { if(a.port()==0 || a.is_private() || a.is_reserved() || a.is_multicast()) { LogError(9,"node address %s is not valid",a.to_string()); return 0; } if(a.family()!=af) { assert(!responded); // we should not get replies from different AF const SMTaskRef& d=Torrent::GetDHT(a); d->Enter(); d->FoundNode(id,a,false); d->Leave(); return 0; } Node *n=nodes.lookup(id); if(!n) { n=node_by_addr.lookup(a.compact()); if(n) { ChangeNodeId(n,id); } else { n=new Node(id,a); AddNode(n); } } else { AddRoute(n); } if(responded) { n->responded=true; n->ResetLostPing(); } if(n->responded) n->SetGood(); // continue search if(s && s->IsFeasible(n)) s->ContinueOn(this,n); return n; } void DHT::RemoveNode(Node *n) { RemoveRoute(n); node_by_addr.remove(n->addr.compact()); nodes.remove(n->id); } void DHT::ChangeNodeId(Node *n,const xstring& new_node_id) { LogNote(1,"node_id changed for %s, old_node_id=%s, new_node_id=%s", n->GetName(),n->id.hexdump(),new_node_id.hexdump()); // change node_id in the in-flight requests for(Request *r=sent_req.each_begin(); r; r=sent_req.each_next()) { if(r->node_id.eq(n->id) && r->addr==n->addr) r->node_id.set(new_node_id); } RemoveRoute(n); nodes.borrow(n->id); // borrow to avoid freeing the node n->id.set(new_node_id); nodes.add(n->id,n); AddRoute(n); } void DHT::AddNode(Node *n) { assert(n->id.length()==20); assert(!nodes.exists(n->id)); assert(!node_by_addr.exists(n->addr.compact())); nodes.add(n->id,n); node_by_addr.add(n->addr.compact(),n); AddRoute(n); if(nodes.count()==1 && search.count()==0) Bootstrap(); } int DHT::FindRoute(const xstring& id,int i) { // routes are ordered by prefix length decreasing // the first route bucket always matches our node_id for( ; iPrefixMatch(id)) { return i; } } return -1; } void DHT::RemoveRoute(Node *n) { int i=FindRoute(n->id); if(i==-1) return; routes[i]->RemoveNode(n); } void DHT::AddRoute(Node *n) { int i=FindRoute(n->id); if(i==-1) { assert(routes.count()==0); routes.append(new RouteBucket(0,xstring::null)); i=0; } try_again: const Ref& r=routes[i]; xarray &nodes=r->nodes; // check if the node is already in the bucket for(int j=0; jSetFresh(); nodes.remove(j); if(nodes.count()=K) { for(int j=0; jIsBad()) { r->RemoveNode(j); break; } } } // prefer responded nodes if(i>0 && nodes.count()>=K && n->responded) { for(int j=0; jresponded) { r->RemoveNode(j); break; } } } // remove a non-good and not responded node to free space if(i>0 && nodes.count()>=K) { for(int j=0; jIsGood() && !nodes[j]->responded) { r->RemoveNode(j); break; } } } if(nodes.count()>=K && i==0 && r->prefix_bits<160) { // split the bucket int bits=r->prefix_bits; size_t byte=bits/8; unsigned mask = 1<<(7-bits%8); if(r->prefix.length()<=byte) r->prefix.append('\0'); xstring p1(r->prefix.copy()); xstring p2(r->prefix.copy()); p1.get_non_const()[byte]&=~mask; p2.get_non_const()[byte]|=mask; RouteBucket *b1=new RouteBucket(bits+1,p1); RouteBucket *b2=new RouteBucket(bits+1,p2); for(int j=0; jid[byte]&mask) b2->nodes.append(nodes[j]); else b1->nodes.append(nodes[j]); } if(node_id[byte]&mask) { routes[0]=b2; routes.insert(b1,1); i=(n->id[byte]&mask)?0:1; } else { routes[0]=b1; routes.insert(b2,1); i=(n->id[byte]&mask)?1:0; } LogNote(9,"splitted route bucket 0"); LogNote(9,"new route[0] prefix=%s",routes[0]->to_string()); LogNote(9,"new route[1] prefix=%s",routes[1]->to_string()); assert(routes[0]->PrefixMatch(node_id)); goto try_again; } if(nodes.count()>=K) { int q_num=PingQuestionable(nodes,nodes.count()-K+1); // check if we have already candidates for the questionable nodes if(nodes.count()>=K+q_num) { LogNote(9,"skipping node %s (too many in route bucket %d)",n->GetName(),i); return; } } r->SetFresh(); LogNote(3,"adding node %s to route bucket %d (prefix=%s)",n->GetName(),i,r->to_string()); n->in_routes=true; nodes.append(n); } int DHT::PingQuestionable(const xarray& nodes,int limit) { int q_num=0; // ping questionable nodes, return the number of questionable nodes for(int j=0; jIsGood()) { q_num++; if(n->ping_timer.Stopped()) SendPing(n); } } return q_num; } void DHT::RouteBucket::RemoveNode(Node *n) { for(int j=0; j=0 && iin_routes=false; nodes.remove(i); } bool DHT::RouteBucket::PrefixMatch(const xstring& id) const { int bytes=prefix_bits/8; int bits=prefix_bits%8; unsigned mask=~((1<<(8-bits))-1); if(bytes>0 && memcmp(prefix.get(),id.get(),bytes)) return false; if(bits>0 && (prefix[bytes]&mask)!=(id[bytes]&mask)) return false; return true; } const char *DHT::RouteBucket::to_string() const { xstring &buf=xstring::get_tmp("",0); prefix.hexdump_to(buf); buf.truncate((prefix_bits+3)/4); buf.append('/'); buf.appendf("%d",prefix_bits); return buf; } void DHT::FindNodes(const xstring& target_id,xarray &a,int max_count,bool only_good) { a.truncate(); int i=0; while(a.count() &nodes=routes[i]->nodes; int limit=max_count-a.count(); for(int j=0; j0; j++) { if(!nodes[j]->IsBad() && (!only_good || nodes[j]->IsGood())) { a.append(nodes[j]); limit--; } } i++; } } void DHT::AddPeer(const xstring& info_hash,const sockaddr_compact& a,bool seed) { KnownTorrent *t=torrents.lookup(info_hash); if(!t) { if(torrents.count()>=MAX_TORRENTS) { // remove random torrent int r=random()/13%torrents.count(); int i=0; for(torrents.each_begin(); ; torrents.each_next(), i++) { if(i==r) { torrents.remove(torrents.each_key()); break; } } } torrents.add(info_hash,t=new KnownTorrent()); } t->AddPeer(new Peer(a,seed)); sockaddr_u addr(a); LogNote(9,"added peer %s to torrent %s",addr.to_string(),info_hash.hexdump()); } void DHT::KnownTorrent::AddPeer(Peer *peer) { for(int i=0; icompact_addr.eq(peer->compact_addr)) { peers.remove(i); break; } } if(peers.count()>=MAX_PEERS) peers.remove(0); peers.append(peer); } void DHT::MakeNodeId(xstring &id,const sockaddr_compact& ip,int r) { // http://www.rasterbar.com/products/libtorrent/dht_sec.html static char v4mask[] = { 0x01, 0x07, 0x1f, 0x7f }; static char v6mask[] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f }; char *mask=(ip.length()==4?v4mask:v6mask); int len=(ip.length()==4?sizeof(v4mask):sizeof(v6mask)); int i; xstring seed; for(i=0; iIsGood()) AddRoute(n); } } void DHT::Save(const SMTaskRef& buf) { xmap_p state; state.add("id",new BeNode(node_id)); int count=0; int responded_count=0; xstring compact_nodes; for(Node *n=nodes.each_begin(); n; n=nodes.each_next()) { if(n->IsGood() || n->in_routes) { compact_nodes.append(n->id); compact_nodes.append(n->addr.compact()); count++; responded_count+=n->responded; } } LogNote(9,"saving state, %d nodes (%d responded)",count,responded_count); if(compact_nodes) state.add("nodes",new BeNode(compact_nodes)); BeNode(&state).Pack(buf); for(int i=0; inodes.count(),r->to_string()); } } void DHT::Load(const SMTaskRef& buf) { int rest; Ref state(BeNode::Parse(buf->Get(),buf->Size(),&rest)); if(!state || state->type!=BeNode::BE_DICT) return; const xstring& b_id=state->lookup_str("id"); if(b_id.length()==20) { node_id.set(b_id); Restart(); } const xstring& nodes=state->lookup_str("nodes"); if(!nodes) return; const char *data=nodes; int len=nodes.length(); const int addr_len=(af==AF_INET?6:18); const int node_len=20+addr_len; while(len>=node_len) { xstring id(data,20); sockaddr_u a; a.set_compact(data+20,addr_len); data+=node_len; len-=node_len; FoundNode(id,a,false); // loaded node is not good by default (learned long ago). Node *n=DHT::nodes.lookup(id); if(n) { n->good_timer.Stop(); n->ping_timer.Stop(); } } // refresh routes after loading for(int i=0; ifresh_timer.StopDelayed(i+3); } void DHT::Save() { if(!state_file) return; FileStream *f=new FileStream(state_file,O_WRONLY|O_TRUNC|O_CREAT); f->set_lock(); f->set_create_mode(0600); state_io=new IOBufferFDStream(f,IOBuffer::PUT); Save(state_io); state_io->PutEOF(); } void DHT::Load() { if(!state_file) return; FileStream *f=new FileStream(state_file,O_RDONLY); f->set_lock(); state_io=new IOBufferFDStream(f,IOBuffer::GET); state_io->Roll(); Roll(); } void DHT::Reconfig(const char *name) { rate_limit.Reconfig(name,"DHT"); } lftp-4.6.3a/src/fg.cc0000644000015000007670000000304312122057350011242 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include "trio.h" #include "fg.h" void FgData::cont() { if(!pg) return; if(kill(-pg,SIGCONT)==-1) kill(pg,SIGCONT); } FgData::FgData(pid_t npg,bool fg) { old_pgrp=0; pg=npg; if(!pg) return; if(fg) Fg(); else cont(); } FgData::~FgData() { if(old_pgrp) Bg(); } void FgData::Fg() { if(!pg) return; pid_t tc_grp=tcgetpgrp(0); if(tc_grp==-1 || tc_grp==getpgrp()) { old_pgrp=getpgrp(); #ifdef FG_DEBUG printf("fg: tcsetpgrp(%d)\n",(int)pg); #endif tcsetpgrp(0,pg); } cont(); } void FgData::Bg() { if(old_pgrp) { #ifdef FG_DEBUG printf("bg: tcsetpgrp(%d)\n",(int)old_pgrp); #endif tcsetpgrp(0,old_pgrp); old_pgrp=0; } } lftp-4.6.3a/src/misc.h0000644000015000007670000001037112513707112011447 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef MISC_H #define MISC_H #include "trio.h" #include #include #ifdef TIME_WITH_SYS_TIME # include #endif #include #include "xstring.h" // expands tilde; returns pointer to static data const char *expand_home_relative(const char *); // returns ptr to last path element const char *basename_ptr(const char *); static inline char *basename_ptr(char *f) { return const_cast(basename_ptr(const_cast(f))); } // glues file to dir; returns pointer to static storage const char *dir_file(const char *dir,const char *file); // glues file to given url; returns pointer to static storage const char *url_file(const char *url,const char *file); const char *output_file_name(const char *src,const char *dst,bool dst_local, const char *dst_base,bool make_dirs); const char *squeeze_file_name(const char *name,int w); // mkdir -p int create_directories(char *); // rm -rf void truncate_file_tree(const char *dir); /* returns file descriptor terminal width; -1 on error, 0 on N/A */ int fd_width(int fd); /* returns true if current pgrp is the foreground pgrp of controlling tty * or if the fg pgrp is unknown */ bool in_foreground_pgrp(); // returns malloc'ed cwd no matter how long it is // returns 0 on error. char *xgetcwd(); int percent(off_t offset,off_t size); #define find_char(buf,len,ch) ((const char *)memchr(buf,ch,len)) extern const char month_names[][4]; int parse_month(const char *); int parse_perms(const char *); const char *format_perms(int p); int parse_year_or_time(const char *year_or_time,int *year,int *hour,int *minute); int guess_year(int month,int day,int hour,int minute); time_t mktime_from_utc(const struct tm *); time_t mktime_from_tz(struct tm *,const char *tz); bool re_match(const char *line,const char *a,int flags=0); struct subst_t { char from; const char *to; }; /* Subst changes escape sequences to given strings, also substitutes \nnn * with corresponding character. Returns allocated buffer to be free'd */ char *Subst(const char *txt, const subst_t *s); /* uses gettimeofday if available */ void xgettimeofday(time_t *sec, int *usec); /* returns malloc'd date */ char *xstrftime(const char *format, const struct tm *tm); const char *xhuman(long long n); void strip_trailing_slashes(xstring& fn); xstring& dirname_modify(xstring& fn); xstring& dirname(const char *path); // returns a tmp /* returns last character of string or \0 if string is empty */ char last_char(const char *str); int base64_length (int len); void base64_encode (const char *s, char *store, int length); bool temporary_network_error(int e); CDECL const char *get_home(); CDECL const char *get_lftp_config_dir(); CDECL const char *get_lftp_data_dir(); CDECL const char *get_lftp_cache_dir(); const char *memrchr(const char *buf,char c,size_t len); static inline char *memrchr(char *buf,char c,size_t len) { return const_cast(memrchr(const_cast(buf),c,len)); } bool is_shell_special(char c); const xstring& shell_encode(const char *s,int len); static inline const xstring& shell_encode(const char *s) { return shell_encode(s,strlen(s)); } static inline const xstring& shell_encode(const xstring& s) { return shell_encode(s.get(),s.length()); } void remove_tags(char *buf); void rtrim(char *s); void random_init(); double random01(); const char *get_nodename(); const char *xidna_to_ascii(const char *name); bool xtld_name_ok(const char *name); bool is_ipv4_address(const char *); bool is_ipv6_address(const char *); #endif // MISC_H lftp-4.6.3a/src/Filter.h0000644000015000007670000001005612500302231011726 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FILTER_H #define FILTER_H #include "ProcWait.h" #include "ArgV.h" struct FileTimestamp; class FDStream { bool close_when_done; protected: bool closed; void DoCloseFD(); void SetFD(int new_fd,bool c); public: int fd; xstring_c name; xstring_c full_name; xstring_c cwd; xstring error_text; const char *status; bool error() { return error_text!=0; } virtual int getfd() { return fd; } bool is_closed() const { return closed; } FDStream(); FDStream(int new_fd,const char *new_name); virtual ~FDStream(); void MakeErrorText(int e=0); bool NonFatalError(int err); void set_status(const char *str) { status=str; } void clear_status() { status=0; } void CloseWhenDone() { close_when_done=true; } void SetCwd(const char *); const char *GetCwd() const { return cwd; } virtual off_t get_size() { return -1; } virtual void setmtime(const FileTimestamp &) {} virtual bool can_setmtime() { return false; } virtual void remove_if_empty() {} virtual void remove() {} virtual bool Done(); virtual bool usesfd(int n_fd) { return fd==n_fd; } virtual void Kill(int=SIGTERM) {} virtual pid_t GetProcGroup() const { return 0; } virtual bool broken() { return false; } virtual bool can_seek() { return false; } }; class OutputFilter : public FDStream { Ref a; ProcWait *w; pid_t pg; Ref my_second; const Ref& second; bool stderr_to_stdout; bool stdout_to_null; void Init(); virtual void Parent(int *p); // what to do with pipe if parent virtual void Child (int *p); // same for child protected: int second_fd; public: OutputFilter(const char *filter,int second_fd=-1); OutputFilter(const char *filter,FDStream *second); OutputFilter(const char *filter,const Ref& second); OutputFilter(ArgV *a,int second_fd=-1); OutputFilter(ArgV *a,FDStream *second); OutputFilter(ArgV *a,const Ref& second); virtual ~OutputFilter(); void StderrToStdout() { stderr_to_stdout=true; } void StdoutToNull() { stdout_to_null=true; } int getfd(); bool Done(); bool usesfd(int n_fd); void Kill(int sig=SIGTERM); pid_t GetProcGroup() const { return pg; } void SetProcGroup(pid_t new_pg) { pg=new_pg; } ProcWait::State GetProcState() { return w->GetState(); } int GetProcExitCode() { return w->GetInfo()>>8; } bool broken(); }; class InputFilter : public OutputFilter { virtual void Parent(int *p); virtual void Child (int *p); public: InputFilter(const char *filter,int second_fd=-1) : OutputFilter(filter,second_fd) {} InputFilter(const char *filter,FDStream *second) : OutputFilter(filter,second) {} InputFilter(ArgV *a,int second_fd=-1) : OutputFilter(a,second_fd) {} InputFilter(ArgV *a,FDStream *second) : OutputFilter(a,second) {} }; class FileStream : public FDStream { int mode; int create_mode; bool do_lock; public: FileStream(const char *fname,int open_mode); ~FileStream(); void setmtime(const FileTimestamp &); bool can_setmtime() { return true; } void remove_if_empty(); void remove(); int getfd(); bool can_seek(); off_t get_size(); void set_lock(bool flag=true) { do_lock=flag; } void set_create_mode(int m) { create_mode=m; } }; #endif /* FILTER_H */ lftp-4.6.3a/src/OutputJob.h0000644000015000007670000000665512244564320012464 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef OUTPUTJOB_H #define OUTPUTJOB_H #include "Job.h" #include "FileCopy.h" #include "CopyJob.h" #include "Timer.h" class StatusBar; class OutputJob : public Job { /* Main CopyJob: */ CopyJob *input; /* CopyJob that sends to the output. (output may be equal to input) */ CopyJob *output; Ref tmp_buf; // to store data while !initialized Ref output_fd; // to initialize CopyJobs FileAccessRef fa; xstring_c fa_path; bool initialized; xstring_c a0; xstring_c filter; bool error; bool is_stdout; bool fail_if_broken; bool statusbar_redisplay; int width; bool is_a_tty; /* if true, we never contribute to the parent job's status * (Status() == "") */ bool no_status; Timer update_timer; void Init(const char *a0); void InitCopy(); /* Get the input FileCopyPeer */ const SMTaskRef& InputPeer() const; /* Get the output FileCopyPeer (the FileCopyPeer that's doing the final output) */ const SMTaskRef& OutputPeer() const; public: OutputJob(FDStream *output, const char *a0); OutputJob(const char *path, const char *a0, FA *fa=0); void PrepareToDie(); /* Set the main filter: */ void SetFilter(const char *f) { filter.set(f); } /* Prepend a filter before the main filter: */ void PreFilter(const char *f); void DontFailIfBroken(bool y=true) { fail_if_broken=!y; } bool Error(); int Done(); int Do(); void Put(const char *buf,int size); void Put(const char *buf) { Put(buf,strlen(buf)); } void Put(const xstring& str) { Put(str.get(),str.length()); } void Format(const char *f,...) PRINTF_LIKE(2,3); void PutEOF(); /* If sending large amounts of data, call this function and stop * sending if it returns true. (This always accept more input; * this is optional.) */ bool Full(); /* Get properties of the output: */ int GetWidth() const; bool IsTTY() const; /* Whether the ultimate destination is stdout: */ bool IsStdout() const { return is_stdout; } /* Whether the output is filtered: */ bool IsFiltered() const { return filter; } /* Call before showing a StatusLine on a job using this class. If it * returns false, don't display it. */ bool ShowStatusLine(const SMTaskRef&); /* For commands that stream output from servers, redisplaying the * statusbar when output becomes idle can be annoying, especially * if the line is rate-limited. */ void DontRedisplayStatusbar() { statusbar_redisplay=false; } const char *Status(const StatusLine *s); void Fg(); void Bg(); void SuspendInternal(); void ResumeInternal(); int AcceptSig(int sig); }; #endif lftp-4.6.3a/src/PatternSet.h0000644000015000007670000000427712210074447012617 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef EXCLUDE_H #define EXCLUDE_H #include CDECL_BEGIN #include CDECL_END #include "xstring.h" class PatternSet { public: enum Type { EXCLUDE,INCLUDE }; class Pattern { protected: xstring_c pattern; public: virtual bool Match(const char *str)=0; Pattern(const char *str) : pattern(str) {} virtual ~Pattern() {} }; private: class PatternLink { friend class PatternSet; Type type; Pattern *pattern; PatternLink *next; PatternLink(Type t,Pattern *p,PatternLink *n) { type=t; pattern=p; next=n; } ~PatternLink() { delete pattern; } }; PatternLink *chain; PatternLink *first; public: PatternSet(); ~PatternSet(); void Add(Type,Pattern *); void AddFirst(Type,Pattern *); Type GetFirstType() const; bool Match(Type t,const char *str) const; bool MatchExclude(const char *str) const { return Match(EXCLUDE,str); } bool MatchInclude(const char *str) const { return Match(INCLUDE,str); } class Regex : public Pattern { regex_t compiled; xstring error; public: Regex(const char *str); bool Error() { return error!=0; } const char *ErrorText() { return error; } bool Match(const char *str); ~Regex(); }; class Glob : public Pattern { int slash_count; public: Glob(const char *p); bool Match(const char *str); }; }; #endif lftp-4.6.3a/src/buffer_zlib.cc0000644000015000007670000000544312410743014013144 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "buffer_zlib.h" void DataInflator::PutTranslated(Buffer *target,const char *put_buf,int size) { bool from_untranslated=false; if(Size()>0) { Put(put_buf,size); Get(&put_buf,&size); from_untranslated=true; } // process all data we can, save the rest in the untranslated buffer while(size>0) { if(z_err==Z_STREAM_END) { // assume the data after the compressed stream are not compressed. target->Put(put_buf,size); if(from_untranslated) Skip(size); return; } size_t put_size=size; int size_coeff=6; size_t store_size=size_coeff*put_size+256; char *store_space=target->GetSpace(store_size); char *store_buf=store_space; // do the inflation z.next_in=(Bytef*)put_buf; z.avail_in=put_size; z.next_out=(Bytef*)store_buf; z.avail_out=store_size; int ret = inflate(&z, Z_NO_FLUSH); assert(ret != Z_STREAM_ERROR); /* state not clobbered */ switch (ret) { case Z_NEED_DICT: ret = Z_DATA_ERROR; /* and fall through */ case Z_DATA_ERROR: case Z_MEM_ERROR: z_err=ret; target->SetError(xstring::cat("zlib inflate error: ",z.msg,NULL),true); return; case Z_STREAM_END: z_err=ret; break; } int inflated_size=store_size-z.avail_out; int processed_size=put_size-z.avail_in; target->SpaceAdd(inflated_size); if(from_untranslated) { Skip(processed_size); Get(&put_buf,&size); } else { put_buf+=processed_size; size-=processed_size; } if(inflated_size==0) { // could not inflate any data, save unprocessed data if(!from_untranslated) Put(put_buf,size); return; } } } DataInflator::DataInflator() { /* allocate inflate state */ z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL; z.avail_in = 0; z.next_in = Z_NULL; z_err = inflateInit2(&z, 16+MAX_WBITS); } DataInflator::~DataInflator() { (void)inflateEnd(&z); } void DataInflator::ResetTranslation() { z_err = inflateReset(&z); } lftp-4.6.3a/src/FileAccess.h0000644000015000007670000003636712455133327012540 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FILEACCESS_H #define FILEACCESS_H #include #include #include "SMTask.h" #include "trio.h" #include "xstring.h" #include "ResMgr.h" #include "FileSet.h" #include "ArgV.h" #include "ProtoLog.h" #include "xlist.h" #include "xmap.h" #include "Timer.h" #define FILE_END ((off_t)-1L) #define UNKNOWN_POS ((off_t)-1L) class ListInfo; class Glob; class NoGlob; class DirList; class FileAccessRef; class Buffer; class FileAccess : public SMTask, public ResClient, protected ProtoLog { static bool class_inited; public: static class LsCache *cache; enum open_mode { CLOSED, RETRIEVE, STORE, LONG_LIST, LIST, MP_LIST, CHANGE_DIR, MAKE_DIR, REMOVE_DIR, REMOVE, QUOTE_CMD, RENAME, ARRAY_INFO, CONNECT_VERIFY, CHANGE_MODE, LINK, SYMLINK, }; class Path { void init(); public: int device_prefix_len; xstring path; bool is_file; xstring url; Path() { init(); } Path(const Path *o) { init(); Set(o); } Path(const Path &o) { init(); Set(o); } Path(const char *new_path) { init(); Set(new_path); } Path(const char *new_path,bool new_is_file,const char *new_url=0,int new_device_prefix_len=0) { init(); Set(new_path,new_is_file,new_url,new_device_prefix_len); } ~Path(); void Set(const Path*); void Set(const Path &o) { Set(&o); } void Set(const char *new_path,bool new_is_file=false,const char *new_url=0,int device_prefix_len=0); void SetURL(const char *u) { url.set(u); } void Change(const char *new_path,bool new_is_file=false,const char *new_path_enc=0,int device_prefix_len=0); const xstring& GetDirectory() const { return is_file?dirname(path):path; } void ExpandTilde(const Path &home); static void Optimize(xstring& p,int dev_prefix=0); void Optimize() { Optimize(path,device_prefix_len); } const Path& operator=(const Path &o) { Set(&o); return *this; } operator const char *() const { return path; } bool operator==(const Path &p2) const; bool operator!=(const Path &p2) const { return !(*this==p2); } }; protected: xstring_c vproto; xstring_c hostname; xstring_c portname; xstring_c user; xstring_c pass; bool pass_open; const char *default_cwd; Path home; Path cwd; Ref new_cwd; xstring file; xstring file_url; xstring file1; int mode; off_t pos; off_t real_pos; off_t limit; FileTimestamp *opt_date; off_t *opt_size; FileSet *fileset_for_info; Timer reconnect_timer; int retries; int max_retries; bool mkdir_p; int saved_errno; void ExpandTildeInCWD(); const char *ExpandTildeStatic(const char *s) const; xstring real_cwd; void set_real_cwd(const char *c) { real_cwd.set(c); } void set_home(const char *h); off_t entity_size; // size of file to be sent time_t entity_date; // date of file to be sent xstring_c closure; const char *res_prefix; const char *ResPrefix() const { return res_prefix?res_prefix:GetProto(); } const char *ResClosure() const { return closure?closure.get():GetHostName(); } int chmod_mode; bool ascii; bool norest_manual; int priority; // higher priority can take over other session. int last_priority; bool Error() { return error_code!=OK; } void ClearError(); void SetError(int code,const char *mess=0); void Fatal(const char *mess); xstring error; int error_code; xstring_c location; xstring_c suggested_filename; void SetSuggestedFileName(const char *fn); xstring_c entity_content_type; xstring_c entity_charset; xstring_c last_disconnect_cause; xlist all_fa_node; static xlist_head all_fa; FileAccess *FirstSameSite() const { return NextSameSite(0); } FileAccess *NextSameSite(FileAccess *) const; StringSet *MkdirMakeSet() const; // splits the path for mkdir -p int device_prefix_len(const char *path) const; virtual ~FileAccess(); public: virtual const char *GetProto() const = 0; // http, ftp, file etc bool SameProtoAs(const FileAccess *fa) const { return !strcmp(GetProto(),fa->GetProto()); } virtual FileAccess *Clone() const = 0; virtual const char *ProtocolSubstitution(const char *host) { return 0; } const char *GetVisualProto() const { return vproto?vproto.get():GetProto(); } void SetVisualProto(const char *p) { vproto.set(p); } const char *GetHome() const { return home; } const char *GetHostName() const { return hostname; } const char *GetUser() const { return user; } const char *GetPassword() const { return pass; } const char *GetPort() const { return portname; } const char *GetConnectURL(int flags=0) const; const char *GetFileURL(const char *file,int flags=0) const; enum { NO_PATH=1,WITH_PASSWORD=2,NO_PASSWORD=4,NO_USER=8 }; const char *GetLastDisconnectCause() const { return last_disconnect_cause; } void Connect(const char *h,const char *p); void ConnectVerify(); void PathVerify(const Path &); virtual void AnonymousLogin(); virtual void Login(const char *u,const char *p); // reset location-related state on Connect/Login/AnonymousLogin virtual void ResetLocationData(); virtual void Open(const char *file,int mode,off_t pos=0); void Open2(const char *f1,const char *f2,open_mode m); void SetFileURL(const char *u); void SetLimit(off_t lim) { limit=lim; } void SetSize(off_t s) { entity_size=s; } void SetDate(time_t d) { entity_date=d; } void WantDate(FileTimestamp *d) { opt_date=d; } void WantSize(off_t *s) { opt_size=s; } void AsciiTransfer() { ascii=true; } virtual void Close(); void Rename(const char *rfile,const char *to) { Open2(rfile,to,RENAME); } void Link(const char *f1,const char *f2) { Open2(f1,f2,LINK); } void Symlink(const char *f1,const char *f2) { Open2(f1,f2,SYMLINK); } void Mkdir(const char *rfile,bool allpath=false); void Chdir(const char *dir,bool verify=true); void ChdirAccept() { cwd=*new_cwd; } void SetCwd(const Path &new_cwd) { cwd=new_cwd; } void Remove(const char *rfile) { Open(rfile,REMOVE); } void RemoveDir(const char *dir) { Open(dir,REMOVE_DIR); } void Chmod(const char *file,int m); void GetInfoArray(FileSet *info); int InfoArrayPercentDone() { return fileset_for_info->curr_pct(); } virtual const char *CurrentStatus(); virtual int Read(Buffer *buf,int size) = 0; virtual int Write(const void *buf,int size) = 0; virtual int Buffered(); virtual int StoreStatus() = 0; virtual bool IOReady(); off_t GetPos() const { return pos; } off_t GetRealPos() const { return real_pos<0?pos:real_pos; } void SeekReal() { pos=GetRealPos(); } void RereadManual() { norest_manual=true; } const Path& GetCwd() const { return cwd; } const Path& GetNewCwd() const { return *new_cwd; } const char *GetFile() const { return file; } virtual int Do() = 0; virtual int Done() = 0; virtual bool SameLocationAs(const FileAccess *fa) const; virtual bool SameSiteAs(const FileAccess *fa) const; bool IsBetterThan(const FileAccess *fa) const; void Init(); FileAccess() : all_fa_node(this) { Init(); } FileAccess(const FileAccess *); void DontSleep() { reconnect_timer.Stop(); } bool IsClosed() { return mode==CLOSED; } bool IsOpen() { return !IsClosed(); } int OpenMode() { return mode; } virtual int IsConnected() const; // level of connection (0 - not connected). void Disconnect(const char *dc=0) { last_disconnect_cause.set(dc); DisconnectLL(); } virtual void DisconnectLL() {} virtual void UseCache(bool); virtual bool NeedSizeDateBeforehand(); int GetErrorCode() { return error_code; } enum status { IN_PROGRESS=1, // is returned only by *Status() or Done() OK=0, SEE_ERRNO=-100, LOOKUP_ERROR, NOT_OPEN, NO_FILE, NO_HOST, FILE_MOVED, FATAL, STORE_FAILED, LOGIN_FAILED, DO_AGAIN, NOT_SUPP }; virtual const char *StrError(int err); virtual void Cleanup(); virtual void CleanupThis(); void CleanupAll(); // ^^ close idle connections, etc. virtual ListInfo *MakeListInfo(const char *path=0); virtual Glob *MakeGlob(const char *pattern); virtual DirList *MakeDirList(ArgV *a); virtual FileSet *ParseLongList(const char *buf,int len,int *err=0) const { return 0; } static bool NotSerious(int err) { return temporary_network_error(err); } const char *GetNewLocation() { return location; } const char *GetSuggestedFileName() { return suggested_filename; } const char *GetEntityContentType() { return entity_content_type; } const char *GetEntityCharset() { return entity_charset; } void Reconfig(const char *); typedef FileAccess *SessionCreator(); class Protocol { static xmap proto_by_name; const char *proto; SessionCreator *New; static Protocol *FindProto(const char *proto); public: static FileAccess *NewSession(const char *proto); Protocol(const char *proto,SessionCreator *creator); }; static void Register(const char *proto,SessionCreator *creator) { (void)new Protocol(proto,creator); } static FileAccess *New(const char *proto,const char *host=0,const char *port=0); static FileAccess *New(const class ParsedURL *u,bool dummy=true); void SetPasswordGlobal(const char *p); void InsecurePassword(bool i) { pass_open=i; } void SetPriority(int p) { if(p==priority) return; priority=p; current->Timeout(0); } int GetPriority() const { return priority; } // not pretty (FIXME) int GetRetries() const { return retries; } void SetRetries(int r) { retries=r; } int GetMaxRetries() const { return max_retries; } time_t GetTryTime() const { return reconnect_timer.GetStartTime(); } void SetTryTime(time_t t); const char *GetLogContext() { return hostname; } static void ClassInit(); static void ClassCleanup(); }; // shortcut #define FA FileAccess // cache of used sessions class SessionPool { enum { pool_size=64 }; static FileAccess *pool[pool_size]; public: static void Reuse(FileAccess *); static void Print(FILE *f); static FileAccess *GetSession(int n); // start with n==0, then increase n; returns 0 when no more static FileAccess *Walk(int *n,const char *proto); static void ClearAll(); }; class FileAccessRef : public SMTaskRef { FileAccessRef(const FileAccessRef&); // disable cloning void operator=(const FileAccessRef&); // and assignment void reuse() { if(ptr) { ptr->DecRefCount(); SessionPool::Reuse(ptr); ptr=0; } } public: FileAccessRef() {} FileAccessRef(FileAccess *p) : SMTaskRef(p) {} ~FileAccessRef() { reuse(); } const FileAccessRef& operator=(FileAccess *p); template const SMTaskRef& Cast() const { void(static_cast(this->ptr)); return *(const SMTaskRef*)this; } static const FileAccessRef null; }; // constant ref (ref clone) class FileAccessRefC { void close() { if(*ref) (*ref)->Close(); } protected: const FileAccessRef *ref; public: FileAccessRefC(const FileAccessRef& p) { ref=&p; } const FileAccessRef& operator=(const FileAccessRef& p) { close(); ref=&p; return p; } operator const FileAccess*() const { return *ref; } FileAccess *operator->() const { return ref->operator->(); } operator const FileAccessRef&() { return *ref; } }; // static reference class FileAccessRefS : public FileAccessRef { FileAccessRefS(const FileAccessRefS&); // disable cloning void operator=(const FileAccessRefS&); // and assignment public: FileAccessRefS() {} FileAccessRefS(FileAccess *p) { ptr=p; } ~FileAccessRefS() { ptr=0; } const FileAccessRefS& operator=(FileAccess *p) { ptr=p; return *this; } }; class FileAccessOperation : public SMTask { protected: FileAccessRefS session; bool done; xstring error_text; void SetError(const char *); void SetErrorCached(const char *); bool use_cache; void PrepareToDie() { if(session) session->Close(); } public: FileAccessOperation(FileAccess *s) : session(s), done(false), use_cache(true) {} virtual int Do() = 0; bool Done() { return done; } bool Error() { return error_text!=0; } const char *ErrorText() { return error_text; } virtual const char *Status() = 0; void UseCache(bool y=true) { use_cache=y; } }; #include "PatternSet.h" class ListInfo : public FileAccessOperation { protected: FileAccess::Path saved_cwd; Ref result; const char *exclude_prefix; const PatternSet *exclude; unsigned need; bool follow_symlinks; void PrepareToDie(); ~ListInfo(); public: ListInfo(FileAccess *session,const char *path); void SetExclude(const char *p,const PatternSet *e) { exclude_prefix=p; exclude=e; } // caller has to delete the resulting FileSet itself. FileSet *GetResult() { return result.borrow(); } void Need(unsigned mask) { need|=mask; } void NoNeed(unsigned mask) { need&=~mask; } void FollowSymlinks() { follow_symlinks=true; } }; #include "buffer.h" class LsOptions { public: bool append_type:1; bool multi_column:1; bool show_all:1; LsOptions() { append_type=false; multi_column=false; show_all=false; } }; class DirList : public FileAccessOperation { protected: Ref buf; Ref args; bool color; ~DirList(); public: DirList(FileAccess *s,ArgV *a); virtual int Do() = 0; virtual const char *Status() = 0; int Size() { return buf->Size(); } bool Eof() { return buf->Eof(); } void Get(const char **b,int *size) { buf->Get(b,size); } void Skip(int len) { buf->Skip(len); } void UseColor(bool c=true) { color=c; } }; class UploadState { time_t try_time; off_t pos_watermark; int retries; public: UploadState() : try_time(NO_DATE), pos_watermark(0),retries(-1) {} void Clear() { try_time=NO_DATE; pos_watermark=0; retries=-1; } void Save(const FileAccess *session) { try_time=session->GetTryTime(); retries=session->GetRetries(); off_t pos=session->GetRealPos(); int max_retries=session->GetMaxRetries(); if(max_retries>0 && retries>=max_retries) pos=0; if(pos_watermarkSetTryTime(try_time); if(retries>=0) session->SetRetries(retries+1); } }; #endif /* FILEACCESS_H */ lftp-4.6.3a/src/SignalHook.cc0000644000015000007670000000432412122060612012702 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "SignalHook.h" int *SignalHook::counts=0; struct sigaction *SignalHook::old_handlers=0; bool *SignalHook::old_saved=0; void SignalHook::cnt_handler(int sig) { counts[sig]++; } void SignalHook::set_signal(int sig,signal_handler handler) { if(!old_saved[sig]) { sigaction(sig,0,&old_handlers[sig]); if(sig==SIGINT && old_handlers[sig].sa_handler==(signal_handler)SIG_IGN) return; old_saved[sig]=true; } struct sigaction act; act.sa_handler=handler; act.sa_flags=0; sigemptyset(&act.sa_mask); sigaction(sig,&act,0); } void SignalHook::Restore(int i) { if(old_saved[i]) sigaction(i,&old_handlers[i],0); SignalHook::Unblock(i); } void SignalHook::RestoreAll() { for(int i=0; i<256; i++) Restore(i); } void SignalHook::Block(int sig) { sigset_t s; sigemptyset(&s); sigaddset(&s,sig); sigprocmask(SIG_BLOCK,&s,0); } void SignalHook::Unblock(int sig) { sigset_t s; sigemptyset(&s); sigaddset(&s,sig); sigprocmask(SIG_UNBLOCK,&s,0); } void SignalHook::ClassInit() { if(counts) return; counts=new int[256]; old_handlers=new struct sigaction[256]; old_saved=new bool[256]; for(int i=0; i<256; i++) { counts[i]=0; old_saved[i]=false; } Ignore(SIGPIPE); // want to get EPIPE #ifdef SIGXFSZ Ignore(SIGXFSZ); // and EFBIG #endif } void SignalHook::Cleanup() { delete [] counts; delete [] old_handlers; delete [] old_saved; } lftp-4.6.3a/src/Resolver.h0000644000015000007670000001030212122060557012310 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef RESOLVER_H #define RESOLVER_H #include "ProcWait.h" #include "buffer.h" #include "xarray.h" #include "Cache.h" #include "network.h" class Resolver : public SMTask, protected ProtoLog { xstring hostname; xstring portname; xstring service; xstring proto; xstring defport; int port_number; int pipe_to_child[2]; SMTaskRef w; SMTaskRef buf; Timer timeout_timer; xarray addr; void AddAddress(int family,const char *a,int len,unsigned int scope); xstring err_msg; bool done; void MakeErrMsg(const char *f); void DoGethostbyname(); static int FindAddressFamily(const char *name); static void ParseOrder(const char *s,int *o); void LookupOne(const char *name); void LookupSRV_RR(); const char *error; static class ResolverCache *cache; bool no_cache; bool use_fork; public: int Do(); bool Done() { return done; } bool Error() { return err_msg!=0; } const char *ErrorMsg() { return err_msg; } const xarray& Result() { return addr; } size_t GetResultSize() { return addr.count()*addr.get_element_size(); } int GetResultNum() { return addr.count(); } void GetResult(void *m) { memcpy(m,addr.get(),GetResultSize()); } void UseCache(bool y) { no_cache=!y; } void NoCache() { UseCache(false); } Resolver(const char *h,const char *p,const char *defp=0,const char *ser=0, const char *pr=0); ~Resolver(); void Reconfig(const char *name=0); const char *GetLogContext() { return hostname; } }; class ResolverCacheEntryLoc { xstring_c hostname; xstring_c portname; xstring_c defport; xstring_c service; xstring_c proto; public: ResolverCacheEntryLoc(const char *h,const char *p,const char *defp,const char *ser,const char *pr) : hostname(h), portname(p), defport(defp), service(ser), proto(pr) {} const char *GetClosure() const { return hostname; } bool Matches(const char *h,const char *p,const char *defp,const char *ser,const char *pr); }; class ResolverCacheEntryData { xarray addr; public: ResolverCacheEntryData(const sockaddr_u *a,int n) { addr.nset(a,n); } void SetData(const sockaddr_u *a,int n) { addr.nset(a,n); } void GetData(const sockaddr_u **a,int *n) { *n=addr.count(); *a=addr.get(); } }; class ResolverCacheEntry : public CacheEntry, public ResolverCacheEntryLoc, public ResolverCacheEntryData { public: ResolverCacheEntry(const char *h,const char *p,const char *defp,const char *ser,const char *pr, const sockaddr_u *a,int n) : ResolverCacheEntryLoc(h,p,defp,ser,pr), ResolverCacheEntryData(a,n) { SetResource("dns:cache-expire",GetClosure()); } }; class ResolverCache : public Cache, public ResClient { ResolverCacheEntry *Find(const char *h,const char *p,const char *defp,const char *ser,const char *pr); ResolverCacheEntry *IterateFirst() { return (ResolverCacheEntry*)Cache::IterateFirst(); } ResolverCacheEntry *IterateNext() { return (ResolverCacheEntry*)Cache::IterateNext(); } ResolverCacheEntry *IterateDelete(){ return (ResolverCacheEntry*)Cache::IterateDelete(); } public: void Add(const char *h,const char *p,const char *defp, const char *ser,const char *pr,const sockaddr_u *a,int n); void Find(const char *h,const char *p,const char *defp, const char *ser,const char *pr,const sockaddr_u **a,int *n); ResolverCache(); void Reconfig(const char *); }; #endif // RESOLVER_H lftp-4.6.3a/src/SSH_Access.cc0000644000015000007670000001137012455207163012576 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "SSH_Access.h" #include "misc.h" void SSH_Access::MakePtyBuffers() { int fd=ssh->getfd(); if(fd==-1) return; ssh->Kill(SIGCONT); send_buf=new IOBufferFDStream(new FDStream(ssh->getfd_pipe_out(),"pipe-out"),IOBuffer::PUT); recv_buf=new IOBufferFDStream(new FDStream(ssh->getfd_pipe_in(),"pipe-in"),IOBuffer::GET); pty_send_buf=new IOBufferFDStream(ssh.borrow(),IOBuffer::PUT); pty_recv_buf=new IOBufferFDStream(new FDStream(fd,"pseudo-tty"),IOBuffer::GET); } int SSH_Access::HandleSSHMessage() { int m=STALL; const char *b; int s; pty_recv_buf->Get(&b,&s); const char *eol=find_char(b,s,'\n'); if(!eol) { const char *p="password:"; const char *p_for="password for "; const char *y="(yes/no)?"; int p_len=strlen(p); int p_for_len=strlen(p_for); int y_len=strlen(y); if(s>0 && b[s-1]==' ') s--; if((s>=p_len && !strncasecmp(b+s-p_len,p,p_len)) || (s>10 && !strncmp(b+s-2,"':",2)) || (s>p_for_len && b[s-1]==':' && !strncasecmp(b,p_for,p_for_len))) { if(!pass) { SetError(LOGIN_FAILED,_("Password required")); return MOVED; } if(password_sent>0) { SetError(LOGIN_FAILED,_("Login incorrect")); return MOVED; } pty_recv_buf->Put("XXXX"); pty_send_buf->Put(pass); pty_send_buf->Put("\n"); password_sent++; return m; } if(s>=y_len && !strncasecmp(b+s-y_len,y,y_len)) { const char *answer=QueryBool("auto-confirm",hostname)?"yes\n":"no\n"; pty_recv_buf->Put(answer); pty_send_buf->Put(answer); return m; } if(!received_greeting && recv_buf->Size()>0) { recv_buf->Get(&b,&s); eol=find_char(b,s,'\n'); if(eol) { xstring &line=xstring::get_tmp(b,eol-b); if(line.eq(greeting)) received_greeting=true; LogRecv(4,line); recv_buf->Skip(eol-b+1); } } LogSSHMessage(); return m; } const char *f=N_("Host key verification failed"); if(!strncasecmp(b,f,strlen(f))) { LogSSHMessage(); SetError(FATAL,_(f)); return MOVED; } if(eol>b && eol[-1]=='\r') eol--; f=N_("Name or service not known"); int f_len=strlen(f); if(eol-b>=f_len && !strncasecmp(eol-f_len,f,f_len)) { LogSSHMessage(); SetError(LOOKUP_ERROR,xstring::get_tmp(b,eol-b)); return MOVED; } LogSSHMessage(); return MOVED; } void SSH_Access::LogSSHMessage() { const char *b; int s; pty_recv_buf->Get(&b,&s); const char *eol=find_char(b,s,'\n'); if(!eol) { if(pty_recv_buf->Eof()) { if(s>0) LogRecv(4,b); LogError(0,_("Peer closed connection")); } if(pty_recv_buf->Error()) LogError(4,"pty read: %s",pty_recv_buf->ErrorText()); if(pty_recv_buf->Eof() || pty_recv_buf->Error()) { if(last_ssh_message && time_t(now)-last_ssh_message_time<4) LogError(0,"%s",last_ssh_message.get()); Disconnect(last_ssh_message); } return; } s=eol-b+1; int chomp_cr=(s>=2 && b[s-2]=='\r'); last_ssh_message.nset(b,s-1-chomp_cr); last_ssh_message_time=now; pty_recv_buf->Skip(s); LogRecv(4,last_ssh_message); if(last_ssh_message.begins_with("ssh: ")) last_ssh_message.set(last_ssh_message+5); if(!received_greeting && last_ssh_message.eq(greeting)) received_greeting=true; } void SSH_Access::DisconnectLL() { if(send_buf) LogNote(9,_("Disconnecting")); send_buf=0; recv_buf=0; pty_send_buf=0; pty_recv_buf=0; ssh=0; received_greeting=false; password_sent=0; last_ssh_message.unset(); last_ssh_message_time=0; } void SSH_Access::MoveConnectionHere(SSH_Access *o) { send_buf=o->send_buf.borrow(); recv_buf=o->recv_buf.borrow(); pty_send_buf=o->pty_send_buf.borrow(); pty_recv_buf=o->pty_recv_buf.borrow(); ssh=o->ssh.borrow(); received_greeting=o->received_greeting; password_sent=o->password_sent; last_ssh_message.move_here(o->last_ssh_message); last_ssh_message_time=o->last_ssh_message_time; o->last_ssh_message_time=0; } lftp-4.6.3a/src/TimeDate.h0000644000015000007670000001321012252264130012201 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef TIMEDATE_H #define TIMEDATE_H #include #include #include class time_tuple { time_t sec; int usec; void addU(time_t s,int us); // must be |us|<1000000 protected: time_t get_seconds() const { return sec; } int get_milliseconds() const { return usec/1000; } int get_microseconds() const { return usec; } void normalize(); void add_sec(long s) { sec+=s; } void add(double); void add(const time_tuple &o) { addU(o.sec,o.usec); } void sub(const time_tuple &o) { addU(-o.sec,-o.usec); } void sub(double o) { add(-o); } void set(time_t s,int ms,int us) { sec=s; usec=ms*1000+us; normalize(); } void set(const time_tuple &o) { sec=o.sec; usec=o.usec; } bool lt(const time_tuple &o) const { return seclt(o); } bool operator>=(const Time &o) const { return !(*thisset(a); sub(b); } TimeDiff() {} TimeDiff(const Time&a,const Time&b) { SetDiff(a,b); } TimeDiff(time_t s,int ms,int us=0) { set(s,ms,us); } void Set(time_t s,int ms,int us=0) { set(s,ms,us); } operator double() const { return to_double(); } void Set(double s); bool operator<(const TimeDiff &o) const { return this->lt(o); } bool operator>=(const TimeDiff &o) const { return !(*this=(int s) const { return get_seconds()>=s; } const TimeDiff &operator-=(const TimeDiff &o) { sub(o); return *this; } const TimeDiff &operator+=(const TimeDiff &o) { add(o); return *this; } int MicroSeconds() const; int MilliSeconds() const; time_t Seconds() const; static const TimeDiff& valueOf(double v); timeval toTimeval() const { timeval tv={get_seconds(),get_microseconds()}; return tv; } }; inline TimeDiff Time::operator-(const Time &o) const { return TimeDiff(*this,o); } inline const Time &Time::operator+=(const TimeDiff &o) { add(o); return *this; } inline const Time &Time::operator-=(const TimeDiff &o) { sub(o); return *this; } class TimeInterval : public TimeDiff { protected: bool infty; public: TimeInterval() : TimeDiff(0,0) { infty=true; } TimeInterval(time_t s,int ms,int us=0) : TimeDiff(s,ms,us) { infty=false; } TimeInterval(const TimeDiff &d) : TimeDiff(d) { infty=false; } void SetInfty(bool i=true) { infty=i; } bool IsInfty() const { return infty; } bool Finished(const Time &base) const; int GetTimeout(const Time &base) const { return GetTimeoutU(base)/1000; } int GetTimeoutU(const Time &base) const; bool operator<(const TimeInterval &o) const { return infty=(const TimeInterval &o) const { return !(*this=(int s) const { return infty || get_seconds()>=s; } const char *toString(unsigned flags); enum { TO_STR_TRANSLATE=1, TO_STR_TERSE=2 }; }; #define MINUTE (60) #define HOUR (60*MINUTE) #define DAY (24*HOUR) #endif lftp-4.6.3a/src/FileCopyOutputJob.h0000644000015000007670000000223312122057444014102 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FILECOPYPEEROUTPUTJOB_H #define FILECOPYPEEROUTPUTJOB_H #include "OutputJob.h" class FileCopyPeerOutputJob : public FileCopyPeer { const JobRef& o; int Put_LL(const char *buf,int len); public: FileCopyPeerOutputJob(const JobRef& o); int Do(); void Fg(); void Bg(); const char *GetDescriptionForLog() { return "[pipe to other job]"; } }; #endif lftp-4.6.3a/src/Speedometer.h0000644000015000007670000000327112247537430013001 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef SPEEDOMETER_H #define SPEEDOMETER_H #include "SMTask.h" #include "ResMgr.h" class Speedometer : public ResClient { int period; float rate; Time last_second; Time last_bytes; Time start; bool terse; const char *period_resource; public: Speedometer(const char *p="xfer:rate-period"); float Get(); float Get() const { return rate; } static xstring& GetStr(float r); static xstring& GetStrProper(float r); xstring& GetStr(); static const char *GetStrS(float r); const char *GetStrS(); xstring& GetETAStrFromSize(off_t s); const char *GetETAStrSFromSize(off_t s); xstring& GetETAStrFromTime(long t); const char *GetETAStrSFromTime(long t); bool Valid(); void Add(int bytes); void Reset(); void SetPeriod(int p) { period=p; } void SetPeriodName(const char *p) { period_resource=p; Reconfig(0); } void SetTerseETA(bool t) { terse=t; } void Reconfig(const char *s); }; #endif lftp-4.6.3a/src/Bencode.cc0000644000015000007670000001757312410755150012225 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "Bencode.h" #include "c-ctype.h" BeNode::BeNode(long long n) : type(BE_INT),num(n) {} BeNode::BeNode(const xstring& s) : type(BE_STR),str(s.get(),s.length()) {} BeNode::BeNode(const char *s,int len) : type(BE_STR),str(s,len) {} BeNode::BeNode(const char *s) : type(BE_STR),str(s) {} BeNode::BeNode(xarray_p *a) : type(BE_LIST) { list.move_here(*a); } BeNode::BeNode(xmap_p *m) : type(BE_DICT) { dict.move_here(*m); } BeNode *BeNode::Parse(const char *s,int s_len,int *rest) { if(s_len<2) { *rest=0; return 0; } switch(*s) { case 'i': { s++; s_len--; bool neg=false; if(*s=='-') { neg=true; s++; s_len--; } if(s_len<2) { *rest=0; return 0; } if(c_isdigit(*s)) { if(*s=='0' && s[1]!='e') { *rest=s_len; return 0; } long long n=*s++-'0'; s_len--; while(s_len>1 && c_isdigit(*s)) { n=n*10+*s++-'0'; s_len--; } if(s_len<1 || *s!='e') { *rest=s_len; return 0; } *rest=s_len-1; return new BeNode(neg?-n:n); } *rest=s_len; return 0; } case 'l': { s++; s_len--; xarray_p a; while(s_len>1 && *s!='e') { int rest1; BeNode *n=Parse(s,s_len,&rest1); if(!n) { *rest=rest1; return 0; } a.append(n); s+=(s_len-rest1); s_len=rest1; } if(s_len<1 || *s!='e') { *rest=s_len; return 0; } *rest=s_len-1; return new BeNode(&a); } case 'd': { const char *d_begin=s; s++; s_len--; xmap_p map; while(s_len>1 && *s!='e') { int rest1; Ref n(Parse(s,s_len,&rest1)); if(!n) { *rest=rest1; return 0; } if(n->type!=BE_STR) { *rest=s_len; return 0; } s+=(s_len-rest1); s_len=rest1; BeNode *v=Parse(s,s_len,&rest1); if(!v) { *rest=rest1; return 0; } map.add(n->str,v); s+=(s_len-rest1); s_len=rest1; } if(s_len<1 || *s!='e') { *rest=s_len; return 0; } s++; s_len--; *rest=s_len; BeNode *node=new BeNode(&map); node->str.nset(d_begin,s-d_begin); return node; } default: if(c_isdigit(*s)) { int n=*s++-'0'; s_len--; while(s_len>0 && c_isdigit(*s)) { if(n>=s_len) { *rest=0; return 0; } n=n*10+*s++-'0'; s_len--; } if(s_len<1 || *s!=':') { *rest=s_len; return 0; } s++; s_len--; if(s_lenFormat(buf,level+1); break; case BE_DICT: buf.appendf("DICT: %d items\n",dict.count()); for(BeNode *e=dict.each_begin(); e; e=dict.each_next()) { for(i=0; iFormat(buf,level+2); } break; } } const char *BeNode::Format() { static xstring buf; buf.set(""); Format(buf,0); return buf; } #include #include void BeNode::Format1(xstring &buf) { int i; switch(type) { case BE_STR: buf.append('"'); (str_lc?str_lc:str).dump_to(buf); buf.append('"'); break; case BE_INT: buf.appendf("%lld",num); break; case BE_LIST: buf.append('['); for(i=0; i0) buf.append(", "); list[i]->Format1(buf); } buf.append(']'); break; case BE_DICT: buf.append('{'); i=0; for(BeNode *e=dict.each_begin(); e; e=dict.each_next(), i++) { if(i>0) buf.append(", "); const xstring& key=dict.each_key(); buf.appendf("\"%s\":",key.get()); if(e->type==BE_STR) { char tmp[40]; if(e->str.length()==4 && (key.eq("ip",2) || key.eq("ipv4",4) || key.eq("yourip",6))) { inet_ntop(AF_INET,e->str.get(),tmp,sizeof(tmp)); buf.append(tmp); continue; } #if INET6 else if(e->str.length()==16 && (key.eq("ip",2) || key.eq("ipv6",4) || key.eq("yourip",6))) { inet_ntop(AF_INET6,e->str.get(),tmp,sizeof(tmp)); buf.append(tmp); continue; } #endif//INET6 } e->Format1(buf); } buf.append('}'); break; } } const char *BeNode::Format1() { static xstring buf; buf.set(""); Format1(buf); return buf; } const char *BeNode::TypeName(be_type_t t) { static const char *table[]={ "STR", "INT", "LIST", "DICT" }; return table[t]; } int BeNode::ComputeLength() { int len=0; int i; switch(type) { case BE_STR: i=str.length(); len+=1+i; // ':' + string while(i>=10) { len++; i/=10; } len++; // last digit break; case BE_INT: len+=1+xstring::format("%lld",num).length()+1; // 'i' + number + 'e' break; case BE_LIST: len++; // 'l' for(i=0; iComputeLength(); len++; // 'e' break; case BE_DICT: len++; // 'd' for(BeNode *e=dict.each_begin(); e; e=dict.each_next()) { const xstring &key=dict.each_key(); i=key.length(); len+=1+i; // ':' + string while(i>=10) { len++; i/=10; } len++; // last digit len+=e->ComputeLength(); } len++; // 'e' break; } return len; } void BeNode::Pack(const SMTaskRef &buf) { xstring &tmp=xstring::get_tmp(""); Pack(tmp); buf->Put(tmp); } static int xstring_ptr_cmp(const xstring*const*a,const xstring*const*b) { return (*a)->cmp(**b); } void BeNode::PackDict(xstring &buf) { xarray keys; for(BeNode *e=dict.each_begin(); e; e=dict.each_next()) keys.append(&dict.each_key()); keys.qsort(xstring_ptr_cmp); for(int i=0; iPack(buf); } } void BeNode::Pack(xstring &buf) { int i; switch(type) { case BE_STR: i=str.length(); buf.appendf("%d:",i); buf.append(str); break; case BE_INT: buf.appendf("i%llde",num); break; case BE_LIST: buf.append('l'); for(i=0; iPack(buf); buf.append('e'); break; case BE_DICT: buf.append('d'); PackDict(buf); buf.append('e'); break; } } const xstring& BeNode::Pack() { xstring& tmp=xstring::get_tmp(""); Pack(tmp); return tmp; } lftp-4.6.3a/src/ArgV.cc0000644000015000007670000000504312457747551011533 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "misc.h" #include "ArgV.h" ArgV::ArgV(const char *a0, const char *args_c) { ind=0; Append(a0); char *args=alloca_strdup(args_c); for(char *t=strtok(args," "); t; t=strtok(NULL," ")) Append(t); } ArgV::~ArgV() { } void ArgV::seek(int n) { if(n>=Count()) n=Count(); ind=n; } const char *ArgV::getnext() { const char *s=String(++ind); if(!s) ind=Count(); // getcurr will return 0 return s; } void ArgV::back() { if(ind>0) ind--; } char *ArgV::Combine(int start,int end) const { xstring res(""); if(!end) end=Count(); if(start>=end) return res.borrow(); for(;;) { res.append(getarg(start++)); if(start>=end) return(res.borrow()); res.append(' '); } } char *ArgV::CombineShellQuoted(int start) const { xstring res(""); if(start>=Count()) return res.borrow(); for(;;) { for(const char *arg=String(start++); *arg; arg++) { if (is_shell_special(*arg)) res.append('\\'); res.append(*arg); } if(start>=Count()) return(res.borrow()); res.append(' '); } } int ArgV::getopt_long(const char *opts,const struct option *lopts,int *lind) { optind=ind; int r=::getopt_long(Count(),SetNonConst(),opts,lopts,lind); ind=optind; return r; } const char *ArgV::getopt_error_message(int e) { if(optopt>=32 && optopt<127) { if(e==':') return xstring::format("%s -- %c",_("option requires an argument"),optopt); else return xstring::format("%s -- %c",_("invalid option"),optopt); } if(ind>1) { if(e==':') return xstring::format(_("option `%s' requires an argument"),getarg(ind-1)); else return xstring::format(_("unrecognized option `%s'"),getarg(ind-1)); } return _("invalid option"); } lftp-4.6.3a/src/FileGlob.h0000644000015000007670000000534112311763574012212 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef GLOB_H #define GLOB_H #include "FileAccess.h" class Glob : public FileAccessOperation { protected: xstring_c pattern; FileSet list; bool dirs_only; bool files_only; bool match_period; bool inhibit_tilde; bool casefold; void add(const FileInfo *info); void add_force(const FileInfo *info); public: const char *GetPattern() { return pattern; } FileSet *GetResult() { return &list; } Glob(FileAccess *s,const char *p); ~Glob(); void DirectoriesOnly() { dirs_only=true; } void FilesOnly() { files_only=true; } void NoMatchPeriod() { match_period=false; } void NoInhibitTilde() { inhibit_tilde=false; } void CaseFold() { casefold=true; } static bool HasWildcards(const char *); static void UnquoteWildcards(char *); }; class NoGlob : public Glob { public: NoGlob(const char *p); const char *Status() { return ""; } int Do(); }; class GlobURL { const FileAccessRef& orig_session; FileAccessRef my_session; FileAccessRefC session; xstring_c url_prefix; public: SMTaskRef glob; enum type_select { ALL, FILES_ONLY, DIRS_ONLY }; GlobURL(const FileAccessRef& s,const char *p,type_select t=ALL); ~GlobURL(); FileSet *GetResult(); bool Done() { return glob->Done(); } bool Error() { return glob->Error(); } const char *ErrorText() { return glob->ErrorText(); } const char *Status() { return glob->Status(); } void NewGlob(const char *p); const char *GetPattern() { return glob->GetPattern(); } void NoMatchPeriod() { if(glob) glob->NoMatchPeriod(); } void NoInhibitTilde() { if(glob) glob->NoInhibitTilde(); } void CaseFold() { if(glob) glob->CaseFold(); } private: type_select type; }; class GenericGlob : public Glob { const char *curr_dir; FileSet *dir_list; SMTaskRef updir_glob; SMTaskRef li; public: int Do(); const char *Status(); GenericGlob(FileAccess *session,const char *n_pattern); }; #endif lftp-4.6.3a/src/DummyProto.h0000644000015000007670000000264312252527531012643 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef DUMMYPROTO_H #define DUMMYPROTO_H #include "FileAccess.h" class DummyProto : public FileAccess { public: int Do(); int Done(); const char *GetProto() const; FileAccess *Clone() const; int Read(Buffer *buf,int size); int Write(const void *buf,int size); int StoreStatus(); void Reconfig(const char *) {} ListInfo *MakeListInfo(const char *path); DirList *MakeDirList(ArgV *); DummyProto(); ~DummyProto(); }; class DummyNoProto : public DummyProto { xstring_c proto; public: DummyNoProto(const char *p) : proto(p) {} const char *GetProto() const; FileAccess *Clone() const; const char *StrError(int err); }; #endif lftp-4.6.3a/src/SysCmdJob.cc0000644000015000007670000000434112122060724012504 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include "SysCmdJob.h" #include "SignalHook.h" #include "misc.h" #define super Job SysCmdJob::SysCmdJob(const char *c) : cmd(c) { } void SysCmdJob::PrepareToDie() { Bg(); AcceptSig(SIGTERM); if(w) w.borrow()->Auto(); super::PrepareToDie(); } SysCmdJob::~SysCmdJob() {} int SysCmdJob::Do() { int m=STALL; if(w) return m; const char *shell=getenv("SHELL"); if(!shell) shell="/bin/sh"; ProcWait::Signal(false); pid_t pid; fflush(stderr); switch(pid=fork()) { case(0): /* child */ setpgid(0,0); kill(getpid(),SIGSTOP); SignalHook::RestoreAll(); if(cmd) execlp(shell,basename_ptr(shell),"-c",cmd.get(),NULL); else execlp(shell,basename_ptr(shell),NULL); fprintf(stderr,_("execlp(%s) failed: %s\n"),shell,strerror(errno)); fflush(stderr); _exit(1); case(-1): /* error */ TimeoutS(1); // wait a second and retry goto out; } /* parent */ int info; waitpid(pid,&info,WUNTRACED); // wait until the process stops w=new ProcWait(pid); fg_data=new FgData(pid,fg); m=MOVED; out: ProcWait::Signal(true); return m; } int SysCmdJob::AcceptSig(int sig) { if(!w) { if(sig==SIGINT) return WANTDIE; return STALL; } w->Kill(sig); if(sig!=SIGCONT) AcceptSig(SIGCONT); // for the case of stopped process return MOVED; } lftp-4.6.3a/src/example2.cc0000644000015000007670000000167512343575100012377 00000000000000#include #include #include "FileAccess.h" #include "log.h" char *program_name; int main(int argc,char **argv) { program_name=argv[0]; Log::global=new Log; Log::global->SetOutput(2,false); Log::global->SetLevel(5); Log::global->Enable(); Log::global->ShowNothing(); FileAccess *f=FileAccess::New("http","lftp.yar.ru"); if(!f) { fprintf(stderr,"http: unknown protocol, cannot create http session\n"); return 1; } f->Open("/ftp/",f->RETRIEVE); Buffer buf; for(;;) { SMTask::Schedule(); int res=f->Read(&buf,sizeof(buf)); if(res<0) { if(res==f->DO_AGAIN) { SMTask::Block(); continue; } fprintf(stderr,"Error: %s\n",f->StrError(res)); return 1; } if(res==0) // eof { f->Close(); return 0; } buf.SpaceAdd(res); write(1,buf.Get(),res); buf.Skip(res); } SMTask::Delete(f); return 0; } lftp-4.6.3a/src/SSH_Access.h0000644000015000007670000000333612332160236012434 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef SSH_ACCESS_H #define SSH_ACCESS_H #include "NetAccess.h" #include "PtyShell.h" class SSH_Access : public NetAccess { protected: SMTaskRef pty_send_buf; SMTaskRef pty_recv_buf; SMTaskRef send_buf; SMTaskRef recv_buf; Ref ssh; int password_sent; const char *greeting; bool received_greeting; xstring last_ssh_message; time_t last_ssh_message_time; void MoveConnectionHere(SSH_Access *o); void DisconnectLL(); void MakePtyBuffers(); int HandleSSHMessage(); void LogSSHMessage(); /* it's called after the greeting is received * (or internally from HandleSSHMessage). */ SSH_Access(const char *g) : password_sent(0), greeting(g), received_greeting(false), last_ssh_message_time(0) {} SSH_Access(const SSH_Access *o) : NetAccess(o), password_sent(0), greeting(o->greeting), received_greeting(false), last_ssh_message_time(0) {} }; #endif lftp-4.6.3a/src/LsCache.h0000644000015000007670000000670412210044412012012 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef LSCACHE_H #define LSCACHE_H #include #include "Cache.h" #include "FileAccess.h" class Buffer; class FileAccess; class LsCacheEntryLoc { friend class LsCache; xstring_c arg; SMTaskRef loc; // no FileAccessRef -> no reuse here int mode; public: bool Matches(const FileAccess *p_loc,const char *a,int m); LsCacheEntryLoc(const FileAccess *p_loc,const char *a,int m); int EstimateSize() const { return xstrlen(arg)+(arg!=0); } const char *GetClosure() const; }; class LsCacheEntryData { int err_code; xstring data; Ref afset; // associated file set public: LsCacheEntryData(int e,const char *d,int l,const FileSet *fs); void SetData(int e,const char *d,int l,const FileSet *fs); void GetData(int *e,const char **d,int *l,const FileSet **fs); const FileSet *GetFileSet(const FileAccess *parser); void UpdateFileSet(const FileSet *fs) { if(afset) afset->Merge(fs); } int EstimateSize() const { return data.length()+(afset?afset->EstimateMemory():0); } }; class LsCacheEntry : public CacheEntry, public LsCacheEntryLoc, public LsCacheEntryData { public: int EstimateSize() const; LsCacheEntry(const FileAccess *p_loc,const char *a,int m,int e,const char *d,int l,const FileSet *fs); }; class LsCache : public Cache { LsCacheEntry *Find(const FileAccess *p_loc,const char *a,int m); LsCacheEntry *IterateFirst() { return (LsCacheEntry*)Cache::IterateFirst(); } LsCacheEntry *IterateNext() { return (LsCacheEntry*)Cache::IterateNext(); } LsCacheEntry *IterateDelete(){ return (LsCacheEntry*)Cache::IterateDelete(); } public: LsCache(); void Add(const FileAccess *p_loc,const char *a,int m,int err,const char *d,int l,const FileSet *f=0); void Add(const FileAccess *p_loc,const char *a,int m,int err,const Buffer *ubuf,const FileSet *f=0); bool Find(const FileAccess *p_loc,const char *a,int m,int *err,const char **d, int *l,const FileSet **f=0); const FileSet *FindFileSet(const FileAccess *p_loc,const char *a,int m); void UpdateFileSet(const FileAccess *p_loc,const char *a,int m,const FileSet *fs); int IsDirectory(const FileAccess *p_loc,const char *dir); void SetDirectory(const FileAccess *p_loc, const char *path, bool dir); enum change_mode { FILE_CHANGED, DIR_CHANGED, TREE_CHANGED }; void Changed(change_mode m,const FileAccess *f,const char *what); void FileChanged(const FileAccess *f,const char *file) { Changed(FILE_CHANGED,f,file); } void DirectoryChanged(const FileAccess *f,const char *dir) { Changed(DIR_CHANGED,f,dir); } void TreeChanged(const FileAccess *f,const char *dir) { Changed(TREE_CHANGED,f,dir); } void List(); }; #endif//LSCACHE_H lftp-4.6.3a/src/IdNameCache.h0000644000015000007670000000544612122060046012576 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef IDNAMECACHE_H #define IDNAMECACHE_H #include "SMTask.h" #include "Timer.h" #include "StringPool.h" struct IdNamePair { int id; const char *name; IdNamePair *next; IdNamePair(int id1,const char *name1) { id=id1; name=StringPool::Get(name1); } IdNamePair(const IdNamePair *p) { id=p->id; name=StringPool::Get(p->name); } }; class IdNameCache : public SMTask { Ref expire_timer; enum { table_size=131 }; unsigned hash(const char *); unsigned hash(int); IdNamePair *table_id[table_size]; IdNamePair *table_name[table_size]; void init(); void free(); static void free_list(IdNamePair *list); void add(unsigned h,IdNamePair **,IdNamePair *); protected: virtual IdNamePair *get_record(int id)=0; virtual IdNamePair *get_record(const char *name); IdNamePair *lookup(int id); IdNamePair *lookup(const char *id); public: IdNameCache(); virtual ~IdNameCache(); void Clear() { free(); init(); } const char *Lookup(int id); int Lookup(const char *); void SetExpireTimer(Timer *t) { expire_timer=t; } int Do(); }; class PasswdCache : public IdNameCache { static PasswdCache *instance; static PasswdCache *GetInstance(); IdNamePair *get_record(int id); IdNamePair *get_record(const char *name); public: static int LookupS(const char *name) { return GetInstance()->Lookup(name); } static const char *LookupS(int id) { return GetInstance()->Lookup(id); } ~PasswdCache(); static void DeleteInstance() { Delete(instance); } }; class GroupCache : public IdNameCache { static GroupCache *instance; static GroupCache *GetInstance(); IdNamePair *get_record(int id); IdNamePair *get_record(const char *name); public: static int LookupS(const char *name) { return GetInstance()->Lookup(name); } static const char *LookupS(int id) { return GetInstance()->Lookup(id); } ~GroupCache(); static void DeleteInstance() { Delete(instance); } }; inline void IdNameCacheCleanup() { PasswdCache::DeleteInstance(); GroupCache::DeleteInstance(); } #endif lftp-4.6.3a/src/PatternSet.cc0000644000015000007670000000521012210075055012735 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "PatternSet.h" PatternSet::PatternSet() { chain=0; first=0; } void PatternSet::Add(Type t,Pattern *p) { chain=new PatternLink(t,p,chain); if(!first) first=chain; } void PatternSet::AddFirst(Type t,Pattern *p) { PatternLink *new_link=new PatternLink(t,p,NULL); if(!first) first=chain=new_link; else first->next=new_link; } PatternSet::Type PatternSet::GetFirstType() const { return first->type; } PatternSet::~PatternSet() { while(chain) { PatternLink *del=chain; chain=chain->next; delete del; } } bool PatternSet::Match(Type type,const char *str) const { for(PatternLink *scan=chain; scan; scan=scan->next) { if(scan->pattern->Match(str)) return scan->type==type; if(!scan->next) return scan->type!=type; } return false; } PatternSet::Glob::Glob(const char *p) : Pattern(p) { slash_count=0; for(p=pattern; *p; p++) if(*p=='/') slash_count++; } // abc/def.zip matches *.zip // abc/def/ghi matches def/g* bool PatternSet::Glob::Match(const char *str) { const char *scan=str+strlen(str); int countdown=slash_count; while(scan>str) { scan--; if(*scan=='/') { if(countdown==0) { scan++; break; } countdown--; } } return fnmatch(pattern,scan,FNM_PATHNAME)==0; } PatternSet::Regex::Regex(const char *p) : Pattern(p) { memset(&compiled,0,sizeof(compiled)); // safety. int errcode=regcomp(&compiled,pattern,REG_EXTENDED|REG_NOSUB); if(errcode) { size_t need=regerror(errcode,0,0,0); error.get_space(need-1); error.set_length(regerror(errcode,0,error.get_non_const(),need)-1); } } PatternSet::Regex::~Regex() { if(!error) regfree(&compiled); } bool PatternSet::Regex::Match(const char *str) { if(error) return false; return regexec(&compiled,str,0,0,0)==0; } lftp-4.6.3a/src/TorrentTracker.cc0000644000015000007670000004236012540107035013624 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include #include #include #include #include #include "Torrent.h" #include "TorrentTracker.h" #include "log.h" #include "url.h" #include "misc.h" #include "plural.h" void TorrentTracker::AddURL(const char *url) { LogNote(4,"Tracker URL is `%s'",url); ParsedURL u(url,true); if(u.proto.ne("http") && u.proto.ne("https") && u.proto.ne("udp")) { LogError(1,"unsupported tracker protocol `%s', must be http, https or udp",u.proto.get()); return; } xstring& tracker_url=*new xstring(url); if(u.proto.ne("udp")) { if(!u.path || !u.path[0]) tracker_url.append('/'); // fix the URL: append either ? or & if missing. if(tracker_url.last_char()!='?' && tracker_url.last_char()!='&') tracker_url.append(tracker_url.instr('?')>=0?'&':'?'); } tracker_urls.append(&tracker_url); } TorrentTracker::TorrentTracker(Torrent *p,const char *url) : parent(p), current_tracker(0), tracker_timer(600), tracker_timeout_timer(120), started(false), tracker_no(0) { AddURL(url); } bool TorrentTracker::IsActive() const { return backend && backend->IsActive(); } void TorrentTracker::Shutdown() { if(Failed()) // don't stop a failed tracker return; // stop if have started or at least processing a start request if(started || IsActive()) SendTrackerRequest("stopped"); } void TorrentTracker::SetError(const char *e) { if(tracker_urls.count()<=1) error=new Error(-1,e,true); else { LogError(3,"Tracker error: %s, using next tracker URL",e); tracker_urls.remove(current_tracker--); NextTracker(); // retry immediately tracker_timer.Stop(); } } bool TorrentTracker::AddPeerCompact(const char *compact_addr,int len) const { sockaddr_u a; if(!a.set_compact(compact_addr,len)) return false; Enter(parent); parent->AddPeer(new TorrentPeer(parent,&a,tracker_no)); Leave(parent); return true; } bool TorrentTracker::AddPeer(const xstring& addr,int port) const { sockaddr_u a; #if INET6 if(addr.instr(':')>=0) { a.sa.sa_family=AF_INET6; if(inet_pton(AF_INET6,addr,&a.in6.sin6_addr)<=0) return false; } else #endif { a.sa.sa_family=AF_INET; if(!inet_aton(addr,&a.in.sin_addr)) return false; } a.set_port(port); Enter(parent); parent->AddPeer(new TorrentPeer(parent,&a,tracker_no)); Leave(parent); return true; } int TorrentTracker::Do() { int m=STALL; if(Failed()) return m; if(backend && backend->IsActive()) { if(tracker_timeout_timer.Stopped()) { LogError(3,"Tracker timeout"); NextTracker(); return MOVED; } } else { if(tracker_timer.Stopped()) { parent->CleanPeers(); SendTrackerRequest(0); } } return m; } void TorrentTracker::CreateTrackerBackend() { backend=0; ParsedURL u(GetURL(),true); if(u.proto.eq("udp")) { backend=new UdpTracker(this,&u); } else if(u.proto.eq("http") || u.proto.eq("https")) { backend=new HttpTracker(this,&u); } } void TorrentTracker::NextTracker() { current_tracker++; if(current_tracker>=tracker_urls.count()) current_tracker=0; tracker_timer.Reset(); CreateTrackerBackend(); } void TorrentTracker::Start() { if(backend || Failed()) return; CreateTrackerBackend(); SendTrackerRequest("started"); } void TorrentTracker::SendTrackerRequest(const char *event) { backend->SendTrackerRequest(event); tracker_timeout_timer.Reset(); } const char *TorrentTracker::Status() const { if(error) return error->Text(); if(!backend) return _("not started"); if(backend->IsActive()) return backend->Status(); return xstring::format(_("next request in %s"),NextRequestIn()); } // TrackerBackend const xstring& TrackerBackend::GetInfoHash() const { return master->parent->GetInfoHash(); } const xstring& TrackerBackend::GetMyPeerId() const { return master->parent->GetMyPeerId(); } int TrackerBackend::GetPort() const { return master->parent->GetPort(); } unsigned long long TrackerBackend::GetTotalSent() const { return master->parent->GetTotalSent(); } unsigned long long TrackerBackend::GetTotalRecv() const { return master->parent->GetTotalRecv(); } unsigned long long TrackerBackend::GetTotalLeft() const { return master->parent->GetTotalLeft(); } bool TrackerBackend::HasMetadata() const { return master->parent->HasMetadata(); } bool TrackerBackend::Complete() const { return master->parent->Complete(); } int TrackerBackend::GetWantedPeersCount() const { return master->parent->GetWantedPeersCount(); } const xstring& TrackerBackend::GetMyKey() const { return master->parent->GetMyKey(); } unsigned TrackerBackend::GetMyKeyNum() const { return master->parent->GetMyKeyNum(); } const char *TrackerBackend::GetTrackerId() const { return master->tracker_id; } bool TrackerBackend::ShuttingDown() const { return master->parent->ShuttingDown(); } void TrackerBackend::Started() const { master->started=true; } void TrackerBackend::TrackerRequestFinished() const { master->tracker_timer.Reset(); } // HttpTracker #define super TrackerBackend int HttpTracker::HandleTrackerReply() { if(tracker_reply->Error()) { SetError(tracker_reply->ErrorText()); t_session->Close(); tracker_reply=0; return MOVED; } if(!tracker_reply->Eof()) return STALL; t_session->Close(); int rest; Ref reply(BeNode::Parse(tracker_reply->Get(),tracker_reply->Size(),&rest)); if(!reply) { LogError(3,"Tracker reply parse error (data: %s)",tracker_reply->Dump()); tracker_reply=0; NextTracker(); return MOVED; } LogNote(10,"Received tracker reply:"); Log::global->Write(10,reply->Format()); if(ShuttingDown()) { tracker_reply=0; t_session=0; return MOVED; } Started(); if(reply->type!=BeNode::BE_DICT) { SetError("Reply: wrong reply type, must be DICT"); tracker_reply=0; return MOVED; } BeNode *b_failure_reason=reply->lookup("failure reason"); if(b_failure_reason) { if(b_failure_reason->type==BeNode::BE_STR) SetError(b_failure_reason->str); else SetError("Reply: wrong `failure reason' type, must be STR"); tracker_reply=0; return MOVED; } BeNode *b_interval=reply->lookup("interval",BeNode::BE_INT); if(b_interval) SetInterval(b_interval->num); SetTrackerID(reply->lookup_str("tracker id")); int peers_count=0; BeNode *b_peers=reply->lookup("peers"); if(b_peers) { if(b_peers->type==BeNode::BE_STR) { // binary model const char *data=b_peers->str; int len=b_peers->str.length(); LogNote(9,"peers have binary model, length=%d",len); while(len>=6) { if(AddPeerCompact(data,6)) peers_count++; data+=6; len-=6; } } else if(b_peers->type==BeNode::BE_LIST) { // dictionary model int count=b_peers->list.count(); LogNote(9,"peers have dictionary model, count=%d",count); for(int p=0; plist[p]; if(b_peer->type!=BeNode::BE_DICT) continue; BeNode *b_ip=b_peer->lookup("ip",BeNode::BE_STR); if(!b_ip) continue; BeNode *b_port=b_peer->lookup("port",BeNode::BE_INT); if(!b_port) continue; if(AddPeer(b_ip->str,b_port->num)) peers_count++; } } LogNote(4,plural("Received valid info about %d peer$|s$",peers_count),peers_count); } #if INET6 peers_count=0; b_peers=reply->lookup("peers6",BeNode::BE_STR); if(b_peers) { // binary model const char *data=b_peers->str; int len=b_peers->str.length(); while(len>=18) { if(AddPeerCompact(data,18)) peers_count++; data+=18; len-=18; } LogNote(4,plural("Received valid info about %d IPv6 peer$|s$",peers_count),peers_count); } #endif//INET6 tracker_reply=0; TrackerRequestFinished(); return MOVED; } int HttpTracker::Do() { int m=STALL; if(!IsActive()) return m; if(tracker_reply) m|=HandleTrackerReply(); return m; } void HttpTracker::SendTrackerRequest(const char *event) { if(!t_session) return; xstring request(GetURL()); request.appendf("info_hash=%s",url::encode(GetInfoHash(),URL_PATH_UNSAFE).get()); request.appendf("&peer_id=%s",url::encode(GetMyPeerId(),URL_PATH_UNSAFE).get()); request.appendf("&port=%d",GetPort()); request.appendf("&uploaded=%llu",GetTotalSent()); request.appendf("&downloaded=%llu",GetTotalRecv()); if(HasMetadata()) request.appendf("&left=%llu",GetTotalLeft()); request.append("&compact=1&no_peer_id=1"); if(event) request.appendf("&event=%s",event); const char *ip=ResMgr::Query("torrent:ip",0); if(ip && ip[0]) request.appendf("&ip=%s",ip); #if INET6 int port=Torrent::GetPortIPv4(); int port_ipv6=Torrent::GetPortIPv6(); const char *ipv6=ResMgr::Query("torrent:ipv6",0); if(port && ip && ip[0]) request.appendf("&ipv4=%s:%d",ip,port); if(port_ipv6) request.appendf("&ipv6=[%s]:%d",ipv6&&ipv6[0]?ipv6:Torrent::GetAddressIPv6(),port_ipv6); #endif int numwant=GetWantedPeersCount(); if(numwant>=0) request.appendf("&numwant=%d",numwant); const xstring& my_key=GetMyKey(); if(my_key) request.appendf("&key=%s",my_key.get()); const char *tracker_id=GetTrackerId(); if(tracker_id) request.appendf("&trackerid=%s",url::encode(tracker_id,URL_PATH_UNSAFE).get()); LogSend(4,request); t_session->Open(url::path_ptr(request),FA::RETRIEVE); t_session->SetFileURL(request); tracker_reply=new IOBufferFileAccess(t_session); } // UdpTracker int UdpTracker::Do() { int m=STALL; if(!peer) { // need to resolve addresses if(!resolver) { resolver=new Resolver(hostname,portname); resolver->Roll(); m=MOVED; } if(!resolver->Done()) return m; if(resolver->Error()) { SetError(resolver->ErrorMsg()); return(MOVED); } peer.set(resolver->Result()); peer_curr=0; resolver=0; try_number=0; m=MOVED; } if(!IsActive()) return m; if(sock==-1) { // need to create the socket sock=SocketCreate(peer[peer_curr].family(),SOCK_DGRAM,IPPROTO_UDP,hostname); if(sock==-1) { int saved_errno=errno; LogError(9,"socket: %s",strerror(saved_errno)); if(NonFatalError(saved_errno)) return m; xstring& str=xstring::format(_("cannot create socket of address family %d"), peer[peer_curr].family()); str.appendf(" (%s)",strerror(saved_errno)); SetError(str); return MOVED; } } if(current_action!=a_none) { if(!RecvReply()) { if(timeout_timer.Stopped()) { LogError(3,"request timeout"); NextPeer(); return MOVED; } return m; } return MOVED; } if(!has_connection_id) { // need to get connection id SendConnectRequest(); return MOVED; } SendEventRequest(); return MOVED; } void UdpTracker::NextPeer() { current_action=a_none; has_connection_id=false; connection_id=0; int old_peer=peer_curr; peer_curr++; if(peer_curr>=peer.count()) { peer_curr=0; try_number++; } // check if we need to create a socket of different address family if(old_peer!=peer_curr && peer[old_peer].family()!=peer[peer_curr].family()) { close(sock); sock=-1; } } bool UdpTracker::RecvReply() { Buffer buf; const int max_len=0x1000; sockaddr_u addr; socklen_t addr_len=sizeof(addr); int len=recvfrom(sock,buf.GetSpace(max_len),max_len,0,&addr.sa,&addr_len); if(len<0) { int saved_errno=errno; if(NonFatalError(saved_errno)) { Block(sock,POLLIN); return false; } SetError(xstring::format("recvfrom: %s",strerror(saved_errno))); return false; } if(len==0) { SetError("recvfrom: EOF?"); return false; } buf.SpaceAdd(len); LogRecv(10,xstring::format("got a packet from %s of length %d {%s}",addr.to_string(),len,buf.Dump())); if(len<16) { LogError(9,"ignoring too short packet"); return false; } unsigned tid=buf.UnpackUINT32BE(4); if(tid!=transaction_id) { LogError(9,"ignoring mismatching transaction packet (0x%08X!=0x%08X)",tid,transaction_id); return false; } int action=buf.UnpackUINT32BE(0); if(action!=current_action && action!=a_error) { LogError(9,"ignoring mismatching action packet (%d!=%d)",action,current_action); return false; } switch(action) { case a_none: abort(); case a_connect: connection_id=buf.UnpackUINT64BE(8); has_connection_id=true; LogNote(9,"connected"); break; case a_announce: case a_announce6: { SetInterval(buf.UnpackUINT32BE(8)); if(buf.Size()<20) break; unsigned leachers=buf.UnpackUINT32BE(12); unsigned seeders=buf.UnpackUINT32BE(16); LogNote(9,"leechers=%u seeders=%u",leachers,seeders); int peers_count=0; int compact_addr_size=6; if(current_action==a_announce6) compact_addr_size=18; for(int i=20; i+compact_addr_size<=buf.Size(); i+=compact_addr_size) { if(AddPeerCompact(buf.Get()+i,compact_addr_size)) peers_count++; } LogNote(4,plural("Received valid info about %d peer$|s$",peers_count),peers_count); current_event=ev_idle; TrackerRequestFinished(); break; } case a_scrape: // not implemented break; case a_error: SetError(buf.Get()+8); break; } current_action=a_none; try_number=0; return true; } bool UdpTracker::SendPacket(Buffer& req) { LogSend(10,xstring::format("sending a packet to %s of length %d {%s}",peer[peer_curr].to_string(),req.Size(),req.Dump())); int len=sendto(sock,req.Get(),req.Size(),0,&peer[peer_curr].sa,peer[peer_curr].addr_len()); if(len<0) { int saved_errno=errno; if(NonFatalError(saved_errno)) { Block(sock,POLLOUT); return false; } SetError(xstring::format("sendto: %s",strerror(saved_errno))); return false; } if(len=0 && e<=3) return map[e]; return "???"; } bool UdpTracker::SendEventRequest() { action_t action=a_announce; const char *a_name="announce"; #if INET6 if(peer[peer_curr].family()==AF_INET6) { action=a_announce6; a_name="announce6"; } #endif LogNote(9,"%s %s",a_name,EventToString(current_event)); assert(has_connection_id); assert(current_event!=ev_idle); Buffer req; req.PackUINT64BE(connection_id); req.PackUINT32BE(action); req.PackUINT32BE(NewTransactionId()); req.Append(GetInfoHash()); req.Append(GetMyPeerId()); req.PackUINT64BE(GetTotalRecv()); req.PackUINT64BE(GetTotalLeft()); req.PackUINT64BE(GetTotalSent()); req.PackUINT32BE(current_event); #if INET6 if(action==a_announce6) { const char *ip=ResMgr::Query("torrent:ipv6",0); char ip_packed[16]; memset(ip_packed,0,16); if(ip && ip[0]) inet_pton(AF_INET6,ip,ip_packed); req.Append(ip_packed,16); } else #endif { const char *ip=ResMgr::Query("torrent:ip",0); char ip_packed[4]; memset(ip_packed,0,4); if(ip && ip[0]) inet_pton(AF_INET,ip,ip_packed); req.Append(ip_packed,4); } req.PackUINT32BE(GetMyKeyNum()); req.PackUINT32BE(GetWantedPeersCount()); req.PackUINT16BE(GetPort()); if(!SendPacket(req)) return false; current_action=action; return true; } const char *UdpTracker::Status() const { if(resolver) return(_("Resolving host address...")); if(!has_connection_id) return(_("Connecting...")); if(current_action!=a_none) return _("Waiting for response..."); return ""; } void UdpTracker::SendTrackerRequest(const char *event) { current_event=ev_none; if(!event) return; if(!strcmp(event,"started")) current_event=ev_started; else if(!strcmp(event,"stopped")) current_event=ev_stopped; else if(!strcmp(event,"completed")) current_event=ev_completed; } lftp-4.6.3a/src/FtpListInfo.cc0000644000015000007670000004177512203062065013064 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "FtpListInfo.h" #include "FileSet.h" #include #include #include #include "xstring.h" #include #include "misc.h" #include "ftpclass.h" #include "ascii_ctype.h" #define number_of_parsers 7 FileSet *FtpListInfo::Parse(const char *buf,int len) { if(mode==FA::LONG_LIST || mode==FA::MP_LIST) { if(len==0 && mode==FA::LONG_LIST && !ResMgr::QueryBool("ftp:list-empty-ok",session->GetHostName())) { mode=FA::LIST; return 0; } int err; FileSet *set=session->ParseLongList(buf,len,&err); if(!set || err>0) { if(mode==FA::MP_LIST) mode=FA::LONG_LIST; else mode=FA::LIST; } return set; } else { return ParseShortList(buf,len); } } FileSet *Ftp::ParseLongList(const char *buf,int len,int *err_ret) const { if(err_ret) *err_ret=0; int err[number_of_parsers]; FileSet *set[number_of_parsers]; int i; for(i=0; iname,'/')) set[i]->Add(info); else delete info; if(*best_err1>err[i]) best_err1=&err[i]; if(*best_err2>err[i] && best_err1!=&err[i]) best_err2=&err[i]; if(*best_err2 > (*best_err1+1)*16) { i=best_err1-err; guessed_parser=line_parsers[i]; the_set=&set[i]; the_err=&err[i]; break; } if(*best_err1>16) goto leave; // too many errors with best parser. } } else { FileInfo *info=(*guessed_parser)(line.get_non_const(),the_err,tz); if(info && !strchr(info->name,'/')) (*the_set)->Add(info); else delete info; } } if(!the_set) { i=best_err1-err; the_set=&set[i]; the_err=&err[i]; } leave: for(i=0; i=2 && buf[0]=='.' && buf[1]=='/') { buf+=2; len-=2; } #if 0 // not possible here if(len>=2 && buf[0]=='/' && buf[1]=='/') { buf++; len--; } #endif const char *nl=(const char*)memchr(buf,'\n',len); if(!nl) break; line_len=nl-buf; if(line_len>0 && buf[line_len-1]=='\r') line_len--; FileInfo::type type=FileInfo::UNKNOWN; const char *slash=(const char*)memchr(buf,'/',line_len); if(slash) { type=FileInfo::DIRECTORY; line_len=slash-buf; } if(line_len==0) { len-=nl+1-buf; buf=nl+1; continue; } if(line_allocUNKNOWN) fi->SetType(type); set->Add(fi); } } return set; } static FileInfo *ParseFtpLongList_UNIX(char *line,int *err,const char *tz) { int tmp; if(sscanf(line,"total %d",&tmp)==1) return 0; if(!strncasecmp(line,"Status of ",10)) return 0; // STAT output. if(strchr("bcpsD",line[0])) // block, char, pipe, socket, Door. return 0; FileInfo *fi=FileInfo::parse_ls_line(line,tz); if(!fi) { (*err)++; return 0; } return fi; } #define FIRST_TOKEN strtok(line," \t") #define NEXT_TOKEN strtok(NULL," \t") #define ERR do{(*err)++;delete fi;return(0);}while(0) /* 07-13-98 09:06PM aix 07-13-98 09:06PM hpux 07-13-98 09:06PM linux 07-13-98 09:06PM ncr 07-13-98 09:06PM solaris 03-18-98 06:01AM 2109440 nlxb318e.tar 07-02-98 11:17AM 13844 Whatsnew.txt */ static FileInfo *ParseFtpLongList_NT(char *line,int *err,const char *tz) { char *t = FIRST_TOKEN; FileInfo *fi=0; if(t==0) ERR; int month,day,year; if(sscanf(t,"%2d-%2d-%2d",&month,&day,&year)!=3) ERR; if(year>=70) year+=1900; else year+=2000; t = NEXT_TOKEN; if(t==0) ERR; int hour,minute; char am; if(sscanf(t,"%2d:%2d%c",&hour,&minute,&am)!=3) ERR; t = NEXT_TOKEN; if(t==0) ERR; if(am=='P') // PM - after noon { hour+=12; if(hour==24) hour=0; } struct tm tms; tms.tm_sec=30; /* seconds after the minute [0, 61] */ tms.tm_min=minute; /* minutes after the hour [0, 59] */ tms.tm_hour=hour; /* hour since midnight [0, 23] */ tms.tm_mday=day; /* day of the month [1, 31] */ tms.tm_mon=month-1; /* months since January [0, 11] */ tms.tm_year=year-1900; /* years since 1900 */ tms.tm_isdst=-1; fi=new FileInfo(); fi->SetDate(mktime_from_tz(&tms,tz),30); long long size; if(!strcmp(t,"")) fi->SetType(fi->DIRECTORY); else { fi->SetType(fi->NORMAL); if(sscanf(t,"%lld",&size)!=1) ERR; fi->SetSize(size); } t=strtok(NULL,""); if(t==0) ERR; while(*t==' ') t++; if(*t==0) ERR; fi->SetName(t); return fi; } /* ASUSER 8192 04/26/05 13:54:16 *DIR dir/ ASUSER 8192 04/26/05 13:57:34 *DIR dir1/ ASUSER 365255 02/28/01 15:41:40 *STMF readme.txt ASUSER 8489625 03/18/03 09:37:00 *STMF saved.zip ASUSER 365255 02/28/01 15:41:40 *STMF unist.old */ static FileInfo *ParseFtpLongList_AS400(char *line,int *err,const char *tz) { char *t = FIRST_TOKEN; FileInfo *fi=0; if(t==0) ERR; char *user=t; t = NEXT_TOKEN; if(t==0) ERR; long long size; if(sscanf(t,"%lld",&size)!=1) ERR; t = NEXT_TOKEN; if(t==0) ERR; int month,day,year; if(sscanf(t,"%2d/%2d/%2d",&month,&day,&year)!=3) ERR; if(year>=70) year+=1900; else year+=2000; t = NEXT_TOKEN; if(t==0) ERR; int hour,minute,second; if(sscanf(t,"%2d:%2d:%2d",&hour,&minute,&second)!=3) ERR; t = NEXT_TOKEN; if(t==0) ERR; struct tm tms; tms.tm_sec=second; /* seconds after the minute [0, 61] */ tms.tm_min=minute; /* minutes after the hour [0, 59] */ tms.tm_hour=hour; /* hour since midnight [0, 23] */ tms.tm_mday=day; /* day of the month [1, 31] */ tms.tm_mon=month-1; /* months since January [0, 11] */ tms.tm_year=year-1900; /* years since 1900 */ tms.tm_isdst=-1; time_t mtime=mktime_from_tz(&tms,tz); t = NEXT_TOKEN; if(t==0) ERR; FileInfo::type type=FileInfo::UNKNOWN; if(!strcmp(t,"*DIR")) type=FileInfo::DIRECTORY; else type=FileInfo::NORMAL; t=strtok(NULL,""); if(t==0) ERR; while(*t==' ') t++; if(*t==0) ERR; char *slash=strchr(t,'/'); if(slash) { if(slash==t) return 0; *slash=0; type=FileInfo::DIRECTORY; if(slash[1]) { fi=new FileInfo(t); fi->SetType(type); return fi; } } fi=new FileInfo(t); fi->SetType(type); fi->SetSize(size); fi->SetDate(mtime,0); fi->SetUser(user); return fi; } /* +i774.71425,m951188401,/, users +i774.49602,m917883130,r,s79126, jgr_www2.exe starts with + comma separated first character of field is type: i - ? m - modification time / - means directory r - means plain file s - size up - permissions in octal \t - file name follows. */ FileInfo *ParseFtpLongList_EPLF(char *line,int *err,const char *) { int len=strlen(line); const char *b=line; FileInfo *fi=0; if(len<2 || b[0]!='+') ERR; const char *name=0; int name_len=0; off_t size=NO_SIZE; time_t date=NO_DATE; long date_l; long long size_ll; bool dir=false; bool type_known=false; int perms=-1; const char *scan=b+1; int scan_len=len-1; while(scan && scan_len>0) { switch(*scan) { case '\t': // the rest is file name. name=scan+1; name_len=scan_len-1; scan=0; break; case 's': if(1 != sscanf(scan+1,"%lld",&size_ll)) break; size = size_ll; break; case 'm': if(1 != sscanf(scan+1,"%ld",&date_l)) break; date = date_l; break; case '/': dir=true; type_known=true; break; case 'r': dir=false; type_known=true; break; case 'i': break; case 'u': if(scan[1]=='p') // permissions. if(sscanf(scan+2,"%o",&perms)!=1) perms=-1; break; default: name=0; scan=0; break; } if(scan==0 || scan_len==0) break; const char *comma=find_char(scan,scan_len,','); if(comma) { scan_len-=comma+1-scan; scan=comma+1; } else break; } if(name==0 || !type_known) ERR; fi=new FileInfo(xstring::get_tmp(name,name_len)); if(size!=NO_SIZE) fi->SetSize(size); if(date!=NO_DATE) fi->SetDate(date,0); if(type_known) { if(dir) fi->SetType(fi->DIRECTORY); else fi->SetType(fi->NORMAL); } if(perms!=-1) fi->SetMode(perms); return fi; } /* 0 DIR 06-27-96 11:57 PROTOCOL 169 11-29-94 09:20 SYSLEVEL.MPT */ static FileInfo *ParseFtpLongList_OS2(char *line,int *err,const char *tz) { FileInfo *fi=0; char *t = FIRST_TOKEN; if(t==0) ERR; long long size; if(sscanf(t,"%lld",&size)!=1) ERR; fi=new FileInfo; fi->SetSize(size); t = NEXT_TOKEN; if(t==0) ERR; fi->SetType(fi->NORMAL); if(!strcmp(t,"DIR")) { fi->SetType(fi->DIRECTORY); t = NEXT_TOKEN; if(t==0) ERR; } int month,day,year; if(sscanf(t,"%2d-%2d-%2d",&month,&day,&year)!=3) ERR; if(year>=70) year+=1900; else year+=2000; t = NEXT_TOKEN; if(t==0) ERR; int hour,minute; if(sscanf(t,"%2d:%2d",&hour,&minute)!=3) ERR; struct tm tms; tms.tm_sec=30; /* seconds after the minute [0, 61] */ tms.tm_min=minute; /* minutes after the hour [0, 59] */ tms.tm_hour=hour; /* hour since midnight [0, 23] */ tms.tm_mday=day; /* day of the month [1, 31] */ tms.tm_mon=month-1; /* months since January [0, 11] */ tms.tm_year=year-1900; /* years since 1900 */ tms.tm_isdst=-1; fi->SetDate(mktime_from_tz(&tms,tz),30); t=strtok(NULL,""); if(t==0) ERR; while(*t==' ') t++; if(*t==0) ERR; fi->SetName(t); return fi; } static FileInfo *ParseFtpLongList_MacWebStar(char *line,int *err,const char *tz) { FileInfo *fi=0; char *t = FIRST_TOKEN; if(t==0) ERR; fi=new FileInfo; switch(t[0]) { case('l'): // symlink fi->SetType(fi->SYMLINK); break; case('d'): // directory fi->SetType(fi->DIRECTORY); break; case('-'): // plain file fi->SetType(fi->NORMAL); break; case('b'): // block case('c'): // char case('p'): // pipe case('s'): // sock return 0; // ignore default: ERR; } mode_t mode=parse_perms(t+1); if(mode==(mode_t)-1) ERR; // permissions are meaningless here. // "folder" or 0 t = NEXT_TOKEN; if(!t) ERR; if(strcmp(t,"folder")) { // size? t = NEXT_TOKEN; if(!t) ERR; // size t = NEXT_TOKEN; if(!t) ERR; if(isdigit((unsigned char)*t)) { long long size; if(sscanf(t,"%lld",&size)==1) fi->SetSize(size); } else ERR; } else { // ?? t = NEXT_TOKEN; if(!t) ERR; } // month t = NEXT_TOKEN; if(!t) ERR; struct tm date; memset(&date,0,sizeof(date)); date.tm_mon=parse_month(t); if(date.tm_mon==-1) ERR; const char *day_of_month = NEXT_TOKEN; if(!day_of_month) ERR; date.tm_mday=atoi(day_of_month); // time or year t = NEXT_TOKEN; if(!t) ERR; if(parse_year_or_time(t,&date.tm_year,&date.tm_hour,&date.tm_min)==-1) ERR; date.tm_isdst=-1; date.tm_sec=30; int prec=30; if(date.tm_year==-1) date.tm_year=guess_year(date.tm_mon,date.tm_mday,date.tm_hour,date.tm_min) - 1900; else { date.tm_hour=12; prec=12*60*60; } fi->SetDate(mktime_from_tz(&date,tz),prec); char *name=strtok(NULL,""); if(!name) ERR; // no symlinks on Mac, but anyway. if(fi->filetype==fi->SYMLINK) { char *arrow=name; while((arrow=strstr(arrow," -> "))!=0) { if(arrow!=name && arrow[4]!=0) { *arrow=0; fi->SetSymlink(arrow+4); break; } arrow++; } } fi->SetName(name); return fi; } /* Type=cdir;Modify=20021029173810;Perm=el;Unique=BP8AAjJufAA; / Type=pdir;Modify=20021029173810;Perm=el;Unique=BP8AAjJufAA; .. Type=dir;Modify=20010118144705;Perm=e;Unique=BP8AAjNufAA; bin Type=dir;Modify=19981021003019;Perm=el;Unique=BP8AAlhufAA; pub Type=file;Size=12303;Modify=19970124132601;Perm=r;Unique=BP8AAo9ufAA; mailserv.FAQ */ FileInfo *ParseFtpLongList_MLSD(char *line,int *err,const char *) { FileInfo *fi=0; const char *name=0; off_t size=NO_SIZE; time_t date=NO_DATE; const char *owner=0; const char *group=0; bool dir=false; bool type_known=false; int perms=-1; char *space=strstr(line,"; "); if(space) { name=space+2; *space=0; } else { /* NcFTPd does not put a semicolon after last fact, workaround it. */ space=strchr(line,' '); if(!space) ERR; name=space+1; *space=0; } for(char *tok=strtok(line,";"); tok; tok=strtok(0,";")) { if(!strcasecmp(tok,"Type=cdir") || !strcasecmp(tok,"Type=pdir") || !strcasecmp(tok,"Type=dir")) { dir=true; type_known=true; continue; } if(!strcasecmp(tok,"Type=file")) { dir=false; type_known=true; } if(!strncasecmp(tok,"Modify=",7)) { date=Ftp::ConvertFtpDate(tok+7); continue; } if(!strncasecmp(tok,"Size=",5)) { long long size_ll; if(sscanf(tok+5,"%lld",&size_ll)==1) size=size_ll; continue; } if(!strncasecmp(tok,"Perm=",5)) { perms=0; for(tok+=5; *tok; tok++) { switch(to_ascii_lower(*tok)) { case 'e': perms|=0111; break; case 'l': perms|=0444; break; case 'r': perms|=0444; break; case 'c': perms|=0200; break; case 'w': perms|=0200; break; } } continue; } if(!strncasecmp(tok,"UNIX.mode=",10)) { if(sscanf(tok+10,"%o",&perms)!=1) perms=-1; continue; } if(!strncasecmp(tok,"UNIX.owner=",11)) { owner=tok+11; continue; } if(!strncasecmp(tok,"UNIX.group=",11)) { group=tok+11; continue; } if(!strncasecmp(tok,"UNIX.uid=",9)) { if(!owner) owner=tok+9; continue; } if(!strncasecmp(tok,"UNIX.gid=",9)) { if(!group) group=tok+9; continue; } } if(name==0 || !type_known) ERR; fi=new FileInfo(name); if(size!=NO_SIZE) fi->SetSize(size); if(date!=NO_DATE) fi->SetDate(date,0); if(type_known) { if(dir) fi->SetType(fi->DIRECTORY); else fi->SetType(fi->NORMAL); } if(perms!=-1) fi->SetMode(perms); if(owner) fi->SetUser(owner); if(group) fi->SetGroup(group); return fi; } Ftp::FtpLineParser Ftp::line_parsers[number_of_parsers+1]={ ParseFtpLongList_UNIX, ParseFtpLongList_NT, ParseFtpLongList_EPLF, ParseFtpLongList_MLSD, ParseFtpLongList_AS400, ParseFtpLongList_OS2, ParseFtpLongList_MacWebStar, 0 }; lftp-4.6.3a/src/Filter.cc0000644000015000007670000002130512500302444012071 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "trio.h" #include #include #include #include #include #include #include #include #include "Filter.h" #include "SignalHook.h" #include "ArgV.h" #include "misc.h" #include "FileSet.h" #include "ResMgr.h" #include "log.h" #ifndef O_BINARY # define O_BINARY 0 #endif FDStream::FDStream(int new_fd,const char *new_name) : close_when_done(false), closed(false), fd(new_fd), name(new_name?expand_home_relative(new_name):0), status(0) {} FDStream::FDStream() : close_when_done(false), closed(false), fd(-1), status(0) {} void FDStream::MakeErrorText(int e) { if(!e) e=errno; if(NonFatalError(e)) return; // not a serious error - can be retried error_text.vset(name.get(),": ",strerror(e),NULL); } void FDStream::SetCwd(const char *new_cwd) { cwd.set(new_cwd); } void FDStream::DoCloseFD() { if(fd!=-1) { if(close_when_done) { close(fd); Log::global->Format(11,"closed FD %d\n",fd); } fd=-1; } } void FDStream::SetFD(int new_fd,bool c) { DoCloseFD(); fd=new_fd; close_when_done=c; } bool FDStream::Done() { if(closed) return true; DoCloseFD(); closed=true; return true; } FDStream::~FDStream() { DoCloseFD(); }; void OutputFilter::Parent(int *p) { close(p[0]); SetFD(p[1],true); } void InputFilter::Parent(int *p) { close(p[1]); SetFD(p[0],true); } void OutputFilter::Child(int *p) { close(p[1]); if(p[0]!=0) { dup2(p[0],0); close(p[0]); } if(second_fd!=-1) { if(second_fd!=1) { dup2(second_fd,1); close(second_fd); } int fl=fcntl(1,F_GETFL); fcntl(1,F_SETFL,fl&~O_NONBLOCK); } } void InputFilter::Child(int *p) { close(p[0]); if(p[1]!=1) { dup2(p[1],1); close(p[1]); } if(second_fd!=-1) { if(second_fd!=0) { dup2(second_fd,0); close(second_fd); } int fl=fcntl(0,F_GETFL); fcntl(0,F_SETFL,fl&~O_NONBLOCK); } } int OutputFilter::getfd() { if(fd!=-1 || error() || closed) return fd; if(second && second_fd==-1) { second_fd=second->getfd(); if(second_fd==-1) { if(second->error()) error_text.set(second->error_text); return -1; } if(pg==0) pg=second->GetProcGroup(); } int p[2]; pid_t pid; if(pipe(p)==-1) { if(NonFatalError(errno)) return -1; error_text.vset(_("pipe() failed: "),strerror(errno),NULL); return -1; } ProcWait::Signal(false); bool had_pg=(pg!=0); fflush(stdout); fflush(stderr); switch(pid=fork()) { case(0): /* child */ setpgid(0,pg); kill(getpid(),SIGSTOP); SignalHook::RestoreAll(); Child(p); if(stderr_to_stdout) dup2(1,2); if(stdout_to_null) { close(1); int null=open("/dev/null",O_RDWR); if(null==-1) perror("open(\"/dev/null\")"); else if(null==0) { if(dup(0)==-1) perror("dup"); } } if(cwd) { if(chdir(cwd)==-1) { fprintf(stderr,_("chdir(%s) failed: %s\n"),cwd.get(),strerror(errno)); fflush(stderr); _exit(1); } } if(a) { execvp(a->a0(),a->GetVNonConst()); fprintf(stderr,_("execvp(%s) failed: %s\n"),a->a0(),strerror(errno)); } else { execl("/bin/sh","sh","-c",name.get(),NULL); fprintf(stderr,_("execl(/bin/sh) failed: %s\n"),strerror(errno)); } fflush(stderr); _exit(1); case(-1): /* error */ close(p[0]); close(p[1]); goto out; } if(pg==0) pg=pid; /* parent */ Parent(p); fcntl(fd,F_SETFD,FD_CLOEXEC); fcntl(fd,F_SETFL,O_NONBLOCK); // wait until the child stops. int info; waitpid(pid,&info,WUNTRACED); w=new ProcWait(pid); if(had_pg) kill(pid,SIGCONT); out: ProcWait::Signal(true); return fd; } void OutputFilter::Init() { w=0; second_fd=-1; cwd.set_allocated(xgetcwd()); pg=0; stderr_to_stdout=false; stdout_to_null=false; if(a) name.set_allocated(a->Combine()); } OutputFilter::OutputFilter(const char *filter,int new_second_fd) : FDStream(-1,filter), second(my_second), second_fd(new_second_fd) { Init(); } OutputFilter::OutputFilter(const char *filter,FDStream *new_second) : FDStream(-1,filter), my_second(new_second), second(my_second) { Init(); } OutputFilter::OutputFilter(const char *filter,const Ref& new_second) : FDStream(-1,filter), second(new_second) { Init(); } OutputFilter::OutputFilter(ArgV *a1,int new_second_fd) : FDStream(-1,0), a(a1), second(my_second), second_fd(new_second_fd) { Init(); } OutputFilter::OutputFilter(ArgV *a1,FDStream *new_second) : FDStream(-1,0), a(a1), my_second(new_second), second(my_second) { Init(); } OutputFilter::OutputFilter(ArgV *a1,const Ref& new_second) : FDStream(-1,0), a(a1), second(new_second) { Init(); } OutputFilter::~OutputFilter() { if(w) w->Auto(); } bool OutputFilter::Done() { if(!FDStream::Done()) return false; if(w==0) return true; if(w->GetState()!=w->RUNNING) { if(my_second) return my_second->Done(); return true; } return false; } bool OutputFilter::broken() { if(w==0) return false; if(fd==-1) return false; if(w->GetState()!=w->RUNNING) return true; // filter process terminated - pipe is broken return false; } void OutputFilter::Kill(int sig) { if(w) w->Kill(sig); if(second) second->Kill(sig); } bool OutputFilter::usesfd(int n_fd) { if(FDStream::usesfd(n_fd)) return true; if(second_fd!=-1 && n_fd==second_fd) return true; if(second) return second->usesfd(n_fd); return n_fd<=2; } void FileStream::setmtime(const FileTimestamp &ts) { getfd(); // this might create the file... But can fail retriably. FIXME. // skip the time update if the timestamp is already accurate enough. struct stat st; if(fstat(fd,&st)!=-1 && labs(st.st_mtime-ts)<=ts.ts_prec) return; struct utimbuf ut; ut.actime=ut.modtime=ts; utime(full_name,&ut); } FileStream::FileStream(const char *fname,int new_mode) : FDStream(-1,fname), mode(new_mode), create_mode(0664), do_lock(ResMgr::QueryBool("file:use-lock",0)) { if(name[0]=='/') full_name.set(name); else { cwd.set_allocated(xgetcwd()); full_name.set(dir_file(cwd,name)); } } FileStream::~FileStream() { } void FileStream::remove() { ::remove(full_name); } void FileStream::remove_if_empty() { if(!full_name) return; struct stat st; int res=stat(full_name,&st); if(res!=-1 && st.st_size==0) remove(); } int FileStream::getfd() { if(fd!=-1 || error() || closed) return fd; int new_fd=open(full_name,mode|O_NONBLOCK|O_BINARY,create_mode); if(new_fd==-1) { MakeErrorText(); return -1; } Log::global->Format(11,"opened FD %d (%s)\n",new_fd,full_name.get()); SetFD(new_fd,true); fcntl(fd,F_SETFD,FD_CLOEXEC); if(do_lock && !(mode&O_APPEND)) { struct flock lk; lk.l_type=((mode&3)==0)?F_RDLCK:F_WRLCK; lk.l_whence=SEEK_SET; lk.l_start=0; lk.l_len=0; if(fcntl(fd,F_SETLKW,&lk)==-1) { MakeErrorText(); DoCloseFD(); return -1; } } return fd; } bool FileStream::can_seek() { if(mode&O_APPEND) return false; // whatever we seek, the writes will go to end of file. return true; } off_t FileStream::get_size() { struct stat st; if(-1==(fd==-1?stat(full_name,&st):fstat(fd,&st))) { if(errno==ENOENT) return 0; // assume non-existent files to be empty. return -1; } return st.st_size; } #include "SMTask.h" bool FDStream::NonFatalError(int err) { if(err==EDQUOT || err==ENOSPC) { struct stat st; if(fd>=0 && fstat(fd,&st)!=-1 && st.st_nlink==0) return false; } bool non_fatal=SMTask::NonFatalError(err); if(non_fatal) set_status(strerror(err)); else clear_status(); return non_fatal; } lftp-4.6.3a/src/ConnectionSlot.h0000644000015000007670000000315012122057271013452 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef CONNECTIONSLOT_H #define CONNECTIONSLOT_H #include "FileAccess.h" #include "keyvalue.h" class ConnectionSlot : public KeyValueDB { static ConnectionSlot lftp_slots; class SlotValue : public KeyValueDB::Pair { public: FileAccessRef session; SlotValue(const char *n,const FileAccess *s); SlotValue(const char *n,const char *v); }; Pair *NewPair(const char *n,const char *v) { return new SlotValue(n,v); } public: static ConnectionSlot::SlotValue *Find(const char *n); static const FileAccess *FindSession(const char *n); static void Set(const char *n,const FileAccess *s); static void SetCwd(const char *n,const FileAccess::Path &cwd); static void Remove(const char *n); static char *Format(); char *FormatThis(); static void Cleanup(); ConnectionSlot(); ~ConnectionSlot(); }; #endif lftp-4.6.3a/src/log.cc0000644000015000007670000000522412343574022011437 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "trio.h" #include "xstring.h" #include "log.h" #include "SMTask.h" #include "strftime.h" SMTaskRef Log::global; void Log::Init() { output=-1; need_close_output=false; tty_cb=0; enabled=false; level=0; tty=false; show_pid=true; show_time=true; show_context=true; at_line_start=true; } bool Log::WillOutput(int l) { if(!this || !enabled || l>level || output==-1) return false; if(tty) { pid_t pg=tcgetpgrp(output); if(pg!=(pid_t)-1 && pg!=getpgrp()) return false; } return true; } void Log::Write(int l,const char *s) { if(!WillOutput(l)) return; DoWrite(s); } void Log::DoWrite(const char *s) { if(!s || !*s) return; if(at_line_start) { if(tty_cb && tty) tty_cb(); if(show_pid) { char *pid=string_alloca(15); pid[14]=0; snprintf(pid,14,"[%ld] ",(long)getpid()); write(output,pid,strlen(pid)); } if(show_time) { time_t t=now; char *ts=string_alloca(21); strftime(ts,21,"%Y-%m-%d %H:%M:%S ",localtime(&t)); write(output,ts,20); } if(show_context) { const char *ctx=current->GetLogContext(); if(ctx) { write(output,ctx,strlen(ctx)); write(output," ",1); } } } int len=strlen(s); write(output,s,len); at_line_start=(s[len-1]=='\n'); } int Log::Do() { return STALL; } void Log::Format(int l,const char *f,...) { if(!WillOutput(l)) return; va_list v; va_start(v,f); DoWrite(xstring::vformat(f,v)); va_end(v); } void Log::vFormat(int l,const char *f,va_list v) { if(!WillOutput(l)) return; DoWrite(xstring::vformat(f,v)); } void Log::Cleanup() { global=0; } Log::~Log() { CloseOutput(); } void Log::SetOutput(int o,bool need_close) { CloseOutput(); output=o; need_close_output=need_close; if(output!=-1) tty=isatty(output); } lftp-4.6.3a/src/lftp_ssl.h0000644000015000007670000001012312122060141012323 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef LFTP_SSL_H #define LFTP_SSL_H #if USE_SSL # if USE_GNUTLS # include # elif USE_OPENSSL # include # include # include # include # endif #include "xstring.h" class lftp_ssl_base { public: bool handshake_done; int fd; xstring_c hostname; enum handshake_mode_t { CLIENT, SERVER } handshake_mode; xstring error; bool fatal; bool cert_error; lftp_ssl_base(int fd,handshake_mode_t m,const char *host=0); enum code { RETRY=-2, ERROR=-1, DONE=0 }; void set_error(const char *s1,const char *s2); void set_cert_error(const char *s); }; #if USE_GNUTLS #include #if LFTP_LIBGNUTLS_VERSION_CODE < 0x010201 /* Compatibility defintions for old gnutls */ typedef gnutls_session gnutls_session_t; typedef gnutls_anon_server_credentials gnutls_anon_server_credentials_t; typedef gnutls_dh_params gnutls_dh_params_t; typedef gnutls_certificate_credentials gnutls_certificate_credentials_t; typedef gnutls_transport_ptr gnutls_transport_ptr_t; typedef gnutls_x509_crt gnutls_x509_crt_t; typedef gnutls_x509_crl gnutls_x509_crl_t; typedef gnutls_x509_crt_fmt gnutls_x509_crt_fmt_t; typedef gnutls_datum gnutls_datum_t; #endif #include "SMTask.h" class lftp_ssl_gnutls_instance : public SMTask { gnutls_x509_crl_t *crl_list; unsigned crl_list_size; gnutls_x509_crt_t *ca_list; unsigned ca_list_size; friend class lftp_ssl_gnutls; void LoadCA(); void LoadCRL(); public: lftp_ssl_gnutls_instance(); ~lftp_ssl_gnutls_instance(); int Do() { return STALL; } void Reconfig(const char *); }; class lftp_ssl_gnutls : public lftp_ssl_base { static lftp_ssl_gnutls_instance *instance; gnutls_session_t session; gnutls_certificate_credentials_t cred; void verify_certificate_chain(const gnutls_datum_t *cert_chain,int cert_chain_length); void verify_cert2(gnutls_x509_crt_t crt,gnutls_x509_crt_t issuer); void verify_last_cert(gnutls_x509_crt_t crt); int do_handshake(); bool check_fatal(int res); public: static void global_init(); static void global_deinit(); lftp_ssl_gnutls(int fd,handshake_mode_t m,const char *host=0); ~lftp_ssl_gnutls(); int read(char *buf,int size); int write(const char *buf,int size); bool want_in(); bool want_out(); void copy_sid(const lftp_ssl_gnutls *); void load_keys(); void shutdown(); }; typedef lftp_ssl_gnutls lftp_ssl; #elif USE_OPENSSL class lftp_ssl_openssl_instance { public: SSL_CTX *ssl_ctx; X509_STORE *crl_store; lftp_ssl_openssl_instance(); ~lftp_ssl_openssl_instance(); }; class lftp_ssl_openssl : public lftp_ssl_base { static lftp_ssl_openssl_instance *instance; SSL *ssl; bool check_fatal(int res); int do_handshake(); const char *strerror(); public: static int verify_crl(X509_STORE_CTX *ctx); static int verify_callback(int ok,X509_STORE_CTX *ctx); void check_certificate(); static void global_init(); static void global_deinit(); lftp_ssl_openssl(int fd,handshake_mode_t m,const char *host=0); ~lftp_ssl_openssl(); int read(char *buf,int size); int write(const char *buf,int size); bool want_in(); bool want_out(); void copy_sid(const lftp_ssl_openssl *); void load_keys(); void shutdown(); }; typedef lftp_ssl_openssl lftp_ssl; #endif #endif//USE_SSL #endif//LFTP_SSL_H lftp-4.6.3a/src/echoJob.h0000644000015000007670000000231512122057331012061 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef ECHOJOB_H #define ECHOJOB_H #include "Job.h" #include "StatusLine.h" #include "OutputJob.h" class echoJob : public Job { JobRef output; public: int Do() { return STALL; } int Done(); int ExitCode(); void ShowRunStatus(const SMTaskRef&); echoJob(const char *buf, OutputJob *output); echoJob(const char *buf, int len, OutputJob *output); ~echoJob(); void Fg(); void Bg(); }; #endif // ECHOJOB_H lftp-4.6.3a/src/lftp_tinfo.cc0000644000015000007670000000422512151576135013026 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include extern "C" { #if defined(HAVE_CURSES_H) # include # if defined(HAVE_TERM_H) # include # elif defined(HAVE_NCURSES_TERM_H) # include # endif #elif defined(HAVE_NCURSES_CURSES_H) # include # if defined(HAVE_NCURSES_TERM_H) # include # elif defined(HAVE_TERM_H) # include # endif #elif defined(HAVE_TERMCAP_H) # include #endif } #include #include "lftp_tinfo.h" static bool terminfo_ok = true; static void init_terminfo() { static bool initted = false; if(initted) return; initted = true; #if defined(HAVE_TIGETSTR) int errret=0; if(setupterm(NULL, 1, &errret) == ERR) terminfo_ok = false; #elif defined(HAVE_TGETSTR) static char buf[2048]; const char *term=getenv("TERM"); if(!term || tgetent(buf,term) == -1) terminfo_ok = false; #endif } const char *get_string_term_cap(const char *terminfo_cap, const char *tcap_cap) { init_terminfo(); if(!terminfo_ok) return 0; #if defined(HAVE_TIGETSTR) /* Cast to work around missing const def in some ncurses installations: */ const char *ret = tigetstr(const_cast(terminfo_cap)); if(ret && ret != (char *)-1) return ret; #elif defined(HAVE_TGETSTR) const char *ret = tgetstr(const_cast(tcap_cap), 0); if(ret && ret != (const char *)-1) return ret; #endif return NULL; } lftp-4.6.3a/src/Resolver.cc0000644000015000007670000005074212377313772012476 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "Resolver.h" #include "SignalHook.h" #include #include #include "trio.h" #include #include #include #include #include #include #include #ifdef HAVE_ARPA_NAMESER_H # define class _class // workaround for FreeBSD 3.2. # include # undef class #endif #ifdef HAVE_RESOLV_H # include #endif #ifdef DNSSEC_LOCAL_VALIDATION # include "validator/validator.h" #endif #include "xstring.h" #include "ResMgr.h" #include "log.h" #include "plural.h" #ifndef C_IN # define C_IN 1 #endif #ifndef T_SRV # define T_SRV 33 #endif #if !HAVE_DECL_HSTRERROR extern "C" { const char *hstrerror(int); } #endif #ifdef HAVE_H_ERRNO #if !HAVE_DECL_H_ERRNO CDECL int h_errno; #endif #endif #if HAVE_RES_SEARCH && !HAVE_DECL_RES_SEARCH CDECL int res_search(const char*,int,int,unsigned char*,int); #endif #if INET6 # define DEFAULT_ORDER "inet inet6" #else # define DEFAULT_ORDER "inet" #endif struct address_family { int number; const char *name; }; static const address_family af_list[]= { { AF_INET, "inet" }, #if INET6 { AF_INET6, "inet6" }, #endif { -1, 0 } }; ResolverCache *Resolver::cache; Resolver::Resolver(const char *h,const char *p,const char *defp, const char *ser,const char *pr) : hostname(h), portname(p), service(ser), proto(pr), defport(defp) { port_number=0; pipe_to_child[0]=pipe_to_child[1]=-1; done=false; timeout_timer.SetResource("dns:fatal-timeout",hostname); Reconfig(); use_fork=ResMgr::QueryBool("dns:use-fork",0); error=0; no_cache=false; } Resolver::~Resolver() { if(pipe_to_child[0]!=-1) close(pipe_to_child[0]); if(pipe_to_child[1]!=-1) close(pipe_to_child[1]); if(w) { w->Kill(SIGKILL); w.borrow()->Auto(); } } int Resolver::Do() { if(done) return STALL; int m=STALL; if(!no_cache && cache) { const sockaddr_u *a; int n; cache->Find(hostname,portname,defport,service,proto,&a,&n); if(a && n>0) { LogNote(10,"dns cache hit"); addr.nset(a,n); done=true; return MOVED; } no_cache=true; } if(use_fork) { if(pipe_to_child[0]==-1) { int res=pipe(pipe_to_child); if(res==-1) { if(NonFatalError(errno)) return m; MakeErrMsg("pipe()"); return MOVED; } fcntl(pipe_to_child[0],F_SETFL,O_NONBLOCK); fcntl(pipe_to_child[0],F_SETFD,FD_CLOEXEC); fcntl(pipe_to_child[1],F_SETFD,FD_CLOEXEC); m=MOVED; LogNote(4,_("Resolving host address...")); } if(!w && !buf) { pid_t proc=fork(); if(proc==-1) { TimeoutS(1); return m; } if(proc==0) { // child SignalHook::Ignore(SIGINT); SignalHook::Ignore(SIGTSTP); SignalHook::Ignore(SIGQUIT); SignalHook::Ignore(SIGHUP); close(0); // no input will be needed. close(pipe_to_child[0]); pipe_to_child[0]=-1; buf=new IOBufferFDStream(new FDStream(pipe_to_child[1],""),IOBuffer::PUT); DoGethostbyname(); _exit(0); } // parent close(pipe_to_child[1]); pipe_to_child[1]=-1; w=new ProcWait(proc); m=MOVED; } if(!buf) { buf=new IOBufferFDStream(new FDStream(pipe_to_child[0],""),IOBuffer::GET); // Roll(buf); m=MOVED; } } else /* !use_fork */ { if(!buf) { LogNote(4,_("Resolving host address...")); buf=new IOBuffer(IOBuffer::GET); DoGethostbyname(); if(Deleted()) return MOVED; } } if(buf->Error()) { err_msg.set(buf->ErrorText()); done=true; return MOVED; } if(!buf->Eof()) // wait for all data to arrive (not too much) { if(timeout_timer.Stopped()) { err_msg.set(_("host name resolve timeout")); done=true; return MOVED; } return m; } const char *s; char c; int n; buf->Get(&s,&n); if(n<1) goto proto_error; c=*s; buf->Skip(1); buf->Get(&s,&n); if(c=='E' || c=='P') // error { const char *tport=portname?portname.get():defport.get(); err_msg.vset(c=='E'?hostname.get():tport,": ",s,NULL); done=true; return MOVED; } if((unsigned)nAdd(hostname,portname,defport,service,proto,addr.get(),addr.count()); xstring report; report.set(xstring::format(plural("%d address$|es$ found",addr.count()),addr.count())); if(addr.count()>0) { report.append(": "); for(int i=0; i0 && addr.last()==add) return; addr.append(add); } int Resolver::FindAddressFamily(const char *name) { for(const address_family *f=af_list; f->name; f++) { if(!strcasecmp(name,f->name)) return f->number; } return -1; } void Resolver::ParseOrder(const char *s,int *o) { const char * const delim="\t "; char *s1=alloca_strdup(s); int idx=0; for(s1=strtok(s1,delim); s1; s1=strtok(0,delim)) { int af=FindAddressFamily(s1); if(af!=-1 && idx<15) { if(o) o[idx]=af; idx++; } } if(o) o[idx]=-1; } #if defined(HAVE_DN_EXPAND) && !HAVE_DECL_DN_EXPAND CDECL int dn_expand(const unsigned char *msg,const unsigned char *eomorig,const unsigned char *comp_dn,char *exp_dn,int length); CDECL int dn_skipname(const unsigned char *msg,const unsigned char *eomorig); #endif #ifdef HAVE_RES_SEARCH static int extract_domain(const unsigned char *answer,const unsigned char *scan,int len, char *store,int store_len) { #ifdef HAVE_DN_EXPAND // newer resolver versions have dn_expand and dn_skipname if(store) dn_expand(answer,scan+len,scan,store,store_len); return dn_skipname(scan,scan+len); #else // ...older don't. int count=1; // reserve space for \0 int refs=0; int consumed=0; const unsigned char *start=scan; for(;;) { if(len<=0) break; int label_len=*scan; scan++; len--; if((label_len & 0xC0) == 0xC0) // compression { if(len<=0) break; int offset=((label_len&0x3F)<<8) + *scan; scan++; len--; if(refs==0) consumed=scan-start; if(answer+offset>=scan+len) break; // error len=scan+len-answer+offset; scan=answer+offset; if(++refs > 256) break; // too many hops. continue; } if(label_len==0) break; while(label_len>0) { if(len<=0) break; if(store && countpriority < sb->priority) return -1; if(sa->priority > sb->priority) return 1; if(sa->order < sb->order) return -1; if(sa->order > sb->order) return 1; if(sa->weight > sb->weight) return -1; if(sa->weight < sb->weight) return 1; return 0; } #endif // RES_SEARCH void Resolver::LookupSRV_RR() { if(!ResMgr::QueryBool("dns:SRV-query",hostname)) return; #ifdef HAVE_RES_SEARCH const char *tproto=proto?proto.get():"tcp"; time_t try_time; unsigned char answer[0x1000]; const char *srv_name=xstring::format("_%s._%s.%s",service.get(),tproto,hostname.get()); srv_name=alloca_strdup(srv_name); int retries=0; int max_retries=ResMgr::Query("dns:max-retries",hostname); int len; for(;;) { if(!use_fork) { Schedule(); if(Deleted()) return; } time(&try_time); #ifndef DNSSEC_LOCAL_VALIDATION len=res_search(srv_name, C_IN, T_SRV, answer, sizeof(answer)); if(len>=0) break; #else val_status_t val_status; bool require_trust = ResMgr::QueryBool("dns:strict-dnssec",hostname); len=val_res_search(NULL, srv_name, C_IN, T_SRV, answer, sizeof(answer), &val_status); if(len>=0) { if(require_trust && !val_istrusted(val_status)) return; else break; } #endif #ifdef HAVE_H_ERRNO if(h_errno!=TRY_AGAIN) return; if(++retries>=max_retries && max_retries) return; time_t t=time(0); if(t-try_time<5) sleep(5-(t-try_time)); #else // no h_errno return; #endif } if(len>(int)sizeof(answer)) len=sizeof(answer); if(len0; question_count--) { int dom_len=extract_domain(answer,scan,len,0,0); if(dom_len<0) return; scan+=dom_len; len-=dom_len; if(len<4) return; scan+=4; len-=4; } xarray SRVs; // now process answers section for( ; answer_count>0; answer_count--) { int dom_len=extract_domain(answer,scan,len,0,0); if(dom_len<0) return; scan+=dom_len; len-=dom_len; if(len<8) return; scan+=8; len-=8; // skip type,class,ttl if(len<2) return; int data_len=(scan[0]<<8)+scan[1]; scan+=2; len-=2; if(len0) { int r=int(rand()/(RAND_MAX+1.0)*weight_sum); if(r>=weight_sum) r=weight_sum-1; int w=0; for(s=base; sai_next) { if(a_res->ai_family!=af) continue; sockname = a_res->ai_addr; addr_scope = 0; switch(a_res->ai_family) { case AF_INET: inet_addr = (sockaddr_in *)sockname; addr_data = (const char *)&(inet_addr->sin_addr.s_addr); addr_len = sizeof(inet_addr->sin_addr.s_addr); break; case AF_INET6: inet6_addr = (sockaddr_in6 *)sockname; addr_data = (const char *)&(inet6_addr->sin6_addr.s6_addr); #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID addr_scope = inet6_addr->sin6_scope_id; #endif addr_len = sizeof(inet6_addr->sin6_addr.s6_addr); break; default: continue; } AddAddress(a_res->ai_family, addr_data, addr_len, addr_scope); } } freeaddrinfo(ainfo); break; } if(ainfo_res != EAI_AGAIN || (++retries>=max_retries && max_retries)) { error = gai_strerror(ainfo_res); break; } #else // !HAVE_GETADDRINFO int af=af_order[af_index]; if(af==-1) break; struct hostent *ha; # if defined(HAVE_GETIPNODEBYNAME) # ifndef HAVE_H_ERRNO # define HAVE_H_ERRNO 1 # endif # undef h_errno // it could be a macro, but we want it to be local variable. int h_errno=0; ha=getipnodebyname(name,af,0,&h_errno); # elif defined(HAVE_GETHOSTBYNAME2) ha=gethostbyname2(name,af); # else if(af==AF_INET) ha=gethostbyname(name); else { retries=0; af_index++; continue; } # endif if(ha) { const char * const *a; for(a=ha->h_addr_list; *a; a++) AddAddress(ha->h_addrtype, *a, ha->h_length, 0); retries=0; af_index++; # if defined(HAVE_GETIPNODEBYNAME) freehostent(ha); # endif continue; } # ifdef HAVE_H_ERRNO if(h_errno!=TRY_AGAIN || (++retries>=max_retries && max_retries)) # endif { if(error==0) { # ifdef HAVE_H_ERRNO error=hstrerror(h_errno); # else error=_("Host name lookup failure"); # endif } retries=0; af_index++; continue; // try other address families } #endif /* HAVE_GETADDRINFO */ time_t t; if((t=time(0))-try_time<5) sleep(5-(t-try_time)); } } void Resolver::DoGethostbyname() { if(port_number==0) { const char *tproto=proto?proto.get():"tcp"; const char *tport=portname?portname.get():defport.get(); if(isdigit((unsigned char)tport[0])) port_number=htons(atoi(tport)); else { struct servent *se=getservbyname(tport,tproto); if(se) port_number=se->s_port; else { buf->Put("P"); buf->Format(_("no such %s service"),tproto); goto flush; } } } if(service && !portname && !isdigit((unsigned char)hostname[0])) LookupSRV_RR(); if(!use_fork && Deleted()) return; LookupOne(hostname); if(!use_fork && Deleted()) return; if(addr.count()==0) { buf->Put("E"); if(error==0) error=_("No address found"); buf->Put(error); goto flush; } buf->Put("O"); buf->Put((const char*)addr.get(),addr.count()*addr.get_element_size()); addr.unset(); flush: buf->PutEOF(); if(use_fork) { while(buf->Size()>0 && !buf->Error() && !buf->Broken()) buf->Roll(); // should flush quickly. } } void Resolver::Reconfig(const char *name) { if(!name || strncmp(name,"dns:",4)) return; } ResolverCache::ResolverCache() : Cache(ResMgr::FindRes("dns:cache-size"),ResMgr::FindRes("dns:cache-enable")) { } void ResolverCache::Reconfig(const char *r) { if(!xstrcmp(r,"dns:SRV-query") || !xstrcmp(r,"dns:order")) Flush(); } ResolverCacheEntry *ResolverCache::Find(const char *h,const char *p,const char *defp,const char *ser,const char *pr) { for(ResolverCacheEntry *c=IterateFirst(); c; c=IterateNext()) { if(c->Matches(h,p,defp,ser,pr)) return c; } return 0; } void ResolverCache::Add(const char *h,const char *p,const char *defp, const char *ser,const char *pr,const sockaddr_u *a,int n) { Trim(); ResolverCacheEntry *c=Find(h,p,defp,ser,pr); if(c) c->SetData(a,n); else { if(!IsEnabled(h)) return; AddCacheEntry(new ResolverCacheEntry(h,p,defp,ser,pr,a,n)); } } bool ResolverCacheEntryLoc::Matches(const char *h,const char *p, const char *defp,const char *ser,const char *pr) { return (!xstrcasecmp(hostname,h) && !xstrcmp(portname,p) && !xstrcmp(defport,defp) && !xstrcmp(service,ser) && !xstrcmp(proto,pr)); } void ResolverCache::Find(const char *h,const char *p,const char *defp, const char *ser,const char *pr,const sockaddr_u **a,int *n) { *a=0; *n=0; // if cache is disabled for this host, return nothing. if(!IsEnabled(h)) return; ResolverCacheEntry *c=Find(h,p,defp,ser,pr); if(c) { if(c->Stopped()) { Trim(); return; } c->GetData(a,n); } } lftp-4.6.3a/src/Cache.cc0000644000015000007670000000313712122057132011653 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "Cache.h" void Cache::Trim() { long sizelimit=res_max_size->Query(0); long size=0; CacheEntry **scan=&chain; while(scan[0]) { if(scan[0]->Stopped()) delete replace_value(scan[0],scan[0]->next); else { size+=scan[0]->EstimateSize(); scan=&scan[0]->next; } } // printf("Cache::Trim size=%ld, limit=%ld\n",size,sizelimit); while(chain && size>sizelimit) { size-=chain->EstimateSize(); delete replace_value(chain,chain->next); } } void Cache::Flush() { while(chain) delete replace_value(chain,chain->next); } CacheEntry *Cache::IterateFirst() { curr=&chain; return *curr; } CacheEntry *Cache::IterateNext() { curr=&curr[0]->next; return *curr; } CacheEntry *Cache::IterateDelete() { delete replace_value(curr[0],curr[0]->next); return *curr; } lftp-4.6.3a/src/modconfig.h0000644000015000007670000000063412122054516012461 00000000000000#ifdef WITH_MODULES # define MODULE_NETWORK 1 # define MODULE_PROTO_FTP 1 # define MODULE_PROTO_HTTP 1 # define MODULE_PROTO_FILE 1 # define MODULE_PROTO_FISH 1 # define MODULE_PROTO_SFTP 1 # define MODULE_CMD_MIRROR 1 # define MODULE_CMD_SLEEP 1 # define MODULE_CMD_TORRENT 1 #endif /* declarations for use in modules */ CDECL_BEGIN extern const char *module_depend[]; extern void module_init(); CDECL_END lftp-4.6.3a/src/lftp_tinfo.h0000644000015000007670000000160512122060154012652 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef LFTP_TINFO_H #define LFTP_TINFO_H const char *get_string_term_cap(const char *terminfo_cap, const char *tcap_cap=NULL); #endif lftp-4.6.3a/src/ResMgr.h0000644000015000007670000001606612513707514011730 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef RESMGR_H #define RESMGR_H #include "trio.h" #include #include #include "TimeDate.h" #include "xstring.h" #include "xlist.h" #include "xmap.h" typedef const char *ResValValid(xstring_c *value); typedef const char *ResClValid(xstring_c *closure); class ResValue; class ResMgr; class Resource; struct ResType { static bool class_inited; static xmap *types_by_name; const char *name; const char *defvalue; ResValValid *val_valid; ResClValid *closure_valid; xlist_head *type_value_list; const char *SimpleQuery(const char *closure) const; ResValue Query(const char *closure) const; bool QueryBool(const char *closure) const; bool QueryTriBool(const char *closure,bool a) const; const char *Set(const char *cclosure,const char *cvalue); static const char *Set(const char *name,const char *closure,const char *value); void Register(); void Unregister(); static char *Format(bool with_defaults,bool only_defaults); static char **Generator(void); static void ClassInit(); enum CmpRes { EXACT_PREFIX=0x00,SUBSTR_PREFIX=0x01, EXACT_NAME =0x00,SUBSTR_NAME =0x10, DIFFERENT=-1 }; static int VarNameCmp(const char *name1,const char *name2); static const char *FindVar(const char *name,const ResType **type); static const char *FindVar(const char *name,ResType **type) { return FindVar(name,const_cast(type)); } static const ResType *FindRes(const char *name); }; class Resource { friend class ResMgr; friend struct ResType; static xlist_head all_list; const ResType *type; xstring_c value; xstring_c closure; xlist all_node; xlist type_value_node; bool ClosureMatch(const char *cl_data); void Format(xstring& buf) const; Resource(ResType *type,const char *closure,const char *value); public: ~Resource(); }; class ResMgr : public ResType { ResMgr(); public: static const char *QueryNext(const char *name,const char **closure,Resource **ptr); static ResValue Query(const char *name,const char *closure); static bool QueryBool(const char *name,const char *closure); static bool QueryTriBool(const char *name,const char *closure,bool a); static const char *BoolValidate(xstring_c *value); static const char *TriBoolValidate(xstring_c *value); static const char *NumberValidate(xstring_c *value); static const char *UNumberValidate(xstring_c *value); static const char *FloatValidate(xstring_c *value); static const char *TimeIntervalValidate(xstring_c *value); static const char *RangeValidate(xstring_c *value); static const char *ERegExpValidate(xstring_c *value); static const char *IPv4AddrValidate(xstring_c *value); static const char *IPv6AddrValidate(xstring_c *value); static const char *UNumberPairValidate(xstring_c *value); static const char *FileAccessible(xstring_c *value,int mode,bool want_dir=false); static const char *FileReadable(xstring_c *value); static const char *FileExecutable(xstring_c *value); static const char *DirReadable(xstring_c *value); static const char *FileCreatable(xstring_c *value); static const char *CharsetValidate(xstring_c *value); static const char *NoClosure(xstring_c *); static bool str2bool(const char *value); static int ResourceCompare(const Resource *a,const Resource *b); }; class ResDecl : public ResType { public: ResDecl(const char *a_name,const char *a_defvalue, ResValValid *a_val_valid,ResClValid *a_closure_valid=0); ~ResDecl() { Unregister(); } }; class ResDecls { xarray r; public: ResDecls(ResType *array); ResDecls(ResType *r1,ResType *r2,...); ~ResDecls(); }; class ResValue { const char *s; public: ResValue(const char *s_new) { s=s_new; } bool to_bool() const { return ResMgr::str2bool(s); } bool to_tri_bool(bool a) const; unsigned long long to_unumber(unsigned long long max) const; long long to_number(long long min,long long max) const; operator int() const; operator long() const; operator unsigned() const; operator unsigned long() const; operator double() const { return atof(s); } operator float() const { return atof(s); } operator const char*() const { return s; } bool is_nil() const { return s==0; } bool is_empty() const { return s==0 || *s==0; } void ToNumberPair(int &a,int &b) const; }; class TimeIntervalR : public TimeInterval { const char *error_text; void init(const char *); public: void Set(const char *s) { init(s); } TimeIntervalR() { error_text=0; } TimeIntervalR(const char *s) : TimeInterval(0,0) { init(s); } TimeIntervalR(ResValue r) : TimeInterval(0,0) { init(r); } TimeIntervalR(time_t s,int ms=0) : TimeInterval(s,ms) { error_text=0; } TimeIntervalR(const TimeDiff &d) : TimeInterval(d) { error_text=0; } bool Error() const { return error_text!=0; }; const char *ErrorText() const { return error_text; } }; class NumberPair { protected: long long n1,n2; bool no_n1,no_n2; const char *error_text; char sep; static const char *scale(long long *value,char suf); long long parse1(const char *s); void init(char sep,const char *s); public: NumberPair(char sep) { init(sep,0); } NumberPair(char sep,const char *s) { init(sep,s); } void Set(const char *s); bool Error() { return error_text!=0; }; const char *ErrorText() { return error_text; } long long N1() { return n1; } long long N2() { return n2; } bool HasN1() { return !no_n1; } bool HasN2() { return !no_n2; } }; class Range : public NumberPair { public: Range(const char *s); bool Match(long long n) const { return (no_n1 || n>=n1) && (no_n2 || n<=n2); } bool IsFull() { return no_n1 && no_n2; } long long Random(); }; class ResClient { static xlist_head list; xlist node; protected: virtual const char *ResPrefix() const { return 0; } virtual const char *ResClosure() const { return 0; } virtual void Reconfig(const char *) {} ResValue Query(const char *name,const char *closure=0) const; bool QueryBool(const char *name,const char *closure=0) const; bool QueryTriBool(const char *name,const char *closure,bool a) const; ResClient(); virtual ~ResClient(); public: static void ReconfigAll(const char *); }; #endif //RESMGR_H lftp-4.6.3a/src/buffer_ssl.cc0000644000015000007670000000446112122057076013012 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "buffer_ssl.h" #if USE_SSL # include "lftp_ssl.h" // IOBufferSSL implementation #undef super #define super IOBuffer int IOBufferSSL::Do() { if(Done() || Error()) return STALL; int res=0; switch(mode) { case PUT: if(Size()==0 && ssl->handshake_done) return STALL; res=Put_LL(buffer+buffer_ptr,Size()); if(res>0) { buffer_ptr+=res; event_time=now; if(eof) PutEOF_LL(); return MOVED; } break; case GET: if(eof) return STALL; res=Get_LL(GET_BUFSIZE); if(res>0) { EmbraceNewData(res); event_time=now; return MOVED; } if(eof) { event_time=now; return MOVED; } break; } if(res<0) { event_time=now; return MOVED; } if(ssl->want_in()) Block(ssl->fd,POLLIN); if(ssl->want_out()) Block(ssl->fd,POLLOUT); return STALL; } int IOBufferSSL::Get_LL(int size) { int res=ssl->read(GetSpace(size),size); if(res<0) { if(res==ssl->RETRY) return 0; else // error { SetError(ssl->error,ssl->fatal); return -1; } } if(res==0) eof=true; return res; } int IOBufferSSL::Put_LL(const char *buf,int size) { int res=ssl->write(buf,size); if(res<0) { if(res==ssl->RETRY) return 0; else // error { SetError(ssl->error,ssl->fatal); return -1; } } return res; } int IOBufferSSL::PutEOF_LL() { if(Size()==0) ssl->shutdown(); return 0; } IOBufferSSL::~IOBufferSSL() { } #endif // USE_SSL lftp-4.6.3a/src/ChmodJob.cc0000644000015000007670000000600112535305613012336 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include "ChmodJob.h" #include "url.h" CDECL_BEGIN #include "filemode.h" #include "modechange.h" CDECL_END void ChmodJob::Init() { verbose=V_NONE; m=0; simple_mode=-1; } ChmodJob::ChmodJob(FileAccess *s,ArgV *a) : TreatFileJob(s,a) { Init(); } ChmodJob::ChmodJob(FileAccess *s,int mode,ArgV *a) : TreatFileJob(s,a) { Init(); simple_mode=mode; } ChmodJob::~ChmodJob() { free(m); } void ChmodJob::Recurse() { set_maxdepth(-1); Need(FileInfo::TYPE); } int ChmodJob::GetMode(const FileInfo *fi) const { if(simple_mode != -1) return simple_mode; if(fi->defined&fi->MODE) return mode_adjust(fi->mode, false, 022, m, NULL); if(!RelativeMode(m)) return mode_adjust(0, false, 022, m, NULL); return -1; } void ChmodJob::CurrentFinished(const char *d,const FileInfo *fi) { const char *fmt; if(session->Done() < 0) { if(quiet) return; fmt = _("Failed to change mode of `%s' to %04o (%s).\n"); } else fmt = _("Mode of `%s' changed to %04o (%s).\n"); int mode=GetMode(fi); if(mode==-1) { eprintf(_("Failed to change mode of `%s' because no old mode is available.\n"),fi->name.get()); return; } if(verbose == V_ALL || (verbose == V_CHANGES && (!(fi->defined&fi->mode) || mode != (int)fi->mode))) { char perms[12]; /* "-rwxrwxrwx " ls-style modes. */ strmode (mode, perms); perms[10] = '\0'; eprintf (fmt, fi->name.get(), (int) mode, perms+1); } } void ChmodJob::SetMode(mode_change *newm) { m=newm; /* request mode info only if we need it */ if(RelativeMode(m)) Need(FileInfo::MODE); /* one or the other */ assert(simple_mode == -1); } void ChmodJob::SetVerbosity(verbosity v) { verbose=v; /* need file mode to show changes */ if(verbose == V_CHANGES) Need(FileInfo::MODE); } bool ChmodJob::RelativeMode(const mode_change *m) const { // relative mode change depends on original mode. return mode_adjust(07777, false, 0, m, NULL) != mode_adjust(00000, false, 0, m, NULL); } void ChmodJob::TreatCurrent(const char *d,const FileInfo *fi) { int new_mode=GetMode(fi); if(new_mode!=-1) session->Chmod(fi->name,new_mode); } lftp-4.6.3a/src/rmJob.cc0000644000015000007670000000405412122060570011720 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "rmJob.h" #include "plural.h" #include "url.h" #include "misc.h" rmJob::rmJob(FileAccess *s,ArgV *a) : TreatFileJob(s,a) { mode=FA::REMOVE; recurse=false; depth_first=true; } void rmJob::Recurse() { set_maxdepth(-1); Need(FileInfo::TYPE); recurse=true; } void rmJob::SayFinal() { if(failed==file_count) return; if(file_count==1) printf(_("%s ok, `%s' removed\n"),op,first->name.get()); else if(failed) { if(mode==FA::REMOVE_DIR) printf(plural("%s failed for %d of %d director$y|ies$\n",file_count), op,failed,file_count); else printf(plural("%s failed for %d of %d file$|s$\n",file_count), op,failed,file_count); } else { if(mode==FA::REMOVE_DIR) printf(plural("%s ok, %d director$y|ies$ removed\n",file_count), op,file_count); else printf(plural("%s ok, %d file$|s$ removed\n",file_count), op,file_count); } } void rmJob::TreatCurrent(const char *d, const FileInfo *fi) { /* If we're recursing and this is a directory, rmdir it. (If we're * not recursing, just send an rm and let it fail.) */ if(recurse && (fi->defined&fi->TYPE) && (fi->filetype==fi->DIRECTORY)) session->Open(fi->name,FA::REMOVE_DIR); else session->Open(fi->name,mode); } lftp-4.6.3a/src/netrc.h0000644000015000007670000000221512122060345011621 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef NETRC_H #define NETRC_H #include "xstring.h" class NetRC { public: class Entry { public: xstring host; xstring user; xstring pass; xstring acct; Entry(const char *h=0,const char *u=0,const char *p=0,const char *a=0) : host(h), user(u), pass(p), acct(a) {} }; static Entry *LookupHost(const char *host,const char *user=0); }; #endif//NETRC_H lftp-4.6.3a/src/Fish.h0000644000015000007670000000743712457746704011437 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FISH_H #define FISH_H #include "SSH_Access.h" #include "StringSet.h" class Fish : public SSH_Access { enum state_t { DISCONNECTED, CONNECTING, CONNECTING_1, CONNECTED, FILE_RECV, FILE_SEND, WAITING, DONE }; state_t state; void Init(); int max_send; void Send(const char *format,...) PRINTF_LIKE(2,3); void SendMethod(); void SendArrayInfoRequests(); void DisconnectLL(); int IsConnected() const { if(state==DISCONNECTED) return 0; if(state==CONNECTING) return 1; return 2; } off_t body_size; off_t bytes_received; enum expect_t { EXPECT_FISH, EXPECT_VER, EXPECT_PWD, EXPECT_CWD, EXPECT_DIR, EXPECT_RETR_INFO, EXPECT_RETR, EXPECT_INFO, EXPECT_DEFAULT, EXPECT_STOR_PRELIMINARY, EXPECT_STOR, EXPECT_QUOTE, EXPECT_IGNORE }; void PushExpect(expect_t); int HandleReplies(); void CloseExpectQueue(); int ReplyLogPriority(int); xqueue > RespQueue; StringSet path_queue; void PushDirectory(const char *d) { path_queue.Append(d); } void PopDirectory(xstring *d) { d->set_allocated(path_queue.Pop()); } void EmptyPathQueue() { path_queue.Empty(); } bool RespQueueIsEmpty() { return RespQueue.count()==0; } int RespQueueSize() { return RespQueue.count(); } void EmptyRespQueue() { RespQueue.empty(); } void GetBetterConnection(int level); void MoveConnectionHere(Fish *o); xstring line; xstring message; bool eof; bool encode_file; public: static void ClassInit(); Fish(); Fish(const Fish*); ~Fish(); const char *GetProto() const { return "fish"; } FileAccess *Clone() const { return new Fish(this); } static FileAccess *New(); int Do(); int Done(); int Read(Buffer *,int); int Write(const void *,int); int StoreStatus(); int Buffered(); void Close(); const char *CurrentStatus(); void Reconfig(const char *name=0); bool SameSiteAs(const FileAccess *fa) const; bool SameLocationAs(const FileAccess *fa) const; DirList *MakeDirList(ArgV *args); Glob *MakeGlob(const char *pattern); ListInfo *MakeListInfo(const char *p); FileSet *ParseLongList(const char *buf,int len,int *err=0) const; void DontEncodeFile() { encode_file=false; } bool NeedSizeDateBeforehand() { return true; } void SuspendInternal(); void ResumeInternal(); void Cleanup(); void CleanupThis(); }; class FishDirList : public DirList { SMTaskRef ubuf; const xstring_ca pattern; public: FishDirList(Fish *s,ArgV *a) : DirList(s,a), pattern(args->CombineShellQuoted(1)) {} const char *Status(); int Do(); void SuspendInternal(); void ResumeInternal(); }; class FishListInfo : public GenericParseListInfo { FileSet *Parse(const char *buf,int len); public: FishListInfo(Fish *session,const char *path) : GenericParseListInfo(session,path) { can_get_prec_time=false; } }; #endif lftp-4.6.3a/src/PollVec.cc0000644000015000007670000000412112366153664012227 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "trio.h" #include "PollVec.h" static inline bool operator<(const timeval& a,const timeval& b) { if(a.tv_sec!=b.tv_sec) return a.tv_sec. */ #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include "GetJob.h" #include "misc.h" #include "ArgV.h" #include "url.h" ResDecl res_clobber ("xfer:clobber", "no", ResMgr::BoolValidate,ResMgr::NoClosure); ResDecl res_make_backup ("xfer:make-backup", "yes",ResMgr::BoolValidate,ResMgr::NoClosure); #define super CopyJobEnv #define NO_MODE ((mode_t)-1) int GetJob::Do() { int m=STALL; if(cp && cp->Done() && !cp->Error()) { // now we can delete old file, since there is new one RemoveBackupFile(); if(file_mode!=NO_MODE && local) chmod(local->full_name,file_mode); } if(super::Do()==MOVED) m=MOVED; return m; } FileCopyPeer *GetJob::SrcLocal(const char *src) { const char *f=(cwd && src[0]!='/') ? dir_file(cwd,src) : src; return FileCopyPeerFDStream::NewGet(f); } FileCopyPeer *GetJob::DstLocal(const char *dst) { bool clobber=(cont || res_clobber.QueryBool(0)); int flags=O_WRONLY|O_CREAT|(truncate_target_first?O_TRUNC:0)|(clobber?0:O_EXCL); dst=expand_home_relative(dst); const char *f=(cwd && dst[0]!='/') ? dir_file(cwd,dst) : dst; if(truncate_target_first && res_make_backup.QueryBool(0)) { /* rename old file if exists and size>0 */ struct stat st; if(stat(f,&st)!=-1) { if(st.st_size>0 && S_ISREG(st.st_mode)) { if(!clobber) { eprintf(_("%s: %s: file already exists and xfer:clobber is unset\n"),op,dst); errors++; count++; return 0; } backup_file.vset(f,"~",NULL); if(rename(f,backup_file)!=0) backup_file.set(0); else file_mode=st.st_mode; } } } local=new FileStream(f,flags); // local is for pget. FileCopyPeerFDStream *p=new FileCopyPeerFDStream(local,FileCopyPeer::PUT); p->CloseWhenDone(); return p; } bool GetJob::IsRemoteNonURL(const ParsedURL &url,FA::open_mode mode) { // store & put || !store & get return (!url.proto && ((mode==FA::STORE)^!reverse)); } bool GetJob::IsLocalNonURL(const ParsedURL &url,FA::open_mode mode) { // store & get || !store & put return (!url.proto && ((mode==FA::STORE)^reverse)); } bool GetJob::IsLocal(const ParsedURL &url) { return !url.proto || !strcasecmp(url.proto,"file"); } // create copy peer from a cloned session FileCopyPeer *GetJob::CreateCopyPeer(FileAccess *session,const char *path,FA::open_mode mode) { ParsedURL url(path,true); if(IsRemoteNonURL(url,mode)) return new FileCopyPeerFA(session,path,mode); Delete(session); // delete cloned session. return CreateCopyPeer(url,path,mode); } // create copy peer using a session reference FileCopyPeer *GetJob::CreateCopyPeer(const FileAccessRef& session,const char *path,FA::open_mode mode) { ParsedURL url(path,true); if(IsRemoteNonURL(url,mode)) return new FileCopyPeerFA(session,path,mode); return CreateCopyPeer(url,path,mode); } FileCopyPeer *GetJob::CreateCopyPeer(const ParsedURL &url,const char *path,FA::open_mode mode) { if(IsLocalNonURL(url,mode)) return CreateCopyPeer(path,mode); if(IsLocal(url)) return CreateCopyPeer(url.path,mode); return new FileCopyPeerFA(&url,mode); } FileCopyPeer *GetJob::CreateCopyPeer(const char *path,FA::open_mode mode) { return mode==FA::STORE ? DstLocal(path) : SrcLocal(path); } void GetJob::NextFile() { try_next: file_mode=NO_MODE; backup_file.set(0); local=0; if(!args) return; const char *src=args->getnext(); const char *dst=args->getnext(); if(!src || !dst) { SetCopier(0,0); return; } FileCopyPeer *dst_peer=CreateCopyPeer(session,dst,FA::STORE); if(!dst_peer) goto try_next; FileCopyPeer *src_peer=CreateCopyPeer(session,src,FA::RETRIEVE); FileCopy *c=FileCopy::New(src_peer,dst_peer,cont); if(delete_files) c->RemoveSourceLater(); if(remove_target_first) c->RemoveTargetFirst(); SetCopier(c,src); } void GetJob::RemoveBackupFile() { if(backup_file) { remove(backup_file); backup_file.set(0); } } GetJob::GetJob(FileAccess *s,ArgV *a,bool c) : CopyJobEnv(s,a,c) { delete_files=false; remove_target_first=false; truncate_target_first=!cont; file_mode=NO_MODE; reverse=false; } lftp-4.6.3a/src/ftpclass.h0000644000015000007670000003643412405754676012364 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FTPCLASS_H #define FTPCLASS_H #include "trio.h" #include #include "NetAccess.h" #if USE_SSL # include "lftp_ssl.h" #endif class TelnetEncode : public DataTranslator { void PutTranslated(Buffer *target,const char *buf,int size); }; class TelnetDecode : public DataTranslator { void PutTranslated(Buffer *target,const char *buf,int size); }; class IOBufferTelnet : public IOBufferStacked { public: IOBufferTelnet(IOBuffer *b) : IOBufferStacked(b) { if(mode==PUT) SetTranslator(new TelnetEncode()); else SetTranslator(new TelnetDecode()); } }; class Ftp : public NetAccess { enum automate_state { EOF_STATE, // control connection is open, idle state INITIAL_STATE, // all connections are closed CONNECTING_STATE, // we are connecting the control socket HTTP_PROXY_CONNECTED,// connected to http proxy, but have no reply yet CONNECTED_STATE, // just after connect WAITING_STATE, // we're waiting for a response with data ACCEPTING_STATE, // we're waiting for an incoming data connection DATA_OPEN_STATE, // data connection is open, for read or write CWD_CWD_WAITING_STATE, // waiting until 'CWD $cwd' finishes USER_RESP_WAITING_STATE,// waiting until 'USER $user' finishes DATASOCKET_CONNECTING_STATE, // waiting for data_sock to connect WAITING_150_STATE, // waiting for 150 message WAITING_CCC_SHUTDOWN // waiting for the server to shutdown SSL connection }; class Connection { xstring_c closure; public: int control_sock; SMTaskRef control_recv; SMTaskRef control_send; IOBufferTelnet *telnet_layer_send; DirectedBuffer send_cmd_buffer; // holds unsent commands. int data_sock; SMTaskRef data_iobuf; int aborted_data_sock; sockaddr_u peer_sa; sockaddr_u data_sa; // address for data accepting bool quit_sent; bool fixed_pasv; // had to fix PASV address. bool translation_activated; bool proxy_is_http; // true when connection was established via http proxy. bool may_show_password; bool can_do_pasv; int multiline_code; // the code of multiline response. int sync_wait; // number of commands in flight. bool ignore_pass; // logged in just with user bool try_feat_after_login; bool tune_after_login; bool utf8_activated; // server is switched to UTF8 mode. bool received_150; char type; // type of transfer: 'A'scii or 'I'mage bool dos_path; bool vms_path; bool have_feat_info; bool mdtm_supported; bool size_supported; bool rest_supported; bool site_chmod_supported; bool site_utime_supported; bool site_utime2_supported; // two-argument SITE UTIME bool pret_supported; bool utf8_supported; bool lang_supported; bool mlst_supported; bool clnt_supported; bool host_supported; bool mfmt_supported; bool epsv_supported; bool tvfs_supported; off_t last_rest; // last successful REST position. off_t rest_pos; // the number sent with REST command. Timer abor_close_timer; // timer for closing aborted connection. Timer stat_timer; // timer for sending periodic STAT commands. Timer waiting_150_timer; // limit time to wait for 150 reply. Timer waiting_ssl_timer; // limit time to wait for ssl shutdown time_t nop_time; off_t nop_offset; int nop_count; #if USE_SSL Ref control_ssl; char prot; // current data protection scheme 'C'lear or 'P'rivate bool auth_sent; bool auth_supported; bool cpsv_supported; bool sscn_supported; bool sscn_on; xstring auth_args_supported; bool ssl_is_activated() { return control_ssl!=0; } Timer waiting_ssl_shutdown; #else bool ssl_is_activated() { return false; } #endif xstring_c mlst_attr_supported; Connection(const char *c); ~Connection(); bool data_address_ok(const sockaddr_u *d,bool verify_address,bool verify_port); void MakeBuffers(); void MakeSSLBuffers(const char *h); void InitTelnetLayer(); void SetControlConnectionTranslation(const char *cs); void CloseDataSocket(); // only closes socket, does not delete iobuf. void CloseDataConnection(); void AbortDataConnection(); void CloseAbortedDataConnection(); void Send(const char *cmd); void SendURI(const char *u,const char *home); void SendCRNL(); void SendEncoded(const char *url); void SendCmd(const char *cmd); void SendCmd2(const char *cmd,const char *f,const char *u=0,const char *home=0); void SendCmd2(const char *cmd,int v); void SendCmdF(const char *fmt,...) PRINTF_LIKE(2,3); int FlushSendQueueOneCmd(); // sends single command from send_cmd_buffer void SuspendInternal() { if(control_send) control_send->SuspendSlave(); if(control_recv && !data_iobuf) control_recv->SuspendSlave(); if(data_iobuf) data_iobuf->SuspendSlave(); } void ResumeInternal() { if(control_send) control_send->ResumeSlave(); if(control_recv) control_recv->ResumeSlave(); if(data_iobuf) data_iobuf->ResumeSlave(); } }; Ref conn; bool last_connection_failed; struct Expect { enum expect_t { NONE, // no special check, reconnect if reply>=400. IGNORE, // ignore response READY, // check response after connect REST, // check response for REST TYPE, // check response for TYPE CWD, // check response for CWD CWD_CURR, // check response for CWD into current directory CWD_STALE, // check response for CWD when it's not critical ABOR, // check response for ABOR SIZE, // check response for SIZE SIZE_OPT, // check response for SIZE and save size to *opt_size MDTM, // check response for MDTM MDTM_OPT, // check response for MDTM and save size to *opt_date PRET, PASV, // check response for PASV and save address EPSV, // check response for EPSV and save address PORT, // check response for PORT or EPRT FILE_ACCESS, // generic check for file access PWD, // check response for PWD and save it to home RNFR, USER, // check response for USER USER_PROXY, // check response for USER sent to proxy PASS, // check response for PASS PASS_PROXY, // check response for PASS sent to proxy OPEN_PROXY, // special UserGate proxy command ACCT_PROXY, // special ACCT with proxy password TRANSFER, // generic check for transfer TRANSFER_CLOSED, // check for transfer complete when Close()d. FEAT, OPTS_UTF8, LANG, SITE_UTIME, SITE_UTIME2, ALLO, QUOTED // check response for any command submitted by QUOTE_CMD #if USE_SSL ,AUTH_TLS,PROT,SSCN,CCC #endif }; expect_t check_case; xstring_c arg; Expect *next; Expect(expect_t e,const char *a=0) : check_case(e), arg(a) {} Expect(expect_t e,char c) : check_case(e) { char cc[2]={c,0}; arg.set(cc); } }; class ExpectQueue; friend class Ftp::ExpectQueue; // grant access to Expect class ExpectQueue { Expect *first; // next to expect Expect **last; // for appending int count; public: ExpectQueue(); ~ExpectQueue(); void Push(Expect *e); void Push(Expect::expect_t e); Expect *Pop(); Expect *FindLastCWD() const; int Count() const { return count; } bool IsEmpty() const { return count==0; } bool Has(Expect::expect_t) const; bool FirstIs(Expect::expect_t) const; void Close(); }; Ref expect; void CheckResp(int resp); int ReplyLogPriority(int code) const; void RestCheck(int); void NoFileCheck(int); void TransferCheck(int); bool Retry530() const; void LoginCheck(int); void NoPassReqCheck(int); void proxy_LoginCheck(int); void proxy_NoPassReqCheck(int); void CheckFEAT(char *reply); char *ExtractPWD(); int SendCWD(const char *path,const char *path_url,Expect::expect_t c); void CatchDATE(int); void CatchDATE_opt(int); void CatchSIZE(int); void CatchSIZE_opt(int); void TurnOffStatForList(); enum pasv_state_t { PASV_NO_ADDRESS_YET, PASV_HAVE_ADDRESS, PASV_DATASOCKET_CONNECTING, PASV_HTTP_PROXY_CONNECTED }; pasv_state_t pasv_state; // state of PASV, when state==DATASOCKET_CONNECTING_STATE pasv_state_t Handle_PASV(); pasv_state_t Handle_EPSV(); bool ServerSaid(const char *) const; bool NonError5XX(int act) const; bool Transient5XX(int act) const; void InitFtp(); void HandleTimeout(); #if USE_SSL protected: bool ftps; // ssl and prot='P' by default (port 990) private: #else static const bool ftps; // for convenience #endif void DataAbort(); void DataClose(); void ControlClose(); void SendUrgentCmd(const char *cmd); int FlushSendQueueOneCmd(); int FlushSendQueue(bool all=false); void SendArrayInfoRequests(); void SendSiteIdle(); void SendAcct(); void SendSiteGroup(); void SendSiteCommands(); void SendUTimeRequest(); void SendAuth(const char *auth); void TuneConnectionAfterFEAT(); void SendOPTS_MLST(); void SendPROT(char want_prot); const char *QueryStringWithUserAtHost(const char *); int ReceiveOneLine(); // If a response is received, it checks it for accordance with // response_queue and switch to a state if necessary int ReceiveResp(); bool ProxyIsHttp(); int http_proxy_status_code; // Send CONNECT method to http proxy. void HttpProxySendConnect(); void HttpProxySendConnectData(); // Send http proxy auth. void HttpProxySendAuth(const SMTaskRef&); // Check if proxy returned a reply, returns true if reply is ok. // May disconnect. bool HttpProxyReplyCheck(const SMTaskRef&); bool AbsolutePath(const char *p) const; void MoveConnectionHere(Ftp *o); bool GetBetterConnection(int level,bool limit_reached); bool SameConnection(const Ftp *o) const; // state automate_state state; int flags; bool eof; Timer retry_timer; xstring line; // last line of last server reply xstring all_lines; // all lines of last server reply void SetError(int code,const char *mess=0); // settings xstring_c anon_user; xstring_c anon_pass; xstring_c charset; xstring_c list_options; int nop_interval; bool verify_data_address; bool verify_data_port; bool rest_list; xstring_c skey_pass; bool allow_skey; bool force_skey; const char *make_skey_reply(); xstring netkey_pass; bool allow_netkey; const char *make_netkey_reply(); bool disconnect_on_close; public: enum copy_mode_t { COPY_NONE, COPY_SOURCE, COPY_DEST }; private: copy_mode_t copy_mode; sockaddr_u copy_addr; bool copy_addr_valid; bool copy_passive; bool copy_protect; bool copy_ssl_connect; bool copy_done; bool copy_connection_open; bool copy_allow_store; bool copy_failed; bool use_stat; bool use_stat_for_list; bool use_mdtm; bool use_size; bool use_pret; bool use_feat; bool use_mlsd; bool use_telnet_iac; int max_buf; const char *get_protect_res(); const char *encode_eprt(const sockaddr_u *); typedef FileInfo *(*FtpLineParser)(char *line,int *err,const char *tz); static FtpLineParser line_parsers[]; int CanRead(); protected: void PrepareToDie(); public: static void ClassInit(); Ftp(); Ftp(const Ftp *); const char *GetProto() const { return "ftp"; } FileAccess *Clone() const { return new Ftp(this); } static FileAccess *New(); const char *ProtocolSubstitution(const char *host); bool SameLocationAs(const FileAccess *) const; bool SameSiteAs(const FileAccess *) const; void ResetLocationData(); enum ConnectLevel { CL_NOT_CONNECTED, CL_CONNECTING, CL_JUST_CONNECTED, CL_NOT_LOGGED_IN, CL_LOGGED_IN, CL_JUST_BEFORE_DISCONNECT }; ConnectLevel GetConnectLevel() const; int IsConnected() const { return GetConnectLevel()!=CL_NOT_CONNECTED; } int Read(Buffer *buf,int size); int Write(const void *buf,int size); int Buffered(); void Close(); bool IOReady(); // When you are putting a file, call SendEOT to terminate // transfer and then call StoreStatus until OK or error. int SendEOT(); int StoreStatus(); int Do(); void DisconnectLL(); void DisconnectNow(); void SetFlag(int flag,bool val); int GetFlag(int flag) const { return flags&flag; } static time_t ConvertFtpDate(const char *); const char *CurrentStatus(); int Done(); enum flag_mask { SYNC_MODE=1, NOREST_MODE=4, IO_FLAG=8, PASSIVE_MODE=32, MODES_MASK=SYNC_MODE|PASSIVE_MODE }; void Reconfig(const char *name=0); void Cleanup(); void CleanupThis(); ListInfo *MakeListInfo(const char *path); Glob *MakeGlob(const char *pattern); DirList *MakeDirList(ArgV *args); FileSet *ParseLongList(const char *buf,int len,int *err=0) const; void SetCopyMode(copy_mode_t cm,bool rp,bool prot,bool sscn,int rnum,time_t tt) { copy_mode=cm; copy_passive=rp; copy_protect=prot; copy_ssl_connect=sscn; retries=rnum; SetTryTime(tt); } bool SetCopyAddress(const Ftp *o) { if(copy_addr_valid || !o->copy_addr_valid) return false; memcpy(©_addr,&o->copy_addr,sizeof(copy_addr)); copy_addr_valid=true; return true; } bool CopyFailed() const { return copy_failed; } bool RestartFailed() const { return flags&NOREST_MODE; } bool IsPassive() const { return flags&PASSIVE_MODE; } bool IsCopyPassive() const { return copy_passive; } void CopyAllowStore() { conn->SendCmd2("STOR",file); expect->Push(new Expect(Expect::TRANSFER)); copy_allow_store=true; } bool CopyStoreAllowed() const { return copy_allow_store; } bool CopyIsReadyForStore() { if(!expect) return false; if(copy_mode==COPY_SOURCE) return copy_addr_valid && expect->FirstIs(Expect::TRANSFER); return state==WAITING_STATE && expect->IsEmpty(); } void CopyCheckTimeout(const Ftp *o) { timeout_timer.Reset(o->timeout_timer); CheckTimeout(); } bool AnonymousQuietMode(); void SuspendInternal(); void ResumeInternal(); }; class FtpS : public Ftp { public: FtpS(); FtpS(const FtpS *); ~FtpS(); const char *GetProto() const { return "ftps"; } FileAccess *Clone() const { return new FtpS(this); } static FileAccess *New(); }; #endif /* FTPCLASS_H */ lftp-4.6.3a/src/FindJobDu.cc0000644000015000007670000001107112431430357012457 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "FindJobDu.h" #include "CmdExec.h" #include "misc.h" #include "buffer_std.h" CDECL_BEGIN #include "human.h" CDECL_END #define stack_ptr (size_stack.count()-1) #define stack_top (*size_stack.last()) FinderJob_Du::FinderJob_Du(FileAccess *s,ArgV *a,FDStream *o) : FinderJob(s), args(a) { op=args->a0(); if(o) { buf=new IOBufferFDStream(o,IOBuffer::PUT); show_sl=!o->usesfd(1); } else { buf=new IOBuffer_STDOUT(this); show_sl=true; } Need(FileInfo::SIZE); /* defaults */ max_print_depth = -1; print_totals = false; output_block_size = 1024; human_opts = 0; all_files = false; separate_dirs = false; file_count = false; tot_size=0; success=false; Init(a->getcurr()); } FinderJob_Du::~FinderJob_Du() { } /* process a new directory */ void FinderJob_Du::Init(const char *d) { NextDir(d); } int FinderJob_Du::Done() { return FinderJob::Done() && args->getcurr()==0 && buf->Done(); } void FinderJob_Du::Finish() { /* if there's anything left, we had an error; clear the stack */ if(stack_ptr != -1) { while(stack_ptr >= 0) Pop(); } else success = true; /* at least one succeeded */ /* next? */ const char *d=args->getnext(); if(d) { /* we have another argument */ Init(d); return; } /* we're done */ if (print_totals) /* don't print totals on error */ print_size(tot_size, _("total")); buf->PutEOF(); } const char *FinderJob_Du::MakeFileName(const char *n) { return size_stack.count()>0 ? dir_file(size_stack.last()->dir,n) : n; } off_t FinderJob_Du::BlockCeil(off_t size) const { size+=output_block_size-1; size-=size%output_block_size; return size; } FinderJob::prf_res FinderJob_Du::ProcessFile(const char *d,const FileInfo *fi) { if(buf->Broken()) return PRF_FATAL; if(buf->Error()) { eprintf("%s: %s\n",op,buf->ErrorText()); return PRF_FATAL; } if(fg_data==0) fg_data=buf->GetFgData(fg); if(buf->Size()>0x10000) return PRF_LATER; if(fi->filetype==fi->DIRECTORY) return PRF_OK; /* don't care */ if(!file_count && !(fi->defined&fi->SIZE)) return PRF_OK; /* can't count this one */ /* add this file to the current dir */ long long add = BlockCeil(fi->size); if (file_count) add = 1; if(size_stack.count()>0) size_stack.last()->size += add; tot_size += add; if(all_files || stack_ptr == -1) { /* this is <, where Pop() is <=, since the file counts in depth */ if(max_print_depth == -1 || stack_ptr < max_print_depth) print_size(BlockCeil(fi->size), MakeFileName(fi->name)); } return PRF_OK; } void FinderJob_Du::ProcessList(FileSet *f) { f->Sort(FileSet::BYNAME, true); } /* push a directory onto the stack */ void FinderJob_Du::Push (const char *d) { size_stack.append(new stack_entry(MakeFileName(d))); } /* pop a directory off the stack, combining as necessary */ void FinderJob_Du::Pop() { assert(stack_ptr!=-1); /* no underflows */ /* merge directory's size with its parent */ if(!separate_dirs && stack_ptr > 0) size_stack[stack_ptr-1]->size += stack_top.size; size_stack.chop(); } void FinderJob_Du::print_size (long long n_blocks, const char *string) { char buffer[LONGEST_HUMAN_READABLE + 1]; /* We get blocks in bytes, since we don't know the remote system's * block size. */ buf->Format("%s\t%s\n", human_readable (n_blocks, buffer, human_opts, 1, human_opts?1:output_block_size), string); } /* finished a directory; print it if necessary and pop it off the stack */ void FinderJob_Du::Exit() { /* print the dir */ if(max_print_depth == -1 || stack_ptr <= max_print_depth) print_size(stack_top.size, stack_top.dir); Pop(); } void FinderJob_Du::Enter(const char *d) { Push(d); } lftp-4.6.3a/src/ProtoLog.h0000644000015000007670000000234212404007115012253 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef PROTOLOG_H #define PROTOLOG_H class ProtoLog { static bool WillOutput(int level); public: static void Log2(int level,xstring& str); static void Log3(int level,const char *prefix,const char *str); static void LogError(int level,const char *fmt,...) PRINTF_LIKE(2,3); static void LogNote(int level,const char *fmt,...) PRINTF_LIKE(2,3); static void LogRecv(int level,const char *line); static void LogSend(int level,const char *line); }; #endif//PROTOLOG_H lftp-4.6.3a/src/plural.h0000644000015000007670000000073312122060437012012 00000000000000/* * plural word form chooser for i18n * * Copyright (c) 1998 by Alexander V. Lukyanov (lav@yars.free.net) * * This file is in public domain. */ #ifndef PLURAL_H #define PLURAL_H #ifdef __cplusplus extern "C" { #endif #ifndef FORMAT_ARG # ifdef __GNUC__ # define FORMAT_ARG(n) __attribute__((format_arg(n))) # else # define FORMAT_ARG(n) # endif #endif const char *plural(const char *format,...) FORMAT_ARG(1); #ifdef __cplusplus } #endif #endif /* PLURAL_H */ lftp-4.6.3a/src/SFtp.cc0000644000015000007670000016045612477534217011555 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "SFtp.h" #include "ArgV.h" #include "log.h" #include "ascii_ctype.h" #include "FileGlob.h" #include "misc.h" #include "LsCache.h" #include #include #include #define max_buf 0x10000 #define super SSH_Access bool SFtp::GetBetterConnection(int level,bool limit_reached) { bool need_sleep=false; for(FA *fo=FirstSameSite(); fo!=0; fo=NextSameSite(fo)) { SFtp *o=(SFtp*)fo; // we are sure it is SFtp. if(!o->recv_buf) continue; if(o->state!=CONNECTED || o->mode!=CLOSED) { if(level<2) continue; if(!connection_takeover || (o->priority>=priority && !o->IsSuspended())) continue; o->Disconnect(); return need_sleep; } if(level==0 && xstrcmp(real_cwd,o->real_cwd)) continue; // borrow the connection MoveConnectionHere(o); break; } return need_sleep; } int SFtp::Do() { int m=STALL; const char *b; int s; // check if idle time exceeded if(mode==CLOSED && send_buf && idle_timer.Stopped()) { LogNote(1,_("Closing idle connection")); Disconnect(); return m; } if(Error()) return m; if(!hostname) return m; if(send_buf && send_buf->Error()) { LogError(0,"send: %s",send_buf->ErrorText()); Disconnect(send_buf->ErrorText()); return MOVED; } if(state!=CONNECTING_1 && state!=CONNECTING_2) m|=HandleReplies(); if(Error()) return m; if(send_buf) timeout_timer.Reset(send_buf->EventTime()); if(recv_buf) timeout_timer.Reset(recv_buf->EventTime()); if(pty_send_buf) timeout_timer.Reset(pty_send_buf->EventTime()); if(pty_recv_buf) timeout_timer.Reset(pty_recv_buf->EventTime()); // check for timeout only if there should be connection activity. if(state!=DISCONNECTED && state!=CONNECTED && mode!=CLOSED && CheckTimeout()) return MOVED; if((state==FILE_RECV || state==FILE_SEND) && rate_limit==0) rate_limit=new RateLimit(hostname); switch(state) { case DISCONNECTED: { if(mode==CLOSED) return m; if(mode==CONNECT_VERIFY) return m; // walk through SFtp classes and try to find identical idle session // first try "easy" cases of session take-over. for(int i=0; i<3; i++) { bool limit_reached=(connection_limit>0 && connection_limit<=CountConnections()); if(i>=2 && !limit_reached) break; bool need_sleep=GetBetterConnection(i,limit_reached); if(state!=DISCONNECTED) return MOVED; if(need_sleep) return m; } if(!ReconnectAllowed()) return m; if(!NextTry()) return MOVED; const char *init=Query("server-program",hostname); const char *prog=Query("connect-program",hostname); if(!prog || !prog[0]) prog="ssh -a -x"; char *a=alloca_strdup(prog); ArgV *cmd=new ArgV; for(a=strtok(a," "); a; a=strtok(0," ")) cmd->Add(a); if(!strchr(init,'/')) { if(init[0]) cmd->Add("-s"); // run ssh2 subsystem // sftpd does not have a greeting received_greeting=true; } else init=xstring::cat("echo SFTP: >&2;",init,NULL); if(user) { cmd->Add("-l"); cmd->Add(user); } if(portname) { cmd->Add("-p"); cmd->Add(portname); } cmd->Add(hostname); if(init[0]) cmd->Add(init); xstring_ca cmd_str(cmd->Combine(0)); LogNote(9,"%s (%s)",_("Running connect program"),cmd_str.get()); ssh=new PtyShell(cmd); ssh->UsePipes(); state=CONNECTING; timeout_timer.Reset(); m=MOVED; } case CONNECTING: { int fd=ssh->getfd(); if(fd==-1) { if(ssh->error()) { SetError(FATAL,ssh->error_text); return MOVED; } TimeoutS(1); return m; } MakePtyBuffers(); set_real_cwd("~"); state=CONNECTING_1; m=MOVED; } case CONNECTING_1: m|=HandleSSHMessage(); if(state!=CONNECTING_1) return MOVED; if(!received_greeting) return m; SendRequest(new Request_INIT(Query("protocol-version",hostname)),Expect::FXP_VERSION); state=CONNECTING_2; return MOVED; case CONNECTING_2: m|=HandleSSHMessage(); if(state!=CONNECTING_2) return MOVED; m|=HandleReplies(); if(protocol_version==0) return m; if(home_auto==0) SendRequest(new Request_REALPATH("."),Expect::HOME_PATH); state=CONNECTED; m=MOVED; case CONNECTED: if(home.path==0 && !RespQueueIsEmpty()) return m; if(mode==CLOSED) return m; SendRequest(); return MOVED; case FILE_RECV: if(file_buf->Size()>=rate_limit->BytesAllowedToGet()) { recv_buf->Suspend(); Timeout(1000); } else if(file_buf->Size()>=max_buf) { recv_buf->Suspend(); m=MOVED; } else if(recv_buf->IsSuspended()) { recv_buf->Resume(); if(recv_buf->Size()>0 || (recv_buf->Size()==0 && recv_buf->Eof())) m=MOVED; } break; case FILE_SEND: // pack data from file_buf. file_buf->Get(&b,&s); if(s==0 && !eof) return m; if(smax_packets_in_flight) return m; if(s==0) { // no more data, set attributes and close the file. if(entity_date!=NO_DATE) { Request_FSETSTAT *req=new Request_FSETSTAT(handle,protocol_version); req->attrs.mtime=entity_date; req->attrs.flags|=SSH_FILEXFER_ATTR_MODIFYTIME; SendRequest(req,Expect::IGNORE); } CloseHandle(Expect::DEFAULT); state=WAITING; m=MOVED; break; } if(s>size_write) s=size_write; SendRequest(new Request_WRITE(handle,request_pos,b,s),Expect::WRITE_STATUS); file_buf->Skip(s); request_pos+=s; flush_timer.Reset(); m=MOVED; break; case WAITING: if(mode==ARRAY_INFO) SendArrayInfoRequests(); break; case DONE: break; } return m; } void SFtp::MoveConnectionHere(SFtp *o) { super::MoveConnectionHere(o); protocol_version=o->protocol_version; recv_translate=o->recv_translate.borrow(); send_translate=o->send_translate.borrow(); rate_limit=o->rate_limit.borrow(); expect_queue_size=o->expect_queue_size; o->expect_queue_size=0; expect_chain=o->expect_chain; o->expect_chain=0; expect_chain_end=o->expect_chain_end; if(expect_chain_end==&o->expect_chain) expect_chain_end=&expect_chain; o->expect_chain_end=&o->expect_chain; timeout_timer.Reset(o->timeout_timer); ssh_id=o->ssh_id; state=CONNECTED; o->Disconnect(); if(!home) set_home(home_auto); ResumeInternal(); } void SFtp::DisconnectLL() { super::DisconnectLL(); handle.set(0); file_buf=0; EmptyRespQueue(); state=DISCONNECTED; if(mode==STORE) SetError(STORE_FAILED); protocol_version=0; send_translate=0; recv_translate=0; ssh_id=0; home_auto.set(FindHomeAuto()); // may have to resend file info queries. if(fileset_for_info) fileset_for_info->rewind(); } void SFtp::Init() { state=DISCONNECTED; ssh_id=0; eof=false; received_greeting=false; password_sent=0; expect_queue_size=0; expect_chain=0; expect_chain_end=&expect_chain; ooo_chain=0; protocol_version=0; send_translate=0; recv_translate=0; max_packets_in_flight=16; max_packets_in_flight_slow_start=1; size_read=0x8000; size_write=0x8000; use_full_path=false; flush_timer.Set(0,500); } SFtp::SFtp() : SSH_Access("SFTP:") { Init(); Reconfig(0); } SFtp::~SFtp() { Disconnect(); Close(); } SFtp::SFtp(const SFtp *o) : super(o) { Init(); Reconfig(0); } bool SFtp::Packet::HasID() { return(type!=SSH_FXP_INIT && type!=SSH_FXP_VERSION); } void SFtp::Packet::PackString(Buffer *b,const char *str,int len) { if(len==-1) len=strlen(str); b->PackUINT32BE(len); b->Put(str,len); } SFtp::unpack_status_t SFtp::Packet::UnpackString(const Buffer *b,int *offset,int limit,xstring *str_out) { if(limit-*offset<4) { // We unpack strings when we have already received complete packet, // so it is not possible to receive any more data. LogError(2,"bad string in reply (truncated length field)"); return UNPACK_WRONG_FORMAT; } int len=b->UnpackUINT32BE(*offset); if(len>limit-*offset-4) { LogError(2,"bad string in reply (invalid length field)"); return UNPACK_WRONG_FORMAT; } *offset+=4; const char *data; int data_len; b->Get(&data,&data_len); str_out->nset(data+*offset,len); *offset+=len; return UNPACK_SUCCESS; } SFtp::unpack_status_t SFtp::Packet::Unpack(const Buffer *b) { unpacked=0; if(b->Size()<4) return b->Eof()?UNPACK_PREMATURE_EOF:UNPACK_NO_DATA_YET; length=b->UnpackUINT32BE(0); unpacked+=4; if(length<1) return UNPACK_WRONG_FORMAT; if(b->Size()Eof()?UNPACK_PREMATURE_EOF:UNPACK_NO_DATA_YET; int t=b->UnpackUINT8(4); unpacked++; if(!is_valid_reply(t)) return UNPACK_WRONG_FORMAT; type=(packet_type)t; if(HasID()) { if(length<5) return UNPACK_WRONG_FORMAT; id=b->UnpackUINT32BE(5); unpacked+=4; } else { id=0; } return UNPACK_SUCCESS; } SFtp::unpack_status_t SFtp::UnpackPacket(Buffer *b,SFtp::Packet **p) { Packet *&pp=*p; pp=0; Packet probe; unpack_status_t res=probe.Unpack(b); if(res!=UNPACK_SUCCESS) return res; Log::global->Format(9,"<--- got a packet, length=%d, type=%d(%s), id=%u\n", probe.GetLength(),probe.GetPacketType(),probe.GetPacketTypeText(),probe.GetID()); switch(probe.GetPacketType()) { case SSH_FXP_VERSION: pp=new Reply_VERSION(); break; case SSH_FXP_NAME: pp=new Reply_NAME(protocol_version); break; case SSH_FXP_ATTRS: pp=new Reply_ATTRS(protocol_version); break; case SSH_FXP_STATUS: pp=new Reply_STATUS(protocol_version); break; case SSH_FXP_HANDLE: pp=new Reply_HANDLE(); break; case SSH_FXP_DATA: pp=new Reply_DATA(); break; case SSH_FXP_INIT: case SSH_FXP_OPEN: case SSH_FXP_CLOSE: case SSH_FXP_READ: case SSH_FXP_WRITE: case SSH_FXP_LSTAT: case SSH_FXP_FSTAT: case SSH_FXP_SETSTAT: case SSH_FXP_FSETSTAT: case SSH_FXP_OPENDIR: case SSH_FXP_READDIR: case SSH_FXP_REMOVE: case SSH_FXP_MKDIR: case SSH_FXP_RMDIR: case SSH_FXP_REALPATH: case SSH_FXP_STAT: case SSH_FXP_RENAME: case SSH_FXP_READLINK: case SSH_FXP_SYMLINK: case SSH_FXP_LINK: case SSH_FXP_BLOCK: case SSH_FXP_UNBLOCK: case SSH_FXP_EXTENDED: LogError(0,"request in reply??"); return UNPACK_WRONG_FORMAT; case SSH_FXP_EXTENDED_REPLY: LogError(0,"unexpected SSH_FXP_EXTENDED_REPLY"); return UNPACK_WRONG_FORMAT; } res=pp->Unpack(b); if(res!=UNPACK_SUCCESS) { switch(res) { case UNPACK_PREMATURE_EOF: LogError(0,"premature eof"); break; case UNPACK_WRONG_FORMAT: LogError(0,"wrong packet format"); break; case UNPACK_NO_DATA_YET: case UNPACK_SUCCESS: ; } probe.DropData(b); delete pp; pp=0; } return res; } void SFtp::SendRequest(Packet *request,Expect::expect_t tag,int i) { request->SetID(ssh_id++); request->ComputeLength(); Log::global->Format(9,"---> sending a packet, length=%d, type=%d(%s), id=%u\n", request->GetLength(),request->GetPacketType(),request->GetPacketTypeText(),request->GetID()); request->Pack(send_buf.get_non_const()); PushExpect(new Expect(request,tag,i)); } const char *SFtp::SkipHome(const char *path) { if(path[0]=='~' && path[1]=='/' && path[2]) return path+2; if(path[0]=='~' && !path[1]) return "."; if(!home) return path; int home_len=home.path.length(); if(strncmp(home,path,home_len)) return path; if(path[home_len]=='/' && path[home_len+1] && path[home_len+1]!='/') return path+home_len+1; if(!path[home_len]) return "."; return path; } const char *SFtp::WirePath(const char *path) { path=dir_file(cwd,path); if(!use_full_path || path[0]=='~') path=SkipHome(path); LogNote(9,"path on wire is `%s'",path); return lc_to_utf8(path); } void SFtp::SendRequest() { max_packets_in_flight_slow_start=1; ExpandTildeInCWD(); switch((open_mode)mode) { case CHANGE_DIR: LogNote(9,"checking directory `%s'",file.get()); SendRequest(new Request_STAT(lc_to_utf8(file),0,protocol_version),Expect::CWD); SendRequest(new Request_STAT(lc_to_utf8(dir_file(file,".")),0,protocol_version),Expect::CWD); state=WAITING; break; case RETRIEVE: SendRequest(new Request_OPEN(WirePath(file),SSH_FXF_READ, ACE4_READ_DATA|ACE4_READ_ATTRIBUTES,SSH_FXF_OPEN_EXISTING,protocol_version),Expect::HANDLE); state=WAITING; break; case LIST: case LONG_LIST: SendRequest(new Request_OPENDIR(WirePath(file)),Expect::HANDLE); state=WAITING; break; case STORE: SendRequest( new Request_OPEN(WirePath(file), SSH_FXF_WRITE|SSH_FXF_CREAT|(pos==0?SSH_FXF_TRUNC:0), ACE4_WRITE_DATA|ACE4_WRITE_ATTRIBUTES, pos==0?SSH_FXF_CREATE_TRUNCATE:SSH_FXF_OPEN_OR_CREATE, protocol_version), Expect::HANDLE); state=WAITING; break; case ARRAY_INFO: state=WAITING; break; case RENAME: { if(protocol_version<3) { SetError(NOT_SUPP); break; } unsigned options=SSH_FXF_RENAME_NATIVE; if(QueryBool("xfer:clobber",0)) options|=SSH_FXF_RENAME_OVERWRITE; SendRequest(new Request_RENAME(WirePath(file),WirePath(file1), options,protocol_version),Expect::DEFAULT); state=WAITING; break; } case CHANGE_MODE: { Request_SETSTAT *req=new Request_SETSTAT(WirePath(file),protocol_version); req->attrs.permissions=chmod_mode; req->attrs.flags|=SSH_FILEXFER_ATTR_PERMISSIONS; SendRequest(req,Expect::DEFAULT); state=WAITING; break; } case MAKE_DIR: if(mkdir_p) { Ref dirs(MkdirMakeSet()); for(int i=0; iCount(); i++) SendRequest(new Request_MKDIR(WirePath(dirs->String(i)),protocol_version),Expect::IGNORE); } SendRequest(new Request_MKDIR(WirePath(file),protocol_version),Expect::DEFAULT); state=WAITING; break; case REMOVE_DIR: SendRequest(new Request_RMDIR(WirePath(file)),Expect::DEFAULT); state=WAITING; break; case REMOVE: SendRequest(new Request_REMOVE(WirePath(file)),Expect::DEFAULT); state=WAITING; break; case LINK: if(protocol_version<6) { SetError(NOT_SUPP); break; } case SYMLINK: if(protocol_version<3) { SetError(NOT_SUPP); break; } if(protocol_version>=6) SendRequest(new Request_LINK(mode==SYMLINK?lc_to_utf8(file):WirePath(file),WirePath(file1),mode==SYMLINK),Expect::DEFAULT); else SendRequest(new Request_SYMLINK(lc_to_utf8(file),WirePath(file1)),Expect::DEFAULT); state=WAITING; break; case QUOTE_CMD: case MP_LIST: SetError(NOT_SUPP); break; case CONNECT_VERIFY: case CLOSED: abort(); } } void SFtp::SendArrayInfoRequests() { for(FileInfo *fi=fileset_for_info->curr(); fi && RespQueueSize()next()) { if(fi->need&(fi->SIZE|fi->DATE|fi->MODE|fi->TYPE|fi->USER|fi->GROUP)) { unsigned flags=0; if(fi->need&fi->SIZE) flags|=SSH_FILEXFER_ATTR_SIZE; if(fi->need&fi->DATE) flags|=SSH_FILEXFER_ATTR_MODIFYTIME; if(fi->need&fi->MODE) flags|=SSH_FILEXFER_ATTR_PERMISSIONS; if(fi->need&(fi->USER|fi->GROUP)) flags|=SSH_FILEXFER_ATTR_OWNERGROUP; SendRequest(new Request_STAT(WirePath(fi->name),flags, protocol_version),Expect::INFO,fileset_for_info->curr_index()); } if(fi->need&fi->SYMLINK_DEF && protocol_version>=3) SendRequest(new Request_READLINK(WirePath(fi->name)), Expect::INFO_READLINK,fileset_for_info->curr_index()); } if(RespQueueIsEmpty()) state=DONE; } void SFtp::CloseHandle(Expect::expect_t c) { if(handle) { SendRequest(new Request_CLOSE(handle),c); handle.set(0); } } void SFtp::Close() { switch(state) { case(DISCONNECTED): case(WAITING): case(CONNECTED): case(DONE): case(FILE_RECV): case(FILE_SEND): break; case(CONNECTING): case(CONNECTING_1): case(CONNECTING_2): Disconnect(); } CloseExpectQueue(); state=(recv_buf?CONNECTED:DISCONNECTED); eof=false; file_buf=0; file_set=0; CloseHandle(Expect::IGNORE); super::Close(); // don't need these out-of-order packets anymore while(ooo_chain) DeleteExpect(&ooo_chain); if(recv_buf) recv_buf->Resume(); } int SFtp::HandlePty() { int m=STALL; if(pty_recv_buf==0) return m; const char *b; int s; pty_recv_buf->Get(&b,&s); const char *eol=(const char*)memchr(b,'\n',s); if(!eol) { if(pty_recv_buf->Eof()) LogError(0,_("Peer closed connection")); if(pty_recv_buf->Error()) LogError(0,"pty read: %s",pty_recv_buf->ErrorText()); if(pty_recv_buf->Eof() || pty_recv_buf->Error()) { Disconnect(pty_recv_buf->ErrorText()); m=MOVED; } return m; } m=MOVED; s=eol-b+1; char *line=string_alloca(s); memcpy(line,b,s-1); line[s-1]=0; pty_recv_buf->Skip(s); LogRecv(4,line); return m; } void SFtp::HandleExpect(Expect *e) { const Packet *reply=e->reply; if(reply->TypeIs(SSH_FXP_STATUS)) { Reply_STATUS *r=(Reply_STATUS*)reply; const char *message=r->GetMessage(); LogNote(9,"status code=%d(%s), message=%s",r->GetCode(),r->GetCodeText(), message?message:"NULL"); } switch(e->tag) { case Expect::FXP_VERSION: if(reply->TypeIs(SSH_FXP_VERSION)) { protocol_version=((Reply_VERSION*)reply)->GetVersion(); LogNote(9,"protocol version set to %d",protocol_version); const char *charset=0; if(protocol_version>=4) charset="UTF-8"; else charset=ResMgr::Query("sftp:charset",hostname); if(charset && *charset) { send_translate=new DirectedBuffer(DirectedBuffer::PUT); recv_translate=new DirectedBuffer(DirectedBuffer::GET); send_translate->SetTranslation(charset,false); recv_translate->SetTranslation(charset,true); } } else { Disconnect(); SetError(FATAL,"cannot negotiate protocol version"); } break; case Expect::HOME_PATH: if(reply->TypeIs(SSH_FXP_NAME)) { Reply_NAME *r=(Reply_NAME*)reply; const NameAttrs *a=r->GetNameAttrs(0); if(a && !home_auto) { home_auto.set(utf8_to_lc(a->name)); LogNote(9,"home set to %s",home_auto.get()); PropagateHomeAuto(); if(!home) set_home(home_auto); cache->SetDirectory(this, home, true); } } break; case Expect::CWD: if(reply->TypeIs(SSH_FXP_ATTRS)) { const FileAttrs *a=((Reply_ATTRS*)reply)->GetAttrs(); if(a->type!=SSH_FILEXFER_TYPE_DIRECTORY && a->type!=SSH_FILEXFER_TYPE_SYMLINK) // workaround for RouterOS v6 { LogError(1,"got file type %d",a->type); cache->SetDirectory(this,cwd,false); SetError(NO_FILE,strerror(ENOTDIR)); break; } if(mode==CHANGE_DIR && RespQueueIsEmpty()) { cwd.Set(file); eof=true; cache->SetDirectory(this,cwd,true); } } else SetError(NO_FILE,reply); break; case Expect::HANDLE: if(reply->TypeIs(SSH_FXP_HANDLE)) { handle.set(((Reply_HANDLE*)reply)->GetHandle()); state=(mode==STORE?FILE_SEND:FILE_RECV); file_buf=new Buffer; xstring handle_x(""); int handle_len=handle.length(); for(int i=0; i0) { // truncate the file at write position. Request_FSETSTAT *req=new Request_FSETSTAT(handle,protocol_version); req->attrs.size=pos; req->attrs.flags|=SSH_FILEXFER_ATTR_SIZE; SendRequest(req,Expect::IGNORE); } } else SetError(NO_FILE,reply); break; case Expect::HANDLE_STALE: if(reply->TypeIs(SSH_FXP_HANDLE)) { // close the handle immediately. const xstring &handle=((Reply_HANDLE*)reply)->GetHandle(); SendRequest(new Request_CLOSE(handle),Expect::IGNORE); } break; case Expect::DATA: if(max_packets_in_flight_slow_startTypeIs(SSH_FXP_DATA)) { const Request_READ *r=e->request.Cast(); Reply_DATA *d=(Reply_DATA*)reply; if(r->pos==pos+file_buf->Size()) { const char *b; int s; d->GetData(&b,&s); LogNote(9,"data packet: pos=%lld, size=%d",(long long)r->pos,s); file_buf->Put(b,s); if(d->Eof()) goto eof; if(r->len > unsigned(s)) // received less than requested? { // if we have not yet requested next chunk of data, // then adjust request position, else re-request missed data. if(r->pos+r->len==request_pos) request_pos=r->pos+s; else SendRequest(new Request_READ(handle,r->pos+s,r->len-s),Expect::DATA); } } else { if(e->next!=ooo_chain) LogNote(9,"put a packet with id=%d on out-of-order chain (need_pos=%lld packet_pos=%lld)", reply->GetID(),(long long)(pos+file_buf->Size()),(long long)r->pos); e->next=ooo_chain; ooo_chain=e; return; } } else if(reply->TypeIs(SSH_FXP_NAME)) { Reply_NAME *r=(Reply_NAME*)reply; LogNote(9,"file name count=%d",r->GetCount()); for(int i=0; iGetCount(); i++) { const NameAttrs *a=r->GetNameAttrs(i); FileInfo *info=MakeFileInfo(a); if(mode==LIST) { file_buf->Put(a->name); if(a->attrs.type==SSH_FILEXFER_TYPE_DIRECTORY) file_buf->Put("/"); file_buf->Put("\n"); } else if(mode==LONG_LIST) { if(a->longname) { file_buf->Put(a->longname); file_buf->Put("\n"); } else if(info) { info->MakeLongName(); file_buf->Put(info->longname); file_buf->Put("\n"); } } if(info) { if(!file_set) file_set=new FileSet; file_set->Add(info); } } if(r->Eof()) goto eof; } else { if(reply->TypeIs(SSH_FXP_STATUS)) { if(((Reply_STATUS*)reply)->GetCode()==SSH_FX_EOF) { eof: if(!eof) LogNote(9,"eof"); eof=true; state=DONE; if(file_buf && !ooo_chain) file_buf->PutEOF(); break; } } SetError(NO_FILE,reply); } break; case Expect::INFO: if(mode==ARRAY_INFO) { if(reply->TypeIs(SSH_FXP_ATTRS)) { FileInfo *fi=(*fileset_for_info)[e->i]; MergeAttrs(fi,((Reply_ATTRS*)reply)->GetAttrs()); } break; } entity_size=NO_SIZE; entity_date=NO_DATE; if(reply->TypeIs(SSH_FXP_ATTRS)) { const FileAttrs *a=((Reply_ATTRS*)reply)->GetAttrs(); if(a->flags&SSH_FILEXFER_ATTR_SIZE) entity_size=a->size; if(a->flags&SSH_FILEXFER_ATTR_MODIFYTIME) entity_date=a->mtime; LogNote(9,"file info: size=%lld, date=%s",(long long)entity_size,ctime(&entity_date)); } if(opt_size) *opt_size=entity_size; if(opt_date) *opt_date=entity_date; break; case Expect::INFO_READLINK: if(reply->TypeIs(SSH_FXP_NAME)) { Reply_NAME *r=(Reply_NAME*)reply; const NameAttrs *a=r->GetNameAttrs(0); LogNote(9,"file info: symlink=%s",a->name.get()); if(mode==ARRAY_INFO) { FileInfo *fi=(*fileset_for_info)[e->i]; fi->SetSymlink(a->name); } } break; case Expect::WRITE_STATUS: if(reply->TypeIs(SSH_FXP_STATUS)) { if(((Reply_STATUS*)reply)->GetCode()==SSH_FX_OK) break; } SetError(NO_FILE,reply); break; case Expect::DEFAULT: if(reply->TypeIs(SSH_FXP_STATUS)) { if(((Reply_STATUS*)reply)->GetCode()==SSH_FX_OK) { state=DONE; break; } } SetError(NO_FILE,reply); break; case Expect::IGNORE: break; } delete e; } void SFtp::RequestMoreData() { if(mode==RETRIEVE) { int req_len=size_read; SendRequest(new Request_READ(handle,request_pos,req_len),Expect::DATA); request_pos+=req_len; } else if(mode==LIST || mode==LONG_LIST) { SendRequest(new Request_READDIR(handle),Expect::DATA); } } int SFtp::HandleReplies() { int m=STALL; if(recv_buf==0) return m; if(state!=CONNECTING_2) m|=HandlePty(); if(!recv_buf) return MOVED; int i=0; Expect *ooo_scan=ooo_chain; while(ooo_scan) { Expect *next=ooo_scan->next; ooo_chain=next; HandleExpect(ooo_scan); ooo_scan=next; if(++i>64) { LogError(0,"Too many out-of-order packets"); Disconnect(); return MOVED; } } if(!ooo_chain && eof && file_buf && !file_buf->Eof()) file_buf->PutEOF(); if(recv_buf->Size()<4) { if(recv_buf->Error()) { LogError(0,"receive: %s",recv_buf->ErrorText()); Disconnect(recv_buf->ErrorText()); return MOVED; } if(recv_buf->Eof() && pty_recv_buf->Size()==0) { LogError(0,_("Peer closed connection")); Disconnect(last_ssh_message?last_ssh_message.get():_("Peer closed connection")); m=MOVED; } return m; } if(recv_buf->IsSuspended()) return m; Packet *reply=0; unpack_status_t st=UnpackPacket(recv_buf.get_non_const(),&reply); if(st==UNPACK_NO_DATA_YET) return m; if(st!=UNPACK_SUCCESS) { LogError(2,_("invalid server response format")); Disconnect(_("invalid server response format")); return MOVED; } reply->DropData(recv_buf.get_non_const()); Expect *e=FindExpectExclusive(reply); if(e==0) { LogError(3,_("extra server response")); delete reply; return MOVED; } HandleExpect(e); return MOVED; } SFtp::Expect **SFtp::FindExpect(Packet *p) { unsigned id=p->GetID(); for(Expect **scan=&expect_chain; *scan; scan=&scan[0]->next) { if(scan[0]->request->GetID()==id) { assert(!scan[0]->reply); scan[0]->reply=p; return scan; } } return 0; } void SFtp::PushExpect(Expect *e) { e->next=*expect_chain_end; *expect_chain_end=e; expect_chain_end=&e->next; expect_queue_size++; } void SFtp::DeleteExpect(Expect **e) { if(expect_chain_end==&e[0]->next) expect_chain_end=e; Expect *d=*e; *e=e[0]->next; delete d; expect_queue_size--; } SFtp::Expect *SFtp::FindExpectExclusive(Packet *p) { Expect **e=FindExpect(p); if(!e || !*e) return 0; Expect *res=*e; if(expect_chain_end==&res->next) expect_chain_end=e; *e=res->next; expect_queue_size--; return res; } void SFtp::CloseExpectQueue() { for(Expect *e=expect_chain; e; e=e->next) { switch(e->tag) { case Expect::IGNORE: case Expect::HANDLE_STALE: case Expect::HOME_PATH: case Expect::FXP_VERSION: break; case Expect::CWD: case Expect::INFO: case Expect::INFO_READLINK: case Expect::DEFAULT: case Expect::DATA: case Expect::WRITE_STATUS: e->tag=Expect::IGNORE; break; case Expect::HANDLE: e->tag=Expect::HANDLE_STALE; break; } } } Glob *SFtp::MakeGlob(const char *pat) { return new GenericGlob(this,pat); } ListInfo *SFtp::MakeListInfo(const char *dir) { return new SFtpListInfo(this,dir); } int SFtp::Read(Buffer *buf,int size) { if(Error()) return error_code; if(mode==CLOSED) return 0; if(state==DONE) return 0; // eof if(state==FILE_RECV) { // keep some packets in flight. int limit=(entity_size>=0?max_packets_in_flight:max_packets_in_flight_slow_start); if(RespQueueSize()Eof()) { // but don't request much after possible EOF. if(entity_size<0 || request_posGet(&buf1,&size1); if(buf1==0) return 0; int bytes_allowed=rate_limit->BytesAllowedToGet(); if(size1>bytes_allowed) size1=bytes_allowed; if(size1==0) return DO_AGAIN; if(size>size1) size=size1; size=buf->MoveDataHere(file_buf,size); if(size<=0) return DO_AGAIN; pos+=size; real_pos+=size; rate_limit->BytesGot(size); TrySuccess(); return size; } return DO_AGAIN; } int SFtp::Write(const void *buf,int size) { if(mode!=STORE) return(0); Resume(); Do(); if(Error()) return(error_code); if(state!=FILE_SEND || rate_limit==0 || send_buf->Size()>2*max_buf) return DO_AGAIN; { int allowed=rate_limit->BytesAllowedToPut(); if(allowed==0) return DO_AGAIN; if(size+file_buf->Size()>allowed) size=allowed-send_buf->Size(); } if(size+file_buf->Size()>max_buf) size=max_buf-file_buf->Size(); if(entity_size>=0 && pos+size>entity_size) size=entity_size-pos; if(size<=0) return 0; file_buf->Put(static_cast(buf),size); TrySuccess(); rate_limit->BytesPut(size); pos+=size; real_pos+=size; return(size); } int SFtp::Buffered() { if(file_buf==0) return 0; off_t b=file_buf->Size()+send_buf->Size()*size_write/(size_write+20); if(b<0) b=0; else if(b>real_pos) b=real_pos; return b; } int SFtp::StoreStatus() { if(Error()) return error_code; if(state==FILE_SEND && !eof) { eof=true; return IN_PROGRESS; } if(state==DONE) return OK; return IN_PROGRESS; } int SFtp::Done() { if(mode==CLOSED) return OK; if(Error()) return error_code; if(eof || state==DONE) return OK; if(mode==CONNECT_VERIFY) return OK; return IN_PROGRESS; } void SFtp::SuspendInternal() { super::SuspendInternal(); if(recv_buf) recv_buf->SuspendSlave(); if(send_buf) send_buf->SuspendSlave(); if(pty_send_buf) pty_send_buf->SuspendSlave(); if(pty_recv_buf) pty_recv_buf->SuspendSlave(); } void SFtp::ResumeInternal() { if(recv_buf) recv_buf->ResumeSlave(); if(send_buf) send_buf->ResumeSlave(); if(pty_send_buf) pty_send_buf->ResumeSlave(); if(pty_recv_buf) pty_recv_buf->ResumeSlave(); super::ResumeInternal(); } const char *SFtp::CurrentStatus() { switch(state) { case DISCONNECTED: if(!ReconnectAllowed()) return DelayingMessage(); return _("Not connected"); case CONNECTING: if(ssh && ssh->status) return ssh->status; case CONNECTING_1: case CONNECTING_2: return _("Connecting..."); case CONNECTED: return _("Connected"); case WAITING: return _("Waiting for response..."); case FILE_RECV: return _("Receiving data"); case FILE_SEND: return _("Sending data"); case DONE: return _("Done"); } return ""; } bool SFtp::SameSiteAs(const FileAccess *fa) const { if(!SameProtoAs(fa)) return false; SFtp *o=(SFtp*)fa; return(!xstrcasecmp(hostname,o->hostname) && !xstrcmp(portname,o->portname) && !xstrcmp(user,o->user) && !xstrcmp(pass,o->pass)); } bool SFtp::SameLocationAs(const FileAccess *fa) const { if(!SameSiteAs(fa)) return false; SFtp *o=(SFtp*)fa; if(xstrcmp(cwd,o->cwd)) return false; if(xstrcmp(home,o->home)) return false; return true; } void SFtp::Cleanup() { if(hostname==0) return; for(FA *fo=FirstSameSite(); fo!=0; fo=NextSameSite(fo)) fo->CleanupThis(); CleanupThis(); } void SFtp::CleanupThis() { if(mode!=CLOSED) return; Disconnect(); } void SFtp::Reconfig(const char *name) { super::Reconfig(name); const char *c=hostname; max_packets_in_flight=Query("max-packets-in-flight",c); if(max_packets_in_flight<1) max_packets_in_flight=1; if(max_packets_in_flight_slow_start>max_packets_in_flight) max_packets_in_flight_slow_start=max_packets_in_flight; size_read=Query("size-read",c); size_write=Query("size-write",c); if(size_read<16) size_read=16; if(size_write<16) size_write=16; use_full_path=QueryBool("use-full-path",c); if(!xstrcmp(name,"sftp:charset") && protocol_version && protocol_version<4) { if(!IsSuspended()) cache->TreeChanged(this,"/"); const char *charset=ResMgr::Query("sftp:charset",hostname); if(charset && *charset) { if(!send_translate) send_translate=new DirectedBuffer(DirectedBuffer::PUT); if(!recv_translate) recv_translate=new DirectedBuffer(DirectedBuffer::GET); send_translate->SetTranslation(charset,false); recv_translate->SetTranslation(charset,true); } else { send_translate=0; recv_translate=0; } } } void SFtp::ClassInit() { // register the class Register("sftp",SFtp::New); } FileAccess *SFtp::New() { return new SFtp(); } DirList *SFtp::MakeDirList(ArgV *args) { return new SFtpDirList(this,args); } struct code_text { int code; const char *text; }; const char *SFtp::Packet::GetPacketTypeText() { struct code_text text_table[]={ { SSH_FXP_INIT, "INIT" }, { SSH_FXP_VERSION, "VERSION" }, { SSH_FXP_OPEN, "OPEN" }, { SSH_FXP_CLOSE, "CLOSE" }, { SSH_FXP_READ, "READ" }, { SSH_FXP_WRITE, "WRITE" }, { SSH_FXP_LSTAT, "LSTAT" }, { SSH_FXP_FSTAT, "FSTAT" }, { SSH_FXP_SETSTAT, "SETSTAT" }, { SSH_FXP_FSETSTAT, "FSETSTAT" }, { SSH_FXP_OPENDIR, "OPENDIR" }, { SSH_FXP_READDIR, "READDIR" }, { SSH_FXP_REMOVE, "REMOVE" }, { SSH_FXP_MKDIR, "MKDIR" }, { SSH_FXP_RMDIR, "RMDIR" }, { SSH_FXP_REALPATH, "REALPATH" }, { SSH_FXP_STAT, "STAT" }, { SSH_FXP_RENAME, "RENAME" }, { SSH_FXP_READLINK, "READLINK" }, { SSH_FXP_SYMLINK, "SYMLINK" }, { SSH_FXP_LINK, "LINK" }, { SSH_FXP_BLOCK, "BLOCK" }, { SSH_FXP_UNBLOCK, "UNBLOCK" }, { SSH_FXP_STATUS, "STATUS" }, { SSH_FXP_HANDLE, "HANDLE" }, { SSH_FXP_DATA, "DATA" }, { SSH_FXP_NAME, "NAME" }, { SSH_FXP_ATTRS, "ATTRS" }, { SSH_FXP_EXTENDED, "EXTENDED" }, { SSH_FXP_EXTENDED_REPLY,"EXTENDED_REPLY" }, {0,0} }; for(int i=0; text_table[i].text; i++) if(text_table[i].code==type) return text_table[i].text; return "UNKNOWN"; } const char *SFtp::Reply_STATUS::GetCodeText() { static const char *text_table[]={ "OK", "EOF", "No such file", "Permission denied", "Failure", "Bad message", "No connection", "Connection lost", "Operation not supported", "Invalid handle", "File already exists", "Write protect", "No media", "No space on filesystem", "Quota exceeded", "Unknown principal", "Lock conflict", "Directory not empty", "Not a directory", "Invalid file name", "Link loop", "Cannot delete", "Invalid parameter", "File is a directory", "Byte range lock conflict", "Byte range lock refused", "Delete pending", "File corrupt", "Owner invalid", "Group invalid" }; if(code>=0 && codeTypeIs(SSH_FXP_STATUS)) { SetError(code); return; } Reply_STATUS *status=(Reply_STATUS*)reply; const char *message=status->GetMessage(); if(message) { SetError(code,utf8_to_lc(message)); return; } message=status->GetCodeText(); if(message) { SetError(code,_(message)); return; } SetError(code); } #define UNPACK_GENERIC(out,size,fun) \ do { \ if(limit-*offset<(size)) \ return UNPACK_WRONG_FORMAT; \ out=b->fun(*offset); \ *offset+=(size); \ } while(0) #define UNPACK8(out) UNPACK_GENERIC(out,1,UnpackUINT8) #define UNPACK32(out) UNPACK_GENERIC(out,4,UnpackUINT32BE) #define UNPACK64(out) UNPACK_GENERIC(out,8,UnpackUINT64BE) #define UNPACK32_SIGNED(out) UNPACK_GENERIC(out,4,UnpackINT32BE) #define UNPACK64_SIGNED(out) UNPACK_GENERIC(out,8,UnpackINT64BE) #define PACK8(data) b->PackUINT8(data) #define PACK32(data) b->PackUINT32BE(data) #define PACK64(data) b->PackUINT64BE(data) #define PACK32_SIGNED(data) b->PackINT32BE(data) #define PACK64_SIGNED(data) b->PackINT64BE(data) SFtp::unpack_status_t SFtp::PacketSTRING::Unpack(const Buffer *b) { unpack_status_t res; res=Packet::Unpack(b); if(res!=UNPACK_SUCCESS) return res; res=UnpackString(b,&unpacked,length+4,&string); return res; } SFtp::unpack_status_t SFtp::Reply_NAME::Unpack(const Buffer *b) { unpack_status_t res=Packet::Unpack(b); if(res!=UNPACK_SUCCESS) return res; int *offset=&unpacked; int limit=length+4; UNPACK32(count); names=new NameAttrs[count]; for(int i=0; i=4) UNPACK8(type); if(flags & SSH_FILEXFER_ATTR_SIZE) UNPACK64(size); if(protocol_version<=3 && (flags & SSH_FILEXFER_ATTR_UIDGID)) { UNPACK32(uid); UNPACK32(gid); } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_OWNERGROUP)) { res=Packet::UnpackString(b,offset,limit,&owner); if(res!=UNPACK_SUCCESS) return res; res=Packet::UnpackString(b,offset,limit,&group); if(res!=UNPACK_SUCCESS) return res; } if(flags & SSH_FILEXFER_ATTR_PERMISSIONS) { UNPACK32(permissions); if(protocol_version<=3) { switch(permissions&S_IFMT) { case S_IFREG: type=SSH_FILEXFER_TYPE_REGULAR; break; case S_IFDIR: type=SSH_FILEXFER_TYPE_DIRECTORY; break; case S_IFLNK: type=SSH_FILEXFER_TYPE_SYMLINK; break; case S_IFIFO: case S_IFCHR: case S_IFBLK: type=SSH_FILEXFER_TYPE_SPECIAL; break; default: type=SSH_FILEXFER_TYPE_UNKNOWN; break; } } } if(protocol_version<=3 && (flags & SSH_FILEXFER_ATTR_ACMODTIME)) { UNPACK32_SIGNED(atime); UNPACK32_SIGNED(mtime); flags|=SSH_FILEXFER_ATTR_MODIFYTIME; } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_ACCESSTIME)) { UNPACK64_SIGNED(atime); if(flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) UNPACK32(atime_nseconds); } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_CREATETIME)) { UNPACK64_SIGNED(createtime); if(flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) UNPACK32(createtime_nseconds); } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_MODIFYTIME)) { UNPACK64_SIGNED(mtime); if(flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) UNPACK32(mtime_nseconds); } if(protocol_version>=5 && (flags & SSH_FILEXFER_ATTR_CTIME)) { UNPACK64_SIGNED(ctime); if(flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) UNPACK32(ctime_nseconds); } if(atime_nseconds>999999999 || createtime_nseconds>999999999 || mtime_nseconds>999999999 || ctime_nseconds>999999999) return UNPACK_WRONG_FORMAT; if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_ACL)) { UNPACK32(ace_count); ace=new FileACE[ace_count]; for(unsigned i=0; i=5 && (flags & SSH_FILEXFER_ATTR_BITS)) { UNPACK32(attrib_bits); if(protocol_version>=6) UNPACK32(attrib_bits_valid); } if(protocol_version>=6 && (flags & SSH_FILEXFER_ATTR_TEXT_HINT)) UNPACK8(text_hint); if(protocol_version>=6 && (flags & SSH_FILEXFER_ATTR_MIME_TYPE)) { res=Packet::UnpackString(b,offset,limit,&mime_type); if(res!=UNPACK_SUCCESS) return res; } if(protocol_version>=6 && (flags & SSH_FILEXFER_ATTR_LINK_COUNT)) UNPACK32(link_count); if(protocol_version>=6 && (flags & SSH_FILEXFER_ATTR_UNTRANSLATED_NAME)) { res=Packet::UnpackString(b,offset,limit,&untranslated_name); if(res!=UNPACK_SUCCESS) return res; } if(flags & SSH_FILEXFER_ATTR_EXTENDED) { UNPACK32(extended_count); extended_attrs=new ExtFileAttr[extended_count]; for(unsigned i=0; i=6) flags_mask=SSH_FILEXFER_ATTR_MASK_V6; PACK32(flags&flags_mask); if(protocol_version>=4) { if(type==0) { switch(permissions&S_IFMT) { case S_IFREG: type=SSH_FILEXFER_TYPE_REGULAR; break; case S_IFDIR: type=SSH_FILEXFER_TYPE_DIRECTORY; break; case S_IFLNK: type=SSH_FILEXFER_TYPE_SYMLINK; break; case S_IFIFO: case S_IFCHR: case S_IFBLK: type=SSH_FILEXFER_TYPE_SPECIAL; break; default: type=SSH_FILEXFER_TYPE_UNKNOWN; break; } } PACK8(type); } if(flags & SSH_FILEXFER_ATTR_SIZE) PACK64(size); if(protocol_version<=3 && (flags & SSH_FILEXFER_ATTR_UIDGID)) { PACK32(uid); PACK32(gid); } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_OWNERGROUP)) { Packet::PackString(b,owner); Packet::PackString(b,group); } if(flags & SSH_FILEXFER_ATTR_PERMISSIONS) PACK32(permissions); if(protocol_version<=3 && (flags & SSH_FILEXFER_ATTR_ACMODTIME)) { PACK32_SIGNED(atime); PACK32_SIGNED(mtime); } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_ACCESSTIME)) { PACK64_SIGNED(atime); if(flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) PACK32(atime_nseconds); } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_CREATETIME)) { PACK64_SIGNED(createtime); if(flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) PACK32(createtime_nseconds); } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_MODIFYTIME)) { PACK64_SIGNED(mtime); if(flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) PACK32(mtime_nseconds); } if(protocol_version>=5 && (flags & SSH_FILEXFER_ATTR_CTIME)) { PACK64_SIGNED(ctime); if(flags & SSH_FILEXFER_ATTR_SUBSECOND_TIMES) PACK32(ctime_nseconds); } if(protocol_version>=4 && (flags & SSH_FILEXFER_ATTR_ACL)) { PACK32(ace_count); for(unsigned i=0; i=5 && (flags & SSH_FILEXFER_ATTR_BITS)) { PACK32(attrib_bits); if(protocol_version>=6) PACK32(attrib_bits_valid); } if(protocol_version>=6 && (flags & SSH_FILEXFER_ATTR_TEXT_HINT)) PACK8(text_hint); if(protocol_version>=6 && (flags & SSH_FILEXFER_ATTR_MIME_TYPE)) Packet::PackString(b,mime_type); if(protocol_version>=6 && (flags & SSH_FILEXFER_ATTR_LINK_COUNT)) PACK32(link_count); if(protocol_version>=6 && (flags & SSH_FILEXFER_ATTR_UNTRANSLATED_NAME)) Packet::PackString(b,untranslated_name); if(flags & SSH_FILEXFER_ATTR_EXTENDED) { PACK32(extended_count); for(unsigned i=0; i=3) { if(unpacked>=limit) { LogError(2,"Status reply lacks `error message' field"); return UNPACK_SUCCESS; } res=Packet::UnpackString(b,offset,limit,&message); if(res!=UNPACK_SUCCESS) return res; if(unpacked>=limit) { LogError(2,"Status reply lacks `language tag' field"); return UNPACK_SUCCESS; } res=Packet::UnpackString(b,offset,limit,&language); if(res!=UNPACK_SUCCESS) return res; } return UNPACK_SUCCESS; } void SFtp::Request_READ::Pack(Buffer *b) { PacketSTRING::Pack(b); PACK64(pos); PACK32(len); } void SFtp::Request_WRITE::Pack(Buffer *b) { PacketSTRING::Pack(b); PACK64(pos); int len=data.length(); PACK32(len); b->Put(data,len); } void SFtp::Request_OPEN::Pack(Buffer *b) { PacketSTRING::Pack(b); if(protocol_version<=4) PACK32(pflags); if(protocol_version>=5) { PACK32(desired_access); PACK32(flags); } attrs.Pack(b,protocol_version); } void SFtp::Request_RENAME::ComputeLength() { Packet::ComputeLength(); length+=4+strlen(oldpath)+4+strlen(newpath); if(protocol_version>=5) length+=4; // flags } void SFtp::Request_RENAME::Pack(Buffer *b) { Packet::Pack(b); Packet::PackString(b,oldpath); Packet::PackString(b,newpath); if(protocol_version>=5) PACK32(flags); } void SFtp::Request_SYMLINK::Pack(Buffer *b) { Packet::Pack(b); Packet::PackString(b,oldpath); Packet::PackString(b,newpath); } void SFtp::Request_LINK::Pack(Buffer *b) { Packet::Pack(b); Packet::PackString(b,newpath); Packet::PackString(b,oldpath); PACK8(symbolic); } const char *SFtp::utf8_to_lc(const char *s) { if(!recv_translate || !s) return s; recv_translate->ResetTranslation(); recv_translate->PutTranslated(s); recv_translate->Buffer::Put("",1); int len; recv_translate->Get(&s,&len); recv_translate->Skip(len); return xstring::get_tmp(s,len); } const char *SFtp::lc_to_utf8(const char *s) { if(!send_translate || !s) return s; send_translate->ResetTranslation(); send_translate->PutTranslated(s); send_translate->Buffer::Put("",1); int len; send_translate->Get(&s,&len); send_translate->Skip(len); return xstring::get_tmp(s,len); } FileSet *SFtp::GetFileSet() { FileSet *fset=file_set.borrow(); return fset?fset:new FileSet; } void SFtp::MergeAttrs(FileInfo *fi,const FileAttrs *a) { switch(a->type) { case SSH_FILEXFER_TYPE_REGULAR: fi->SetType(fi->NORMAL); break; case SSH_FILEXFER_TYPE_DIRECTORY:fi->SetType(fi->DIRECTORY); break; case SSH_FILEXFER_TYPE_SYMLINK: fi->SetType(fi->SYMLINK); break; default: break; } if(a->flags&SSH_FILEXFER_ATTR_SIZE) fi->SetSize(a->size); if(a->flags&SSH_FILEXFER_ATTR_UIDGID) { char id[24]; snprintf(id,sizeof(id),"%u",a->uid); fi->SetUser(id); snprintf(id,sizeof(id),"%u",a->gid); fi->SetGroup(id); } if(a->flags&SSH_FILEXFER_ATTR_OWNERGROUP) { fi->SetUser (utf8_to_lc(a->owner)); fi->SetGroup(utf8_to_lc(a->group)); } if(a->flags&SSH_FILEXFER_ATTR_PERMISSIONS) fi->SetMode(a->permissions&07777); if(a->flags&SSH_FILEXFER_ATTR_MODIFYTIME) fi->SetDate(a->mtime,0); } FileInfo *SFtp::MakeFileInfo(const NameAttrs *na) { const FileAttrs *a=&na->attrs; const char *name=utf8_to_lc(na->name); const char *longname=utf8_to_lc(na->longname); LogNote(10,"NameAttrs(name=\"%s\",type=%d,longname=\"%s\")\n",name?name:"",a->type,longname?longname:""); if(!name || !name[0]) return 0; if(name[0]=='~') name=dir_file(".",name); Ref fi(new FileInfo(name)); switch(a->type) { case SSH_FILEXFER_TYPE_REGULAR: case SSH_FILEXFER_TYPE_DIRECTORY: case SSH_FILEXFER_TYPE_SYMLINK: case SSH_FILEXFER_TYPE_UNKNOWN: break; default: return 0; } if(longname) fi->SetLongName(longname); MergeAttrs(fi.get_non_const(),a); if(fi->longname && !a->owner) { // try to extract owner/group from long name. Ref ls(FileInfo::parse_ls_line(fi->longname,0)); if(ls) { if(ls->user) fi->SetUser(ls->user); if(ls->group) fi->SetGroup(ls->group); if(ls->nlinks>0) fi->SetNlink(ls->nlinks); } } return fi.borrow(); } #undef super #define super DirList #include "ArgV.h" int SFtpDirList::Do() { int m=STALL; if(done) return m; if(buf->Eof()) { done=true; return MOVED; } if(!ubuf) { const char *cache_buffer=0; int cache_buffer_size=0; int err; const FileSet *fset_c; if(use_cache && FileAccess::cache->Find(session,dir,FA::LONG_LIST,&err, &cache_buffer,&cache_buffer_size,&fset_c)) { if(err) { SetErrorCached(cache_buffer); return MOVED; } ubuf=new IOBuffer(IOBuffer::GET); ubuf->Put(cache_buffer,cache_buffer_size); ubuf->PutEOF(); fset=new FileSet(fset_c); } else { session->Open(dir,FA::LONG_LIST); ubuf=new IOBufferFileAccess(session); if(FileAccess::cache->IsEnabled(session->GetHostName())) ubuf->Save(FileAccess::cache->SizeLimit()); } } const char *b; int len; ubuf->Get(&b,&len); if(b==0) // eof { if(!fset && session->IsOpen()) fset=session.Cast()->GetFileSet(); FileAccess::cache->Add(session,dir,FA::LONG_LIST,FA::OK,ubuf,fset); if(use_file_set) { fset->Sort(fset->BYNAME,false); for(fset->rewind(); fset->curr(); fset->next()) { FileInfo *fi=fset->curr(); buf->Put(fi->GetLongName()); buf->Put("\n"); } fset=0; } ubuf=0; dir=args->getnext(); if(!dir) buf->PutEOF(); else buf->Format("\n%s:\n",dir); return MOVED; } if(len>0) { if(!use_file_set) buf->Put(b,len); ubuf->Skip(len); m=MOVED; } if(ubuf->Error()) { SetError(ubuf->ErrorText()); m=MOVED; } return m; } SFtpDirList::SFtpDirList(SFtp *s,ArgV *a) : DirList(s,a) { use_file_set=true; args->rewind(); int opt; while((opt=args->getopt("fCFl"))!=EOF) { switch(opt) { case('a'): ls_options.show_all=true; break; case('C'): ls_options.multi_column=true; break; case('F'): ls_options.append_type=true; break; } } while(args->getindex()>1) args->delarg(1); // remove options. if(args->count()<2) args->Append(""); args->rewind(); dir=args->getnext(); if(args->getindex()+1count()) buf->Format("%s:\n",dir); } const char *SFtpDirList::Status() { if(ubuf && !ubuf->Eof() && session->IsOpen()) return xstring::format(_("Getting file list (%lld) [%s]"), (long long)session->GetPos(),session->CurrentStatus()); return ""; } void SFtpDirList::SuspendInternal() { super::SuspendInternal(); if(ubuf) ubuf->SuspendSlave(); } void SFtpDirList::ResumeInternal() { if(ubuf) ubuf->ResumeSlave(); super::ResumeInternal(); } #undef super #define super ListInfo int SFtpListInfo::Do() { int m=STALL; if(done) return m; if(!ubuf && !result) { const char *cache_buffer=0; int cache_buffer_size=0; int err; const FileSet *fset_c; if(use_cache && FileAccess::cache->Find(session,"",FA::LONG_LIST,&err, &cache_buffer,&cache_buffer_size,&fset_c)) { if(err) { SetErrorCached(cache_buffer); return MOVED; } ubuf=new IOBuffer(IOBuffer::GET); ubuf->Put(cache_buffer,cache_buffer_size); ubuf->PutEOF(); result=new FileSet(fset_c); } else { session->Open("",FA::LONG_LIST); ubuf=new IOBufferFileAccess(session); if(FileAccess::cache->IsEnabled(session->GetHostName())) ubuf->Save(FileAccess::cache->SizeLimit()); } } if(!result) { const char *b; int len; ubuf->Get(&b,&len); if(len>0) { ubuf->Skip(len); return MOVED; } if(ubuf->Error()) { SetError(ubuf->ErrorText()); return MOVED; } if(b) return m; // eof if(!result && session->IsOpen()) result=session.Cast()->GetFileSet(); FileAccess::cache->Add(session,"",FA::LONG_LIST,FA::OK,ubuf,result); result->Exclude(exclude_prefix,exclude); m=MOVED; } if(result && session->OpenMode()!=FA::ARRAY_INFO) { ubuf=0; result->ExcludeCompound(); result->rewind(); for(FileInfo *file=result->curr(); file!=0; file=result->next()) { file->need=0; if(file->defined & file->TYPE) { if(file->filetype==file->SYMLINK && follow_symlinks) { file->defined &= ~(file->SIZE|file->DATE|file->SYMLINK_DEF|file->MODE|file->TYPE|file->USER|file->GROUP); file->Need(file->SIZE|file->DATE|file->MODE|file->TYPE|file->USER|file->GROUP); } else if(file->filetype==file->SYMLINK) { // need the link target if(!file->Has(file->SYMLINK_DEF)) file->Need(file->SYMLINK_DEF); } } } session->GetInfoArray(result.get_non_const()); session->Roll(); m=MOVED; } if(session->OpenMode()==FA::ARRAY_INFO) { int res=session->Done(); if(res==FA::DO_AGAIN) return m; if(res==FA::IN_PROGRESS) return m; session->Close(); done=true; m=MOVED; } return m; } const char *SFtpListInfo::Status() { if(ubuf && !ubuf->Eof() && session->IsOpen()) return xstring::format(_("Getting file list (%lld) [%s]"), (long long)session->GetPos(),session->CurrentStatus()); return ""; } #include "modconfig.h" #ifdef MODULE_PROTO_SFTP void module_init() { SFtp::ClassInit(); } #endif lftp-4.6.3a/src/FindJobDu.h0000644000015000007670000000427312431427156012332 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef FINDJOBDU_H #define FINDJOBDU_H #include "FindJob.h" class FinderJob_Du : public FinderJob { SMTaskRef buf; /* We keep traversing deeper than this, but we never print a total * past this. */ int max_print_depth; bool print_totals; int output_block_size; int human_opts; bool all_files; bool separate_dirs; bool file_count; bool success; long long tot_size; void Init(const char *d); struct stack_entry { xstring_c dir; long long size; stack_entry(const char *dir) : dir(dir), size(0) {} }; RefArray size_stack; Ref args; void print_size (long long n_blocks, const char *string); off_t BlockCeil(off_t size) const; // prepends last directory name const char *MakeFileName(const char *n); void Push (const char *d); void Pop(); public: FinderJob_Du(FileAccess *s,ArgV *a,FDStream *o); ~FinderJob_Du(); int Done(); void PrintTotals() { print_totals=true; } void SetBlockSize(int n,int ho) { output_block_size = n; human_opts = ho; } void PrintDepth(int n) { max_print_depth = n; } void AllFiles() { all_files=true; } void SeparateDirs() { separate_dirs=true; } void FileCount() { file_count=true; } protected: /* virtuals */ prf_res ProcessFile(const char *d,const FileInfo *fi); void ProcessList(FileSet *f); void Finish(); void Enter(const char *d); void Exit(); }; #endif // FINDJOBDU_H lftp-4.6.3a/src/xdg-move0000755000015000007670000000142512122054657012024 00000000000000#!/bin/bash # # This script moves ~/.lftp (or $LFTP_HOME) files to XDG directories. # ~/.lftp should be removed after execution of this script. # src=${LFTP_HOME:-$HOME/.lftp} if ! [ -d "$src" ]; then echo "Nothing to move (no $src directory found)." >&2 exit 0 fi function move() { test -a "$src/$1" || return test -d "$2" || mkdir -p "$2" || exit 1 mv "$src/$1" "$2/" } function move_data() { move "$1" "${XDG_DATA_HOME:-$HOME/.local/share}/lftp" } function move_config() { move "$1" "${XDG_CONFIG_HOME:-$HOME/.config}/lftp" } function move_cache() { move "$1" "${XDG_CACHE_HOME:-$HOME/.cache}/lftp" } move_data bg move_data bookmarks move_data cwd_history move_cache DHT move_data log move_config rc move_data rl_history move_data transfer_log rmdir "$src" lftp-4.6.3a/src/example1.cc0000644000015000007670000000151612343574760012403 00000000000000/* This example shows blocking usage of Ftp class */ #include #include #include "FileAccess.h" char *program_name; int main(int argc,char **argv) { program_name=argv[0]; FileAccess *f=FileAccess::New("ftp","ftp.yar.ru"); if(!f) { fprintf(stderr,"ftp: unknown protocol, cannot create ftp session\n"); return 1; } f->Open("/pub/source/lftp",f->LONG_LIST); Buffer buf; for(;;) { SMTask::Schedule(); int res=f->Read(&buf,1024); if(res<0) { if(res==f->DO_AGAIN) { SMTask::Block(); continue; } fprintf(stderr,"Error: %s\n",f->StrError(res)); return 1; } if(res==0) // eof { f->Close(); break; } buf.SpaceAdd(res); write(1,buf.Get(),res); buf.Skip(res); } SMTask::Delete(f); return 0; } lftp-4.6.3a/src/SysCmdJob.h0000644000015000007670000000224412122060730012343 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef SYSCMDJOB_H #define SYSCMDJOB_H #include "trio.h" #include "Job.h" #include "ProcWait.h" class SysCmdJob : public Job { xstring cmd; SMTaskRef w; void PrepareToDie(); public: SysCmdJob(const char *new_cmd); ~SysCmdJob(); int Do(); int Done() { return(w && w->GetState()!=w->RUNNING); } int AcceptSig(int); int ExitCode() { return w?w->GetInfo()>>8:1; } }; #endif//SYSCMDJOB_H lftp-4.6.3a/src/attach.h0000644000015000007670000001553312170763153011773 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef ATTACH_H #define ATTACH_H #include #include // for mkdir() #include #include #include #include #include #include #include #include #if HAVE_SYS_SOCKET_H # include #elif HAVE_WS2TCPIP_H # include #endif #include "SMTask.h" #include "Error.h" #include "SignalHook.h" #include "misc.h" #include "passfd.h" #ifndef SUN_LEN #define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) #endif class AcceptTermFD : public SMTask { int sock; int a_sock; int recv_i; int fds[3]; bool accepted; bool detached; public: AcceptTermFD() : sock(-1), a_sock(-1), recv_i(0), accepted(false), detached(false) { do_listen(); } ~AcceptTermFD() { for(int i=0; i=recv_i) close(fds[i]); } close(sock); sock=-1; unlink(get_sock_path()); accepted=true; printf(_("[%u] Attached to terminal.\n"),(unsigned)getpid()); return MOVED; } static xstring& get_sock_path(int pid=0) { if(!pid) pid=getpid(); const char *home=get_lftp_data_dir(); mkdir(xstring::format("%s/bg",home),0700); return xstring::format("%s/bg/%s-%d",home,get_nodename(),pid); } void do_listen() { const char *path=get_sock_path(); unlink(path); if(sock>=0) close(sock); if(a_sock>=0) { close(a_sock); a_sock=-1; } for(int i=0; i=0) listen(sock,1); } } bool Accepted() { return accepted; } void Detach() { do_listen(); } bool Detached() { return detached; } }; class SendTermFD : public SMTask { static pid_t pass_pid; static void pass_sig(int s) { kill(pass_pid,s); } Ref error; pid_t pid; int sock; bool connected; bool sent; int send_i; bool detached; public: SendTermFD(pid_t p) : pid(p), sock(-1), connected(false), sent(false), send_i(0), detached(false) {} ~SendTermFD() { if(sock>=0) close(sock); } int Do() { int m=STALL; if(error || detached) return m; if(sent) { char buf; int res=read(sock,&buf,1); if(res==-1 && E_RETRY(errno)) { Block(sock,POLLIN); return m; } if(res<=0) { detached=true; close(sock); sock=-1; SignalHook::DoCount(SIGINT); SignalHook::Restore(SIGQUIT); SignalHook::DoCount(SIGTSTP); SignalHook::Restore(SIGWINCH); } return MOVED; } if(sock==-1) { sock=socket(AF_UNIX,SOCK_STREAM,0); if(sock==-1) { if(NonFatalError(errno)) { TimeoutS(1); return m; } error=Error::Fatal(xstring::format("socket(): %s",strerror(errno))); return MOVED; } int fl=fcntl(sock,F_GETFL); fcntl(sock,F_SETFL,fl|O_NONBLOCK); fcntl(sock,F_SETFD,FD_CLOEXEC); connected=false; m=MOVED; } if(!connected) { struct sockaddr_un sun_addr; memset(&sun_addr,0,sizeof(sun_addr)); sun_addr.sun_family=AF_UNIX; const char *path=AcceptTermFD::get_sock_path(pid); strncpy(sun_addr.sun_path,path,sizeof(sun_addr.sun_path)); int res=connect(sock,(sockaddr*)&sun_addr,SUN_LEN(&sun_addr)); if(res==-1 && !NonFatalError(errno)) { error=Error::Fatal(xstring::format("connect(%s): %s",path,strerror(errno))); return MOVED; } if(res==-1) { Block(sock,POLLOUT); return m; } connected=true; m=MOVED; } while(send_i<=2) { if(sendfd(sock,send_i)<0) { if(NonFatalError(errno)) { Block(sock,POLLOUT); return m; } error=Error::Fatal(xstring::format("sendfd: %s",strerror(errno))); close(sock); sock=-1; return 0; } ++send_i; m=MOVED; } sent=true; pass_pid=pid; if(isatty(0)) { SignalHook::Handle(SIGINT,pass_sig); SignalHook::Handle(SIGQUIT,pass_sig); SignalHook::Handle(SIGTSTP,pass_sig); SignalHook::Handle(SIGWINCH,pass_sig); } return MOVED; } bool Done() { return error || detached; } bool Failed() { return error; } const char *ErrorText() { return error->Text(); } }; #endif lftp-4.6.3a/src/url.h0000644000015000007670000000501212406041334011310 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef URL_H #define URL_H #include "xstring.h" class ParsedURL { public: xstring_c proto; xstring_c user; xstring_c pass; xstring_c host; xstring_c port; xstring path; xstring_c orig_url; ParsedURL(const char *url,bool proto_required=false,bool use_rfc1738=true); void parse(const char *url,bool proto_required=false,bool use_rfc1738=true); ~ParsedURL(); // returns allocated memory char *Combine(const char *home=0,bool use_rfc1738=true); }; # define URL_UNSAFE " <>\"'%{}|\\^[]`" # define URL_PATH_UNSAFE URL_UNSAFE"#;?&+" # define URL_HOST_UNSAFE URL_UNSAFE":/" # define URL_PORT_UNSAFE URL_UNSAFE"/" # define URL_USER_UNSAFE URL_UNSAFE"/:@" # define URL_PASS_UNSAFE URL_UNSAFE"/:@" class url { public: char *proto; char *user; char *pass; char *host; char *port; char *path; url(const char *u); url(); ~url(); void SetPath(const char *p,const char *q=URL_PATH_UNSAFE); char *Combine(); // encode unsafe chars as %XY static xstring& encode(const char *s,int len,const char *unsafe,unsigned flags=0); static xstring& encode(const xstring &s,const char *unsafe,unsigned flags=0) { return encode(s,s.length(),unsafe,flags); } static xstring& encode(const char *s,const char *unsafe,unsigned flags=0) { return encode(s,strlen(s),unsafe,flags); } static xstring& decode(const char *) __attribute__((warn_unused_result)); static bool is_url(const char *p); static int path_index(const char *p); static const char *path_ptr(const char *p); static bool dir_needs_trailing_slash(const char *proto); static bool find_password_pos(const char *url,int *start,int *len); static const char *remove_password(const char *url); static const char *hide_password(const char *url); }; #endif//URL_H lftp-4.6.3a/src/ColumnOutput.h0000644000015000007670000000370112122057234013170 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef DISPCOLUMNS_H #define DISPCOLUMNS_H #include "OutputJob.h" #include "xarray.h" class datum { int ws, curwidth; public: /* Each entry has a series of strings; each string has a color. */ StringSet names; StringSet colors; datum() : ws(0), curwidth(0) {} void append(const char *name, const char *color); // get the total display width int width() const { return curwidth; } // print with or without color void print(const JobRef& o, bool color, int skip, const char *color_pref, const char *color_suf, const char *color_reset) const; /* count leading whitespace in the first name only. */ int whitespace() const { return ws; } }; class ColumnOutput { void get_print_info(unsigned width, xarray &col_arr, xarray &ws_arr, int &cols) const; public: enum mode_t { VERT }; void append(); void add(const char *name, const char *color); void addf(const char *fmt, const char *color, ...); void SetWidth(unsigned width); void SetColor(bool color); void print(const JobRef& o, unsigned width, bool color) const; void set_mode(mode_t m) { mode = m; } private: RefArray lst; mode_t mode; }; #endif lftp-4.6.3a/src/buffer.h0000644000015000007670000002105312401264616011767 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef BUFFER_H #define BUFFER_H #include "SMTask.h" #include "Filter.h" #include "Timer.h" #include "fg.h" #include "xstring.h" #include "Speedometer.h" #include #ifdef HAVE_ICONV CDECL_BEGIN # include CDECL_END #endif class Buffer { protected: xstring error_text; int saved_errno; bool error_fatal; xstring buffer; int buffer_ptr; bool eof; // no reads possible (except from mem buffer) bool broken; // no writes possible bool save; // save skipped data int save_max; off_t pos; Ref rate; void RateAdd(int n); void Allocate(int size); void SaveMaxCheck(int addsize); public: bool Error() const { return error_text!=0; } bool ErrorFatal() const { return error_fatal; } void SetError(const char *e,bool fatal=false); void SetErrorCached(const char *e); const char *ErrorText() const { return error_text; } int Size() const { return buffer.length()-buffer_ptr; } bool Eof() const { return eof; } bool Broken() const { return broken; } const char *Get() const; void Get(const char **buf,int *size) const; void Skip(int len); // Get(); consume; Skip() void UnSkip(int len); // this only works if there were no Put's. void Append(const char *buf,int size); void Append(const xstring& s) { Append(s.get(),s.length()); } void Put(const char *buf,int size); void Put(const char *buf) { Put(buf,strlen(buf)); } void Put(const xstring &s) { Put(s.get(),s.length()); } void Put(char c) { Put(&c,1); } void Format(const char *f,...) PRINTF_LIKE(2,3); void vFormat(const char *f, va_list v); void PutEOF() { eof=true; } char *GetSpace(int size) { Allocate(size); return buffer.get_non_const()+buffer.length(); } void SpaceAdd(int size) { buffer.set_length(buffer.length()+size); } void Prepend(const char *buf,int size); void Prepend(const char *buf) { Prepend(buf,strlen(buf)); } int MoveDataHere(Buffer *o,int len); template int MoveDataHere(const Ref& o,int len) { return MoveDataHere(o.get_non_const(),len); } template int MoveDataHere(const SMTaskRef& o,int len) { return MoveDataHere(o.get_non_const(),len); } unsigned long long UnpackUINT64BE(int offset=0) const; unsigned UnpackUINT32BE(int offset=0) const; unsigned UnpackUINT16BE(int offset=0) const; unsigned UnpackUINT8(int offset=0) const; void PackUINT64BE(unsigned long long data); void PackUINT32BE(unsigned data); void PackUINT16BE(unsigned data); void PackUINT8(unsigned data); long long UnpackINT64BE(int offset=0) const; int UnpackINT32BE(int offset=0) const; int UnpackINT16BE(int offset=0) const; int UnpackINT8(int offset=0) const; void PackINT64BE(long long data); void PackINT32BE(int data); void PackINT16BE(int data); void PackINT8(int data); // useful for cache. void Save(int m) { save=true; save_max=m; } bool IsSaving() const { return save; } void GetSaved(const char **buf,int *size) const; void SaveRollback(off_t p); void SetPos(off_t p) { pos=p; } off_t GetPos() const { return pos; } void SetSpeedometer(Speedometer *s) { rate=s; } const char *GetRateStrS(); void Empty(); Buffer(); ~Buffer(); const char *Dump() const; }; class DataTranslator : public Buffer { public: virtual void PutTranslated(Buffer *dst,const char *buf,int size)=0; virtual void ResetTranslation() { Empty(); } virtual ~DataTranslator() {} // same as PutTranslated, but does not advance pos. void AppendTranslated(Buffer *dst,const char *buf,int size); }; #ifdef HAVE_ICONV class DataRecoder : public DataTranslator { iconv_t backend_translate; public: void PutTranslated(Buffer *dst,const char *buf,int size); void ResetTranslation(); DataRecoder(const char *from_code,const char *to_code,bool translit=true); ~DataRecoder(); }; #endif //HAVE_ICONV class DirectedBuffer : public Buffer { public: enum dir_t { GET, PUT }; protected: Ref translator; dir_t mode; void EmbraceNewData(int len); public: DirectedBuffer(dir_t m) : mode(m) {} void SetTranslator(DataTranslator *t); void SetTranslation(const char *be_encoding,bool translit=true) #ifdef HAVE_ICONV ; #else {} #endif //HAVE_ICONV void PutTranslated(const char *buf,int size); void PutTranslated(const char *buf) { PutTranslated(buf,strlen(buf)); } void PutTranslated(const xstring& s) { PutTranslated(s.get(),s.length()); } void ResetTranslation(); void PutRaw(const char *buf,int size) { Buffer::Put(buf,size); } void PutRaw(const char *buf) { Buffer::Put(buf); } void Put(const char *buf,int size); void Put(const char *buf) { Put(buf,strlen(buf)); } int MoveDataHere(Buffer *o,int len); template int MoveDataHere(const SMTaskRef& o,int len) { return MoveDataHere(o.get_non_const(),len); } dir_t GetDirection() { return mode; } }; class IOBuffer : public DirectedBuffer, public SMTask { protected: // low-level for derived classes virtual int Get_LL(int size) { return 0; } virtual int Put_LL(const char *buf,int size) { return 0; } virtual int PutEOF_LL() { return 0; } Time event_time; // used to detect timeouts int max_buf; int get_size; int TuneGetSize(int res); enum { GET_BUFSIZE=0x10000, PUT_LL_MIN=0x2000, }; virtual ~IOBuffer(); public: IOBuffer(dir_t m); virtual const Time& EventTime() { if(IsSuspended()) return now; return event_time; } virtual bool Done() { return(broken || Error() || (eof && (mode==GET || Size()==0))); } virtual int Do(); virtual FgData *GetFgData(bool) { return 0; } virtual const char *Status() { return ""; } virtual int Buffered() { return Size(); } // Put method with Put_LL shortcut void Put(const char *,int); void Put(const char *buf); void Put(const xstring &s) { Put(s.get(),s.length()); } void Put(char c) { Put(&c,1); } // anchor to PutEOF_LL void PutEOF() { DirectedBuffer::PutEOF(); PutEOF_LL(); } void SetMaxBuffered(int m) { max_buf=m; } bool IsFull() { return Size()+(translator?translator->Size():0) >= max_buf; } }; class IOBufferStacked : public IOBuffer { SMTaskRef down; int Get_LL(int size); int Put_LL(const char *buf,int size); void SuspendInternal(); void ResumeInternal(); public: IOBufferStacked(IOBuffer *b) : IOBuffer(b->GetDirection()), down(b) {} void PrepareToDie() { down=0; } const Time& EventTime() { return down->EventTime(); } int Do(); bool Done(); }; class IOBufferFDStream : public IOBuffer { Ref my_stream; const Ref& stream; Ref put_ll_timer; int Get_LL(int size); int Put_LL(const char *buf,int size); public: IOBufferFDStream(FDStream *o,dir_t m) : IOBuffer(m), my_stream(o), stream(my_stream) {} IOBufferFDStream(const Ref& o,dir_t m) : IOBuffer(m), stream(o) {} IOBufferFDStream(FDStream *o,dir_t m,Timer *t) : IOBuffer(m), my_stream(o), stream(my_stream), put_ll_timer(t) {} IOBufferFDStream(const Ref& o,dir_t m,Timer *t) : IOBuffer(m), stream(o), put_ll_timer(t) {} ~IOBufferFDStream(); bool Done(); FgData *GetFgData(bool fg); const char *Status() { return stream->status; } }; #include class IOBufferFileAccess : public IOBuffer { const FileAccessRef& session; FileAccessRef session_ref; int Get_LL(int size); void SuspendInternal(); void ResumeInternal(); public: IOBufferFileAccess(const FileAccessRef& i) : IOBuffer(GET), session(i) {} IOBufferFileAccess(FileAccess *fa) : IOBuffer(GET), session(session_ref), session_ref(fa) {} ~IOBufferFileAccess() { // we don't want to delete the session (void)session_ref.borrow(); } const char *Status(); }; #endif // BUFFER_H lftp-4.6.3a/src/xmap.h0000644000015000007670000001035312410755150011462 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef XMAP_H #define XMAP_H 1 #include "xarray.h" class _xmap { protected: struct entry { entry *next; xstring key; }; int value_size; int hash_size; int make_hash(const xstring& s) const; xarray_p<_xmap::entry> map; void new_map(); void rebuild_map(); int entry_count; int each_hash; entry *each_entry; entry *last_entry; // the entry returned by last each_begin/next public: _xmap(int vs); ~_xmap(); void _add(const xstring& key,void *value); _xmap::entry **_lookup(const xstring& key); _xmap::entry *_lookup_c(const xstring& key) const; entry *_add(const xstring& key); void _remove(entry **ep); entry *_each_begin(); entry *_each_next(); const xstring& each_key() const { return last_entry->key; } bool each_finished() const { return last_entry==0; } int count() const { return entry_count; } void _move_here(_xmap &o); void _empty(); }; template class xmap : public _xmap { xmap& operator=(const xmap&); // make assignment fail xmap(const xmap&); // disable cloning public: xmap() : _xmap(sizeof(T)) {} ~xmap() {} static T& payload(entry *e) { return *(T*)(e+1); } static T zero; T& lookup_Lv(const xstring& key) { entry **e=_lookup(key); if(e && *e) return payload(*e); return zero; } const T& lookup(const xstring& key) const { entry *e=_lookup_c(key); if(e) return payload(e); return zero; } const T& lookup(const char *key) const { return lookup(xstring::get_tmp(key)); } T& operator[](const xstring& key) { return lookup_Lv(key); } void remove(const xstring& key) { _remove(_lookup(key)); } void add(const xstring& key,T e0) { payload(_add(key))=e0; } const T& each_begin() { entry *e=_each_begin(); return e?payload(e):zero; } const T& each_next() { entry *e=_each_next(); return e?payload(e):zero; } void move_here(xmap &o) { _move_here(o); } void empty() { _empty(); } bool exists(const xstring& key) const { return _lookup_c(key); } }; template T xmap::zero; template class xmap_p : public _xmap { void dispose(T *p) { delete p; } public: xmap_p() : _xmap(sizeof(T*)) {} ~xmap_p() { for(entry *e=_each_begin(); e; e=_each_next()) dispose(payload(e)); } T*& payload_Lv(entry *e) { return *(T**)(e+1); } T* payload(entry *e) const { return *(T**)(e+1); } T* lookup(const xstring& key) const { entry *e=_lookup_c(key); if(e) return payload(e); return 0; } T* lookup(const char *key) const { return lookup(xstring::get_tmp(key)); } T* borrow(const xstring& key) { entry **e=_lookup(key); if(e && *e) { T *p=payload(*e); _remove(e); return p; } return 0; } void remove(const xstring& key) { dispose(borrow(key)); } void add(const xstring& key,T *e0) { entry *e=_add(key); dispose(payload(e)); payload_Lv(e)=e0; } void add(const char *key,T *e0) { add(xstring::get_tmp(key),e0); } T *each_begin() { entry *e=_each_begin(); return e?payload(e):0; } T *each_next() { entry *e=_each_next(); return e?payload(e):0; } void each_set(T *n) { payload_Lv(last_entry)=n; } void move_here(xmap_p &o) { _move_here(o); } void empty() { for(int i=0; i. */ #include #include #include #include "trio.h" #include "ProcWait.h" #include "SignalHook.h" xmap ProcWait::all_proc; const xstring& ProcWait::proc_key(pid_t p) { static xstring tmp_key; tmp_key.nset((const char*)&p,sizeof(p)); return tmp_key; } int ProcWait::Do() { int m=STALL; if(status!=RUNNING) { final: if(auto_die) { Delete(this); return MOVED; } return m; } int info; int res=waitpid(pid,&info,WNOHANG|WUNTRACED); if(res==-1) { if(status!=RUNNING) return MOVED; // waitpid failed, check the process existence if(kill(pid,0)==-1) { status=TERMINATED; term_info=255; m=MOVED; goto final; } goto leave; } if(res==pid) { if(handle_info(info)) { m=MOVED; goto final; } } leave: Timeout(500); // check from time to time, in case SIGCHLD fails return m; } bool ProcWait::handle_info(int info) { if(WIFSTOPPED(info)) { SignalHook::IncreaseCount(SIGTSTP); return false; } else { if(WIFSIGNALED(info) && WTERMSIG(info)==SIGINT) SignalHook::IncreaseCount(SIGINT); status=TERMINATED; term_info=info; return true; } } int ProcWait::Kill(int sig) { Do(); if(status!=RUNNING) return -1; int res; res=kill(-pid,sig); if(res==-1) res=kill(pid,sig); return res; } ProcWait::ProcWait(pid_t p) : pid(p) { auto_die=false; status=RUNNING; term_info=-1; saved_errno=0; all_proc.add(proc_key(pid),this); } ProcWait::~ProcWait() { all_proc.remove(proc_key(pid)); } void ProcWait::SIGCHLD_handler(int sig) { (void)sig; int info; pid_t pp=waitpid(-1,&info,WUNTRACED|WNOHANG); if(pp==-1) return; ProcWait *w=all_proc.lookup(proc_key(pp)); if(w && w->handle_info(info)) w->Timeout(0); } void ProcWait::Signal(bool yes) { if(yes) { SignalHook::Handle(SIGCHLD,&ProcWait::SIGCHLD_handler); SignalHook::Unblock(SIGCHLD); } else SignalHook::Block(SIGCHLD); } void ProcWait::DeleteAll() { Signal(false); for(ProcWait *w=all_proc.each_begin(); w; w=all_proc.each_next()) Delete(w); } lftp-4.6.3a/src/DHT.h0000644000015000007670000001566612334321674011155 00000000000000/* * lftp - file transfer program * * Copyright (c) 2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef DHT_H #define DHT_H class Torrent; class DHT : public SMTask, protected ProtoLog, public ResClient { static const int K = 8; static const int MAX_NODES = 160*K; static const int MAX_TORRENTS = 1024; static const int MAX_PEERS = 60; // per torrent static const int MAX_SEND_QUEUE = 256; class Node { public: xstring id; xstring token; xstring my_token; xstring my_last_token; sockaddr_u addr; Timer good_timer; // 15 minutes, questionable when expired Timer token_timer; Timer ping_timer; // don't send pings too often bool responded; // has ever responded to our query bool in_routes; // belongs to the routing table; int ping_lost_count; bool IsGood() const { return !good_timer.Stopped(); } void SetGood() { good_timer.Reset(); } bool IsBad() const { return !IsGood() && ping_lost_count>=2; } void LostPing() { ping_lost_count++; } void ResetLostPing() { ping_lost_count=0; } bool IsBetterThan(const Node *node,const xstring& target) const; const char *GetName() const { return addr.to_string(); } Node(const xstring& i,const sockaddr_u& a) : id(i.copy()), addr(a), good_timer(15*60), token_timer(5*60), ping_timer(30), responded(false), in_routes(false), ping_lost_count(0) { good_timer.AddRandom(5); ping_timer.Stop(); ping_timer.AddRandom(5); } const xstring& GetToken(); bool TokenIsValid(const xstring& token) const; }; class RouteBucket { public: int prefix_bits; xstring prefix; xarray nodes; Timer fresh_timer; bool IsFresh() const { return !fresh_timer.Stopped(); } void SetFresh() { fresh_timer.Reset(); } bool PrefixMatch(const xstring& i) const; void RemoveNode(Node *n); void RemoveNode(int i); RouteBucket(int pb,const xstring& p) : prefix_bits(pb), prefix(p.copy()), fresh_timer(15*60) { assert(prefix.length()>=size_t((prefix_bits+7)/8)); } const char *to_string() const; }; class Request { public: Ref data; sockaddr_u addr; xstring node_id; Timer expire_timer; bool Expired() const { return expire_timer.Stopped(); } const xstring& GetNodeId() const { return node_id; } const xstring& GetSearchTarget() const; Request(BeNode *b,const sockaddr_u& a,const xstring& id) : data(b), addr(a), node_id(id.copy()), expire_timer(180) {} }; class Search { public: xstring target_id; xstring best_node_id; xmap searched; int depth; Timer search_timer; bool want_peers; bool noseed; bool bootstrap; Search(const xstring& i) : target_id(i.copy()), depth(0), search_timer(185), want_peers(false), noseed(false), bootstrap(false) {} bool IsFeasible(const xstring &id) const; bool IsFeasible(const Node *n) const { return IsFeasible(n->id); } void ContinueOn(DHT *d,const Node *n); void WantPeers(bool ns) { want_peers=true; noseed=ns; } void Bootstrap() { bootstrap=true; } }; class Peer { public: sockaddr_compact compact_addr; Timer good_timer; bool seed; Peer(const sockaddr_compact &a,bool s) : compact_addr(a), good_timer(15*60), seed(s) {} bool IsGood() const { return !good_timer.Stopped(); } }; class KnownTorrent { public: xarray_p peers; void AddPeer(Peer *); }; int af; RateLimit rate_limit; RefQueue send_queue; xmap_p sent_req; // the key is "t" Timer sent_req_expire_scan; Timer search_cleanup_timer; Timer refresh_timer; Timer nodes_cleanup_timer; Timer save_timer; // voting for new external IP xmap ip_votes; xmap ip_voted; xstring node_id; xmap_p nodes; xmap node_by_addr; RefArray routes; xmap_p search; xmap_p torrents; xqueue_p bootstrap_nodes; SMTaskRef resolver; void Bootstrap(); void AddNode(Node *); void RemoveNode(Node *); void ChangeNodeId(Node *n,const xstring& new_node_id); void AddRoute(Node *); void RemoveRoute(Node *n); Node *FoundNode(const xstring& id,const sockaddr_u& a,bool responded,Search *s=0); int FindRoute(const xstring& i,int start=0); void FindNodes(const xstring& i,xarray &a,int max_count,bool only_good); void StartSearch(Search *s); void RestartSearch(Search *s); void AddPeer(const xstring& ih,const sockaddr_compact& ca,bool seed); unsigned t; // transaction id BeNode *NewQuery(const char *q,xmap_p& a); BeNode *NewReply(const xstring& t0,xmap_p& r); BeNode *NewError(const xstring& t0,int code,const char *msg); void SendMessage(BeNode *q,const sockaddr_u& a,const xstring& id=xstring::null); void SendMessage(Request *); bool MaySendMessage(); static const char *MessageType(BeNode *q); static int AddNodesToReply(xmap_p &r,const xstring& target,bool want_n4,bool want_n6); int AddNodesToReply(xmap_p &r,const xstring& target,int max_count); enum { ERR_GENERIC=201, ERR_SERVER=202, ERR_PROTOCOL=203, ERR_UNKNOWN_METHOD=204, }; SMTaskRef state_io; public: DHT(int af,const xstring &id); ~DHT(); int Do(); static void MakeNodeId(xstring &id,const sockaddr_compact& ip,int r=random()/13); static bool ValidNodeId(const xstring &id,const sockaddr_compact& ip); void Restart(); void Reconfig(const char *name); const char *GetLogContext() { return af==AF_INET?"DHT":"DHT6"; } const xstring& GetNodeID() const { return node_id; } void SendPing(const sockaddr_u& addr,const xstring& id=xstring::null); void SendPing(Node *n); int PingQuestionable(const xarray& nodes,int limit); void AnnouncePeer(const Torrent *); void DenouncePeer(const Torrent *); void HandlePacket(BeNode *b,const sockaddr_u& src); void Save(const SMTaskRef& buf); void Load(const SMTaskRef& buf); xstring state_file; void Save(); void Load(); void AddBootstrapNode(const char *n) { bootstrap_nodes.push(new xstring(n)); } }; #endif//DHT_H lftp-4.6.3a/src/ArgV.h0000644000015000007670000000466412457747562011407 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef ARGV_H #define ARGV_H #include "trio.h" #include "StringSet.h" #include "getopt.h" class ArgV : public StringSet { int ind; public: ArgV() { ind=0; } ArgV(const char *a0) : StringSet(&a0,1) { ind=0; } ArgV(const char *a0, const char *args); ArgV(const ArgV& a) : StringSet(a) { ind=0; } ArgV(const ArgV *a) : StringSet(*a) { ind=0; } ArgV(int new_c,const char * const *new_v) : StringSet(new_v,new_c) { ind=0; } ~ArgV(); void Append(const char *s) { StringSet::Append(s); } void Append(int a) { char buf[32]; sprintf(buf,"%d",a); Append(buf); } void Add(const char *a) { Append(a); } // alias char *Combine(int start_index=0,int end_index=0) const; // for the UNIX shell char *CombineShellQuoted(int start) const; // for lftp's CmdExec char *CombineQuoted(int start_index=0) const; char *CombineCmd(int i=0) const; int getopt_long(const char *opts,const struct option *lopts,int *lind=0); int getopt(const char *opts) { return getopt_long(opts,0,0); } const char *getopt_error_message(int e); void seek(int n); void rewind() { seek(0); } const char *getnext(); const char *getarg(int n) const { return String(n); } const char *getcurr() const { return indn)--ind; Remove(n); } void insarg(int n,const char *s) { InsertBefore(n,s); } const char *a0() const { return getarg(0); } void back(); int count() const { return Count(); } const char *const*GetV() const { return Set(); } char **GetVNonConst() { return SetNonConst(); } }; #endif//ARGV_H lftp-4.6.3a/src/complete.h0000644000015000007670000000174312122057257012333 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef COMPLETE_H #define COMPLETE_H #include "trio.h" #include "CmdExec.h" extern CmdExec *completion_shell; extern int remote_completion; int lftp_rl_getc(FILE *); extern "C" void lftp_line_complete(); #endif //COMPLETE_H lftp-4.6.3a/src/DirColors.cc0000644000015000007670000002030012535254246012554 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "DirColors.h" #include "ResMgr.h" #include "FileSet.h" #include "buffer.h" DirColors *DirColors::instance; const char DirColors::resource[]="color:dir-colors"; /* Parse a string as part of the LS_COLORS variable; this may involve decoding all kinds of escape characters. If equals_end is set an unescaped equal sign ends the string, otherwise only a : or \0 does. Returns the number of characters output, or -1 on failure. The resulting string is *not* null-terminated, but may contain embedded nulls. Note that both dest and src are char **; on return they point to the first free byte after the array and the character that ended the input string, respectively. */ static int get_funky_string (char **dest, const char **src, int equals_end) { int num; /* For numerical codes */ int count; /* Something to count with */ enum { ST_GND, ST_BACKSLASH, ST_OCTAL, ST_HEX, ST_CARET, ST_END, ST_ERROR } state; const char *p; char *q; p = *src; /* We don't want to double-indirect */ q = *dest; /* the whole darn time. */ count = 0; /* No characters counted in yet. */ num = 0; state = ST_GND; /* Start in ground state. */ while (state < ST_END) { switch (state) { case ST_GND: /* Ground state (no escapes) */ switch (*p) { case ':': case '\0': state = ST_END; /* End of string */ break; case '\\': state = ST_BACKSLASH; /* Backslash scape sequence */ ++p; break; case '^': state = ST_CARET; /* Caret escape */ ++p; break; case '=': if (equals_end) { state = ST_END; /* End */ break; } /* else fall through */ default: *(q++) = *(p++); ++count; break; } break; case ST_BACKSLASH: /* Backslash escaped character */ switch (*p) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': state = ST_OCTAL; /* Octal sequence */ num = *p - '0'; break; case 'x': case 'X': state = ST_HEX; /* Hex sequence */ num = 0; break; case 'a': /* Bell */ num = 7; /* Not all C compilers know what \a means */ break; case 'b': /* Backspace */ num = '\b'; break; case 'e': /* Escape */ num = 27; break; case 'f': /* Form feed */ num = '\f'; break; case 'n': /* Newline */ num = '\n'; break; case 'r': /* Carriage return */ num = '\r'; break; case 't': /* Tab */ num = '\t'; break; case 'v': /* Vtab */ num = '\v'; break; case '?': /* Delete */ num = 127; break; case '_': /* Space */ num = ' '; break; case '\0': /* End of string */ state = ST_ERROR; /* Error! */ break; default: /* Escaped character like \ ^ : = */ num = *p; break; } if (state == ST_BACKSLASH) { *(q++) = num; ++count; state = ST_GND; } ++p; break; case ST_OCTAL: /* Octal sequence */ if (*p < '0' || *p > '7') { *(q++) = num; ++count; state = ST_GND; } else num = (num << 3) + (*(p++) - '0'); break; case ST_HEX: /* Hex sequence */ switch (*p) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': num = (num << 4) + (*(p++) - '0'); break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': num = (num << 4) + (*(p++) - 'a') + 10; break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': num = (num << 4) + (*(p++) - 'A') + 10; break; default: *(q++) = num; ++count; state = ST_GND; break; } break; case ST_CARET: /* Caret escape */ state = ST_GND; /* Should be the next state... */ if (*p >= '@' && *p <= '~') { *(q++) = *(p++) & 037; ++count; } else if (*p == '?') { *(q++) = 127; ++count; } else state = ST_ERROR; break; default: abort (); } } *(q++) = 0; *dest = q; *src = p; if(state == ST_ERROR) return -1; return count; } void DirColors::Parse(const char *p) { Empty(); Add(".lc", "\033["); Add(".rc", "m"); Add(".no", ""); Add(".fi", ""); Add(".di", ""); Add(".ln", ""); if(!p) return; char *buf; /* color_buf buffer pointer */ int state; /* State of parser */ char label[4]; /* Indicator label */ const char *ext; label[0] = '.'; label[3] = 0; ext = NULL; buf = alloca_strdup (p); state = 1; while (state > 0) { switch (state) { case 1: /* First label character */ switch (*p) { case ':': ++p; break; case '*': /* Allocate new extension block and add to head of linked list (this way a later definition will override an earlier one, which can be useful for having terminal-specific defs override global). */ ++p; /* next should be . */ if(*p++ != '.') { state = -1; break; } ext = buf; state = get_funky_string (&buf, &p, 1) < 0 ? -1 : 4; break; case '\0': state = 0; /* Done! */ break; default: /* Assume it is file type label */ label[1] = *(p++); state = 2; break; } break; case 2: /* Second label character */ if (*p) { label[2] = *(p++); state = 3; } else state = -1; /* Error */ break; case 3: /* Equal sign after indicator label */ state = -1; /* Assume failure... */ if (*(p++) == '=')/* It *should* be... */ { const char *b = buf; state = get_funky_string (&buf, &p, 0) < 0 ? -1 : 1; Add(label, b); } break; case 4: /* Equal sign after *.ext */ if (*(p++) == '=') { const char *b = buf; state = get_funky_string (&buf, &p, 0) < 0 ? -1 : 1; Add(ext, b); } else state = -1; break; } } // if (color_indicator[C_LINK].len == 6 // && !strncmp (color_indicator[C_LINK].string, "target", 6)) // color_symlink_as_referent = 1; if(!Lookup(".ec")) { const char *no=Lookup(".no"); const char *lc=Lookup(".lc"); const char *rc=Lookup(".rc"); Add(".ec",xstring::cat(lc,no,rc,NULL)); } } DirColors::DirColors() { Reconfig(resource); } const char *DirColors::GetColor(const char *name,int type) { const char *ret=0; if(type==FileInfo::DIRECTORY) { ret=Lookup(".di"); if(ret) return ret; } else if(type==FileInfo::SYMLINK) { ret=Lookup(".ln"); if(ret) return ret; } else if(type==FileInfo::NORMAL) ret=Lookup(".fi"); const char *ext = strrchr(name, '.'); if(ext && *++ext) { const char *l=Lookup(ext); if(l) return l; } return ret?ret:""; } const char *DirColors::GetColor(const FileInfo *fi) { return GetColor(fi->name,fi->defined&fi->TYPE?fi->filetype:-1); } void DirColors::PutColored(const Ref& buf,const char *name,int type) { const char *color=GetColor(name,type); const char *lc=Lookup(".lc"); const char *rc=Lookup(".rc"); if(!color || !*color || !lc || !rc) { buf->Put(name); return; } buf->Put(lc); buf->Put(color); buf->Put(rc); buf->Put(name); PutReset(buf); } void DirColors::PutReset(const Ref& buf) { const char *reset=Lookup(".ec"); buf->Put(reset); } void DirColors::Reconfig(const char *name) { if(!xstrcmp(name,resource)) Parse(ResMgr::Query(resource,0)); } lftp-4.6.3a/src/GetPass.h0000644000015000007670000000161512122057774012073 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef GETPASS_H #define GETPASS_H #include "trio.h" const char *GetPass(const char *p); char *readline_from_file(int fd); #endif//GETPASS_H lftp-4.6.3a/src/ftpget0000755000015000007670000000256712122057725011576 00000000000000#!/bin/bash # ftpget - script replacement for old utility # Copyright (c) 2000 Alexander V. Lukyanov # This file is covered by GNU GPL. See file COPYING for details. usage() { echo "Usage: $0 [OPTS] host filename [-o local] [filename...]" echo " -p set port number" echo " -u login as user using pass as password" echo " -l get listing of specified directory(ies)" echo " -c reget specified file(s)" echo " -q quiet (no output)" echo " -v verbose (lots of output)" echo " -o output to this file (default - base name of filename)" exit 1 } port="" user="" list=false cont="" verb="" final="set verbose yes; " while getopts +p:u:lcv opt do case $opt in \?) usage;; p) port=":$OPTARG";; u) user="-u $OPTARG ";; l) list=true;; c) cont=" -c";; v) verb="debug 5; ";; q) final="";; esac done while [ $OPTIND -gt 1 ] do OPTIND=$(($OPTIND-1)) shift done host="$1" shift if [ -z "$host" ]; then usage fi cmd="get$cont" ok=false $list && { cmd="ls"; ok=true; } for f do case "$f" in "*[\"'\\]*") # need to quote f="`echo "$f" | sed 's/\([\\\"'\'']\)/\\\1/g'`" ;; esac cmd="$cmd \"$f\"" ok=true; done $ok || { usage; } exec lftp -c "$final${verb}open $user$host$port; $cmd" lftp-4.6.3a/src/Fish.cc0000644000015000007670000006132212525430242011545 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "Fish.h" #include "trio.h" #include #include #include #include #include #include "ascii_ctype.h" #include "LsCache.h" #include "misc.h" #include "log.h" #include "ArgV.h" #define super SSH_Access #define max_buf 0x10000 void Fish::GetBetterConnection(int level) { for(FA *fo=FirstSameSite(); fo!=0; fo=NextSameSite(fo)) { Fish *o=(Fish*)fo; // we are sure it is Fish. if(!o->recv_buf) continue; if(o->state!=CONNECTED || o->mode!=CLOSED) { if(level<2) continue; if(!connection_takeover || (o->priority>=priority && !o->IsSuspended())) continue; o->Disconnect(); return; } if(level==0 && xstrcmp(real_cwd,o->real_cwd)) continue; // borrow the connection MoveConnectionHere(o); return; } } int Fish::Do() { int m=STALL; int fd; // check if idle time exceeded if(mode==CLOSED && send_buf && idle_timer.Stopped()) { LogNote(1,_("Closing idle connection")); Disconnect(); return m; } if(Error()) return m; if(!hostname) return m; if(send_buf && send_buf->Error()) { Disconnect(); return MOVED; } if(state!=CONNECTING_1) m|=HandleReplies(); if(Error()) return m; if(send_buf) timeout_timer.Reset(send_buf->EventTime()); if(recv_buf) timeout_timer.Reset(recv_buf->EventTime()); if(pty_send_buf) timeout_timer.Reset(pty_send_buf->EventTime()); if(pty_recv_buf) timeout_timer.Reset(pty_recv_buf->EventTime()); // check for timeout only if there should be connection activity. if(state!=DISCONNECTED && (state!=CONNECTED || !RespQueueIsEmpty()) && mode!=CLOSED && CheckTimeout()) return MOVED; if((state==FILE_RECV || state==FILE_SEND) && rate_limit==0) rate_limit=new RateLimit(hostname); const char *charset; switch(state) { case DISCONNECTED: { if(mode==CLOSED) return m; if(mode==CONNECT_VERIFY) return m; // walk through Fish classes and try to find identical idle session // first try "easy" cases of session take-over. for(int i=0; i<3; i++) { if(i>=2 && (connection_limit==0 || connection_limit>CountConnections())) break; GetBetterConnection(i); if(state!=DISCONNECTED) return MOVED; } if(!ReconnectAllowed()) return m; if(!NextTry()) return MOVED; const char *shell=Query("shell",hostname); const char *init=xstring::cat("echo FISH:;",shell,NULL); const char *prog=Query("connect-program",hostname); if(!prog || !prog[0]) prog="ssh -a -x"; char *a=alloca_strdup(prog); ArgV *cmd=new ArgV; for(a=strtok(a," "); a; a=strtok(0," ")) cmd->Add(a); if(user) { cmd->Add("-l"); cmd->Add(user); } if(portname) { cmd->Add("-p"); cmd->Add(portname); } cmd->Add(hostname); cmd->Add(init); xstring_ca cmd_str(cmd->Combine(0)); Log::global->Format(9,"---- %s (%s)\n",_("Running connect program"),cmd_str.get()); ssh=new PtyShell(cmd); ssh->UsePipes(); state=CONNECTING; timeout_timer.Reset(); m=MOVED; } case CONNECTING: fd=ssh->getfd(); if(fd==-1) { if(ssh->error()) { SetError(FATAL,ssh->error_text); return MOVED; } TimeoutS(1); return m; } MakePtyBuffers(); set_real_cwd("~"); state=CONNECTING_1; m=MOVED; case CONNECTING_1: m|=HandleSSHMessage(); if(state!=CONNECTING_1) return MOVED; if(!received_greeting) return m; charset=ResMgr::Query("fish:charset",hostname); if(charset && *charset) { send_buf->SetTranslation(charset,false); recv_buf->SetTranslation(charset,true); } Send("#FISH\n" "TZ=GMT;export TZ;LC_ALL=C;export LC_ALL;" "exec 2>&1;echo;start_fish_server;" "echo '### 200'\n"); PushExpect(EXPECT_FISH); Send("#VER 0.0.2\n" "echo '### 000'\n"); PushExpect(EXPECT_VER); if(home_auto==0) { Send("#PWD\n" "pwd; echo '### 200'\n"); PushExpect(EXPECT_PWD); } state=CONNECTED; m=MOVED; case CONNECTED: if(mode==CLOSED) return m; if(home.path==0 && !RespQueueIsEmpty()) break; ExpandTildeInCWD(); if(mode!=CHANGE_DIR && xstrcmp(cwd,real_cwd)) { if(xstrcmp(path_queue.LastString(),cwd)) { Send("#CWD %s\n" "cd %s; echo '### 000'\n",cwd.path.get(),shell_encode(cwd).get()); PushExpect(EXPECT_CWD); PushDirectory(cwd); } if(!RespQueueIsEmpty()) break; } SendMethod(); if(mode==LONG_LIST || mode==LIST || mode==QUOTE_CMD) { state=FILE_RECV; m=MOVED; break; } state=WAITING; m=MOVED; case WAITING: if(RespQueueSize()==1 && mode==RETRIEVE) { state=FILE_RECV; m=MOVED; } if(RespQueueSize()==1 && mode==STORE) { state=FILE_SEND; real_pos=0; pos=0; m=MOVED; } if(RespQueueSize()==0) { state=DONE; m=MOVED; } break; case FILE_RECV: if(recv_buf->Size()>=rate_limit->BytesAllowedToGet()) { recv_buf->Suspend(); Timeout(1000); } else if(recv_buf->Size()>=max_buf) { recv_buf->Suspend(); m=MOVED; } else if(recv_buf->IsSuspended()) { recv_buf->Resume(); if(recv_buf->Size()>0 || (recv_buf->Size()==0 && recv_buf->Eof())) m=MOVED; } break; case FILE_SEND: case DONE: break; } return m; } void Fish::MoveConnectionHere(Fish *o) { super::MoveConnectionHere(o); rate_limit=o->rate_limit.borrow(); path_queue.MoveHere(o->path_queue); RespQueue.move_here(o->RespQueue); timeout_timer.Reset(o->timeout_timer); set_real_cwd(o->real_cwd); state=CONNECTED; o->Disconnect(); if(!home) set_home(home_auto); ResumeInternal(); } void Fish::DisconnectLL() { super::DisconnectLL(); EmptyRespQueue(); EmptyPathQueue(); state=DISCONNECTED; if(mode==STORE) SetError(STORE_FAILED,0); home_auto.set(FindHomeAuto()); } void Fish::Init() { state=DISCONNECTED; max_send=0; eof=false; } Fish::Fish() : SSH_Access("FISH:") { Init(); Reconfig(0); } Fish::~Fish() { Disconnect(); } Fish::Fish(const Fish *o) : super(o) { Init(); Reconfig(0); } void Fish::Close() { switch(state) { case(DISCONNECTED): case(CONNECTED): case(DONE): break; case(WAITING): if(mode==STORE || mode==RETRIEVE) Disconnect(); break; case(FILE_SEND): if(!RespQueueIsEmpty()) Disconnect(); break; case(FILE_RECV): case(CONNECTING): case(CONNECTING_1): Disconnect(); } // if(!RespQueueIsEmpty()) // Disconnect(); // play safe. CloseExpectQueue(); state=(recv_buf?CONNECTED:DISCONNECTED); eof=false; encode_file=true; super::Close(); } void Fish::Send(const char *format,...) { va_list va; va_start(va,format); xstring& str=xstring::vformat(format,va); va_end(va); LogSend(5,str); send_buf->Put(str); } void Fish::SendArrayInfoRequests() { for(int i=fileset_for_info->curr_index(); icount(); i++) { FileInfo *fi=(*fileset_for_info)[i]; if(fi->need) { const char *e=shell_encode(fi->name); Send("#INFO %s\n" "ls -lLd %s; echo '### 200'\n",fi->name.get(),e); PushExpect(EXPECT_INFO); } } } void Fish::SendMethod() { const char *e=alloca_strdup(shell_encode(file)); const char *e1=shell_encode(file1); switch((open_mode)mode) { case CHANGE_DIR: Send("#CWD %s\n" "cd %s; echo '### 000'\n",e,e); PushExpect(EXPECT_CWD); PushDirectory(file); break; case LONG_LIST: if(!encode_file) e=file; Send("#LIST %s\n" "ls -la %s; echo '### 200'\n",e,e); PushExpect(EXPECT_DIR); real_pos=0; break; case LIST: if(!encode_file) e=file; Send("#LIST %s\n" "ls -a %s; echo '### 200'\n",e,e); PushExpect(EXPECT_DIR); real_pos=0; break; case RETRIEVE: if(pos>0) { int bs=0x1000; real_pos=pos-pos%bs; // non-standard extension Send("#RETRP %lld %s\n" "ls -lLd %s; " "echo '### 100'; " "dd ibs=%d skip=%lld if=%s 2>/dev/null; " "echo '### 200'\n", (long long)real_pos,e,e,bs,(long long)real_pos/bs,e); } else { Send("#RETR %s\n" "ls -lLd %s; " "echo '### 100'; cat %s; echo '### 200'\n",e,e,e); real_pos=0; } PushExpect(EXPECT_RETR_INFO); PushExpect(EXPECT_RETR); break; case STORE: if(entity_size<0) { SetError(NO_FILE,"Have to know file size before upload"); break; } if(entity_size>0) { Send("#STOR %lld %s\n" "rest=%lld;file=%s;:>$file;echo '### 001';" "if echo 1|head -c 1 -q ->/dev/null 2>&1;then " "head -c $rest -q -|(cat>$file;cat>/dev/null);" "else while [ $rest -gt 0 ];do " "bs=4096;cnt=`expr $rest / $bs`;" "[ $cnt -eq 0 ] && { cnt=1;bs=$rest; }; " "n=`dd ibs=$bs count=$cnt 2>/dev/null|tee -a $file|wc -c`;" "[ \"$n\" -le 0 ] && exit;" "rest=`expr $rest - $n`; " "done;fi;echo '### 200'\n", (long long)entity_size,e,(long long)entity_size,e); #if 0 // dd pays attension to read boundaries and reads wrong number // of bytes when ibs>1. Have to use the inefficient ibs=1. Send("#STOR %lld %s\n" ">%s;echo '### 001';" "dd ibs=1 count=%lld 2>/dev/null" "|(cat>%s;cat>/dev/null);echo '### 200'\n", (long long)entity_size,e, e, (long long)entity_size, e); #endif } else { Send("#STOR %lld %s\n" ">%s;echo '### 001';echo '### 200'\n", (long long)entity_size,e,e); } PushExpect(EXPECT_STOR_PRELIMINARY); PushExpect(EXPECT_STOR); real_pos=0; pos=0; break; case ARRAY_INFO: SendArrayInfoRequests(); break; case REMOVE: Send("#DELE %s\n" "rm -f %s; echo '### 000'\n",e,e); PushExpect(EXPECT_DEFAULT); break; case REMOVE_DIR: Send("#RMD %s\n" "rmdir %s; echo '### 000'\n",e,e); PushExpect(EXPECT_DEFAULT); break; case MAKE_DIR: Send("#MKD %s\n" "mkdir %s; echo '### 000'\n",e,e); PushExpect(EXPECT_DEFAULT); break; case RENAME: Send("#RENAME %s %s\n" "mv %s %s; echo '### 000'\n",e,e1,e,e1); PushExpect(EXPECT_DEFAULT); break; case CHANGE_MODE: Send("#CHMOD %04o %s\n" "chmod %04o %s; echo '### 000'\n",chmod_mode,e,chmod_mode,e); PushExpect(EXPECT_DEFAULT); break; case LINK: Send("#LINK %s %s\n" "ln %s %s; echo '### 000'\n",e,e1,e,e1); PushExpect(EXPECT_DEFAULT); break; case SYMLINK: Send("#SYMLINK %s %s\n" "ln -s %s %s; echo '### 000'\n",e,e1,e,e1); PushExpect(EXPECT_DEFAULT); break; case QUOTE_CMD: // non-standard extension Send("#EXEC %s\n" "%s; echo '### 200'\n",e,file.get()); PushExpect(EXPECT_QUOTE); real_pos=0; break; case MP_LIST: SetError(NOT_SUPP); break; case CONNECT_VERIFY: case CLOSED: abort(); } } int Fish::ReplyLogPriority(int code) { if(code==-1) return 3; return 4; } int Fish::HandleReplies() { int m=STALL; if(recv_buf==0) return m; if(state==FILE_RECV) { const char *err=pty_recv_buf->Get(); if(err && err[0]) { const char *eol=strchr(err,'\n'); if(eol) { xstring &e=xstring::get_tmp(err,eol-err); LogError(0,"%s",e.get()); SetError(NO_FILE,e); if(pty_recv_buf) pty_recv_buf->Skip(eol-err+1); return MOVED; } } if(pty_recv_buf->Eof()) { Disconnect(); return MOVED; } if(entity_size!=NO_SIZE && real_posPut(pty_recv_buf->Get(),pty_recv_buf->Size()); // join the messages. pty_recv_buf->Skip(pty_recv_buf->Size()); if(recv_buf->Size()<5) { hup: if(recv_buf->Error()) { Disconnect(); return MOVED; } if(recv_buf->Eof()) { LogError(0,_("Peer closed connection")); // Solaris' shell exists when is given with wrong directory if(!RespQueueIsEmpty() && RespQueue[0]==EXPECT_CWD && message) SetError(NO_FILE,message); Disconnect(); m=MOVED; } return m; } const char *b; int s; recv_buf->Get(&b,&s); const char *eol=(const char*)memchr(b,'\n',s); if(!eol) { if(recv_buf->Eof() || recv_buf->Error()) goto hup; return m; } m=MOVED; s=eol-b+1; line.nset(b,s-1); recv_buf->Skip(s); int code=-1; if(s>7 && !memcmp(line,"### ",4)) { if(sscanf(line+4,"%3d",&code)!=1) code=-1; } LogRecv(ReplyLogPriority(code),line); if(code==-1) { if(message==0) message.set(line); else { message.append('\n'); message.append(line); } return m; } if(RespQueueIsEmpty()) { LogError(3,_("extra server response")); message.set(0); return m; } expect_t e=RespQueue.next(); bool keep_message=false; switch(e) { case EXPECT_FISH: case EXPECT_VER: /* nothing yet */ break;; case EXPECT_PWD: if(!message) break; home_auto.set(message); Log::global->Format(9,"---- home set to %s\n",home_auto.get()); PropagateHomeAuto(); if(!home) set_home(home_auto); cache->SetDirectory(this, home, true); break; case EXPECT_CWD: { xstring p; PopDirectory(&p); if(message==0) { set_real_cwd(p); if(mode==CHANGE_DIR && RespQueueIsEmpty()) { cwd.Set(p); eof=true; } cache->SetDirectory(this,p,true); } else SetError(NO_FILE,message); break; } case EXPECT_RETR_INFO: if(message && is_ascii_digit(message[0]) && !strchr(message,':')) { long long size_ll; if(1==sscanf(message,"%lld",&size_ll)) { entity_size=size_ll; if(opt_size) *opt_size=entity_size; } } else if(message && message[0]!='#') { FileInfo *fi=FileInfo::parse_ls_line(message,"GMT"); if(!fi || !strncmp(message,"ls: ",4)) { SetError(NO_FILE,message); break; } if(fi->defined&fi->SIZE) { entity_size=fi->size; if(opt_size) *opt_size=entity_size; } if(fi->defined&fi->DATE) { entity_date=fi->date; if(opt_date) *opt_date=entity_date; } } state=FILE_RECV; break; case EXPECT_INFO: { Ref new_info(FileInfo::parse_ls_line(message,"GMT")); FileInfo *fi=fileset_for_info->curr(); while(!fi->need) fi=fileset_for_info->next(); fi->Merge(*new_info); fi->need=0; break; } case EXPECT_RETR: case EXPECT_DIR: case EXPECT_QUOTE: eof=true; state=DONE; break; case EXPECT_DEFAULT: if(message) SetError(NO_FILE,message); break; case EXPECT_STOR_PRELIMINARY: if(message) { Disconnect(); SetError(NO_FILE,message); } break; case EXPECT_STOR: if(message) { Disconnect(); SetError(NO_FILE,message); } break; case EXPECT_IGNORE: break; } if(!keep_message) message.set(0); return m; } void Fish::PushExpect(expect_t e) { RespQueue.push(e); } void Fish::CloseExpectQueue() { int count=RespQueue.count(); for(int i=0; i=str_len) { if(!memcmp(mem,str,str_len)) return mem; mem++; len--; } return 0; } int Fish::Read(Buffer *buf,int size) { if(Error()) return error_code; if(mode==CLOSED) return 0; if(state==DONE) return 0; // eof if(state==FILE_RECV && real_pos>=0) { const char *buf1; int size1; get_again: if(recv_buf->Size()==0 && recv_buf->Error()) { Disconnect(); return DO_AGAIN; } recv_buf->Get(&buf1,&size1); if(buf1==0) // eof { Disconnect(); return DO_AGAIN; } if(size1==0) return DO_AGAIN; if(entity_size!=NO_SIZE && real_posentity_size) size1=entity_size-real_pos; } else { const char *end=memstr(buf1,size1,"### "); if(end) { size1=end-buf1; if(size1==0) { state=WAITING; if(HandleReplies()==MOVED) current->Timeout(0); return DO_AGAIN; } } else { for(int j=0; j<3; j++) if(size1>0 && buf1[size1-1]=='#') size1--; if(size1==0 && recv_buf->Eof()) { Disconnect(); return DO_AGAIN; } } } int bytes_allowed=rate_limit->BytesAllowedToGet(); if(size1>bytes_allowed) size1=bytes_allowed; if(size1==0) return DO_AGAIN; if(norest_manual && real_pos==0 && pos>0) return DO_AGAIN; if(real_possize1) to_skip=size1; recv_buf->Skip(to_skip); real_pos+=to_skip; goto get_again; } if(size>size1) size=size1; size=buf->MoveDataHere(recv_buf,size); if(size<=0) return DO_AGAIN; pos+=size; real_pos+=size; rate_limit->BytesGot(size); TrySuccess(); return size; } return DO_AGAIN; } int Fish::Write(const void *buf,int size) { if(mode!=STORE) return(0); Resume(); Do(); if(Error()) return(error_code); if(state!=FILE_SEND || rate_limit==0) return DO_AGAIN; { int allowed=rate_limit->BytesAllowedToPut(); if(allowed==0) return DO_AGAIN; if(size+send_buf->Size()>allowed) size=allowed-send_buf->Size(); } if(size+send_buf->Size()>0x4000) size=0x4000-send_buf->Size(); if(pos+size>entity_size) { size=entity_size-pos; // tried to write more than originally requested. Make it retry with Open: if(size==0) return STORE_FAILED; } if(size<=0) return 0; send_buf->Put((char*)buf,size); TrySuccess(); rate_limit->BytesPut(size); pos+=size; real_pos+=size; return(size); } int Fish::Buffered() { if(send_buf==0) return 0; return send_buf->Size(); } int Fish::StoreStatus() { if(Error()) return error_code; if(state!=FILE_SEND) return IN_PROGRESS; if(real_pos!=entity_size) { Disconnect(); return IN_PROGRESS; } if(RespQueueSize()==0) return OK; return IN_PROGRESS; } int Fish::Done() { if(mode==CLOSED) return OK; if(Error()) return error_code; if(eof || state==DONE) return OK; if(mode==CONNECT_VERIFY) return OK; return IN_PROGRESS; } void Fish::SuspendInternal() { super::SuspendInternal(); if(recv_buf) recv_buf->SuspendSlave(); if(send_buf) send_buf->SuspendSlave(); } void Fish::ResumeInternal() { if(recv_buf) recv_buf->ResumeSlave(); if(send_buf) send_buf->ResumeSlave(); super::ResumeInternal(); } const char *Fish::CurrentStatus() { switch(state) { case DISCONNECTED: if(!ReconnectAllowed()) return DelayingMessage(); return _("Not connected"); case CONNECTING: if(ssh && ssh->status) return ssh->status; case CONNECTING_1: return _("Connecting..."); case CONNECTED: return _("Connected"); case WAITING: return _("Waiting for response..."); case FILE_RECV: return _("Receiving data"); case FILE_SEND: return _("Sending data"); case DONE: return _("Done"); } return ""; } bool Fish::SameSiteAs(const FileAccess *fa) const { if(!SameProtoAs(fa)) return false; Fish *o=(Fish*)fa; return(!xstrcasecmp(hostname,o->hostname) && !xstrcmp(portname,o->portname) && !xstrcmp(user,o->user) && !xstrcmp(pass,o->pass)); } bool Fish::SameLocationAs(const FileAccess *fa) const { if(!SameSiteAs(fa)) return false; Fish *o=(Fish*)fa; if(xstrcmp(cwd,o->cwd)) return false; return true; } void Fish::Cleanup() { if(hostname==0) return; for(FA *fo=FirstSameSite(); fo!=0; fo=NextSameSite(fo)) fo->CleanupThis(); CleanupThis(); } void Fish::CleanupThis() { if(mode!=CLOSED) return; Disconnect(); } void Fish::Reconfig(const char *name) { super::Reconfig(name); if(!xstrcmp(name,"fish:charset") && recv_buf && send_buf) { if(!IsSuspended()) cache->TreeChanged(this,"/"); const char *charset=ResMgr::Query("fish:charset",hostname); if(charset && *charset) { send_buf->SetTranslation(charset,false); recv_buf->SetTranslation(charset,true); } else { send_buf->SetTranslator(0); recv_buf->SetTranslator(0); } } } void Fish::ClassInit() { // register the class Register("fish",Fish::New); } FileAccess *Fish::New() { return new Fish(); } DirList *Fish::MakeDirList(ArgV *args) { return new FishDirList(this,args); } #include "FileGlob.h" Glob *Fish::MakeGlob(const char *pattern) { return new GenericGlob(this,pattern); } ListInfo *Fish::MakeListInfo(const char *p) { return new FishListInfo(this,p); } #undef super #define super DirList #include "ArgV.h" int FishDirList::Do() { if(done) return STALL; if(buf->Eof()) { done=true; return MOVED; } if(!ubuf) { const char *cache_buffer=0; int cache_buffer_size=0; int err; if(use_cache && FileAccess::cache->Find(session,pattern,FA::LONG_LIST,&err, &cache_buffer,&cache_buffer_size)) { if(err) { SetErrorCached(cache_buffer); return MOVED; } ubuf=new IOBuffer(IOBuffer::GET); ubuf->Put(cache_buffer,cache_buffer_size); ubuf->PutEOF(); } else { session->Open(pattern,FA::LONG_LIST); session.Cast()->DontEncodeFile(); ubuf=new IOBufferFileAccess(session); if(FileAccess::cache->IsEnabled(session->GetHostName())) ubuf->Save(FileAccess::cache->SizeLimit()); } } const char *b; int len; ubuf->Get(&b,&len); if(b==0) // eof { buf->PutEOF(); FileAccess::cache->Add(session,pattern,FA::LONG_LIST,FA::OK,ubuf); return MOVED; } int m=STALL; if(len>0) { buf->Put(b,len); ubuf->Skip(len); m=MOVED; } if(ubuf->Error()) { SetError(ubuf->ErrorText()); m=MOVED; } return m; } const char *FishDirList::Status() { if(ubuf && !ubuf->Eof() && session->IsOpen()) { return xstring::format(_("Getting file list (%lld) [%s]"), (long long)session->GetPos(),session->CurrentStatus()); } return ""; } void FishDirList::SuspendInternal() { super::SuspendInternal(); if(ubuf) ubuf->SuspendSlave(); } void FishDirList::ResumeInternal() { if(ubuf) ubuf->ResumeSlave(); super::ResumeInternal(); } static FileSet *ls_to_FileSet(const char *b,int len) { FileSet *set=new FileSet; while(len>0) { // find one line const char *line=b; int ll=len; const char *eol=find_char(b,len,'\n'); if(eol) { ll=eol-b; len-=ll+1; b+=ll+1; } else { len=0; } if(ll && line[ll-1]=='\r') --ll; if(ll==0) continue; FileInfo *f=FileInfo::parse_ls_line(line,ll,"GMT"); if(!f) continue; set->Add(f); } return set; } FileSet *Fish::ParseLongList(const char *b,int len,int *err) const { if(err) *err=0; return ls_to_FileSet(b,len); } // FishListInfo implementation FileSet *FishListInfo::Parse(const char *b,int len) { return ls_to_FileSet(b,len); } #include "modconfig.h" #ifdef MODULE_PROTO_FISH void module_init() { Fish::ClassInit(); } #endif lftp-4.6.3a/src/ChmodJob.h0000644000015000007670000000321512122057207012177 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef CHMODJOB_H #define CHMODJOB_H #include "TreatFileJob.h" #include "FileSet.h" CDECL_BEGIN #include "modechange.h" CDECL_END class ChmodJob : public TreatFileJob { public: enum verbosity { V_NONE, V_CHANGES, V_ALL }; private: void TreatCurrent(const char *d,const FileInfo *fi); void CurrentFinished(const char *d,const FileInfo *fi); void Init(); void Report(const char *d,const FileInfo *fi, bool success); bool RelativeMode(const mode_change *m) const; verbosity verbose; mode_change *m; int simple_mode; int GetMode(const FileInfo *fi) const; public: /* if you use this constructor, also set a mode with SetMode() */ ChmodJob(FileAccess *s,ArgV *a); /* simple "chmod 123" interface: */ ChmodJob(FileAccess *s,int m,ArgV *a); ~ChmodJob(); void SetVerbosity(verbosity v); void SetMode(mode_change *newm); void Recurse(); }; #endif//CHMODJOB_H lftp-4.6.3a/src/GetFileInfo.h0000644000015000007670000000434412133433750012654 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef GETFILEINFO_H #define GETFILEINFO_H #include "trio.h" #include "SMTask.h" #include "FileAccess.h" class GetFileInfo : public ListInfo { const FileAccessRef& session; SMTaskRef li; /* file or dir we're listing: */ xstring_c dir; /* directory we've actually listed: */ xstring_c path_to_prefix; /* directory we started in: */ FileAccess::Path origdir; /* In showdir mode, we make sure the path actually exists; this is * the filename to look for. */ xstring verify_fn; bool showdir; enum state_t { INITIAL, CHANGE_DIR, CHANGING_DIR, GETTING_LIST, GETTING_INFO_ARRAY, DONE } state; /* whether we've tried to cd to the whole dir (treating it as a dir): */ bool tried_dir; /* and whether we've tried to cd to the basename (treating it as a file): */ bool tried_file; /* and the last-ditch GetInfoArray */ bool tried_info; /* whether we found out the file type from cache */ bool from_cache; /* whether the given path was a file or directory. */ bool was_directory; /* if true, prepend the appropriate relative path to the result */ bool prepend_path; xstring_c saved_error_text; FileSet get_info; void PrepareToDie(); public: GetFileInfo(const FileAccessRef& a, const char *path, bool showdir); virtual ~GetFileInfo(); int Do(); const char *Status(); bool WasDirectory() const { return was_directory; } void DontPrependPath() { prepend_path=false; } }; #endif /* GETFILEINFO_H */ lftp-4.6.3a/src/Speedometer.cc0000644000015000007670000001021312247537603013133 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include "Speedometer.h" #include "misc.h" #include "xstring.h" #include "ResMgr.h" #define now SMTask::now Speedometer::Speedometer(const char *p) { period=15; rate=0; last_second=now; start=now; last_bytes=0; terse=true; period_resource=p; Reconfig(0); } bool Speedometer::Valid() { return now>=start+TimeDiff(1,0) && nowTimeout(500); return rate; } void Speedometer::Add(int b) { if(b==0 && (now==last_second || TimeDiff(now,last_second).MilliSeconds()<100)) return; // This makes Speedometer start only when first data come. if(rate==0) Reset(); double div=period; if(start>now) start=now; // time was adjusted? if(now0) last_bytes=now; if(rate<0) rate=0; } // These `incorrect' units are used to fit on status line xstring& Speedometer::GetStr(float r) { if(r<1) return xstring::get_tmp(""); if(r<1024) // for translator: those are the units. This is 'byte per second' return xstring::format(_("%.0fb/s"),r); else if(r<1024*1024) // for translator: This is 'Kibibyte per second' return xstring::format(_("%.1fK/s"),r/1024.); else // for translator: This is 'Mebibyte per second' return xstring::format(_("%.2fM/s"),r/(1024.*1024)); } xstring& Speedometer::GetStrProper(float r) { if(r<1) return xstring::get_tmp(""); if(r<1024) return xstring::format(_("%.0f B/s"),r); else if(r<1024*1024) return xstring::format(_("%.1f KiB/s"),r/1024.); else return xstring::format(_("%.2f MiB/s"),r/(1024.*1024)); } xstring& Speedometer::GetStr() { return Valid() ? GetStr(Get()) : xstring::get_tmp(""); } xstring& Speedometer::GetETAStrFromSize(off_t size) { if(!Valid() || Get()<1) return xstring::get_tmp(""); return GetETAStrFromTime(long(size/rate+.5)); } xstring& Speedometer::GetETAStrFromTime(long eta) { if(eta<0) return xstring::get_tmp(""); unsigned flags=TimeInterval::TO_STR_TRANSLATE; if(terse) flags+=TimeInterval::TO_STR_TERSE; // for translator: Estimated Time of Arrival. return xstring::cat(_("eta:"),TimeInterval(eta,0).toString(flags),NULL); } const char *Speedometer::GetStrS(float r) { xstring &rate=GetStr(r); if(rate.length()) rate.append(' '); return rate; } const char *Speedometer::GetStrS() { return Valid() ? GetStrS(Get()) : ""; } const char *Speedometer::GetETAStrSFromSize(off_t s) { xstring &eta=GetETAStrFromSize(s); if(eta.length()) eta.append(' '); return eta; } const char *Speedometer::GetETAStrSFromTime(long s) { xstring &eta=GetETAStrFromTime(s); if(eta.length()) eta.append(' '); return eta; } void Speedometer::Reset() { start=now; last_second=now; rate=0; last_bytes=0; } ResDecl res_eta_terse("xfer:eta-terse", "yes",ResMgr::BoolValidate,ResMgr::NoClosure); void Speedometer::Reconfig(const char *n) { terse=res_eta_terse.QueryBool(0); SetPeriod(ResMgr::Query(period_resource,0)); } lftp-4.6.3a/src/FtpDirList.cc0000644000015000007670000001413312311775657012715 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2013 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "FileAccess.h" #include "FtpDirList.h" #include "LsCache.h" #include "ArgV.h" #include "misc.h" #include "DirColors.h" #include "ftpclass.h" #include #include #ifdef TM_IN_SYS_TIME # include #endif #define super DirList int FtpDirList::Do() { int m=STALL; if(done) return m; if(buf->Eof()) { done=true; return MOVED; } if(!ubuf) { const char *cache_buffer=0; int cache_buffer_size=0; int err; if(use_cache && FileAccess::cache->Find(session,pattern,FA::LONG_LIST,&err, &cache_buffer,&cache_buffer_size)) { if(err) { SetErrorCached(cache_buffer); return MOVED; } ubuf=new IOBuffer(IOBuffer::GET); ubuf->Put(cache_buffer,cache_buffer_size); ubuf->PutEOF(); } else { session->Open(pattern,FA::LONG_LIST); ubuf=new IOBufferFileAccess(session); if(FileAccess::cache->IsEnabled(session->GetHostName())) ubuf->Save(FileAccess::cache->SizeLimit()); } } const char *b; int len; ubuf->Get(&b,&len); if(b==0) // eof { buf->PutEOF(); FileAccess::cache->Add(session,pattern,FA::LONG_LIST,FA::OK,ubuf); return MOVED; } while(len>0) { const char *eol=find_char(b,len,'\n'); if(!eol && !ubuf->Eof() && len<0x1000) return m; if(eol) { int line_len=eol+1-b; if(!TryEPLF(b, eol-b) && !TryMLSD(b, eol-b) && !TryColor(b, eol-b)) buf->Put(b,line_len); ubuf->Skip(line_len); } else { // too long line of missing \n on last line. buf->Put(b,len); ubuf->Skip(len); } ubuf->Get(&b,&len); m=MOVED; } if(ubuf->Error()) { SetError(ubuf->ErrorText()); m=MOVED; } return m; } const char *FtpDirList::Status() { if(ubuf && !ubuf->Eof() && session->IsOpen()) { return xstring::format(_("Getting file list (%lld) [%s]"), (long long)session->GetPos(),session->CurrentStatus()); } return ""; } void FtpDirList::SuspendInternal() { super::SuspendInternal(); if(ubuf) ubuf->SuspendSlave(); } void FtpDirList::ResumeInternal() { if(ubuf) ubuf->ResumeSlave(); super::ResumeInternal(); } void FtpDirList::FormatGeneric(FileInfo *fi) { bool dir=(fi->defined&fi->TYPE) && fi->filetype==fi->DIRECTORY; if(!(fi->defined&fi->MODE)) fi->mode=(dir?0755:0644); char size_str[32]; if(fi->defined&fi->SIZE) snprintf(size_str,sizeof(size_str),"%lld",(long long)fi->size); else strcpy(size_str,"-"); const char *date_str="-"; if(fi->defined&fi->DATE) date_str=TimeDate(fi->date).IsoDateTime(); buf->Format("%c%s %10s %16s ", dir ? 'd':'-', format_perms(fi->mode), size_str, date_str); if(color) DirColors::GetInstance()-> PutColored(buf,fi->name,fi->filetype); else buf->Put(fi->name); buf->Put("\r\n"); delete fi; } FileInfo *ParseFtpLongList_EPLF(char *line,int *err,const char *); bool FtpDirList::TryEPLF(const char *line_c, int len) { // check for EPLF listing if(len<2) return false; if(line_c[0]!='+') return false; char *line=string_alloca(len+1); strncpy(line,line_c,len); line[len]=0; int err=0; FileInfo *fi=ParseFtpLongList_EPLF(line,&err,0); if(!fi) return false; // ok, this is EPLF. Format new string. FormatGeneric(fi); return true; } bool FtpDirList::TryColor(const char *line_c,int len) { if(!color) return false; char *line=string_alloca(len+1); strncpy(line,line_c,len); line[len]=0; if(len>0 && line[len-1]=='\r') line[len-1]=0; char year_or_time[6]; char perms[12],user[32],group[32],month_name[4]; int nlink,day,year,hour,minute; long long size; int consumed=0; int n=sscanf(line,"%11s %d %31s %31s %lld %3s %2d %5s%n",perms,&nlink, user,group,&size,month_name,&day,year_or_time,&consumed); if(n==4) // bsd-like listing without group? { group[0]=0; n=sscanf(line,"%11s %d %31s %lld %3s %2d %5s%n",perms,&nlink, user,&size,month_name,&day,year_or_time,&consumed); if(n!=7) return false; } else if(n!=8) return false; if(consumed>0 && -1!=(parse_perms(perms+1)) && -1!=(parse_month(month_name)) && -1!=parse_year_or_time(year_or_time,&year,&hour,&minute) && strlen(line+consumed)>1) { // good. int type=-1; int name_start=consumed+1; int name_len=strlen(line+name_start); if(perms[0]=='d') type=FileInfo::DIRECTORY; else if(perms[0]=='l') { type=FileInfo::SYMLINK; const char *str=strstr(line+name_start+1," -> "); if(str) name_len=str-(line+name_start); } else if(perms[0]=='-') type=FileInfo::NORMAL; buf->Put(line,consumed+1); char *name=string_alloca(name_len+1); strncpy(name,line+name_start,name_len); name[name_len]=0; DirColors::GetInstance()->PutColored(buf,name,type); buf->Put(line+name_start+name_len); buf->Put("\r\n"); return true; } return false; } FileInfo *ParseFtpLongList_MLSD(char *line,int *err,const char *); bool FtpDirList::TryMLSD(const char *line_c,int len) { char *line=string_alloca(len+1); strncpy(line,line_c,len); line[len]=0; int err=0; FileInfo *fi=ParseFtpLongList_MLSD(line,&err,0); if(!fi) return false; FormatGeneric(fi); return true; } lftp-4.6.3a/src/FindJob.cc0000644000015000007670000002101412311773000012154 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include "FindJob.h" #include "CmdExec.h" #include "misc.h" #include "GetFileInfo.h" #include "url.h" #include "PatternSet.h" #include "buffer_std.h" #define top (*stack.last()) #define stack_ptr (stack.count()-1) #define super SessionJob #define orig_session super::session int FinderJob::Do() { int m=STALL; prf_res pres; Job *j; switch(state) { case START_INFO: { if(stack_ptr==-1) { ParsedURL u(dir,true); if(u.proto) { session=my_session=FileAccess::New(&u); session->SetPriority(fg?1:0); init_dir=session->GetCwd(); Down(u.path?u.path.get():init_dir.path.get()); } } /* If we're not validating, and this is an argument (first-level path), * pretend the file exists. */ if((file_info_need|FileInfo::NAME) == FileInfo::NAME && !validate_args && stack_ptr == -1) { FileSet *fs = new FileSet(); fs->Add(new FileInfo(dir)); Push(fs); state=LOOP; return MOVED; } /* The first time we get here (stack_ptr == -1), dir is an actual * argument, so it might be a file. (Every other time, it's guaranteed * to be a directory.) Set show_dirs to true, so it'll end up actually * being on the stack, with type information. */ li=new GetFileInfo(session, dir, stack_ptr == -1); /* Prepend for the argument level entry only: */ if(stack_ptr != -1) li->DontPrependPath(); int need = file_info_need|FileInfo::NAME; /* We only explicitely need the type if we're recursing further. */ if(stack_ptr+1 < maxdepth) need |= FileInfo::TYPE; li->Need(need); if(use_cache) li->UseCache(); state=INFO; m=MOVED; } case INFO: if(!li->Done()) return m; if(li->Error()) { if(!quiet) eprintf("%s: %s\n",op,li->ErrorText()); li=0; errors++; depth_done=true; state=LOOP; return MOVED; } if(stack_ptr != -1 && li->WasDirectory()) Enter(dir); Push(li->GetResult()); top.fset->rewind(); li=0; state=LOOP; m=MOVED; case LOOP: if(stack_ptr==-1 || top.fset->curr()==0) { Up(); return MOVED; } session->SetCwd(init_dir); session->Chdir(top.path,false); // at this point either is true: // 1. we just process another file (!depth_done) // 2. we just returned from a subdir (depth_done) if(depth_first && !depth_done && (maxdepth == -1 || stack_ptr+1 < maxdepth)) { FileInfo *f=top.fset->curr(); if((f->defined&f->TYPE) && f->filetype==f->DIRECTORY) { Down(f->name); return MOVED; } } state=PROCESSING; m=MOVED; case PROCESSING: pres=ProcessFile(top.path,top.fset->curr()); if(pres==PRF_LATER) return m; depth_done=false; switch(pres) { case(PRF_FATAL): errors++; state=DONE; return MOVED; case(PRF_ERR): errors++; break; case(PRF_WAIT): state=WAIT; return MOVED; case(PRF_OK): break; case(PRF_LATER): abort(); } post_WAIT: state=LOOP; m=MOVED; if(stack_ptr==-1) return m; if(!depth_first && (maxdepth == -1 || stack_ptr+1 < maxdepth)) { FileInfo *f=top.fset->curr(); if((f->defined&f->TYPE) && f->filetype==f->DIRECTORY) { top.fset->next(); Down(f->name); return MOVED; } } top.fset->next(); return MOVED; case WAIT: j=FindDoneAwaitedJob(); if(!j) return m; RemoveWaiting(j); Delete(j); goto post_WAIT; case DONE: return m; } return m; } void FinderJob::Up() { if(stack_ptr==-1) { done: state=DONE; Finish(); return; } /* stack[0] is the dir entry for the argument (ie. ls -d dir), and * stack[1] is the contents (ls dir); don't exit for the first. */ if(stack_ptr) Exit(); stack.chop(); if(stack_ptr==-1) goto done; depth_done=true; state=LOOP; } void FinderJob::Push(FileSet *fset) { const char *old_path=0; if(stack_ptr>=0) { old_path=top.path; fset->ExcludeDots(); /* don't need . and .. (except for stack[0]) */ } const char *new_path=""; if(old_path) // the first path will be empty new_path=alloca_strdup(dir_file(old_path,dir)); /* matching exclusions don't include the path, so they operate * on the filename portion only */ if(exclude) fset->Exclude(0, exclude); stack.append(new place(new_path,fset)); /* give a chance to operate on the list as a whole, and * possibly sort it */ ProcessList(fset); } void FinderJob::Down(const char *p) { #ifdef FIND_DEBUG printf("Down(%s)\n",p.get()); #endif dir.set(p); state=START_INFO; } FinderJob::prf_res FinderJob::ProcessFile(const char *d,const FileInfo *f) { return PRF_OK; } void FinderJob::Init() { op="find"; errors=0; li=0; show_sl=true; depth_first=false; // useful for rm -r depth_done=false; file_info_need=0; use_cache=true; validate_args=false; quiet=false; maxdepth=-1; exclude=0; state=START_INFO; } FinderJob::FinderJob(FileAccess *s) : SessionJob(s), orig_init_dir(orig_session->GetCwd()), session(orig_session), init_dir(session->GetCwd()) { Init(); } void FinderJob::NextDir(const char *d) { if(session!=orig_session) { session=orig_session; init_dir=orig_init_dir; } session->SetCwd(init_dir); Down(d); } FinderJob::~FinderJob() { } void FinderJob::ShowRunStatus(const SMTaskRef& sl) { if(!show_sl) return; switch(state) { case INFO: sl->Show("%s: %s",dir_file(stack_ptr>=0?top.path.get():0,dir),li->Status()); break; case WAIT: Job::ShowRunStatus(sl); break; default: sl->Clear(); break; } } xstring& FinderJob::FormatStatus(xstring& s,int v,const char *prefix) { SessionJob::FormatStatus(s,v,prefix); switch(state) { case INFO: s.appendf("\t%s: %s\n",dir_file(stack_ptr>=0?top.path.get():0,dir),li->Status()); break; case WAIT: break; default: break; } return s; } void FinderJob::Fg() { super::Fg(); if(orig_session!=session) session->SetPriority(1); } void FinderJob::Bg() { if(orig_session!=session) session->SetPriority(0); super::Bg(); } // FinderJob_List implementation // find files and write list to a stream FinderJob::prf_res FinderJob_List::ProcessFile(const char *d,const FileInfo *fi) { if(buf->Broken()) return PRF_FATAL; if(buf->Error()) { eprintf("%s: %s\n",op,buf->ErrorText()); return PRF_FATAL; } if(fg_data==0) fg_data=buf->GetFgData(fg); if(buf->Size()>0x10000) return PRF_LATER; xstring path_to_show; if(ProcessingURL()) { FileAccess::Path old_cwd=session->GetCwd(); session->SetCwd(init_dir); path_to_show.set(session->GetFileURL(dir_file(d,fi->name))); session->SetCwd(old_cwd); } else path_to_show.set(dir_file(d,fi->name)); if((fi->defined&fi->TYPE) && fi->filetype==fi->DIRECTORY && strcmp(fi->name,"/")) path_to_show.append('/'); if(long_listing) { FileInfo n(*fi); n.SetName(path_to_show); n.MakeLongName(); buf->Put(n.longname); } else { buf->Put(path_to_show); } buf->Put("\n"); return FinderJob::ProcessFile(d,fi); } FinderJob_List::FinderJob_List(FileAccess *s,ArgV *a,FDStream *o) : FinderJob(s), args(a), long_listing(false) { if(o) buf=new IOBufferFDStream(o,IOBuffer::PUT); else buf=new IOBuffer_STDOUT(this); show_sl = !o || !o->usesfd(1); NextDir(a->getcurr()); ValidateArgs(); } void FinderJob_List::Finish() { const char *d=args->getnext(); if(!d) { buf->PutEOF(); return; } NextDir(d); } lftp-4.6.3a/src/ascii_ctype.h0000644000015000007670000000245712122056701013013 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef ASCII_CTYPE_H #define ASCII_CTYPE_H // We need these functions because network protocols should not depend // on current locale. #include "c-ctype.h" #define is_ascii_digit(c) c_isdigit((c)) #define is_ascii_xdigit(c) c_isxdigit((c)) #define is_ascii_space(c) c_isspace((c)) #define is_ascii_lower(c) c_islower((c)) #define is_ascii_upper(c) c_isupper((c)) #define is_ascii_alpha(c) c_isalpha((c)) #define is_ascii_alnum(c) c_isalnum((c)) #define to_ascii_lower(c) c_tolower((c)) #define to_ascii_upper(c) c_toupper((c)) #endif//ASCII_CTYPE_H lftp-4.6.3a/src/ProtoLog.cc0000644000015000007670000000347212404505000012412 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "log.h" #include "ProtoLog.h" bool ProtoLog::WillOutput(int level) { return Log::global && Log::global->WillOutput(level); } void ProtoLog::Log2(int level,xstring& str) { if(!WillOutput(level)) return; str.chomp('\n'); str.chomp('\r'); str.append('\n'); Log::global->Write(level,str); } void ProtoLog::Log3(int level,const char *prefix,const char *str0) { if(!WillOutput(level)) return; Log2(level,xstring::get_tmp(prefix).append(str0)); } void ProtoLog::LogError(int level,const char *fmt,...) { if(!WillOutput(level)) return; va_list v; va_start(v,fmt); Log2(level,xstring::get_tmp("**** ").vappendf(fmt,v)); va_end(v); } void ProtoLog::LogNote(int level,const char *fmt,...) { if(!WillOutput(level)) return; va_list v; va_start(v,fmt); Log2(level,xstring::get_tmp("---- ").vappendf(fmt,v)); va_end(v); } void ProtoLog::LogRecv(int level,const char *line) { Log3(level,"<--- ",line); } void ProtoLog::LogSend(int level,const char *line) { Log3(level,"---> ",line); } lftp-4.6.3a/src/RateLimit.cc0000644000015000007670000000777512252603651012565 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "RateLimit.h" #include "ResMgr.h" #include "SMTask.h" // RateLimit class implementation. int RateLimit::total_xfer_number; RateLimit::BytesPool RateLimit::total[2]; bool RateLimit::total_reconfig_needed=true; RateLimit::RateLimit(const char *c) { if(total_xfer_number==0) { total[GET].Reset(); total[PUT].Reset(); } total_xfer_number++; Reconfig(0,c); } RateLimit::~RateLimit() { total_xfer_number--; } #define LARGE 0x10000000 #define DEFAULT_MAX_COEFF 2 void RateLimit::BytesPool::AdjustTime() { double dif=TimeDiff(SMTask::now,t); if(dif>0) { // prevent overflow if((LARGE-pool)/dif < rate) pool = pool_max; else pool += int(dif*rate+0.5); if(pool>pool_max) pool=pool_max; t=SMTask::now; } } int RateLimit::BytesAllowed(dir_t dir) { if(total_reconfig_needed) ReconfigTotal(); if(one[dir].rate==0 && total[dir].rate==0) // unlimited return LARGE; one [dir].AdjustTime(); total[dir].AdjustTime(); int ret=LARGE; if(total[dir].rate>0) ret=total[dir].pool/total_xfer_number; if(one[dir].rate>0 && ret>one[dir].pool) ret=one[dir].pool; return ret; } bool RateLimit::Relaxed(dir_t dir) { if(total_reconfig_needed) ReconfigTotal(); if(one[dir].rate==0 && total[dir].rate==0) // unlimited return true; one [dir].AdjustTime(); total[dir].AdjustTime(); if(total[dir].rate>0 && total[dir].pool < total[dir].pool_max/2) return false; if(one[dir].rate>0 && one[dir].pool < one[dir].pool_max/2) return false; return true; } void RateLimit::BytesPool::Used(int bytes) { if(poolone[d].pool_max) size=one[d].pool_max; return size; } void RateLimit::SetBufferSize(IOBuffer *buf,int size) const { dir_t d = (buf->GetDirection()==buf->GET ? GET : PUT); buf->SetMaxBuffered(LimitBufferSize(size,d)); } lftp-4.6.3a/src/MirrorJob.cc0000644000015000007670000015663012540277120012571 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include #include #include #include "MirrorJob.h" #include "CmdExec.h" #include "rmJob.h" #include "mvJob.h" #include "ChmodJob.h" #include "mkdirJob.h" #include "misc.h" #include "plural.h" #include "FindJob.h" #include "url.h" #include "CopyJob.h" #include "pgetJob.h" #include "log.h" #define set_state(s) do { state=(s); \ Log::global->Format(11,"mirror(%p) enters state %s\n", this, #s); } while(0) #define waiting_num waiting.count() xstring& MirrorJob::FormatStatus(xstring& s,int v,const char *tab) { if(Done()) goto final; switch(state) { case(INITIAL_STATE): case(FINISHING): case(DONE): case(WAITING_FOR_TRANSFER): case(TARGET_REMOVE_OLD): case(TARGET_REMOVE_OLD_FIRST): case(TARGET_CHMOD): case(TARGET_MKDIR): case(SOURCE_REMOVING_SAME): case(LAST_EXEC): break; case(MAKE_TARGET_DIR): s.appendf("\tmkdir `%s' [%s]\n",target_dir.get(),target_session->CurrentStatus()); break; case(CHANGING_DIR_SOURCE): case(CHANGING_DIR_TARGET): if(target_session->IsOpen()) s.appendf("\tcd `%s' [%s]\n",target_dir.get(),target_session->CurrentStatus()); if(source_session->IsOpen()) s.appendf("\tcd `%s' [%s]\n",source_dir.get(),source_session->CurrentStatus()); break; case(GETTING_LIST_INFO): if(target_list_info) { if(target_relative_dir) s.appendf("\t%s: %s\n",target_relative_dir.get(),target_list_info->Status()); else s.appendf("\t%s\n",target_list_info->Status()); } if(source_list_info) { if(source_relative_dir) s.appendf("\t%s: %s\n",source_relative_dir.get(),source_list_info->Status()); else s.appendf("\t%s\n",source_list_info->Status()); } break; } return s; final: if(stats.dirs>0) s.appendf(plural("%sTotal: %d director$y|ies$, %d file$|s$, %d symlink$|s$\n", stats.dirs,stats.tot_files,stats.tot_symlinks), tab,stats.dirs,stats.tot_files,stats.tot_symlinks); if(stats.new_files || stats.new_symlinks) s.appendf(plural("%sNew: %d file$|s$, %d symlink$|s$\n", stats.new_files,stats.new_symlinks), tab,stats.new_files,stats.new_symlinks); if(stats.mod_files || stats.mod_symlinks) s.appendf(plural("%sModified: %d file$|s$, %d symlink$|s$\n", stats.mod_files,stats.mod_symlinks), tab,stats.mod_files,stats.mod_symlinks); if(stats.bytes) s.appendf("%s%s\n",tab,CopyJob::FormatBytesTimeRate(stats.bytes,transfer_time_elapsed)); if(stats.del_dirs || stats.del_files || stats.del_symlinks) s.appendf(plural(flags&DELETE ? "%sRemoved: %d director$y|ies$, %d file$|s$, %d symlink$|s$\n" :"%sTo be removed: %d director$y|ies$, %d file$|s$, %d symlink$|s$\n", stats.del_dirs,stats.del_files,stats.del_symlinks), tab,stats.del_dirs,stats.del_files,stats.del_symlinks); if(stats.error_count) s.appendf(plural("%s%d error$|s$ detected\n",stats.error_count), tab,stats.error_count); return s; } void MirrorJob::ShowRunStatus(const SMTaskRef& s) { int w=s->GetWidthDelayed(); switch(state) { case(INITIAL_STATE): break; // these have a sub-job case(WAITING_FOR_TRANSFER): case(TARGET_REMOVE_OLD): case(TARGET_REMOVE_OLD_FIRST): case(TARGET_CHMOD): case(TARGET_MKDIR): case(SOURCE_REMOVING_SAME): case(FINISHING): case(DONE): case(LAST_EXEC): Job::ShowRunStatus(s); break; case(MAKE_TARGET_DIR): s->Show("mkdir `%s' [%s]",target_dir.get(),target_session->CurrentStatus()); break; case(CHANGING_DIR_SOURCE): case(CHANGING_DIR_TARGET): if(target_session->IsOpen() && (!source_session->IsOpen() || now%4>=2)) s->Show("cd `%s' [%s]",target_dir.get(),target_session->CurrentStatus()); else if(source_session->IsOpen()) s->Show("cd `%s' [%s]",source_dir.get(),source_session->CurrentStatus()); break; case(GETTING_LIST_INFO): if(target_list_info && (!source_list_info || now%4>=2)) { const char *status=target_list_info->Status(); int status_w=mbswidth(status, 0); int dw=w-status_w; if(dw<20) dw=20; if(target_relative_dir) s->Show("%s: %s",squeeze_file_name(target_relative_dir,dw),status); else s->Show("%s",status); } else if(source_list_info) { const char *status=source_list_info->Status(); int status_w=mbswidth(status, 0); int dw=w-status_w; if(dw<20) dw=20; if(source_relative_dir) s->Show("%s: %s",squeeze_file_name(source_relative_dir,dw),status); else s->Show("%s",status); } break; } } xstring& MirrorJob::FormatShortStatus(xstring& s) { if(bytes_to_transfer>0 && (!parent_mirror || parent_mirror->bytes_to_transfer!=bytes_to_transfer)) { long long curr_bytes_transferred=GetBytesCount(); if(parent_mirror) curr_bytes_transferred+=bytes_transferred; s.appendf("%s/%s (%d%%)", xhuman(curr_bytes_transferred),xhuman(bytes_to_transfer), percent(curr_bytes_transferred,bytes_to_transfer)); double rate=GetTransferRate(); if(rate>=1) s.append(' ').append(Speedometer::GetStrProper(rate)); } return s; } void MirrorJob::TransferStarted(CopyJob *cp) { if(transfer_count==0) root_mirror->transfer_start_ts=now; JobStarted(cp); } void MirrorJob::JobStarted(Job *j) { AddWaiting(j); transfer_count++; } void MirrorJob::TransferFinished(Job *j) { long long bytes_count=j->GetBytesCount(); AddBytesTransferred(bytes_count); stats.bytes+=bytes_count; stats.time +=j->GetTimeSpent(); if(j->ExitCode()==0 && verbose_report>=2) { xstring finished; const xstring& cmd=j->GetCmdLine(); if(cmd[0]=='\\') finished.append(cmd+1,cmd.length()-1); else finished.append(cmd); const xstring& rate=Speedometer::GetStrProper(j->GetTransferRate()); if(rate.length()>0) finished.append(" (").append(rate).append(')'); if(!(FlagSet(SCAN_ALL_FIRST) && finished.begins_with("mirror"))) Report(_("Finished %s"),finished.get()); } JobFinished(j); if(transfer_count==0) root_mirror->transfer_time_elapsed += now-root_mirror->transfer_start_ts; } void MirrorJob::JobFinished(Job *j) { if(j->ExitCode()!=0) stats.error_count++; RemoveWaiting(j); Delete(j); transfer_count--; } void MirrorJob::HandleFile(FileInfo *file) { int res; struct stat st; // TODO: get rid of local hacks. // dir_name returns pointer to static data - need to dup it. const char *source_name=dir_file(source_dir,file->name); source_name=alloca_strdup(source_name); const char *target_name=dir_file(target_dir,file->name); target_name=alloca_strdup(target_name); const char *source_name_rel=dir_file(source_relative_dir,file->name); source_name_rel=alloca_strdup(source_name_rel); const char *target_name_rel=dir_file(target_relative_dir,file->name); target_name_rel=alloca_strdup(target_name_rel); FileInfo::type filetype=FileInfo::NORMAL; if(file->Has(file->TYPE)) filetype=file->filetype; else { FileInfo *target=target_set->FindByName(file->name); if(target && target->Has(target->TYPE)) filetype=target->filetype; } switch(filetype) { case(FileInfo::NORMAL): { bool remove_target=false; bool cont_this=false; bool use_pget=(pget_n>1) && target_is_local; if(file->Has(file->SIZE) && file->sizeFindByName(file->name); if(old) goto skip; // file has appeared after mirror start old=old_files_set->FindByName(file->name); if(old && ((old->Has(old->SIZE) && old->size!=st.st_size) ||(old->Has(old->DATE) && old->date!=st.st_mtime))) goto skip; // the file has changed after mirror start } } FileInfo *old=target_set->FindByName(file->name); if(old) { if((flags&CONTINUE) && old->Has(file->TYPE) && old->filetype==old->NORMAL && (flags&IGNORE_TIME || (file->Has(file->DATE) && old->Has(old->DATE) && file->date + file->date.ts_prec < old->date - old->date.ts_prec)) && file->Has(file->SIZE) && old->Has(old->SIZE) && file->size >= old->size) { cont_this=true; if(target_is_local && !script_only) { if(access(target_name,W_OK)==-1) { // try to enable write access. chmod(target_name,st.st_mode|0200); } } stats.mod_files++; } else if(!to_rm_mismatched->FindByName(file->name)) { if(!FlagSet(OVERWRITE)) { remove_target=true; Report(_("Removing old file `%s'"),target_name_rel); } else { Report(_("Overwriting old file `%s'"),target_name_rel); } stats.mod_files++; } else stats.new_files++; } else if(flags&ONLY_EXISTING) { Report(_("Skipping file `%s' (only-existing)"),source_name_rel); goto skip; } else stats.new_files++; Report(_("Transferring file `%s'"),source_name_rel); if(script) { ArgV args(use_pget?"pget":"get"); if(use_pget) { args.Append("-n"); args.Append(pget_n); } if(cont_this) args.Append("-c"); if(remove_target) args.Append("-e"); if(FlagSet(ASCII)) args.Append("-a"); if(remove_source_files) args.Append("-E"); args.Append("-O"); args.Append(target_is_local?target_dir.get() :target_session->GetConnectURL()); args.Append(source_session->GetFileURL(file->name)); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); if(script_only) goto skip; } FileCopyPeer *src_peer=0; if(source_is_local) src_peer=new FileCopyPeerFDStream(new FileStream(source_name,O_RDONLY),FileCopyPeer::GET); else src_peer=new FileCopyPeerFA(source_session->Clone(),file->name,FA::RETRIEVE); FileCopyPeer *dst_peer=0; if(target_is_local) dst_peer=new FileCopyPeerFDStream(new FileStream(target_name,O_WRONLY|O_CREAT|(cont_this?0:O_TRUNC)),FileCopyPeer::PUT); else dst_peer=new FileCopyPeerFA(target_session->Clone(),file->name,FA::STORE); FileCopy *c=FileCopy::New(src_peer,dst_peer,cont_this); if(remove_source_files) c->RemoveSourceLater(); if(remove_target) c->RemoveTargetFirst(); if(FlagSet(ASCII)) c->Ascii(); CopyJob *cp=(use_pget ? new pgetJob(c,file->name,pget_n) : new CopyJob(c,file->name,"mirror")); if(file->Has(file->DATE)) cp->SetDate(file->date); if(file->Has(file->SIZE)) cp->SetSize(file->size); TransferStarted(cp); cp->cmdline.vset("\\transfer `",source_name_rel,"'",NULL); set_state(WAITING_FOR_TRANSFER); break; } case(FileInfo::DIRECTORY): { if(recursion_mode==RECURSION_NEVER || FlagSet(NO_RECURSION)) goto skip; bool create_target_dir=true; const FileInfo *old=0; if(target_set) old=target_set->FindByName(file->name); if(!old) { if(flags&ONLY_EXISTING) { Report(_("Skipping directory `%s' (only-existing)"),target_name_rel); goto skip; } } else if(old->TypeIs(old->DIRECTORY)) { create_target_dir=false; } if(target_is_local && !script_only) { if((flags&RETR_SYMLINKS?stat:lstat)(target_name,&st)!=-1) { if(S_ISDIR(st.st_mode)) { chmod(target_name,st.st_mode|0700); create_target_dir=false; } else { Report(_("Removing old local file `%s'"),target_name_rel); if(remove(target_name)==-1) { eprintf("mirror: remove(%s): %s\n",target_name,strerror(errno)); goto skip; } create_target_dir=true; } } } // launch sub-mirror MirrorJob *mj=new MirrorJob(this, source_session->Clone(),target_session->Clone(), source_name,target_name); AddWaiting(mj); mj->cmdline.vset("\\mirror `",source_name_rel,"'",NULL); // inherit flags and other things mj->SetFlags(flags,1); mj->UseCache(use_cache); mj->SetExclude(exclude); mj->source_relative_dir.set(source_name_rel); mj->target_relative_dir.set(target_name_rel); mj->verbose_report=verbose_report; mj->newer_than=newer_than; mj->older_than=older_than; mj->size_range=size_range; mj->parallel=parallel; mj->pget_n=pget_n; mj->pget_minchunk=pget_minchunk; mj->remove_source_files=remove_source_files; mj->skip_noaccess=skip_noaccess; mj->create_target_dir=create_target_dir; mj->no_target_dir=no_target_dir; mj->recursion_mode=recursion_mode; mj->script=script; mj->script_needs_closing=false; mj->script_name.set(script_name); mj->script_only=script_only; mj->max_error_count=max_error_count; if(verbose_report>=3) { if(FlagSet(SCAN_ALL_FIRST)) Report(_("Scanning directory `%s'"),mj->target_relative_dir.get()); else Report(_("Mirroring directory `%s'"),mj->target_relative_dir.get()); } break; } case(FileInfo::SYMLINK): { if(flags&NO_SYMLINKS) goto skip; if(!file->symlink) goto skip; if(!target_is_local) { if(script) { ArgV args("ln"); args.Append("-s"); args.Append(file->symlink); args.Append(target_name); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); if(script_only) goto skip; } bool remove_target=false; FileInfo *old=target_set->FindByName(file->name); if(old && !to_rm_mismatched->FindByName(file->name)) { Report(_("Removing old file `%s'"),target_name_rel); remove_target=true; stats.mod_symlinks++; } else stats.new_symlinks++; mvJob *j=new mvJob(target_session->Clone(),file->symlink,target_name,FA::SYMLINK); if(remove_target) j->RemoveTargetFirst(); AddWaiting(j); break; } if(script) { ArgV args("shell"); args.Append("ln"); args.Append("-sf"); args.Append(shell_encode(file->symlink)); args.Append(shell_encode(target_name)); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); if(script_only) goto skip; } if(file->Has(file->SYMLINK)) { struct stat st; if(lstat(target_name,&st)!=-1) { Report(_("Removing old local file `%s'"),target_name_rel); stats.mod_symlinks++; if(remove(target_name)==-1) { eprintf("mirror: remove(%s): %s\n",target_name,strerror(errno)); goto skip; } } else { if(flags&ONLY_EXISTING) { Report(_("Skipping symlink `%s' (only-existing)"),target_name_rel); goto skip; } stats.new_symlinks++; } Report(_("Making symbolic link `%s' to `%s'"),target_name_rel,file->symlink.get()); res=symlink(file->symlink,target_name); if(res==-1) eprintf("mirror: symlink(%s): %s\n",target_name,strerror(errno)); } break; } case FileInfo::UNKNOWN: break; } skip: return; } void MirrorJob::InitSets(const FileSet *source,const FileSet *dest) { source->Count(NULL,&stats.tot_files,&stats.tot_symlinks,&stats.tot_files); to_rm=new FileSet(dest); to_rm->SubtractAny(source); same=new FileSet(source); to_transfer=new FileSet(source); int ignore=0; if(flags&ONLY_NEWER) ignore|=FileInfo::IGNORE_SIZE_IF_OLDER|FileInfo::IGNORE_DATE_IF_OLDER; if(!FlagSet(UPLOAD_OLDER) && strcmp(target_session->GetProto(),"file")) ignore|=FileInfo::IGNORE_DATE_IF_OLDER; if(flags&IGNORE_TIME) ignore|=FileInfo::DATE; if(flags&IGNORE_SIZE) ignore|=FileInfo::SIZE; to_transfer->SubtractSame(dest,ignore); same->SubtractAny(to_transfer); if(newer_than!=NO_DATE) to_transfer->SubtractNotNewerThan(newer_than); if(older_than!=NO_DATE) to_transfer->SubtractNotOlderThan(older_than); if(size_range) to_transfer->SubtractSizeOutside(size_range); if(FlagSet(SCAN_ALL_FIRST)) { to_mkdir=new FileSet(to_transfer); to_mkdir->SubtractNotDirs(); to_mkdir->SubtractAny(dest); } switch(recursion_mode) { case RECURSION_NEVER: to_transfer->SubtractDirs(); break; case RECURSION_MISSING: to_transfer->SubtractDirs(dest); break; case RECURSION_NEWER: to_transfer->SubtractNotOlderDirs(dest); break; case RECURSION_ALWAYS: break; } if(skip_noaccess) to_transfer->ExcludeUnaccessible(); new_files_set=new FileSet(to_transfer); new_files_set->SubtractAny(dest); old_files_set=new FileSet(dest); old_files_set->SubtractNotIn(to_transfer); to_rm_mismatched=new FileSet(old_files_set); to_rm_mismatched->SubtractSameType(to_transfer); to_rm_mismatched->SubtractNotDirs(); if(!(flags&DELETE)) to_transfer->SubtractAny(to_rm_mismatched); const char *sort_by=ResMgr::Query("mirror:sort-by",0); bool desc=strstr(sort_by,"-desc"); if(!strncmp(sort_by,"name",4)) to_transfer->SortByPatternList(ResMgr::Query("mirror:order",0)); else if(!strncmp(sort_by,"date",4)) to_transfer->Sort(FileSet::BYDATE); else if(!strncmp(sort_by,"size",4)) to_transfer->Sort(FileSet::BYSIZE,false,true); if(desc) to_transfer->ReverseSort(); int dir_count=0; if(to_mkdir) { to_mkdir->Count(&dir_count,NULL,NULL,NULL); only_dirs = (dir_count==to_mkdir->count()); } else { to_transfer->Count(&dir_count,NULL,NULL,NULL); only_dirs = (dir_count==to_transfer->count()); } } void MirrorJob::HandleChdir(FileAccessRef& session, int &redirections) { if(!session->IsOpen()) return; int res=session->Done(); if(res<0) { if(res==FA::FILE_MOVED) { // cd to another url. const char *loc_c=session->GetNewLocation(); int max_redirections=ResMgr::Query("xfer:max-redirections",0); if(loc_c && max_redirections>0) { if(++redirections>max_redirections) goto cd_err_normal; eprintf(_("%s: received redirection to `%s'\n"),"mirror",loc_c); char *loc=alloca_strdup(loc_c); ParsedURL u(loc,true); bool is_file=(last_char(loc)!='/'); if(!u.proto) { FileAccess::Path new_cwd(session->GetNewCwd()); new_cwd.Change(0,is_file,loc); session->PathVerify(new_cwd); session->Roll(); return; } session->Close(); // loc_c is no longer valid. session=FA::New(&u); FileAccess::Path new_cwd(u.path,is_file,url::path_ptr(loc)); session->PathVerify(new_cwd); return; } } cd_err_normal: if(session==target_session && (script_only || FlagSet(SCAN_ALL_FIRST))) { char *dir=alloca_strdup(session->GetFile()); session->Close(); session->Chdir(dir,false); no_target_dir=true; return; } eprintf("mirror: %s\n",session->StrError(res)); stats.error_count++; transfer_count-=root_transfer_count; set_state(FINISHING); source_session->Close(); target_session->Close(); return; } if(res==FA::OK) session->Close(); } void MirrorJob::HandleListInfoCreation(const FileAccessRef& session,SMTaskRef& list_info,const char *relative_dir) { if(state!=GETTING_LIST_INFO) return; if(session==target_session && no_target_dir) { target_set=new FileSet(); return; } list_info=session->MakeListInfo(); if(list_info==0) { eprintf(_("mirror: protocol `%s' is not suitable for mirror\n"), session->GetProto()); transfer_count-=root_transfer_count; set_state(FINISHING); return; } list_info->UseCache(use_cache); int need=FileInfo::ALL_INFO; if(flags&IGNORE_TIME) need&=~FileInfo::DATE; if(flags&IGNORE_SIZE) need&=~FileInfo::SIZE; list_info->Need(need); if(flags&RETR_SYMLINKS) list_info->FollowSymlinks(); list_info->SetExclude(relative_dir,exclude); list_info->Roll(); } void MirrorJob::HandleListInfo(SMTaskRef& list_info, Ref& set) { if(!list_info) return; if(!list_info->Done()) return; if(list_info->Error()) { eprintf("mirror: %s\n",list_info->ErrorText()); stats.error_count++; transfer_count-=root_transfer_count; set_state(FINISHING); source_list_info=0; target_list_info=0; return; } set=list_info->GetResult(); list_info=0; set->ExcludeDots(); // don't need .. and . } int MirrorJob::Do() { int res; int m=STALL; FileInfo *file; Job *j; switch(state) { case(INITIAL_STATE): source_session->Chdir(source_dir); source_redirections=0; source_session->Roll(); set_state(CHANGING_DIR_SOURCE); m=MOVED; /*fallthrough*/ case(CHANGING_DIR_SOURCE): HandleChdir(source_session,source_redirections); if(state!=CHANGING_DIR_SOURCE) return MOVED; if(source_session->IsOpen()) return m; source_dir.set(source_session->GetCwd().GetDirectory()); pre_MAKE_TARGET_DIR: { if(!strcmp(target_dir,".") || !strcmp(target_dir,"..") || (FlagSet(SCAN_ALL_FIRST) && parent_mirror)) create_target_dir=false; if(!create_target_dir) goto pre_CHANGING_DIR_TARGET; if(target_is_local) { struct stat st; if((flags&RETR_SYMLINKS?stat:lstat)(target_dir,&st)!=-1) { if(S_ISDIR(st.st_mode)) { if(!script_only) chmod(target_dir,st.st_mode|0700); create_target_dir=false; goto pre_CHANGING_DIR_TARGET; } else { Report(_("Removing old local file `%s'"),target_dir.get()); if(script) { ArgV args("rm"); args.Append(target_session->GetFileURL(target_dir)); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); } if(!script_only) { if(remove(target_dir)==-1) eprintf("mirror: remove(%s): %s\n",target_dir.get(),strerror(errno)); } } } } if(FlagSet(DEPTH_FIRST)) goto pre_GETTING_LIST_INFO; if(target_relative_dir) Report(_("Making directory `%s'"),target_relative_dir.get()); bool mkdir_p=(parent_mirror==0 || parent_mirror->create_target_dir); if(script) { ArgV args("mkdir"); if(mkdir_p) args.Append("-p"); args.Append(target_session->GetFileURL(target_dir)); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); if(script_only) goto pre_CHANGING_DIR_TARGET; } target_session->Mkdir(target_dir,mkdir_p); set_state(MAKE_TARGET_DIR); m=MOVED; } /*fallthrough*/ case(MAKE_TARGET_DIR): res=target_session->Done(); if(res==FA::IN_PROGRESS) return m; target_session->Close(); create_target_dir=false; pre_CHANGING_DIR_TARGET: target_session->Chdir(target_dir); target_redirections=0; target_session->Roll(); set_state(CHANGING_DIR_TARGET); m=MOVED; /*fallthrough*/ case(CHANGING_DIR_TARGET): HandleChdir(target_session,target_redirections); if(state!=CHANGING_DIR_TARGET) return MOVED; if(target_session->IsOpen()) return m; create_target_dir=false; target_dir.set(target_session->GetCwd().GetDirectory()); pre_GETTING_LIST_INFO: set_state(GETTING_LIST_INFO); m=MOVED; if(!source_set) HandleListInfoCreation(source_session,source_list_info,source_relative_dir); if(!target_set && !create_target_dir && (!FlagSet(DEPTH_FIRST) || FlagSet(ONLY_EXISTING))) HandleListInfoCreation(target_session,target_list_info,target_relative_dir); if(state!=GETTING_LIST_INFO) { source_list_info=0; target_list_info=0; } return m; // give time to other tasks case(GETTING_LIST_INFO): HandleListInfo(source_list_info,source_set); HandleListInfo(target_list_info,target_set); if(state!=GETTING_LIST_INFO) return MOVED; if(source_list_info || target_list_info) return m; transfer_count-=root_transfer_count; // leave room for transfers. if(FlagSet(DEPTH_FIRST) && source_set && !target_set) { // transfer directories first InitSets(source_set,NULL); to_transfer->Unsort(); to_transfer->SubtractNotDirs(); goto pre_WAITING_FOR_TRANSFER; } // now we have both target and source file sets. if(parent_mirror) stats.dirs++; if(FlagSet(SCAN_ALL_FIRST) && parent_mirror) { source_set->PrependPath(source_relative_dir); if(root_mirror->source_set_recursive) root_mirror->source_set_recursive->Merge(source_set); else root_mirror->source_set_recursive=source_set.borrow(); if(target_set) { target_set->PrependPath(target_relative_dir); if(root_mirror->target_set_recursive) root_mirror->target_set_recursive->Merge(target_set); else root_mirror->target_set_recursive=target_set.borrow(); } root_mirror->stats.dirs++; goto pre_DONE; } if(source_set_recursive) { source_set->Merge(source_set_recursive); source_set_recursive=0; } if(target_set_recursive) { target_set->Merge(target_set_recursive); target_set_recursive=0; } InitSets(source_set,target_set); to_transfer->CountBytes(&bytes_to_transfer); if(parent_mirror) parent_mirror->AddBytesToTransfer(bytes_to_transfer); to_rm->Count(&stats.del_dirs,&stats.del_files,&stats.del_symlinks,&stats.del_files); to_rm->rewind(); to_rm_mismatched->Count(&stats.del_dirs,&stats.del_files,&stats.del_symlinks,&stats.del_files); to_rm_mismatched->rewind(); set_state(TARGET_REMOVE_OLD_FIRST); goto TARGET_REMOVE_OLD_FIRST_label; pre_TARGET_MKDIR: if(!to_mkdir) goto pre_WAITING_FOR_TRANSFER; to_mkdir->rewind(); set_state(TARGET_MKDIR); m=MOVED; /*fallthrough*/ case(TARGET_MKDIR): while((j=FindDoneAwaitedJob())!=0) { JobFinished(j); m=MOVED; } if(max_error_count>0 && stats.error_count>=max_error_count) goto pre_FINISHING; while(transfer_countcurr(); if(!file) goto pre_WAITING_FOR_TRANSFER; to_mkdir->next(); if(!file->TypeIs(file->DIRECTORY)) continue; if(script) fprintf(script,"mkdir %s\n",target_session->GetFileURL(file->name)); if(!script_only) { ArgV *a=new ArgV("mkdir"); a->Append(file->name); mkdirJob *mkj=new mkdirJob(target_session->Clone(),a); mkj->cmdline.set_allocated(a->Combine()); JobStarted(mkj); m=MOVED; } } break; pre_WAITING_FOR_TRANSFER: to_transfer->rewind(); set_state(WAITING_FOR_TRANSFER); m=MOVED; /*fallthrough*/ case(WAITING_FOR_TRANSFER): while((j=FindDoneAwaitedJob())!=0) { TransferFinished(j); m=MOVED; } if(max_error_count>0 && stats.error_count>=max_error_count) goto pre_FINISHING; while(transfer_countcurr(); if(!file) { // go to the next step only when all transfers have finished if(waiting_num>0) break; if(FlagSet(DEPTH_FIRST)) { // we have been in the depth, don't go there again SetFlags(DEPTH_FIRST,false); SetFlags(NO_RECURSION,true); // if we have not created any subdirs and there are only subdirs, // then the directory would be empty - skip it. if(FlagSet(NO_EMPTY_DIRS) && stats.dirs==0 && only_dirs) goto pre_FINISHING_FIX_LOCAL; transfer_count+=root_transfer_count; goto pre_MAKE_TARGET_DIR; } goto pre_TARGET_REMOVE_OLD; } HandleFile(file); to_transfer->next(); m=MOVED; } break; pre_TARGET_REMOVE_OLD: if(flags&REMOVE_FIRST) goto pre_TARGET_CHMOD; set_state(TARGET_REMOVE_OLD); m=MOVED; /*fallthrough*/ case(TARGET_REMOVE_OLD): case(TARGET_REMOVE_OLD_FIRST): TARGET_REMOVE_OLD_FIRST_label: while((j=FindDoneAwaitedJob())!=0) { JobFinished(j); m=MOVED; } if(max_error_count>0 && stats.error_count>=max_error_count) goto pre_FINISHING; while(transfer_countcurr(); to_rm_mismatched->next(); } if(!file && (state==TARGET_REMOVE_OLD || (flags&REMOVE_FIRST))) { file=to_rm->curr(); to_rm->next(); } if(!file) { if(waiting_num>0) break; if(state==TARGET_REMOVE_OLD) goto pre_TARGET_CHMOD; goto pre_TARGET_MKDIR; } const char *target_name_rel=dir_file(target_relative_dir,file->name); target_name_rel=alloca_strdup(target_name_rel); if(!(flags&DELETE)) { if(flags&REPORT_NOT_DELETED) { if(file->TypeIs(file->DIRECTORY)) Report(_("Old directory `%s' is not removed"),target_name_rel); else Report(_("Old file `%s' is not removed"),target_name_rel); } continue; } if(script) { ArgV args("rm"); if(file->TypeIs(file->DIRECTORY)) { if(recursion_mode==RECURSION_NEVER) args.setarg(0,"rmdir"); else args.Append("-r"); } args.Append(target_session->GetFileURL(file->name)); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); } if(!script_only) { ArgV *args=new ArgV("rm"); args->Append(file->name); args->seek(1); rmJob *j=new rmJob(target_session->Clone(),args); j->cmdline.set_allocated(args->Combine()); JobStarted(j); if(file->TypeIs(file->DIRECTORY)) { if(recursion_mode==RECURSION_NEVER) { args->setarg(0,"rmdir"); j->Rmdir(); } else j->Recurse(); } } if(file->TypeIs(file->DIRECTORY)) Report(_("Removing old directory `%s'"),target_name_rel); else Report(_("Removing old file `%s'"),target_name_rel); } break; pre_TARGET_CHMOD: if(flags&NO_PERMS) goto pre_FINISHING_FIX_LOCAL; to_transfer->rewind(); set_state(TARGET_CHMOD); m=MOVED; /*fallthrough*/ case(TARGET_CHMOD): while((j=FindDoneAwaitedJob())!=0) { JobFinished(j); m=MOVED; } if(max_error_count>0 && stats.error_count>=max_error_count) goto pre_FINISHING; while(transfer_countcurr(); if(!file) goto pre_FINISHING_FIX_LOCAL; to_transfer->next(); if(file->TypeIs(file->SYMLINK)) continue; if(!file->Has(file->MODE)) continue; mode_t mode_mask=get_mode_mask(); mode_t def_mode=(file->TypeIs(file->DIRECTORY)?0775:0664)&~mode_mask; if(target_is_local && file->mode==def_mode) { struct stat st; if(!target_is_local || lstat(dir_file(target_dir,file->name),&st)==-1) continue; if((st.st_mode&07777)==(file->mode&~mode_mask)) continue; } FileInfo *target=target_set->FindByName(file->name); if(target && target->filetype==file->DIRECTORY && file->filetype==file->DIRECTORY && target->mode==(file->mode&~mode_mask) && (target->mode&0200)) continue; if(script) { ArgV args("chmod"); args.Append(xstring::format("%03lo",(unsigned long)(file->mode&~mode_mask))); args.Append(target_session->GetFileURL(file->name)); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); } if(!script_only) { ArgV *a=new ArgV("chmod"); a->Append(file->name); a->seek(1); ChmodJob *cj=new ChmodJob(target_session->Clone(), file->mode&~mode_mask,a); cj->cmdline.set_allocated(a->Combine()); cj->BeQuiet(); // chmod is not supported on all servers; be quiet. JobStarted(cj); m=MOVED; } } break; pre_FINISHING_FIX_LOCAL: if(target_is_local && !script_only) // FIXME { to_transfer->LocalUtime(target_dir,/*only_dirs=*/true); if(flags&ALLOW_CHOWN) to_transfer->LocalChown(target_dir); if(!FlagSet(NO_PERMS) && same) same->LocalChmod(target_dir,get_mode_mask()); if(FlagSet(ALLOW_CHOWN) && same) same->LocalChown(target_dir); } if(remove_source_files) goto pre_SOURCE_REMOVING_SAME; pre_FINISHING: set_state(FINISHING); m=MOVED; /*fallthrough*/ case(FINISHING): while((j=FindDoneAwaitedJob())!=0) { JobFinished(j); m=MOVED; } if(waiting_num>0) break; transfer_count++; // parent mirror will decrement it. if(parent_mirror) parent_mirror->stats.Add(stats); else { if(stats.HaveSomethingDone(flags) && on_change) { CmdExec *exec=new CmdExec(source_session->Clone(),0); AddWaiting(exec); exec->FeedCmd(on_change); exec->FeedCmd("\n"); set_state(LAST_EXEC); break; } } goto pre_DONE; pre_SOURCE_REMOVING_SAME: same->rewind(); set_state(SOURCE_REMOVING_SAME); m=MOVED; /*fallthrough*/ case(SOURCE_REMOVING_SAME): while((j=FindDoneAwaitedJob())!=0) { JobFinished(j); m=MOVED; } if(max_error_count>0 && stats.error_count>=max_error_count) goto pre_FINISHING; while(transfer_countcurr(); same->next(); if(!file) goto pre_FINISHING; if(file->TypeIs(file->DIRECTORY)) continue; const char *source_name_rel=dir_file(source_relative_dir,file->name); source_name_rel=alloca_strdup(source_name_rel); if(script) { ArgV args("rm"); args.Append(source_session->GetFileURL(file->name)); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); } if(!script_only) { ArgV *args=new ArgV("rm"); args->Append(file->name); args->seek(1); rmJob *j=new rmJob(source_session->Clone(),args); j->cmdline.set_allocated(args->Combine()); JobStarted(j); } Report(_("Removing source file `%s'"),source_name_rel); } break; case(LAST_EXEC): while((j=FindDoneAwaitedJob())!=0) { RemoveWaiting(j); Delete(j); m=MOVED; } if(waiting_num>0) break; pre_DONE: set_state(DONE); m=MOVED; bytes_transferred=0; if(!parent_mirror && (flags&LOOP) && stats.HaveSomethingDone(flags) && !stats.error_count) { PrintStatus(0,""); printf(_("Retrying mirror...\n")); stats.Reset(); source_set=0; target_set=0; goto pre_GETTING_LIST_INFO; } /*fallthrough*/ case(DONE): break; } // give direct parent priority over grand-parents. if(transfer_countRoll(); return m; } MirrorJob::MirrorJob(MirrorJob *parent, FileAccess *source,FileAccess *target, const char *new_source_dir,const char *new_target_dir) : bytes_transferred(0), bytes_to_transfer(0), source_dir(new_source_dir), target_dir(new_target_dir), transfer_time_elapsed(0), root_transfer_count(0), transfer_count(parent?parent->transfer_count:root_transfer_count), verbose_report(0), parent_mirror(parent), root_mirror(parent?parent->root_mirror:this) { source_session=source; target_session=target; // TODO: get rid of this. source_is_local=!strcmp(source_session->GetProto(),"file"); target_is_local=!strcmp(target_session->GetProto(),"file"); create_target_dir=true; no_target_dir=false; flags=0; max_error_count=0; exclude=0; set_state(INITIAL_STATE); newer_than=NO_DATE; older_than=NO_DATE; size_range=0; script=0; script_only=false; script_needs_closing=false; use_cache=false; remove_source_files=false; skip_noaccess=false; parallel=1; pget_n=1; pget_minchunk=0x10000; source_redirections=0; target_redirections=0; if(parent_mirror) { bool parallel_dirs=ResMgr::QueryBool("mirror:parallel-directories",0); // If parallel_dirs is true, allow parent mirror to continue // processing other directories, otherwise block it until we // get file sets and start transfers. root_transfer_count=parallel_dirs?1:1024; transfer_count+=root_transfer_count; } } MirrorJob::~MirrorJob() { if(script && script_needs_closing) fclose(script); } void MirrorJob::va_Report(const char *fmt,va_list v) { if(parent_mirror) { parent_mirror->va_Report(fmt,v); return; } if(verbose_report) { pid_t p=tcgetpgrp(fileno(stdout)); if(p>0 && p!=getpgrp()) return; vfprintf(stdout,fmt,v); printf("\n"); fflush(stdout); } } void MirrorJob::Report(const char *fmt,...) { va_list v; va_start(v,fmt); va_Report(fmt,v); va_end(v); } extern "C" { #include "parse-datetime.h" } void MirrorJob::SetNewerThan(const char *f) { struct timespec ts; if(parse_datetime(&ts,f,0)) { newer_than=ts.tv_sec; return; } struct stat st; if(stat(f,&st)==-1) { perror(f); return; } newer_than=st.st_mtime; } void MirrorJob::SetOlderThan(const char *f) { struct timespec ts; if(parse_datetime(&ts,f,0)) { older_than=ts.tv_sec; return; } struct stat st; if(stat(f,&st)==-1) { perror(f); return; } older_than=st.st_mtime; } mode_t MirrorJob::get_mode_mask() { mode_t mode_mask=0; if(!(flags&ALLOW_SUID)) mode_mask|=S_ISUID|S_ISGID; if(!(flags&NO_UMASK)) { if(target_is_local) { mode_t u=umask(022); // get+set umask(u); // retore mode_mask|=u; } else mode_mask|=022; // sane default. } return mode_mask; } void MirrorJob::Fg() { Job::Fg(); source_session->SetPriority(1); target_session->SetPriority(1); } void MirrorJob::Bg() { source_session->SetPriority(0); target_session->SetPriority(0); Job::Bg(); } MirrorJob::Statistics::Statistics() { Reset(); error_count=0; bytes=0; time=0; } void MirrorJob::Statistics::Reset() { tot_files=new_files=mod_files=del_files= tot_symlinks=new_symlinks=mod_symlinks=del_symlinks= dirs=del_dirs=0; } void MirrorJob::Statistics::Add(const Statistics &s) { tot_files +=s.tot_files; new_files +=s.new_files; mod_files +=s.mod_files; del_files +=s.del_files; tot_symlinks+=s.tot_symlinks; new_symlinks+=s.new_symlinks; mod_symlinks+=s.mod_symlinks; del_symlinks+=s.del_symlinks; dirs +=s.dirs; del_dirs +=s.del_dirs; error_count +=s.error_count; bytes +=s.bytes; time +=s.time; } bool MirrorJob::Statistics::HaveSomethingDone(int flags) { bool del=(flags&MirrorJob::DELETE); return new_files|mod_files|(del_files*del)|new_symlinks|mod_symlinks|(del_symlinks*del)|(del_dirs*del); } const char *MirrorJob::SetScriptFile(const char *n) { script_name.set(n); if(strcmp(n,"-")) { script=fopen(n,"w"); if(!script) return xstring::format("%s: %s",n,strerror(errno)); setvbuf(script,NULL,_IOLBF,0); script_needs_closing=true; } else { script=stdout; script_needs_closing=false; } return 0; } void MirrorJob::SetOnChange(const char *oc) { on_change.set(oc); } const char *MirrorJob::AddPattern(Ref& exclude,char opt,const char *optarg) { PatternSet::Type type= (opt=='x'||opt=='X'||opt=='\0'?PatternSet::EXCLUDE:PatternSet::INCLUDE); PatternSet::Pattern *pattern=0; if(opt=='x' || opt=='i') { Ref rx(new PatternSet::Regex(optarg)); if(rx->Error()) return xstring::get_tmp(rx->ErrorText()); pattern=rx.borrow(); } else if(opt=='X' || opt=='I') { pattern=new PatternSet::Glob(optarg); } if(!exclude) { const char *default_exclude=ResMgr::Query("mirror:exclude-regex",0); const char *default_include=ResMgr::Query("mirror:include-regex",0); // don't create default pattern set if not needed if(!pattern && !(default_exclude && *default_exclude)) return NULL; exclude=new PatternSet; /* Make default_exclude the first pattern so that it can be * overridden by --include later, and do that only when first * explicit pattern is for exclusion - otherwise all files are * excluded by default and no default exclusion is needed. */ if(type==PatternSet::EXCLUDE && default_exclude && *default_exclude) { exclude->Add(type,new PatternSet::Regex(default_exclude)); if(default_include && *default_include) exclude->Add(PatternSet::INCLUDE,new PatternSet::Regex(default_include)); } } if(pattern) exclude->Add(type,pattern); return NULL; // no error } const char *MirrorJob::SetRecursionMode(const char *m) { struct { const char name[8]; recursion_mode_t mode; } map[]={ {"always", RECURSION_ALWAYS}, {"never", RECURSION_NEVER}, {"missing",RECURSION_MISSING}, {"newer", RECURSION_NEWER}, }; unsigned i; for(i=0; iargs) #define eprintf parent->eprintf enum { OPT_ALLOW_CHOWN, OPT_DELETE_FIRST, OPT_IGNORE_SIZE, OPT_IGNORE_TIME, OPT_LOOP, OPT_MAX_ERRORS, OPT_NO_DEREFERENCE, OPT_NO_SYMLINKS, OPT_NO_UMASK, OPT_OLDER_THAN, OPT_ONLY_MISSING, OPT_ONLY_EXISTING, OPT_PERMS, OPT_REMOVE_SOURCE_FILES, OPT_SCRIPT, OPT_SCRIPT_ONLY, OPT_SIZE_RANGE, OPT_USE_CACHE, OPT_USE_PGET_N, OPT_SKIP_NOACCESS, OPT_ON_CHANGE, OPT_NO_EMPTY_DIRS, OPT_DEPTH_FIRST, OPT_ASCII, OPT_SCAN_ALL_FIRST, OPT_OVERWRITE, OPT_NO_OVERWRITE, OPT_RECURSION, OPT_UPLOAD_OLDER, }; static const struct option mirror_opts[]= { {"delete",no_argument,0,'e'}, {"allow-suid",no_argument,0,'s'}, {"allow-chown",no_argument,0,OPT_ALLOW_CHOWN}, {"include",required_argument,0,'i'}, {"exclude",required_argument,0,'x'}, {"include-glob",required_argument,0,'I'}, {"exclude-glob",required_argument,0,'X'}, {"only-newer",no_argument,0,'n'}, {"no-recursion",no_argument,0,'r'}, {"no-perms",no_argument,0,'p'}, {"perms",no_argument,0,OPT_PERMS}, {"no-umask",no_argument,0,OPT_NO_UMASK}, {"continue",no_argument,0,'c'}, {"reverse",no_argument,0,'R'}, {"verbose",optional_argument,0,'v'}, {"newer-than",required_argument,0,'N'}, {"file",required_argument,0,'f'}, {"older-than",required_argument,0,OPT_OLDER_THAN}, {"size-range",required_argument,0,OPT_SIZE_RANGE}, {"dereference",no_argument,0,'L'}, {"no-dereference",no_argument,0,OPT_NO_DEREFERENCE}, {"use-cache",no_argument,0,OPT_USE_CACHE}, {"Remove-source-files",no_argument,0,OPT_REMOVE_SOURCE_FILES}, {"parallel",optional_argument,0,'P'}, {"ignore-time",no_argument,0,OPT_IGNORE_TIME}, {"ignore-size",no_argument,0,OPT_IGNORE_SIZE}, {"only-missing",no_argument,0,OPT_ONLY_MISSING}, {"only-existing",no_argument,0,OPT_ONLY_EXISTING}, {"log",required_argument,0,OPT_SCRIPT}, {"script", required_argument,0,OPT_SCRIPT_ONLY}, {"just-print",optional_argument,0,OPT_SCRIPT_ONLY}, {"dry-run", optional_argument,0,OPT_SCRIPT_ONLY}, {"delete-first",no_argument,0,OPT_DELETE_FIRST}, {"use-pget-n",optional_argument,0,OPT_USE_PGET_N}, {"no-symlinks",no_argument,0,OPT_NO_SYMLINKS}, {"loop",no_argument,0,OPT_LOOP}, {"max-errors",required_argument,0,OPT_MAX_ERRORS}, {"skip-noaccess",no_argument,0,OPT_SKIP_NOACCESS}, {"on-change",required_argument,0,OPT_ON_CHANGE}, {"no-empty-dirs",no_argument,0,OPT_NO_EMPTY_DIRS}, {"depth-first",no_argument,0,OPT_DEPTH_FIRST}, {"ascii",no_argument,0,OPT_ASCII}, {"target-directory",required_argument,0,'O'}, {"destination-directory",required_argument,0,'O'}, {"scan-all-first",no_argument,0,OPT_SCAN_ALL_FIRST}, {"overwrite",no_argument,0,OPT_OVERWRITE}, {"no-overwrite",no_argument,0,OPT_NO_OVERWRITE}, {"recursion",required_argument,0,OPT_RECURSION}, {"upload-older",no_argument,0,OPT_UPLOAD_OLDER}, {0} }; int opt; int flags=0; int max_error_count=0; bool use_cache=false; FileAccessRef source_session; FileAccessRef target_session; int verbose=0; const char *newer_than=0; const char *older_than=0; Ref size_range; bool remove_source_files=false; bool skip_noaccess=ResMgr::QueryBool("mirror:skip-noaccess",0); int parallel=ResMgr::Query("mirror:parallel-transfer-count",0); int use_pget=ResMgr::Query("mirror:use-pget-n",0); bool reverse=false; bool script_only=false; bool no_empty_dirs=ResMgr::QueryBool("mirror:no-empty-dirs",0); const char *script_file=0; const char *on_change=0; const char *recursion_mode=0; Ref exclude; if(!ResMgr::QueryBool("mirror:set-permissions",0)) flags|=MirrorJob::NO_PERMS; if(ResMgr::QueryBool("mirror:dereference",0)) flags|=MirrorJob::RETR_SYMLINKS; if(ResMgr::QueryBool("mirror:overwrite",0)) flags|=MirrorJob::OVERWRITE; const char *source_dir=NULL; const char *target_dir=NULL; args->rewind(); while((opt=args->getopt_long("esi:x:I:X:nrpcRvN:LP:af:O:",mirror_opts,0))!=EOF) { switch(opt) { case('e'): flags|=MirrorJob::DELETE; break; case('s'): flags|=MirrorJob::ALLOW_SUID; break; case(OPT_ALLOW_CHOWN): flags|=MirrorJob::ALLOW_CHOWN; break; case('a'): flags|=MirrorJob::ALLOW_SUID|MirrorJob::ALLOW_CHOWN|MirrorJob::NO_UMASK; break; case('r'): recursion_mode="never"; break; case('n'): flags|=MirrorJob::ONLY_NEWER; break; case('p'): flags|=MirrorJob::NO_PERMS; break; case(OPT_PERMS): flags&=~MirrorJob::NO_PERMS; break; case('c'): flags|=MirrorJob::CONTINUE; break; case('x'): case('i'): case('X'): case('I'): { const char *err=MirrorJob::AddPattern(exclude,opt,optarg); if(err) { eprintf(_("%s: regular expression `%s': %s\n"), args->a0(),optarg,err); goto no_job; } break; } case('R'): reverse=true; break; case('L'): flags|=MirrorJob::RETR_SYMLINKS; break; case(OPT_NO_DEREFERENCE): flags&=~MirrorJob::RETR_SYMLINKS; break; case('v'): if(optarg) verbose=atoi(optarg); else verbose++; if(verbose>1) flags|=MirrorJob::REPORT_NOT_DELETED; break; case('N'): newer_than=optarg; break; case('f'): { // mirror for a single file (or glob pattern). recursion_mode="never"; MirrorJob::AddPattern(exclude,'I',basename_ptr(optarg)); source_dir=dirname(optarg); source_dir=alloca_strdup(source_dir); // save the temp string break; } case('O'): target_dir=optarg; break; case(OPT_OLDER_THAN): older_than=optarg; break; case(OPT_SIZE_RANGE): size_range=new Range(optarg); if(size_range->Error()) { eprintf("%s: --size-range \"%s\": %s\n", args->a0(),optarg,size_range->ErrorText()); goto no_job; } break; case(OPT_NO_UMASK): flags|=MirrorJob::NO_UMASK; break; case(OPT_USE_CACHE): use_cache=true; break; case(OPT_REMOVE_SOURCE_FILES): remove_source_files=true; break; case(OPT_IGNORE_TIME): flags|=MirrorJob::IGNORE_TIME; break; case(OPT_IGNORE_SIZE): flags|=MirrorJob::IGNORE_SIZE; break; case(OPT_ONLY_MISSING): flags|=MirrorJob::IGNORE_TIME|MirrorJob::IGNORE_SIZE; break; case('P'): if(optarg) parallel=atoi(optarg); else parallel=3; break; case(OPT_USE_PGET_N): if(optarg) use_pget=atoi(optarg); else use_pget=3; break; case(OPT_SCRIPT_ONLY): script_only=true; case(OPT_SCRIPT): script_file=optarg; if(script_file==0) script_file="-"; break; case(OPT_DELETE_FIRST): flags|=MirrorJob::REMOVE_FIRST|MirrorJob::DELETE; break; case(OPT_NO_SYMLINKS): flags|=MirrorJob::NO_SYMLINKS; break; case(OPT_LOOP): flags|=MirrorJob::LOOP; break; case(OPT_MAX_ERRORS): max_error_count=atoi(optarg); break; case(OPT_SKIP_NOACCESS): skip_noaccess=true; break; case(OPT_ON_CHANGE): on_change=optarg; break; case(OPT_ONLY_EXISTING): flags|=MirrorJob::ONLY_EXISTING; break; case(OPT_NO_EMPTY_DIRS): no_empty_dirs=true; flags|=MirrorJob::NO_EMPTY_DIRS|MirrorJob::DEPTH_FIRST; break; case(OPT_DEPTH_FIRST): flags|=MirrorJob::DEPTH_FIRST; break; case(OPT_SCAN_ALL_FIRST): flags|=MirrorJob::SCAN_ALL_FIRST|MirrorJob::DEPTH_FIRST; break; case(OPT_ASCII): flags|=MirrorJob::ASCII|MirrorJob::IGNORE_SIZE; break; case(OPT_OVERWRITE): flags|=MirrorJob::OVERWRITE; break; case(OPT_NO_OVERWRITE): flags&=~MirrorJob::OVERWRITE; break; case(OPT_RECURSION): recursion_mode=optarg; break; case(OPT_UPLOAD_OLDER): flags|=MirrorJob::UPLOAD_OLDER; break; case('?'): eprintf(_("Try `help %s' for more information.\n"),args->a0()); no_job: return 0; } } if(exclude && xstrcasecmp(recursion_mode,"never")) { /* Users usually don't want to exclude all directories when recursing */ if(exclude->GetFirstType()==PatternSet::INCLUDE) exclude->AddFirst(PatternSet::INCLUDE,new PatternSet::Regex("/$")); } /* add default exclusion if no explicit patterns were specified */ if(!exclude) MirrorJob::AddPattern(exclude,'\0',0); args->back(); const char *arg=args->getnext(); if(arg) { if(source_dir) { eprintf(_("%s: ambiguous source directory (`%s' or `%s'?)\n"),args->a0(), source_dir,arg); goto no_job; } source_dir=arg; ParsedURL source_url(source_dir); if(source_url.proto && source_url.path) { source_session=FileAccess::New(&source_url); if(!source_session) { eprintf("%s: %s%s\n",args->a0(),source_url.proto.get(), _(" - not supported protocol")); goto no_job; } source_dir=alloca_strdup(source_url.path); } arg=args->getnext(); if(arg) { if(target_dir) { eprintf(_("%s: ambiguous target directory (`%s' or `%s'?)\n"),args->a0(), target_dir,arg); goto no_job; } target_dir=arg; ParsedURL target_url(target_dir); if(target_url.proto && target_url.path) { target_session=FileAccess::New(&target_url); if(!target_session) { eprintf("%s: %s%s\n",args->a0(),target_url.proto.get(), _(" - not supported protocol")); goto no_job; } target_dir=alloca_strdup(target_url.path); } if(last_char(arg)=='/' && basename_ptr(arg)[0]!='/') { // user wants source dir name appended. const char *base=basename_ptr(source_dir); if(base[0]!='/' && strcmp(base,basename_ptr(arg))) { target_dir=xstring::cat(target_dir,base,NULL); target_dir=alloca_strdup(target_dir); // save the buffer } } } else { target_dir=basename_ptr(source_dir); if(target_dir[0]=='/') target_dir="."; else if(target_dir[0]=='~') { target_dir=dir_file(".",target_dir); target_dir=alloca_strdup(target_dir); // save the buffer } } } if(!source_dir) { if(ResMgr::QueryBool("mirror:require-source",0)) { eprintf(_("%s: source directory is required (mirror:require-source is set)\n"),args->a0()); return 0; } source_dir="."; } if(!target_dir) target_dir="."; if(!reverse) { if(!source_session) source_session=parent->session->Clone(); if(!target_session) target_session=FileAccess::New("file"); } else //reverse { if(!source_session) source_session=FileAccess::New("file"); if(!target_session) target_session=parent->session->Clone(); } if(no_empty_dirs) flags|=MirrorJob::NO_EMPTY_DIRS|MirrorJob::DEPTH_FIRST; JobRef j(new MirrorJob(0,source_session.borrow(),target_session.borrow(),source_dir,target_dir)); j->SetFlags(flags,1); j->SetVerbose(verbose); j->SetExclude(exclude.borrow()); if(newer_than) j->SetNewerThan(newer_than); if(older_than) j->SetOlderThan(older_than); if(size_range) j->SetSizeRange(size_range.borrow()); j->UseCache(use_cache); if(remove_source_files) j->RemoveSourceFiles(); if(skip_noaccess) j->SkipNoAccess(); if(parallel<0) parallel=0; if(parallel>64) parallel=64; // a (in)sane limit. if(parallel) j->SetParallel(parallel); if(use_pget>1 && !(flags&MirrorJob::ASCII)) j->SetPGet(use_pget); if(recursion_mode) { const char *err=j->SetRecursionMode(recursion_mode); if(err) { eprintf("%s: %s\n",args->a0(),err); return 0; } } if(script_file) { const char *err=j->SetScriptFile(script_file); if(err) { eprintf("%s: %s\n",args->a0(),err); return 0; } } if(script_only) { j->ScriptOnly(); if(!script_file) j->SetScriptFile("-"); } j->SetMaxErrorCount(max_error_count); if(on_change) j->SetOnChange(on_change); return j.borrow(); #undef args } #include "modconfig.h" #ifndef MODULE_CMD_MIRROR # define module_init cmd_mirror_module_init #endif CDECL void module_init() { CmdExec::RegisterCommand("mirror",cmd_mirror,0, N_("\nMirror specified remote directory to local directory\n\n" " -c, --continue continue a mirror job if possible\n" " -e, --delete delete files not present at remote site\n" " --delete-first delete old files before transferring new ones\n" " -s, --allow-suid set suid/sgid bits according to remote site\n" " --allow-chown try to set owner and group on files\n" " --ignore-time ignore time when deciding whether to download\n" " -n, --only-newer download only newer files (-c won't work)\n" " -r, --no-recursion don't go to subdirectories\n" " -p, --no-perms don't set file permissions\n" " --no-umask don't apply umask to file modes\n" " -R, --reverse reverse mirror (put files)\n" " -L, --dereference download symbolic links as files\n" " -N, --newer-than=SPEC download only files newer than specified time\n" " -P, --parallel[=N] download N files in parallel\n" " -i RX, --include RX include matching files\n" " -x RX, --exclude RX exclude matching files\n" " RX is extended regular expression\n" " -v, --verbose[=N] verbose operation\n" " --log=FILE write lftp commands being executed to FILE\n" " --script=FILE write lftp commands to FILE, but don't execute them\n" " --just-print, --dry-run same as --script=-\n" "\n" "When using -R, the first directory is local and the second is remote.\n" "If the second directory is omitted, basename of first directory is used.\n" "If both directories are omitted, current local and remote directories are used.\n") ); } lftp-4.6.3a/src/parsecmd.cc0000644000015000007670000001645512457746766012512 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "CmdExec.h" #include "alias.h" #include "xstring.h" bool CmdExec::quotable(char ch,char in_quotes) { if(!ch) return false; if(ch=='\\' || ch=='!' || ch==in_quotes) return true; if(in_quotes) return false; if(strchr("\"' \t>|;&",ch)) return true; return false; } CmdExec::parse_result CmdExec::parse_one_cmd() { char in_quotes; const char *line=cmd_buf.Get(); const char *line_begin=line; static xstring nextarg; const char *alias=0; if(args) args->Empty(); else args=new ArgV; output=0; char redir_type=0; background=0; if(!*line) { // empty command return PARSE_OK; } if(line[0]=='&' && line[1]=='&') { condition=COND_AND; line+=2; } else if(line[0]=='|' && line[1]=='|') { condition=COND_OR; line+=2; } else { condition=COND_ANY; } // loop for all arguments for(;;) { // skip leading whitespace while(is_space(*line)) line++; if(line[0]=='\\' && line[1]=='\n') { line+=2; continue; // and continue skipping space } if(line[0]=='\r' && line[1]=='\n') line++; if(*line==0) return PARSE_AGAIN; if(*line=='\n' || *line=='|' || *line=='>' || *line==';' || *line=='&') break; nextarg.truncate(0); if(args->count()==0 && *line=='#') { // comment -- skip and return while(*line!='\n' && *line) line++; if(*line=='\n') line++; else return PARSE_AGAIN; skip_cmd(line-line_begin); return PARSE_OK; } if(args->count()==0 && *line=='!') { // shell command -- it ends only with '\n' args->Append("!"); line++; while(is_space(*line)) line++; while(*line!='\n' && *line) { if(*line=='\\' && line[1]=='\n') { line+=2; continue; } nextarg.append(*line++); } if(*line==0) return PARSE_AGAIN; if(*line=='\n') line++; skip_cmd(line-line_begin); if(nextarg.length()>0) args->Append(nextarg); return PARSE_OK; } if(args->count()==0 && *line=='(') { line++; args->Append("("); int level=1; in_quotes=0; for(;;) { if(*line==0) return PARSE_AGAIN; if(*line=='\\' && line[1] && (strchr("\"\\",line[1]) || (level==1 && line[1]==')'))) { nextarg.append(*line++); } else { if(!in_quotes) { if(*line==')') { if(--level==0) break; } else if(*line=='(') level++; } if(in_quotes && *line==in_quotes) in_quotes=0; else if(!in_quotes && is_quote(*line)) in_quotes=*line; } nextarg.append(*line++); } args->Append(nextarg); line++; // skip ) while(is_space(*line)) line++; goto cmd_end; } if(args->count()==0 && *line=='?') { line++; args->Append("?"); continue; } // loop for one argument in_quotes=0; for(;;) { if(*line=='\\' && line[1]=='\n') { line+=2; continue; } if(line[0]=='\r' && line[1]=='\n') line++; if(*line=='\\' && quotable(line[1],in_quotes)) { line++; } else { if(*line==0) return PARSE_AGAIN; if(*line=='\n' || (!in_quotes && (is_space(*line) || *line=='>' || *line=='|' || *line==';' || *line=='&'))) break; if(!in_quotes && is_quote(*line)) { in_quotes=*line; line++; continue; } if(in_quotes && *line==in_quotes) { in_quotes=0; line++; continue; } } nextarg.append(*line++); } if(*line==0) return PARSE_AGAIN; // normal commands finish with \n or ; // check if the first arg is an alias, expand it accordingly. if(args->count()==0) { alias=Alias::Find(nextarg); if(alias) { int alias_len=strlen(alias); /* Check if the previous alias ends before the end of new one. * So the new alias does not expand entirely from previous * aliases and we can repeat the expansion from the very beginning. */ if(alias_field<(int)(line-line_begin)) free_used_aliases(); if(!TouchedAlias::IsTouched(alias,used_aliases)) { skip_cmd(line-line_begin); used_aliases=new TouchedAlias(alias,used_aliases); cmd_buf.Prepend(alias); alias_field+=alias_len; line=line_begin=cmd_buf.Get(); continue; } } } args->Append(nextarg); } if(*line==0) return PARSE_AGAIN; if((line[0]=='&' && line[1]=='&') || (line[0]=='|' && line[1]=='|')) { skip_cmd(line-line_begin); return PARSE_OK; } if(*line=='>' || *line=='|') { redir_type=*line; line++; if(*line=='>') { // '>>' means append redir_type='+'; line++; } // skip leading whitespace while(is_space(*line)) line++; if(*line==0) return PARSE_AGAIN; if(*line=='\n' || *line==';' || *line=='&') { if(redir_type=='|') eprintf(_("parse: missing filter command\n")); else eprintf(_("parse: missing redirection filename\n")); if(*line==';' || *line=='&' || *line=='\n') line++; skip_cmd(line-line_begin); return PARSE_ERR; } nextarg.truncate(0); in_quotes=0; for(;;) { if(*line=='\\' && line[1]=='\n') { line+=2; continue; } if(*line=='\\' && quotable(line[1],in_quotes)) line++; else { if(*line==0) return PARSE_AGAIN; // filename can end with a space, filter command can't. if(*line=='\n' || (!in_quotes && ((redir_type!='|' && is_space(*line)) || *line==';' || *line=='&'))) break; if(!in_quotes && is_quote(*line)) { in_quotes=*line; line++; continue; } if(in_quotes && *line==in_quotes) { in_quotes=0; line++; continue; } } nextarg.append(*line++); } // skip spaces while(is_space(*line)) line++; } cmd_end: if((line[0]=='&' && line[1]=='&') || (line[0]=='|' && line[1]=='|')) ; else if(*line==';' || *line=='&' || *line=='\n') { if(*line=='&') background=1; line++; } skip_cmd(line-line_begin); switch(redir_type) { case('|'): output=new OutputFilter(nextarg); break; case('>'): output=new FileStream(nextarg,O_WRONLY|O_TRUNC|O_CREAT); break; case('+'): output=new FileStream(nextarg,O_WRONLY|O_APPEND|O_CREAT); break; } return PARSE_OK; } lftp-4.6.3a/src/CopyJob.cc0000644000015000007670000001544412321204320012213 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include "CopyJob.h" #include "ArgV.h" #include "plural.h" #include "misc.h" #include "url.h" #define waiting_num waiting.count() #define super Job int CopyJob::Do() { if(!c) return STALL; if(!fg_data) fg_data=c->GetFgData(fg); if(done) return STALL; if(c->Error()) { const char *error=c->ErrorText(); const char *name=GetDispName(); if(!strstr(error,name) && op.ne(name)) error=xstring::cat(name,": ",error,NULL); eprintf("%s: %s\n",op.get(),error); done=true; return MOVED; } if(c->Done()) { done=true; return MOVED; } if(!c->WriteAllowed() && c->WritePending()) { if(no_status_on_write || clear_status_on_write) ClearStatus(); if(no_status_on_write) NoStatus(); // disable status. c->AllowWrite(); return MOVED; } return STALL; } int CopyJob::ExitCode() { if(c->Error()) return 1; return 0; } const char *CopyJob::SqueezeName(int w, bool base) { if(base) return squeeze_file_name(basename_ptr(GetDispName()),w); return squeeze_file_name(GetDispName(),w); } // xgettext:c-format static const char copy_status_format[]=N_("`%s' at %lld %s%s%s%s"); #define COPY_STATUS _(copy_status_format),name,\ (long long)c->GetPos(),c->GetPercentDoneStr(),c->GetRateStr(),\ c->GetETAStr(),c->GetStatus() const char *CopyJob::Status(const StatusLine *s, bool base) { if(c->Done() || c->Error()) return ""; const char *name=SqueezeName(s->GetWidthDelayed()-50, base); return xstring::format(COPY_STATUS); } void CopyJob::ShowRunStatus(const SMTaskRef& s) { if(no_status) return; s->Show("%s", Status(s, false)); } xstring& CopyJob::FormatStatus(xstring& s,int v,const char *prefix) { if(c->Done() || c->Error()) return s; if(no_status) return s; s.append(prefix); const char *name=GetDispName(); s.appendf(COPY_STATUS); s.append('\n'); return s; } int CopyJob::AcceptSig(int sig) { if(c==0 || GetProcGroup()==0) { if(sig==SIGINT || sig==SIGTERM) return WANTDIE; return STALL; } c->Kill(sig); if(sig!=SIGCONT) c->Kill(SIGCONT); return MOVED; } void CopyJob::SetDispName() { ParsedURL url(name,true); if(url.proto) dispname.set(url.path); else dispname.set(name); } CopyJob::CopyJob(FileCopy *c1,const char *name1,const char *op1) : c(c1), name(name1), op(op1) { done=false; no_status=false; no_status_on_write=false; clear_status_on_write=false; SetDispName(); } const char *CopyJob::FormatBytesTimeRate(off_t bytes,double time_spent) { if(bytes<=0) return ""; if(time_spent>=1) { xstring& msg=xstring::format( plural("%lld $#ll#byte|bytes$ transferred in %ld $#l#second|seconds$", (long long)bytes,long(time_spent+.5)), (long long)bytes,long(time_spent+.5)); double rate=bytes/time_spent; if(rate>=1) msg.appendf(" (%s)",Speedometer::GetStrProper(rate).get()); return msg; } return xstring::format(plural("%lld $#ll#byte|bytes$ transferred", (long long)bytes),(long long)bytes); } void CopyJob::PrepareToDie() { c=0; super::PrepareToDie(); } CopyJob::~CopyJob() { } #undef super // CopyJobEnv CopyJobEnv::CopyJobEnv(FileAccess *s,ArgV *a,bool cont1) : SessionJob(s) { args=a; args->rewind(); op=args?args->a0():"?"; done=false; cp=0; errors=0; count=0; bytes=0; time_spent=0; no_status=false; cont=cont1; ascii=false; cwd.set_allocated(xgetcwd()); } CopyJobEnv::~CopyJobEnv() { SetCopier(0,0); } int CopyJobEnv::Do() { int m=STALL; if(done) return m; if(waiting_num<1) { NextFile(); if(waiting_num==0) { done=true; m=MOVED; } else if(cp==0) cp=(CopyJob*)waiting[0]; } CopyJob *j=(CopyJob*)FindDoneAwaitedJob(); // we start only CopyJob's. if(j==0) return m; RemoveWaiting(j); if(j->ExitCode()!=0) errors++; count++; bytes+=j->GetBytesCount(); Delete(j); if(cp==j) cp=0; if(waiting_num>0 && cp==0) cp=(CopyJob*)waiting[0]; if(waiting.count()==0) time_spent+=now-transfer_start_ts; return MOVED; } void CopyJobEnv::AddCopier(FileCopy *c,const char *n) { if(c==0) return; if(ascii) c->Ascii(); cp=cj_new?cj_new->New(c,n,op):new CopyJob(c,n,op); if(waiting.count()==0) transfer_start_ts=now; AddWaiting(cp); } void CopyJobEnv::SetCopier(FileCopy *c,const char *n) { while(waiting_num>0) { Job *j=waiting[0]; RemoveWaiting(j); Delete(j); } cp=0; AddCopier(c,n); } xstring& CopyJobEnv::FormatFinalWithPrefix(xstring& s,const char *p) { if(no_status) return s; if(count==errors) return s; if(bytes) s.appendf("%s%s\n",p,CopyJob::FormatBytesTimeRate(bytes,time_spent)); if(errors>0) { s.append(p); s.appendf(plural("Transfer of %d of %d $file|files$ failed\n",count), errors,count); } else if(count>1) { s.append(p); s.appendf(plural("Total %d $file|files$ transferred\n",count),count); } return s; } xstring& CopyJobEnv::FormatStatus(xstring& s,int v,const char *prefix) { SessionJob::FormatStatus(s,v,prefix); if(Done()) FormatFinalWithPrefix(s,prefix); return s; } void CopyJobEnv::SayFinal() { printf("%s",FormatFinalWithPrefix(xstring::get_tmp(""),"").get()); } int CopyJobEnv::AcceptSig(int sig) { if(cp==0) { if(sig==SIGINT || sig==SIGTERM) return WANTDIE; return STALL; } int total; if(sig==SIGINT || sig==SIGTERM) total=WANTDIE; else total=STALL; for(int i=0; iAcceptSig(sig); if(res==WANTDIE) { RemoveWaiting(j); Delete(j); if(cp==j) cp=0; } else if(res==MOVED) total=MOVED; else if(res==STALL) { if(total==WANTDIE) total=MOVED; } } if(waiting_num>0 && cp==0) cp=(CopyJob*)waiting[0]; return total; } int CopyJobEnv::Done() { return done; } lftp-4.6.3a/src/xmap.cc0000644000015000007670000000704412370371440011624 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include "xmap.h" #include void _xmap::new_map() { map.get_space(hash_size,1); map.set_length(hash_size); for(int i=0; ikey.eq(key)) return ep; ep=&e->next; e=*ep; } return ep; } _xmap::entry *_xmap::_lookup_c(const xstring& key) const { for(entry *e=map[make_hash(key)]; e; e=e->next) { if(e->key.eq(key)) return e; } return 0; } void _xmap::rebuild_map() { static const int primes[]={ 17,67,257,1031,4099,16411,65537,262147,1048583,4194319,16777259, 67108879,268435459,1073741827 }; hash_size=entry_count*2; // a prime is better, find it. for(unsigned pi=0; pi old_map; old_map.move_here(map); new_map(); for(int i=0; inext; int hash=make_hash(e->key); e->next=map[hash]; map[hash]=e; e=next; } } } _xmap::entry *_xmap::_add(const xstring& key) { entry **ep=_lookup(key); if(*ep==0) { entry *n=(entry*)xmalloc(sizeof(entry)+value_size); memset(n,0,sizeof(entry)+value_size); n->next=0; n->key.set(key); *ep=n; entry_count++; if(entry_count>hash_size*2) rebuild_map(); return n; } return *ep; } void _xmap::_remove(entry **ep) { if(!ep || !*ep) return; entry *e=*ep; e->key.unset(); *ep=e->next; xfree(e); entry_count--; } _xmap::entry *_xmap::_each_begin() { each_entry=0; each_hash=-1; return _each_next(); } _xmap::entry *_xmap::_each_next() { while(each_hashnext; return e; } each_entry=map[++each_hash]; } last_entry=0; return 0; } void _xmap::_move_here(_xmap &o) { value_size=o.value_size; hash_size=o.hash_size; entry_count=o.entry_count; map.move_here(o.map); o.hash_size=1; o.entry_count=0; o.new_map(); } lftp-4.6.3a/src/example1-cmd.cc0000644000015000007670000000050712122054516013126 00000000000000#include #include #include "CmdExec.h" char *program_name; int main(int argc,char **argv) { program_name=argv[0]; JobRef exec(new CmdExec(0,0)); exec->FeedCmd("open ftp://ftp.yar.ru/pub/source/lftp/\n"); exec->FeedCmd("cls -l\n"); exec->WaitDone(); return exec->ExitCode(); } lftp-4.6.3a/src/GetPass.cc0000644000015000007670000000406512246067473012237 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include #include #include "GetPass.h" #include "CharReader.h" #include "SignalHook.h" const char *GetPass(const char *prompt) { static xstring_c oldpass; static int tty_fd=-2; if(tty_fd==-2) { if(isatty(0)) tty_fd=0; else { tty_fd=open("/dev/tty",O_RDONLY); if(tty_fd!=-1) fcntl(tty_fd,F_SETFD,FD_CLOEXEC); } } if(tty_fd==-1) return 0; write(tty_fd,prompt,strlen(prompt)); struct termios tc; tcgetattr(tty_fd,&tc); tcflag_t old_lflag=tc.c_lflag; tc.c_lflag&=~ECHO; tcsetattr(tty_fd,TCSANOW,&tc); oldpass.set_allocated(readline_from_file(tty_fd)); tc.c_lflag=old_lflag; tcsetattr(tty_fd,TCSANOW,&tc); write(tty_fd,"\r\n",2); return oldpass; } char *readline_from_file(int fd) { xstring line(""); for(;;) { SMTaskRef rr(new CharReader(fd)); CharReader& r=*rr.get_non_const(); int c; for(;;) { SMTask::Schedule(); c=r.GetChar(); if(c!=r.NOCHAR) break; SMTask::Block(); if(SignalHook::GetCount(SIGINT)>0) return(xstrdup("")); } if(c==r.EOFCHAR && line.length()==0) return(NULL); if(c==r.EOFCHAR || c=='\n') return(line.borrow()); line.append(c); } } lftp-4.6.3a/src/StringPool.h0000644000015000007670000000175412375641665012641 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef STRINGPOOL_H #define STRINGPOOL_H #include "xarray.h" // maybe it is better to have many separate pools with dtors. class StringPool { static xarray_m strings; public: static const char *Get(const char *); }; #endif lftp-4.6.3a/src/HttpDir.h0000644000015000007670000000330712247321503012073 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #ifndef HTTPDIR_H #define HTTPDIR_H #include "Http.h" #if USE_EXPAT # include #endif class HttpListInfo : public GenericParseListInfo { FileSet *Parse(const char *buf,int len); public: HttpListInfo(Http *session,const char *path) : GenericParseListInfo(session,path) { get_time_for_dirs=false; } static FileSet *ParseProps(const char *buf,int len,const char *base_dir); }; class ParsedURL; class HttpDirList : public DirList { SMTaskRef ubuf; const char *curr; Ref curr_url; FileSet all_links; int mode; bool parse_as_html; xstring_c base_href; #if USE_EXPAT XML_Parser xml_p; struct xml_context *xml_ctx; #endif LsOptions ls_options; void ParsePropsFormat(const char *b,int len,bool eof); public: HttpDirList(FileAccess *s,ArgV *a); ~HttpDirList(); const char *Status(); int Do(); void SuspendInternal(); void ResumeInternal(); }; #endif//HTTPDIR_H lftp-4.6.3a/src/SleepJob.cc0000644000015000007670000001604512536250765012375 00000000000000/* * lftp - file transfer program * * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net) * * 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 . */ #include #include #include #include "SleepJob.h" #include "CmdExec.h" #include "misc.h" #include "LocalDir.h" SleepJob::SleepJob(const TimeInterval &when,FileAccess *s,LocalDirectory *cwd,char *what) : SessionJob(s), Timer(when), saved_cwd(cwd) { cmd.set_allocated(what); exit_code=0; done=false; repeat=false; weak=false; repeat_count=0; max_repeat_count=0; continue_code=-1; break_code=-1; } SleepJob::~SleepJob() { } int SleepJob::Do() { int m=STALL; if(Done()) return m; if(waiting.count()>0) { Job *j=FindDoneAwaitedJob(); if(!j) return m; exit_code=j->ExitCode(); if(!repeat || (++repeat_count>=max_repeat_count && max_repeat_count) || exit_code==break_code || (continue_code!=-1 && exit_code!=continue_code)) { RemoveWaiting(j); Delete(j); exec=0; done=true; return MOVED; } Reset(); exec=(CmdExec*)j; // we are sure it is CmdExec. RemoveWaiting(j); m=MOVED; } if(Stopped()) { if(cmd) { if(!exec) { exec=new CmdExec(session.borrow(),saved_cwd.borrow()); exec->AllocJobno(); exec->cmdline.vset("(",cmd.get(),")",NULL); } exec->FeedCmd(cmd); exec->FeedCmd("\n"); AddWaiting(exec.borrow()); return MOVED; } done=true; return MOVED; } return m; } const char *SleepJob::Status() { if(Stopped() || TimeLeft().Seconds()<=1) return ""; if(IsInfty()) return(_("Sleeping forever")); return xstring::cat(_("Sleep time left: "), TimeLeft().toString(TimeInterval::TO_STR_TRANSLATE), NULL); } xstring& SleepJob::FormatStatus(xstring& buf,int,const char *prefix) { if(repeat) buf.appendf(_("\tRepeat count: %d\n"),repeat_count); const char *s=Status(); if(s[0]) buf.appendf("\t%s\n",s); return buf; } void SleepJob::ShowRunStatus(const SMTaskRef& s) { if(Stopped()) Job::ShowRunStatus(s); else { s->Show("%s",Status()); current->TimeoutS(1); } } void SleepJob::lftpMovesToBackground() { if(weak || IsInfty() || (repeat && cmd[0]==0)) { // terminate done=true; } } #define args (parent->args) #define eprintf parent->eprintf #define session (parent->session) Job *cmd_sleep(CmdExec *parent) { const char *op=args->a0(); if(args->count()!=2) { eprintf(_("%s: argument required. "),op); err: eprintf(_("Try `help %s' for more information.\n"),op); return 0; } const char *t=args->getarg(1); TimeIntervalR delay(t); if(delay.Error()) { eprintf("%s: %s: %s. ",op,t,delay.ErrorText()); goto err; } return new SleepJob(delay); } Job *cmd_repeat(CmdExec *parent) { const char *op=args->a0(); int cmd_start=1; TimeIntervalR delay(1); int max_count=0; const char *delay_str=0; bool while_ok=false; bool until_ok=false; bool weak=false; int opt; static struct option repeat_opts[]= { {"delay",required_argument,0,'d'}, {"count",required_argument,0,'c'}, {"while-ok",no_argument,0,'o'}, {"until-ok",no_argument,0,'O'}, {"weak",no_argument,0,'w'}, {0}, }; args->rewind(); while((opt=args->getopt_long("+c:d:",repeat_opts,0))!=EOF) { switch(opt) { case('c'): max_count=atoi(optarg); break; case('d'): delay_str=optarg; break; case('o'): while_ok=true; break; case('O'): until_ok=true; break; case('w'): weak=true; break; case('?'): eprintf(_("Try `help %s' for more information.\n"),args->a0()); return 0; } } if(!delay_str) { const char *t=args->getcurr(); if(t && isdigit((unsigned char)t[0])) { args->getnext(); delay_str=t; } } cmd_start=args->getindex(); if(delay_str) { delay.Set(delay_str); if(delay.Error()) { eprintf("%s: %s: %s.\n",op,delay_str,delay.ErrorText()); return 0; } } char *cmd = (args->count()==cmd_start+1 ? args->Combine(cmd_start) : args->CombineQuoted(cmd_start)); SleepJob *s=new SleepJob(delay,session->Clone(),parent->cwd->Clone(),cmd); s->Repeat(max_count); s->SetWeak(weak); if(while_ok) s->ContinueCode(0); if(until_ok) s->BreakCode(0); return s; } extern "C" { #include "parse-datetime.h" } Job *cmd_at(CmdExec *parent) { int count=1; int cmd_start=0; xstring date; for(;;) { const char *arg=args->getnext(); if(arg==0) break; if(!strcmp(arg,"--")) { cmd_start=count+1; break; } if(date) date.append(' '); date.append(arg); count++; } if(!date) { eprintf(_("%s: date-time specification missed\n"),args->a0()); return 0; } struct timespec ts; if(!parse_datetime(&ts,date,0)) { eprintf(_("%s: date-time parse error\n"),args->a0()); return 0; } time_t when=ts.tv_sec; if(whencount()-1) cmd=args->Combine(cmd_start); else cmd=args->CombineQuoted(cmd_start); } if(!cmd) return new SleepJob(Time(when,0)-SMTask::now); return new SleepJob(Time(when,0)-SMTask::now, session->Clone(), parent->cwd->Clone(), cmd); } #undef args #include "modconfig.h" #ifndef MODULE_CMD_SLEEP # define module_init cmd_sleep_module_init #endif CDECL void module_init() { CmdExec::RegisterCommand("sleep",cmd_sleep,0, N_("Usage: sleep